mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
edit cloud project
This commit is contained in:
@@ -58,7 +58,11 @@ public class DialogFactory {
|
||||
}
|
||||
|
||||
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties, String title) {
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(mainFrame, properties, title);
|
||||
return createPropertyEditorDialog(mainFrame, properties, title);
|
||||
}
|
||||
|
||||
public PropertyEditorDialog createPropertyEditorDialog(JFrame owner, List<PropertyWrapper> properties, String title) {
|
||||
PropertyEditorDialog editor = new PropertyEditorDialog(owner, properties, title);
|
||||
return editor;
|
||||
}
|
||||
|
||||
@@ -147,7 +151,8 @@ public class DialogFactory {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public UploadDialog createUploadDialog(JFrame ownerFrame, IPlugInPort plugInPort, String[] categories, boolean isUpdate) {
|
||||
public UploadDialog createUploadDialog(JFrame ownerFrame, IPlugInPort plugInPort, String[] categories,
|
||||
boolean isUpdate) {
|
||||
UploadDialog dialog = new UploadDialog(ownerFrame, plugInPort, categories, isUpdate);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.diylc.swing.gui.components;
|
||||
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
/**
|
||||
* {@link JTextArea} that replaces new line characters with html <br> tags.
|
||||
*
|
||||
* @author Branislav Stojkovic
|
||||
*/
|
||||
public class HTMLTextArea extends JTextArea {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public HTMLTextArea(String text) {
|
||||
super(text.replace("<br>", "\n"));
|
||||
}
|
||||
|
||||
public HTMLTextArea() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return super.getText().replace("\n", "<br>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
super.setText(t.replace("<br>", "\n"));
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import javax.swing.JLabel;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.annotations.EditableProperty;
|
||||
import org.diylc.core.measures.AbstractMeasure;
|
||||
|
||||
public class FieldEditorFactory {
|
||||
@@ -16,6 +17,14 @@ public class FieldEditorFactory {
|
||||
private static final Logger LOG = Logger.getLogger(FieldEditorFactory.class);
|
||||
|
||||
public static Component createFieldEditor(PropertyWrapper property) {
|
||||
if (property.getType().equals(String.class) && property.getListItems() != null) {
|
||||
StringListEditor editor = new StringListEditor(property);
|
||||
return editor;
|
||||
}
|
||||
if (property.getType().equals(String.class) && EditableProperty.MULTI_LINE.equals(property.getAdditionalOptions())) {
|
||||
MultiLineStringEditor editor = new MultiLineStringEditor(property);
|
||||
return editor;
|
||||
}
|
||||
if (property.getType().equals(String.class)) {
|
||||
StringEditor editor = new StringEditor(property);
|
||||
return editor;
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.diylc.swing.gui.editor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.swing.gui.components.HTMLTextArea;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
public class MultiLineStringEditor extends JScrollPane {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Color oldBg;
|
||||
|
||||
private JTextArea textArea;
|
||||
|
||||
private final PropertyWrapper property;
|
||||
|
||||
public MultiLineStringEditor(PropertyWrapper property) {
|
||||
super();
|
||||
this.property = property;
|
||||
setViewportView(getTextArea());
|
||||
setPreferredSize(new Dimension(192, 64));
|
||||
}
|
||||
|
||||
public JTextArea getTextArea() {
|
||||
if (textArea == null) {
|
||||
textArea = new HTMLTextArea(property.getValue() == null ? "" : (String) property.getValue());
|
||||
textArea.setFont(getFont());
|
||||
oldBg = textArea.getBackground();
|
||||
textArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
textChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
textChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
textChanged();
|
||||
}
|
||||
});
|
||||
if (!property.isUnique()) {
|
||||
textArea.setBackground(Constants.MULTI_VALUE_COLOR);
|
||||
}
|
||||
}
|
||||
return textArea;
|
||||
}
|
||||
|
||||
private void textChanged() {
|
||||
property.setChanged(true);
|
||||
getTextArea().setBackground(oldBg);
|
||||
property.setValue(getTextArea().getText());
|
||||
}
|
||||
}
|
||||
@@ -92,19 +92,20 @@ public class PropertyEditorDialog extends ButtonDialog {
|
||||
GridBagConstraints gbc = new GridBagConstraints();
|
||||
|
||||
gbc.gridy = 0;
|
||||
gbc.insets = new Insets(2, 2, 2, 2);
|
||||
gbc.anchor = GridBagConstraints.LINE_START;
|
||||
|
||||
gbc.anchor = GridBagConstraints.FIRST_LINE_START;
|
||||
|
||||
for (PropertyWrapper property : properties) {
|
||||
gbc.gridx = 0;
|
||||
gbc.fill = GridBagConstraints.NONE;
|
||||
gbc.weightx = 0;
|
||||
|
||||
gbc.insets = new Insets(4, 2, 2, 2);
|
||||
editorPanel.add(new JLabel(property.getName() + ": "), gbc);
|
||||
|
||||
gbc.gridx = 1;
|
||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||
gbc.weightx = 1;
|
||||
gbc.insets = new Insets(2, 2, 2, 2);
|
||||
|
||||
Component editor = FieldEditorFactory.createFieldEditor(property);
|
||||
editor.addKeyListener(new KeyAdapter() {
|
||||
|
||||
@@ -20,6 +20,7 @@ public class StringEditor extends JTextField {
|
||||
public StringEditor(PropertyWrapper property) {
|
||||
super(property.getValue() == null ? "" : (String) property.getValue());
|
||||
this.property = property;
|
||||
this.setColumns(32);
|
||||
getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.diylc.swing.gui.editor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JComboBox;
|
||||
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.utils.Constants;
|
||||
|
||||
public class StringListEditor extends JComboBox {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Color oldBg = getBackground();
|
||||
|
||||
private final PropertyWrapper property;
|
||||
|
||||
public StringListEditor(final PropertyWrapper property) {
|
||||
this.property = property;
|
||||
Object[] values = property.getListItems();
|
||||
setModel(new DefaultComboBoxModel(values));
|
||||
setSelectedItem(property.getValue());
|
||||
addItemListener(new ItemListener() {
|
||||
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if (e.getStateChange() == ItemEvent.SELECTED) {
|
||||
property.setChanged(true);
|
||||
setBackground(oldBg);
|
||||
StringListEditor.this.property.setValue(e.getItem());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!property.isUnique()) {
|
||||
setBackground(Constants.MULTI_VALUE_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import org.diylc.plugins.cloud.model.CommentEntity;
|
||||
import org.diylc.plugins.cloud.model.ProjectEntity;
|
||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||
import org.diylc.swing.ISimpleView;
|
||||
import org.diylc.swing.gui.components.HTMLTextArea;
|
||||
|
||||
public class CommentDialog extends JDialog {
|
||||
|
||||
@@ -119,7 +120,7 @@ public class CommentDialog extends JDialog {
|
||||
|
||||
private JTextArea getReplyArea() {
|
||||
if (replyArea == null) {
|
||||
replyArea = new JTextArea();
|
||||
replyArea = new HTMLTextArea();
|
||||
replyArea.setFont(getSendButton().getFont());
|
||||
}
|
||||
return replyArea;
|
||||
@@ -132,7 +133,7 @@ public class CommentDialog extends JDialog {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
final String comment = getReplyArea().getText().replace("\n", "<br>");
|
||||
final String comment = getReplyArea().getText();
|
||||
if (comment.trim().length() == 0)
|
||||
owner.showMessage("Cannot post an empty comment.", "Cloud Error", IView.ERROR_MESSAGE);
|
||||
|
||||
@@ -179,7 +180,7 @@ public class CommentDialog extends JDialog {
|
||||
+ c.getPostedAt() + " </html>"), gbc);
|
||||
gbc.gridy = lastPosition++;
|
||||
|
||||
JTextArea commentArea = new JTextArea(c.getComment().replace("<br>", "\n"));
|
||||
JTextArea commentArea = new HTMLTextArea(c.getComment());
|
||||
commentArea.setEditable(false);
|
||||
commentArea.setFont(getSendButton().getFont());
|
||||
commentArea.setLineWrap(true);
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import org.diylc.common.DrawOption;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.swing.gui.components.HTMLTextArea;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
import org.diylc.utils.KeywordExtractor;
|
||||
|
||||
@@ -213,7 +214,7 @@ public class UploadDialog extends ButtonDialog {
|
||||
|
||||
private JTextArea getDescriptionArea() {
|
||||
if (descriptionArea == null) {
|
||||
descriptionArea = new JTextArea();
|
||||
descriptionArea = new HTMLTextArea();
|
||||
|
||||
// set default from the project
|
||||
for (int i = 0; i < plugInPort.getProjectProperties().size(); i++)
|
||||
@@ -242,7 +243,7 @@ public class UploadDialog extends ButtonDialog {
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return getDescriptionArea().getText().replace("\n", "<br>");
|
||||
return getDescriptionArea().getText();
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
|
||||
@@ -18,6 +18,7 @@ import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import org.diylc.plugins.cloud.model.UserEntity;
|
||||
import org.diylc.swing.gui.components.HTMLTextArea;
|
||||
import org.diylc.swingframework.ButtonDialog;
|
||||
|
||||
public class UserEditDialog extends ButtonDialog {
|
||||
@@ -68,7 +69,7 @@ public class UserEditDialog extends ButtonDialog {
|
||||
}
|
||||
|
||||
public String getBio() {
|
||||
return bio.replace("\n", "<br>");
|
||||
return bio;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -279,9 +280,9 @@ public class UserEditDialog extends ButtonDialog {
|
||||
|
||||
public JTextArea getBioArea() {
|
||||
if (bioArea == null) {
|
||||
bioArea = new JTextArea();
|
||||
bioArea = new HTMLTextArea();
|
||||
if (existingEntity != null)
|
||||
bioArea.setText(existingEntity.getBio().replace("<br>", "\n"));
|
||||
bioArea.setText(existingEntity.getBio());
|
||||
bioArea.setFont(getUserNameField().getFont());
|
||||
bioArea.setBorder(getUserNameField().getBorder());
|
||||
bioArea.setPreferredSize(new Dimension(192, 69));
|
||||
|
||||
+127
-70
@@ -36,6 +36,7 @@ import javax.swing.text.DefaultCaret;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.diylc.common.IPlugInPort;
|
||||
import org.diylc.common.ITask;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.core.IView;
|
||||
import org.diylc.images.IconLoader;
|
||||
import org.diylc.plugins.cloud.model.CommentEntity;
|
||||
@@ -47,6 +48,8 @@ import org.diylc.swing.ISimpleView;
|
||||
import org.diylc.swing.ISwingUI;
|
||||
import org.diylc.swing.gui.DialogFactory;
|
||||
import org.diylc.swing.gui.DummyView;
|
||||
import org.diylc.swing.gui.components.HTMLTextArea;
|
||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.CommentDialog;
|
||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||
@@ -178,7 +181,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
final JLabel nameLabel = new JLabel("<html><b>" + project.getName() + "</b></html>");
|
||||
nameLabel.setFont(nameLabel.getFont().deriveFont(12f));
|
||||
|
||||
final JTextArea descriptionArea = new JTextArea(project.getDescription().replace("<br>", "\n"));
|
||||
final JTextArea descriptionArea = new HTMLTextArea(project.getDescription());
|
||||
descriptionArea.setEditable(false);
|
||||
descriptionArea.setFont(thumbnailLabel.getFont());
|
||||
descriptionArea.setLineWrap(true);
|
||||
@@ -301,91 +304,145 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
final JSeparator separator = new JSeparator();
|
||||
|
||||
final JPanel buttonPanel = new JPanel(new FlowLayout());
|
||||
|
||||
|
||||
final JLabel editButton = new JLabel(IconLoader.CloudEdit.getIcon());
|
||||
editButton.setFocusable(true);
|
||||
editButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
editButton.setToolTipText("Edit details without changing the project file");
|
||||
|
||||
final JLabel reuploadButton = new JLabel(IconLoader.CloudUpload.getIcon());
|
||||
reuploadButton.setFocusable(true);
|
||||
reuploadButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
reuploadButton.setToolTipText("Re-upload to the cloud");
|
||||
reuploadButton.addMouseListener(new MouseAdapter() {
|
||||
editButton.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
final Presenter thumbnailPresenter = new Presenter(new DummyView());
|
||||
final File file =
|
||||
DialogFactory.getInstance().showOpenDialog(FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0], null, cloudUI.getOwnerFrame());
|
||||
if (file != null) {
|
||||
LOG.info("Preparing re-upload of project " + project.getName() + "(" + project.getId() + ")");
|
||||
cloudUI.executeBackgroundTask(new ITask<String[]>() {
|
||||
|
||||
@Override
|
||||
public String[] doInBackground() throws Exception {
|
||||
LOG.debug("Uploading from " + file.getAbsolutePath());
|
||||
thumbnailPresenter.loadProjectFromFile(file.getAbsolutePath());
|
||||
return cloudPresenter.getCategories();
|
||||
List<PropertyWrapper> projectProperties = cloudPresenter.getProjectProperties(project);
|
||||
PropertyEditorDialog editor =
|
||||
DialogFactory.getInstance().createPropertyEditorDialog(cloudUI.getOwnerFrame(), projectProperties,
|
||||
"Edit Published Project");
|
||||
editor.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(editor.getSelectedButtonCaption())) {
|
||||
// Update the project
|
||||
for (PropertyWrapper property : projectProperties) {
|
||||
try {
|
||||
property.writeTo(project);
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Could not update the project", ex);
|
||||
cloudUI.showMessage("Could not update the project. Detailed message is in the logs.", "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
cloudUI.executeBackgroundTask(new ITask<ProjectEntity>() {
|
||||
|
||||
@Override
|
||||
public void complete(final String[] result) {
|
||||
final UploadDialog dialog =
|
||||
DialogFactory.getInstance().createUploadDialog(cloudUI.getOwnerFrame(), thumbnailPresenter, result, true);
|
||||
dialog.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(dialog.getSelectedButtonCaption())) {
|
||||
try {
|
||||
final File thumbnailFile = File.createTempFile("upload-thumbnail", ".png");
|
||||
if (ImageIO.write(dialog.getThumbnail(), "png", thumbnailFile)) {
|
||||
cloudUI.executeBackgroundTask(new ITask<ProjectEntity>() {
|
||||
|
||||
@Override
|
||||
public ProjectEntity doInBackground() throws Exception {
|
||||
cloudPresenter.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(),
|
||||
dialog.getKeywords(), plugInPort.getCurrentVersionNumber().toString(), thumbnailFile, file,
|
||||
project.getId());
|
||||
return cloudPresenter.fetchUserUploads(project.getId()).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
cloudUI.showMessage(e.getMessage(), "Upload Error", IView.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(ProjectEntity result) {
|
||||
nameLabel.setText("<html><b>" + project.getName() + "</b></html>");
|
||||
categoryLabel.setText(result.getCategory());
|
||||
descriptionArea.setText(result.getDescription().replace("<br>", "\n"));
|
||||
categoryLabel.setText("<html>Category: <b>" + result.getCategory() + "</b></html>");
|
||||
updatedLabel.setText("<html>Last updated: <b>" + result.getUpdated() + "</b></html>");
|
||||
thumbnailLabel.setIcon(new ImageIcon(dialog.getThumbnail()));
|
||||
cloudUI
|
||||
.showMessage(
|
||||
"The project has been uploaded to the cloud successfully. Thank you for your contribution!",
|
||||
"Upload Success", IView.INFORMATION_MESSAGE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cloudUI.showMessage("Could not prepare temporary files to be uploaded to the cloud.",
|
||||
"Upload Error", IView.ERROR_MESSAGE);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
cloudUI.showMessage(e.getMessage(), "Upload Error", IView.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
public ProjectEntity doInBackground() throws Exception {
|
||||
cloudPresenter.updateProjectDetails(project, plugInPort.getCurrentVersionNumber().toString());
|
||||
return cloudPresenter.fetchUserUploads(project.getId()).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
cloudUI.showMessage("Could not open file. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
cloudUI.showMessage("Could not update the project. Detailed message is in the logs.", "Error",
|
||||
ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(ProjectEntity result) {
|
||||
nameLabel.setText("<html><b>" + project.getName() + "</b></html>");
|
||||
descriptionArea.setText(result.getDescription());
|
||||
categoryLabel.setText("<html>Category: <b>" + result.getCategory() + "</b></html>");
|
||||
updatedLabel.setText("<html>Last updated: <b>" + result.getUpdated() + "</b></html>");
|
||||
cloudUI.showMessage(
|
||||
"The project has been uploaded to the cloud successfully. Thank you for your contribution!",
|
||||
"Upload Success", IView.INFORMATION_MESSAGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final JLabel replaceButton = new JLabel(IconLoader.CloudUpload.getIcon());
|
||||
replaceButton.setFocusable(true);
|
||||
replaceButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
replaceButton.setToolTipText("Replace project with a new version");
|
||||
replaceButton.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (cloudUI.showConfirmDialog(
|
||||
"Are you sure you want to replace the project \""
|
||||
+ project.getName()
|
||||
+ "\" with a new file?\nThis opperation is irreversible. Once replaced, the old version of the project cannot be restored.",
|
||||
"Replace Project", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) == IView.YES_OPTION) {
|
||||
final Presenter thumbnailPresenter = new Presenter(new DummyView());
|
||||
final File file =
|
||||
DialogFactory.getInstance().showOpenDialog(FileFilterEnum.DIY.getFilter(), null,
|
||||
FileFilterEnum.DIY.getExtensions()[0], null, cloudUI.getOwnerFrame());
|
||||
if (file != null) {
|
||||
LOG.info("Preparing re-upload of project " + project.getName() + "(" + project.getId() + ")");
|
||||
cloudUI.executeBackgroundTask(new ITask<String[]>() {
|
||||
|
||||
@Override
|
||||
public String[] doInBackground() throws Exception {
|
||||
LOG.debug("Uploading from " + file.getAbsolutePath());
|
||||
thumbnailPresenter.loadProjectFromFile(file.getAbsolutePath());
|
||||
return cloudPresenter.getCategories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(final String[] result) {
|
||||
final UploadDialog dialog =
|
||||
DialogFactory.getInstance().createUploadDialog(cloudUI.getOwnerFrame(), thumbnailPresenter, result,
|
||||
true);
|
||||
dialog.setVisible(true);
|
||||
if (ButtonDialog.OK.equals(dialog.getSelectedButtonCaption())) {
|
||||
try {
|
||||
final File thumbnailFile = File.createTempFile("upload-thumbnail", ".png");
|
||||
if (ImageIO.write(dialog.getThumbnail(), "png", thumbnailFile)) {
|
||||
cloudUI.executeBackgroundTask(new ITask<ProjectEntity>() {
|
||||
|
||||
@Override
|
||||
public ProjectEntity doInBackground() throws Exception {
|
||||
cloudPresenter.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(),
|
||||
dialog.getKeywords(), plugInPort.getCurrentVersionNumber().toString(), thumbnailFile,
|
||||
file, project.getId());
|
||||
return cloudPresenter.fetchUserUploads(project.getId()).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
cloudUI.showMessage(e.getMessage(), "Upload Error", IView.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void complete(ProjectEntity result) {
|
||||
nameLabel.setText("<html><b>" + project.getName() + "</b></html>");
|
||||
descriptionArea.setText(result.getDescription());
|
||||
categoryLabel.setText("<html>Category: <b>" + result.getCategory() + "</b></html>");
|
||||
updatedLabel.setText("<html>Last updated: <b>" + result.getUpdated() + "</b></html>");
|
||||
thumbnailLabel.setIcon(new ImageIcon(dialog.getThumbnail()));
|
||||
cloudUI
|
||||
.showMessage(
|
||||
"The project has been uploaded to the cloud successfully. Thank you for your contribution!",
|
||||
"Upload Success", IView.INFORMATION_MESSAGE);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cloudUI.showMessage("Could not prepare temporary files to be uploaded to the cloud.",
|
||||
"Upload Error", IView.ERROR_MESSAGE);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
cloudUI.showMessage(e.getMessage(), "Upload Error", IView.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
cloudUI.showMessage("Could not open file. " + e.getMessage(), "Error", ISwingUI.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final JLabel deleteButton = new JLabel(IconLoader.CloudDelete.getIcon());
|
||||
deleteButton.setFocusable(true);
|
||||
deleteButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
@@ -394,8 +451,8 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (cloudUI.showConfirmDialog("Are you sure you want to permanently delete project " + project.getName()
|
||||
+ " from the cloud?", "Delete Project", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) == IView.YES_OPTION) {
|
||||
if (cloudUI.showConfirmDialog("Are you sure you want to permanently delete project \"" + project.getName()
|
||||
+ "\" from the cloud?", "Delete Project", IView.YES_NO_OPTION, IView.QUESTION_MESSAGE) == IView.YES_OPTION) {
|
||||
LOG.info("Deleting project " + project.getName() + "(" + project.getId() + ")");
|
||||
cloudUI.executeBackgroundTask(new ITask<Void>() {
|
||||
|
||||
@@ -435,7 +492,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
||||
buttonPanel.add(downloadButton);
|
||||
if (showEditControls) {
|
||||
buttonPanel.add(editButton);
|
||||
buttonPanel.add(reuploadButton);
|
||||
buttonPanel.add(replaceButton);
|
||||
buttonPanel.add(deleteButton);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user