mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
cloud search work
This commit is contained in:
@@ -209,6 +209,7 @@ public class CloudPresenter {
|
|||||||
|
|
||||||
public List<ProjectEntity> search(String criteria, String category, String sortOrder, int pageNumber, int itemsPerPage)
|
public List<ProjectEntity> search(String criteria, String category, String sortOrder, int pageNumber, int itemsPerPage)
|
||||||
throws CloudException {
|
throws CloudException {
|
||||||
|
LOG.info(String.format("search(%1$s,%2$s,%3$s,%4$d,%5$d)", criteria, category, sortOrder, pageNumber, itemsPerPage));
|
||||||
try {
|
try {
|
||||||
Object res = service.search(criteria, category, "json", pageNumber, itemsPerPage, sortOrder);
|
Object res = service.search(criteria, category, "json", pageNumber, itemsPerPage, sortOrder);
|
||||||
if (res == null)
|
if (res == null)
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ public enum IconLoader {
|
|||||||
"briefcase_into.png"), RotateCW("rotate_cw.png"), RotateCCW("rotate_ccw.png"), ElementInto("element_into.png"), Arrow(
|
"briefcase_into.png"), RotateCW("rotate_cw.png"), RotateCCW("rotate_ccw.png"), ElementInto("element_into.png"), Arrow(
|
||||||
"arrow.png"), Cloud("cloud.png"), CloudUp("cloud_up.png"), CloudGear("cloud_gear.png"), IdCardEdit(
|
"arrow.png"), Cloud("cloud.png"), CloudUp("cloud_up.png"), CloudGear("cloud_gear.png"), IdCardEdit(
|
||||||
"id_card_edit.png"), KeyEdit("key_edit.png"), Find("find.png"), Dashboard("dashboard.png"), DataFind(
|
"id_card_edit.png"), KeyEdit("key_edit.png"), Find("find.png"), Dashboard("dashboard.png"), DataFind(
|
||||||
"data_find.png"), CloudDownload("cloud-download.png");
|
"data_find.png"), CloudDownload("cloud-download.png"), NavLeftBlue("nav_left_blue.png"), NavRightBlue(
|
||||||
|
"nav_right_blue.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -323,14 +323,16 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
try {
|
try {
|
||||||
T result = get();
|
T result = get();
|
||||||
task.complete(result);
|
task.complete(result);
|
||||||
|
getGlassPane().setVisible(false);
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
|
getGlassPane().setVisible(false);
|
||||||
LOG.error("Background task execution failed", e);
|
LOG.error("Background task execution failed", e);
|
||||||
task.failed(e);
|
task.failed(e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
getGlassPane().setVisible(false);
|
||||||
LOG.error("Background task execution interrupted", e);
|
LOG.error("Background task execution interrupted", e);
|
||||||
task.failed(e);
|
task.failed(e);
|
||||||
}
|
}
|
||||||
getGlassPane().setVisible(false);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
worker.execute();
|
worker.execute();
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
@@ -72,6 +73,10 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
private CloudPresenter cloudPresenter;
|
private CloudPresenter cloudPresenter;
|
||||||
|
|
||||||
|
// search criteria
|
||||||
|
private String searchFor;
|
||||||
|
private String category;
|
||||||
|
private String sort;
|
||||||
private int pageNumber;
|
private int pageNumber;
|
||||||
private int itemsPerPage = 10;
|
private int itemsPerPage = 10;
|
||||||
|
|
||||||
@@ -177,7 +182,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
searchPanel.add(new JLabel("Filter By Category:"), gbc);
|
searchPanel.add(new JLabel("Filter By Category:"), gbc);
|
||||||
|
|
||||||
gbc.gridx = 3;
|
gbc.gridx = 3;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 0.3;
|
||||||
searchPanel.add(getCategoryBox(), gbc);
|
searchPanel.add(getCategoryBox(), gbc);
|
||||||
|
|
||||||
gbc.gridx = 4;
|
gbc.gridx = 4;
|
||||||
@@ -195,7 +200,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
|
|
||||||
private JTextField getSearchField() {
|
private JTextField getSearchField() {
|
||||||
if (searchField == null) {
|
if (searchField == null) {
|
||||||
searchField = new JTextField();
|
searchField = new JTextField(60);
|
||||||
}
|
}
|
||||||
return searchField;
|
return searchField;
|
||||||
}
|
}
|
||||||
@@ -249,20 +254,31 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
CloudBrowserFrame.this.pageNumber = 1;
|
CloudBrowserFrame.this.pageNumber = 1;
|
||||||
|
CloudBrowserFrame.this.searchFor = getSearchField().getText();
|
||||||
|
CloudBrowserFrame.this.category =
|
||||||
|
getCategoryBox().getSelectedItem() == null ? "" : getCategoryBox().getSelectedItem().toString();
|
||||||
|
CloudBrowserFrame.this.sort =
|
||||||
|
getSortBox().getSelectedItem() == null ? "" : getSortBox().getSelectedItem().toString();
|
||||||
|
|
||||||
|
search();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return goButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void search() {
|
||||||
executeBackgroundTask(new ITask<List<ProjectEntity>>() {
|
executeBackgroundTask(new ITask<List<ProjectEntity>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProjectEntity> doInBackground() throws Exception {
|
public List<ProjectEntity> doInBackground() throws Exception {
|
||||||
return cloudPresenter.search(getSearchField().getText(), getCategoryBox().getSelectedItem() == null ? ""
|
return cloudPresenter.search(searchFor, category, sort, pageNumber, itemsPerPage);
|
||||||
: getCategoryBox().getSelectedItem().toString(), getSortBox().getSelectedItem() == null ? ""
|
|
||||||
: getSortBox().getSelectedItem().toString(), CloudBrowserFrame.this.pageNumber,
|
|
||||||
CloudBrowserFrame.this.itemsPerPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed(Exception e) {
|
public void failed(Exception e) {
|
||||||
showMessage("Search failed. Error: " + e.getMessage(), "Search Failed", IView.ERROR_MESSAGE);
|
showMessage("Search failed! Detailed message is in the logs. Please report to the author.", "Search Failed",
|
||||||
|
IView.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -271,51 +287,38 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for (Iterator<ProjectEntity> i = result.iterator(); i.hasNext();) {
|
for (Iterator<ProjectEntity> i = result.iterator(); i.hasNext();) {
|
||||||
ProjectEntity project = i.next();
|
ProjectEntity project = i.next();
|
||||||
addProjectToDisplay(project, count++, i.hasNext());
|
addProjectToDisplay(project, count++);
|
||||||
}
|
}
|
||||||
|
if (count == 0) {
|
||||||
|
showNoMatches();
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
addNavigationPanel(count);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
private void showNoMatches() {
|
||||||
return goButton;
|
JLabel label = new JLabel("<html><font size='5' color='red'>No projects match the search criteria.</font></html>");
|
||||||
|
label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 0;
|
||||||
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc.weightx = 1;
|
||||||
|
gbc.weighty = Integer.MAX_VALUE;
|
||||||
|
getResultsPanel().add(label, gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends Object> void executeBackgroundTask(final ITask<T> task) {
|
private void addProjectToDisplay(final ProjectEntity project, int location) {
|
||||||
getGlassPane().setVisible(true);
|
|
||||||
SwingWorker<T, Void> worker = new SwingWorker<T, Void>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected T doInBackground() throws Exception {
|
|
||||||
return task.doInBackground();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void done() {
|
|
||||||
try {
|
|
||||||
T result = get();
|
|
||||||
task.complete(result);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
LOG.error("Background task execution failed", e);
|
|
||||||
task.failed(e);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
LOG.error("Background task execution interrupted", e);
|
|
||||||
task.failed(e);
|
|
||||||
}
|
|
||||||
getGlassPane().setVisible(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
worker.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addProjectToDisplay(final ProjectEntity project, int location, boolean hasNext) {
|
|
||||||
JLabel thumbnailLabel = new JLabel(downloadImage(project.getThumbnailUrl()));
|
JLabel thumbnailLabel = new JLabel(downloadImage(project.getThumbnailUrl()));
|
||||||
JLabel nameLabel = new JLabel("<html><b>" + project.getName() + "</b></html>");
|
JLabel nameLabel = new JLabel("<html><b>" + project.getName() + "</b></html>");
|
||||||
nameLabel.setFont(nameLabel.getFont().deriveFont(12f));
|
nameLabel.setFont(nameLabel.getFont().deriveFont(12f));
|
||||||
JLabel descriptionLabel = new JLabel("<html>" + project.getDescription() + "</html>");
|
JLabel descriptionLabel = new JLabel("<html>" + project.getDescription() + "</html>");
|
||||||
JLabel categoryLabel = new JLabel("Category: " + project.getCategory());
|
JLabel categoryLabel = new JLabel("<html>Category: <b>" + project.getCategory() + "</b></html>");
|
||||||
JLabel authorLabel = new JLabel("<html>by: <b>" + project.getOwner() + "</b></html>");
|
JLabel authorLabel = new JLabel("<html>Author: <b>" + project.getOwner() + "</b></html>");
|
||||||
JLabel updatedLabel = new JLabel("Last updated: " + project.getUpdated());
|
JLabel updatedLabel = new JLabel("<html>Last updated: <b>" + project.getUpdated() + "</b></html>");
|
||||||
JButton downloadButton = new JButton(IconLoader.CloudDownload.getIcon());
|
JButton downloadButton = new JButton(IconLoader.CloudDownload.getIcon());
|
||||||
|
|
||||||
downloadButton.setBorderPainted(false);
|
downloadButton.setBorderPainted(false);
|
||||||
@@ -365,7 +368,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed(Exception e) {
|
public void failed(Exception e) {
|
||||||
CloudBrowserFrame.this.showMessage("Could not open file. " + e.getMessage(), "Error",
|
CloudBrowserFrame.this.showMessage("Could not open file. Detailed message is in the logs", "Error",
|
||||||
ISwingUI.ERROR_MESSAGE);
|
ISwingUI.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -374,7 +377,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed(Exception e) {
|
public void failed(Exception e) {
|
||||||
CloudBrowserFrame.this.showMessage("Could not save to file. " + e.getMessage(), "Error",
|
CloudBrowserFrame.this.showMessage("Could not save to file. Detailed message is in the logs", "Error",
|
||||||
ISwingUI.ERROR_MESSAGE);
|
ISwingUI.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -386,9 +389,9 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.gridy = location * 5;
|
gbc.gridy = location * 6;
|
||||||
gbc.fill = GridBagConstraints.NONE;
|
gbc.fill = GridBagConstraints.NONE;
|
||||||
gbc.gridheight = 4;
|
gbc.gridheight = 5;
|
||||||
gbc.weightx = 0;
|
gbc.weightx = 0;
|
||||||
getResultsPanel().add(thumbnailLabel, gbc);
|
getResultsPanel().add(thumbnailLabel, gbc);
|
||||||
|
|
||||||
@@ -397,11 +400,11 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.insets = new Insets(2, 6, 2, 2);
|
gbc.insets = new Insets(2, 6, 2, 2);
|
||||||
getResultsPanel().add(nameLabel, gbc);
|
getResultsPanel().add(nameLabel, gbc);
|
||||||
|
//
|
||||||
gbc.gridx = 2;
|
// gbc.gridx = 2;
|
||||||
gbc.anchor = GridBagConstraints.NORTHEAST;
|
// gbc.anchor = GridBagConstraints.NORTHEAST;
|
||||||
gbc.insets = new Insets(2, 2, 2, 8);
|
// gbc.insets = new Insets(2, 2, 2, 8);
|
||||||
getResultsPanel().add(authorLabel, gbc);
|
// getResultsPanel().add(authorLabel, gbc);
|
||||||
|
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
@@ -416,7 +419,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
getResultsPanel().add(categoryLabel, gbc);
|
getResultsPanel().add(categoryLabel, gbc);
|
||||||
|
|
||||||
gbc.gridx = 2;
|
gbc.gridx = 2;
|
||||||
gbc.gridheight = 2;
|
gbc.gridheight = 3;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
gbc.anchor = GridBagConstraints.SOUTHEAST;
|
gbc.anchor = GridBagConstraints.SOUTHEAST;
|
||||||
getResultsPanel().add(downloadButton, gbc);
|
getResultsPanel().add(downloadButton, gbc);
|
||||||
@@ -426,9 +429,11 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
gbc.gridheight = 1;
|
gbc.gridheight = 1;
|
||||||
gbc.insets = new Insets(2, 6, 2, 2);
|
gbc.insets = new Insets(2, 6, 2, 2);
|
||||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
|
getResultsPanel().add(authorLabel, gbc);
|
||||||
|
|
||||||
|
gbc.gridy++;
|
||||||
getResultsPanel().add(updatedLabel, gbc);
|
getResultsPanel().add(updatedLabel, gbc);
|
||||||
|
|
||||||
if (hasNext) {
|
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
gbc.gridwidth = 3;
|
gbc.gridwidth = 3;
|
||||||
@@ -437,6 +442,93 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
getResultsPanel().add(new JSeparator(), gbc);
|
getResultsPanel().add(new JSeparator(), gbc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addNavigationPanel(int location) {
|
||||||
|
JPanel navigationPanel = new JPanel(new GridBagLayout());
|
||||||
|
navigationPanel.setBackground(Color.white);
|
||||||
|
|
||||||
|
JButton prevPageButton = new JButton(IconLoader.NavLeftBlue.getIcon());
|
||||||
|
prevPageButton.setBorderPainted(false);
|
||||||
|
prevPageButton.setContentAreaFilled(false);
|
||||||
|
prevPageButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
|
prevPageButton.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (CloudBrowserFrame.this.pageNumber > 1) {
|
||||||
|
CloudBrowserFrame.this.pageNumber--;
|
||||||
|
CloudBrowserFrame.this.search();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JButton nextPageButton = new JButton(IconLoader.NavRightBlue.getIcon());
|
||||||
|
nextPageButton.setBorderPainted(false);
|
||||||
|
nextPageButton.setContentAreaFilled(false);
|
||||||
|
nextPageButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
|
nextPageButton.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
CloudBrowserFrame.this.pageNumber++;
|
||||||
|
CloudBrowserFrame.this.search();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.anchor = GridBagConstraints.SOUTHWEST;
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.weightx = 0;
|
||||||
|
gbc.fill = GridBagConstraints.NONE;
|
||||||
|
navigationPanel.add(prevPageButton, gbc);
|
||||||
|
|
||||||
|
gbc.gridx++;
|
||||||
|
gbc.weightx = 1;
|
||||||
|
navigationPanel.add(new JLabel(), gbc);
|
||||||
|
|
||||||
|
gbc.gridx++;
|
||||||
|
gbc.weightx = 0;
|
||||||
|
navigationPanel.add(nextPageButton, gbc);
|
||||||
|
|
||||||
|
gbc = new GridBagConstraints();
|
||||||
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = location * 6;
|
||||||
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
|
gbc.weighty = 100;
|
||||||
|
gbc.gridwidth = 3;
|
||||||
|
getResultsPanel().add(navigationPanel, gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends Object> void executeBackgroundTask(final ITask<T> task) {
|
||||||
|
getGlassPane().setVisible(true);
|
||||||
|
SwingWorker<T, Void> worker = new SwingWorker<T, Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected T doInBackground() throws Exception {
|
||||||
|
return task.doInBackground();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
try {
|
||||||
|
T result = get();
|
||||||
|
task.complete(result);
|
||||||
|
getGlassPane().setVisible(false);
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
LOG.error("Background task execution failed", e);
|
||||||
|
getGlassPane().setVisible(false);
|
||||||
|
task.failed(e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
getGlassPane().setVisible(false);
|
||||||
|
LOG.error("Background task execution interrupted", e);
|
||||||
|
task.failed(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
worker.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showMessage(String message, String title, int messageType) {
|
public void showMessage(String message, String title, int messageType) {
|
||||||
|
|||||||
@@ -35,11 +35,15 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final String BULLET = " • ";
|
private static final String BULLET = " • ";
|
||||||
private static final String TERMS_HTML = "<html>" + BULLET
|
private static final String TERMS_HTML = "<html>"
|
||||||
+ "All content uploaded to DIY Cloud is shared under Creative Commons 3.0 Licence.<br>" + BULLET
|
+ BULLET
|
||||||
+ "Only finished and resonably verified projects may be uploaded to the DIY Cloud.<br>" + BULLET
|
+ "All content uploaded to DIY Cloud is shared under Creative Commons 3.0 Licence.<br>"
|
||||||
|
+ BULLET
|
||||||
|
+ "Only finished and resonably verified projects may be uploaded to the DIY Cloud.<br>"
|
||||||
|
+ BULLET
|
||||||
+ "Please provide a meaningful project description to make it possible for others to find the project.<br>"
|
+ "Please provide a meaningful project description to make it possible for others to find the project.<br>"
|
||||||
+ BULLET + "If you are building on top of someone else's work, please leave credits in the description.<br>"
|
+ BULLET
|
||||||
|
+ "If you are building on top of someone else's work, please leave credits in the description.<br>"
|
||||||
+ BULLET
|
+ BULLET
|
||||||
+ "Uploaded content may be reviewed, edited and removed by the administrators if it is not up to standards.<br>"
|
+ "Uploaded content may be reviewed, edited and removed by the administrators if it is not up to standards.<br>"
|
||||||
+ "</html>";
|
+ "</html>";
|
||||||
@@ -56,8 +60,9 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
private CloudPresenter cloudPresenter;
|
private CloudPresenter cloudPresenter;
|
||||||
|
|
||||||
public UploadDialog(JFrame owner, IPlugInPort plugInPort, CloudPresenter cloudPresenter) {
|
public UploadDialog(JFrame owner, IPlugInPort plugInPort,
|
||||||
super(owner, "Upload A Project", new String[] {OK, CANCEL});
|
CloudPresenter cloudPresenter) {
|
||||||
|
super(owner, "Upload A Project", new String[] { OK, CANCEL });
|
||||||
this.plugInPort = plugInPort;
|
this.plugInPort = plugInPort;
|
||||||
this.cloudPresenter = cloudPresenter;
|
this.cloudPresenter = cloudPresenter;
|
||||||
layoutGui();
|
layoutGui();
|
||||||
@@ -153,7 +158,8 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
termsLabel = new JLabel();
|
termsLabel = new JLabel();
|
||||||
termsLabel.setOpaque(true);
|
termsLabel.setOpaque(true);
|
||||||
termsLabel.setBackground(UIManager.getColor("ToolTip.background"));
|
termsLabel.setBackground(UIManager.getColor("ToolTip.background"));
|
||||||
termsLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
|
termsLabel.setBorder(BorderFactory.createCompoundBorder(
|
||||||
|
BorderFactory.createEtchedBorder(),
|
||||||
BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
||||||
termsLabel.setText(TERMS_HTML);
|
termsLabel.setText(TERMS_HTML);
|
||||||
}
|
}
|
||||||
@@ -183,11 +189,14 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
paintThumbnail(g, getBounds());
|
paintThumbnail(g, getBounds());
|
||||||
}
|
}
|
||||||
}, gbc);
|
}, gbc);
|
||||||
Dimension d = UploadDialog.this.plugInPort.getCanvasDimensions(false);
|
Dimension d = UploadDialog.this.plugInPort
|
||||||
|
.getCanvasDimensions(false);
|
||||||
if (d.height > d.width)
|
if (d.height > d.width)
|
||||||
thumbnailPanel.setPreferredSize(new Dimension(192 * d.width / d.height, 192));
|
thumbnailPanel.setPreferredSize(new Dimension(192 * d.width
|
||||||
|
/ d.height, 192));
|
||||||
else
|
else
|
||||||
thumbnailPanel.setPreferredSize(new Dimension(192, 192 * d.height / d.width));
|
thumbnailPanel.setPreferredSize(new Dimension(192, 192
|
||||||
|
* d.height / d.width));
|
||||||
thumbnailPanel.setBorder(BorderFactory.createEtchedBorder());
|
thumbnailPanel.setBorder(BorderFactory.createEtchedBorder());
|
||||||
}
|
}
|
||||||
return thumbnailPanel;
|
return thumbnailPanel;
|
||||||
@@ -199,8 +208,10 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
|
|
||||||
// set default from the project
|
// set default from the project
|
||||||
for (int i = 0; i < plugInPort.getProjectProperties().size(); i++)
|
for (int i = 0; i < plugInPort.getProjectProperties().size(); i++)
|
||||||
if (plugInPort.getProjectProperties().get(i).getName().equals("Title"))
|
if (plugInPort.getProjectProperties().get(i).getName()
|
||||||
nameField.setText(plugInPort.getProjectProperties().get(i).getValue().toString());
|
.equals("Title"))
|
||||||
|
nameField.setText(plugInPort.getProjectProperties().get(i)
|
||||||
|
.getValue().toString());
|
||||||
}
|
}
|
||||||
return nameField;
|
return nameField;
|
||||||
}
|
}
|
||||||
@@ -223,8 +234,14 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
|
|
||||||
// set default from the project
|
// set default from the project
|
||||||
for (int i = 0; i < plugInPort.getProjectProperties().size(); i++)
|
for (int i = 0; i < plugInPort.getProjectProperties().size(); i++)
|
||||||
if (plugInPort.getProjectProperties().get(i).getName().equals("Description"))
|
if (plugInPort.getProjectProperties().get(i).getName()
|
||||||
descriptionArea.setText(plugInPort.getProjectProperties().get(i).getValue().toString());
|
.equals("Description"))
|
||||||
|
try {
|
||||||
|
descriptionArea.setText(plugInPort
|
||||||
|
.getProjectProperties().get(i).getValue()
|
||||||
|
.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
descriptionArea.setBorder(getNameField().getBorder());
|
descriptionArea.setBorder(getNameField().getBorder());
|
||||||
descriptionArea.setFont(getNameField().getFont());
|
descriptionArea.setFont(getNameField().getFont());
|
||||||
}
|
}
|
||||||
@@ -243,7 +260,7 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return getDescriptionArea().getText();
|
return getDescriptionArea().getText().replace("\n", "<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
@@ -251,11 +268,13 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getThumbnail() {
|
public BufferedImage getThumbnail() {
|
||||||
BufferedImage thumbnailImage =
|
BufferedImage thumbnailImage = new BufferedImage(getThumbnailPanel()
|
||||||
new BufferedImage(getThumbnailPanel().getWidth(), getThumbnailPanel().getHeight(), BufferedImage.TYPE_INT_RGB);
|
.getWidth(), getThumbnailPanel().getHeight(),
|
||||||
|
BufferedImage.TYPE_INT_RGB);
|
||||||
Graphics2D cg = thumbnailImage.createGraphics();
|
Graphics2D cg = thumbnailImage.createGraphics();
|
||||||
|
|
||||||
paintThumbnail(cg, new Rectangle(thumbnailImage.getWidth(), thumbnailImage.getHeight()));
|
paintThumbnail(cg, new Rectangle(thumbnailImage.getWidth(),
|
||||||
|
thumbnailImage.getHeight()));
|
||||||
return thumbnailImage;
|
return thumbnailImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +295,8 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g2d.scale(zoomRatio, zoomRatio);
|
g2d.scale(zoomRatio, zoomRatio);
|
||||||
UploadDialog.this.plugInPort.draw(g2d, EnumSet.of(DrawOption.ANTIALIASING), null);
|
UploadDialog.this.plugInPort.draw(g2d,
|
||||||
|
EnumSet.of(DrawOption.ANTIALIASING), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKeywords() {
|
public String getKeywords() {
|
||||||
|
|||||||
Reference in New Issue
Block a user