mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
manage cloud uploads
This commit is contained in:
@@ -5,7 +5,6 @@ import javax.swing.Icon;
|
|||||||
import org.diylc.core.CreationMethod;
|
import org.diylc.core.CreationMethod;
|
||||||
import org.diylc.core.IDIYComponent;
|
import org.diylc.core.IDIYComponent;
|
||||||
import org.diylc.core.annotations.BomPolicy;
|
import org.diylc.core.annotations.BomPolicy;
|
||||||
import org.diylc.core.annotations.IAutoCreator;
|
|
||||||
import org.diylc.core.annotations.KeywordPolicy;
|
import org.diylc.core.annotations.KeywordPolicy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ public class Resistance extends AbstractMeasure<ResistanceUnit> {
|
|||||||
bands = new Color[] {};
|
bands = new Color[] {};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (getValue() == null || getUnit() == null)
|
||||||
|
return new Color[] {};
|
||||||
double base = getValue() * getUnit().getFactor();
|
double base = getValue() * getUnit().getFactor();
|
||||||
int multiplier = 0;
|
int multiplier = 0;
|
||||||
while (base > (resistorColorCode == ResistorColorCode._4_BAND ? 99 : 999)) {
|
while (base > (resistorColorCode == ResistorColorCode._4_BAND ? 99 : 999)) {
|
||||||
|
|||||||
@@ -98,12 +98,13 @@ public interface IServiceAPI {
|
|||||||
* @param itemsPerPage
|
* @param itemsPerPage
|
||||||
* @param sort
|
* @param sort
|
||||||
* @param username
|
* @param username
|
||||||
|
* @param projectId optional parameter used when we want to fetch a particular project
|
||||||
* @return string with error message if the error occurred or a list of {@link ProjectEntity}
|
* @return string with error message if the error occurred or a list of {@link ProjectEntity}
|
||||||
* objects.
|
* objects.
|
||||||
*/
|
*/
|
||||||
Object search(@ParamName("criteria") String criteria, @ParamName("category") String category,
|
Object search(@ParamName("criteria") String criteria, @ParamName("category") String category,
|
||||||
@ParamName("page") Integer page, @ParamName("itemsPerPage") Integer itemsPerPage, @ParamName("sort") String sort,
|
@ParamName("page") Integer page, @ParamName("itemsPerPage") Integer itemsPerPage, @ParamName("sort") String sort,
|
||||||
@ParamName("username") String username);
|
@ParamName("username") String username, @ParamName("projectId") Integer projectId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads a project using token to authenticate. When projectI is specified, it updates the
|
* Uploads a project using token to authenticate. When projectI is specified, it updates the
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class CloudPresenter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void uploadProject(String projectName, String category, String description, String keywords,
|
public void uploadProject(String projectName, String category, String description, String keywords,
|
||||||
String diylcVersion, File thumbnail, File project) throws IOException, CloudException {
|
String diylcVersion, File thumbnail, File project, Integer projectId) throws IOException, CloudException {
|
||||||
String username = ConfigurationManager.getInstance().readString(USERNAME_KEY, null);
|
String username = ConfigurationManager.getInstance().readString(USERNAME_KEY, null);
|
||||||
String token = ConfigurationManager.getInstance().readString(TOKEN_KEY, null);
|
String token = ConfigurationManager.getInstance().readString(TOKEN_KEY, null);
|
||||||
|
|
||||||
@@ -145,7 +145,23 @@ public class CloudPresenter {
|
|||||||
try {
|
try {
|
||||||
String res =
|
String res =
|
||||||
getService().uploadProject(username, token, getMachineId(), projectName, category, description, diylcVersion,
|
getService().uploadProject(username, token, getMachineId(), projectName, category, description, diylcVersion,
|
||||||
keywords, thumbnail, project, null);
|
keywords, thumbnail, project, projectId);
|
||||||
|
if (!res.equals(SUCCESS))
|
||||||
|
throw new CloudException(res);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CloudException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteProject(int projectId) throws CloudException {
|
||||||
|
String username = ConfigurationManager.getInstance().readString(USERNAME_KEY, null);
|
||||||
|
String token = ConfigurationManager.getInstance().readString(TOKEN_KEY, null);
|
||||||
|
|
||||||
|
if (username == null || token == null)
|
||||||
|
throw new CloudException("Login failed. Please try to login again.");
|
||||||
|
|
||||||
|
try {
|
||||||
|
String res = getService().deleteProject(username, token, getMachineId(), projectId);
|
||||||
if (!res.equals(SUCCESS))
|
if (!res.equals(SUCCESS))
|
||||||
throw new CloudException(res);
|
throw new CloudException(res);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -234,7 +250,7 @@ public class CloudPresenter {
|
|||||||
throws CloudException {
|
throws CloudException {
|
||||||
LOG.info(String.format("search(%1$s,%2$s,%3$s,%4$d,%5$d)", criteria, category, sortOrder, pageNumber, itemsPerPage));
|
LOG.info(String.format("search(%1$s,%2$s,%3$s,%4$d,%5$d)", criteria, category, sortOrder, pageNumber, itemsPerPage));
|
||||||
try {
|
try {
|
||||||
Object res = getService().search(criteria, category, pageNumber, itemsPerPage, sortOrder, null);
|
Object res = getService().search(criteria, category, pageNumber, itemsPerPage, sortOrder, null, null);
|
||||||
return processResults(res);
|
return processResults(res);
|
||||||
} catch (CloudException ce) {
|
} catch (CloudException ce) {
|
||||||
throw ce;
|
throw ce;
|
||||||
@@ -243,10 +259,10 @@ public class CloudPresenter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProjectEntity> fetchUserUploads() throws CloudException {
|
public List<ProjectEntity> fetchUserUploads(Integer projectId) throws CloudException {
|
||||||
UserEntity user = getUserDetails();
|
UserEntity user = getUserDetails();
|
||||||
try {
|
try {
|
||||||
Object res = getService().search("", "", 1, Integer.MAX_VALUE, getSortings()[0], user.getUsername());
|
Object res = getService().search("", "", 1, Integer.MAX_VALUE, getSortings()[0], user.getUsername(), projectId);
|
||||||
return processResults(res);
|
return processResults(res);
|
||||||
} catch (CloudException ce) {
|
} catch (CloudException ce) {
|
||||||
throw ce;
|
throw ce;
|
||||||
|
|||||||
@@ -32,10 +32,11 @@ 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"), CloudDelete("cloud_delete.png"), CloudUpload(
|
"data_find.png"), CloudDownload("cloud_download.png"), CloudDelete("cloud_delete.png"), CloudEdit(
|
||||||
"cloud_upload.png"), NavLeftBlue("nav_left_blue.png"), NavRightBlue("nav_right_blue.png"), MissingImage(
|
"cloud_edit.png"), CloudUpload("cloud_upload.png"), NavLeftBlue("nav_left_blue.png"), NavRightBlue(
|
||||||
"missing_image.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudWait("cloud_wait.png"), Spinning(
|
"nav_right_blue.png"), MissingImage("missing_image.png"), CloudBg("cloud_bg.png"), CloudBig("cloud_big.png"), CloudWait(
|
||||||
"spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png"), Messages("messages.png");
|
"cloud_wait.png"), Spinning("spinning.gif"), Megaphone("megaphone.png"), Download("download.png"), Eye("eye.png"), Messages(
|
||||||
|
"messages.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
@@ -77,6 +77,16 @@ public class DialogFactory {
|
|||||||
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||||
|
IFileChooserAccessory accessory, JFrame ownerFrame) {
|
||||||
|
JFileChooser openFileChooser = new JFileChooser();
|
||||||
|
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory);
|
||||||
|
|
||||||
|
int result = openFileChooser.showOpenDialog(ownerFrame);
|
||||||
|
|
||||||
|
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
||||||
|
}
|
||||||
|
|
||||||
public File showSaveDialog(Window owner, FileFilter fileFilter, File initialFile, String defaultExtension,
|
public File showSaveDialog(Window owner, FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||||
IFileChooserAccessory accessory) {
|
IFileChooserAccessory accessory) {
|
||||||
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
||||||
@@ -137,8 +147,8 @@ public class DialogFactory {
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UploadDialog createUploadDialog(IPlugInPort plugInPort, String[] categories) {
|
public UploadDialog createUploadDialog(JFrame ownerFrame, IPlugInPort plugInPort, String[] categories, boolean isUpdate) {
|
||||||
UploadDialog dialog = new UploadDialog(mainFrame, plugInPort, categories);
|
UploadDialog dialog = new UploadDialog(ownerFrame, plugInPort, categories, isUpdate);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -405,7 +405,9 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void complete(final String[] result) {
|
public void complete(final String[] result) {
|
||||||
final UploadDialog dialog = DialogFactory.getInstance().createUploadDialog(thumbnailPresenter, result);
|
final UploadDialog dialog =
|
||||||
|
DialogFactory.getInstance().createUploadDialog(swingUI.getOwnerFrame(), thumbnailPresenter, result,
|
||||||
|
false);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
if (ButtonDialog.OK.equals(dialog.getSelectedButtonCaption())) {
|
if (ButtonDialog.OK.equals(dialog.getSelectedButtonCaption())) {
|
||||||
try {
|
try {
|
||||||
@@ -416,7 +418,8 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
@Override
|
@Override
|
||||||
public Void doInBackground() throws Exception {
|
public Void doInBackground() throws Exception {
|
||||||
cloudPresenter.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(),
|
cloudPresenter.uploadProject(dialog.getName(), dialog.getCategory(), dialog.getDescription(),
|
||||||
dialog.getKeywords(), plugInPort.getCurrentVersionNumber().toString(), thumbnailFile, file);
|
dialog.getKeywords(), plugInPort.getCurrentVersionNumber().toString(), thumbnailFile, file,
|
||||||
|
null);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,8 +435,6 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
"Upload Success", IView.INFORMATION_MESSAGE);
|
"Upload Success", IView.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
swingUI.showMessage("Could not prepare temporary files to be uploaded to the cloud.", "Upload Error",
|
swingUI.showMessage("Could not prepare temporary files to be uploaded to the cloud.", "Upload Error",
|
||||||
IView.ERROR_MESSAGE);
|
IView.ERROR_MESSAGE);
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
private String[] categories;
|
private String[] categories;
|
||||||
|
|
||||||
public UploadDialog(JFrame owner, IPlugInPort plugInPort, String[] categories) {
|
public UploadDialog(JFrame owner, IPlugInPort plugInPort, String[] categories, boolean isUpdate) {
|
||||||
super(owner, "Upload A Project", new String[] {OK, CANCEL});
|
super(owner, isUpdate ? "Re-Upload A Project" : "Upload A Project", new String[] {OK, CANCEL});
|
||||||
this.plugInPort = plugInPort;
|
this.plugInPort = plugInPort;
|
||||||
this.categories = categories;
|
this.categories = categories;
|
||||||
layoutGui();
|
layoutGui();
|
||||||
|
|||||||
+148
-25
@@ -8,8 +8,6 @@ import java.awt.GridBagConstraints;
|
|||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseAdapter;
|
import java.awt.event.MouseAdapter;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@@ -23,7 +21,6 @@ import java.util.List;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
@@ -45,11 +42,15 @@ import org.diylc.plugins.cloud.model.CommentEntity;
|
|||||||
import org.diylc.plugins.cloud.model.ProjectEntity;
|
import org.diylc.plugins.cloud.model.ProjectEntity;
|
||||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||||
import org.diylc.plugins.cloud.presenter.PagingProvider;
|
import org.diylc.plugins.cloud.presenter.PagingProvider;
|
||||||
|
import org.diylc.presenter.Presenter;
|
||||||
import org.diylc.swing.ISimpleView;
|
import org.diylc.swing.ISimpleView;
|
||||||
import org.diylc.swing.ISwingUI;
|
import org.diylc.swing.ISwingUI;
|
||||||
import org.diylc.swing.gui.DialogFactory;
|
import org.diylc.swing.gui.DialogFactory;
|
||||||
|
import org.diylc.swing.gui.DummyView;
|
||||||
import org.diylc.swing.plugins.cloud.view.CommentDialog;
|
import org.diylc.swing.plugins.cloud.view.CommentDialog;
|
||||||
|
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||||
|
import org.diylc.swingframework.ButtonDialog;
|
||||||
|
|
||||||
public class ResultsScrollPanel extends JScrollPane {
|
public class ResultsScrollPanel extends JScrollPane {
|
||||||
|
|
||||||
@@ -173,11 +174,11 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JComponent addProjectToDisplay(final ProjectEntity project) {
|
private JComponent addProjectToDisplay(final ProjectEntity project) {
|
||||||
JLabel thumbnailLabel = new JLabel(loadImage(project.getThumbnailUrl()));
|
final JLabel thumbnailLabel = new JLabel(loadImage(project.getThumbnailUrl()));
|
||||||
JLabel nameLabel = new JLabel("<html><b>" + project.getName() + "</b></html>");
|
final JLabel nameLabel = new JLabel("<html><b>" + project.getName() + "</b></html>");
|
||||||
nameLabel.setFont(nameLabel.getFont().deriveFont(12f));
|
nameLabel.setFont(nameLabel.getFont().deriveFont(12f));
|
||||||
|
|
||||||
JTextArea descriptionArea = new JTextArea(project.getDescription().replace("<br>", "\n"));
|
final JTextArea descriptionArea = new JTextArea(project.getDescription().replace("<br>", "\n"));
|
||||||
descriptionArea.setEditable(false);
|
descriptionArea.setEditable(false);
|
||||||
descriptionArea.setFont(thumbnailLabel.getFont());
|
descriptionArea.setFont(thumbnailLabel.getFont());
|
||||||
descriptionArea.setLineWrap(true);
|
descriptionArea.setLineWrap(true);
|
||||||
@@ -188,7 +189,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
|
caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
|
||||||
descriptionArea.setEnabled(false);
|
descriptionArea.setEnabled(false);
|
||||||
|
|
||||||
JLabel commentLabel =
|
final JLabel commentLabel =
|
||||||
new JLabel(Integer.toString(project.getCommentCount()), IconLoader.Messages.getIcon(), SwingConstants.LEFT);
|
new JLabel(Integer.toString(project.getCommentCount()), IconLoader.Messages.getIcon(), SwingConstants.LEFT);
|
||||||
commentLabel.setToolTipText("Click to see and add public comments");
|
commentLabel.setToolTipText("Click to see and add public comments");
|
||||||
commentLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
commentLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
@@ -218,27 +219,26 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JLabel viewLabel =
|
final JLabel viewLabel =
|
||||||
new JLabel(Integer.toString(project.getViewCount()), IconLoader.Eye.getIcon(), SwingConstants.LEFT);
|
new JLabel(Integer.toString(project.getViewCount()), IconLoader.Eye.getIcon(), SwingConstants.LEFT);
|
||||||
viewLabel.setToolTipText("View count");
|
viewLabel.setToolTipText("View count");
|
||||||
|
|
||||||
JLabel downloadLabel =
|
final JLabel downloadLabel =
|
||||||
new JLabel(Integer.toString(project.getDownloadCount()), IconLoader.Download.getIcon(), SwingConstants.LEFT);
|
new JLabel(Integer.toString(project.getDownloadCount()), IconLoader.Download.getIcon(), SwingConstants.LEFT);
|
||||||
downloadLabel.setToolTipText("Download count");
|
downloadLabel.setToolTipText("Download count");
|
||||||
|
|
||||||
JLabel categoryLabel = new JLabel("<html>Category: <b>" + project.getCategory() + "</b></html>");
|
final JLabel categoryLabel = new JLabel("<html>Category: <b>" + project.getCategory() + "</b></html>");
|
||||||
JLabel authorLabel = new JLabel("<html>Author: <b>" + project.getOwner() + "</b></html>");
|
final JLabel authorLabel = new JLabel("<html>Author: <b>" + project.getOwner() + "</b></html>");
|
||||||
JLabel updatedLabel = new JLabel("<html>Last updated: <b>" + project.getUpdated() + "</b></html>");
|
final JLabel updatedLabel = new JLabel("<html>Last updated: <b>" + project.getUpdated() + "</b></html>");
|
||||||
JButton downloadButton = new JButton(IconLoader.CloudDownload.getIcon());
|
|
||||||
|
|
||||||
downloadButton.setBorderPainted(false);
|
final JLabel downloadButton = new JLabel(IconLoader.CloudDownload.getIcon());
|
||||||
downloadButton.setContentAreaFilled(false);
|
downloadButton.setFocusable(true);
|
||||||
downloadButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
downloadButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
downloadButton.setToolTipText("Download to local drive");
|
downloadButton.setToolTipText("Download to local drive");
|
||||||
downloadButton.addActionListener(new ActionListener() {
|
downloadButton.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
final File file =
|
final File file =
|
||||||
DialogFactory.getInstance().showSaveDialog((JFrame) cloudUI, FileFilterEnum.DIY.getFilter(),
|
DialogFactory.getInstance().showSaveDialog((JFrame) cloudUI, FileFilterEnum.DIY.getFilter(),
|
||||||
new File(project.getName() + ".diy"), FileFilterEnum.DIY.getExtensions()[0], null);
|
new File(project.getName() + ".diy"), FileFilterEnum.DIY.getExtensions()[0], null);
|
||||||
@@ -297,21 +297,144 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JButton reuploadButton = new JButton(IconLoader.CloudUpload.getIcon());
|
final JLabel spacerLabel = new JLabel();
|
||||||
reuploadButton.setContentAreaFilled(false);
|
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.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
reuploadButton.setToolTipText("Re-upload to the cloud");
|
reuploadButton.setToolTipText("Re-upload to the cloud");
|
||||||
|
reuploadButton.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[]>() {
|
||||||
|
|
||||||
JButton deleteButton = new JButton(IconLoader.CloudDelete.getIcon());
|
@Override
|
||||||
deleteButton.setContentAreaFilled(false);
|
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>");
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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));
|
deleteButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
deleteButton.setToolTipText("Delete from the cloud");
|
deleteButton.setToolTipText("Delete from the cloud");
|
||||||
|
deleteButton.addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
|
@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) {
|
||||||
|
LOG.info("Deleting project " + project.getName() + "(" + project.getId() + ")");
|
||||||
|
cloudUI.executeBackgroundTask(new ITask<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void doInBackground() throws Exception {
|
||||||
|
cloudPresenter.deleteProject(project.getId());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(Exception e) {
|
||||||
|
cloudUI.showMessage("Could not delete the project. Detailed message is in the logs.", "Error",
|
||||||
|
ISwingUI.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void complete(Void result) {
|
||||||
|
getResultsPanel().remove(thumbnailLabel);
|
||||||
|
getResultsPanel().remove(nameLabel);
|
||||||
|
getResultsPanel().remove(spacerLabel);
|
||||||
|
getResultsPanel().remove(commentLabel);
|
||||||
|
getResultsPanel().remove(viewLabel);
|
||||||
|
getResultsPanel().remove(downloadLabel);
|
||||||
|
getResultsPanel().remove(descriptionArea);
|
||||||
|
getResultsPanel().remove(categoryLabel);
|
||||||
|
getResultsPanel().remove(buttonPanel);
|
||||||
|
getResultsPanel().remove(authorLabel);
|
||||||
|
getResultsPanel().remove(updatedLabel);
|
||||||
|
getResultsPanel().remove(separator);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout());
|
|
||||||
buttonPanel.setBackground(Color.white);
|
buttonPanel.setBackground(Color.white);
|
||||||
// buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
|
|
||||||
buttonPanel.add(downloadButton);
|
buttonPanel.add(downloadButton);
|
||||||
if (showEditControls) {
|
if (showEditControls) {
|
||||||
|
buttonPanel.add(editButton);
|
||||||
buttonPanel.add(reuploadButton);
|
buttonPanel.add(reuploadButton);
|
||||||
buttonPanel.add(deleteButton);
|
buttonPanel.add(deleteButton);
|
||||||
}
|
}
|
||||||
@@ -334,7 +457,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
|
|
||||||
gbc.gridx++;
|
gbc.gridx++;
|
||||||
gbc.weightx = 0.1;
|
gbc.weightx = 0.1;
|
||||||
getResultsPanel().add(new JLabel(), gbc);
|
getResultsPanel().add(spacerLabel, gbc);
|
||||||
|
|
||||||
gbc.gridx++;
|
gbc.gridx++;
|
||||||
gbc.weightx = 0;
|
gbc.weightx = 0;
|
||||||
@@ -388,7 +511,7 @@ public class ResultsScrollPanel extends JScrollPane {
|
|||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
getResultsPanel().add(new JSeparator(), gbc);
|
getResultsPanel().add(separator, gbc);
|
||||||
|
|
||||||
return nameLabel;
|
return nameLabel;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -62,7 +62,7 @@ public class UploadManagerFrame extends JFrame implements ISimpleView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProjectEntity> doInBackground() throws Exception {
|
public List<ProjectEntity> doInBackground() throws Exception {
|
||||||
return cloudPresenter.fetchUserUploads();
|
return cloudPresenter.fetchUserUploads(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -73,7 +73,7 @@ public class UploadManagerFrame extends JFrame implements ISimpleView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void complete(List<ProjectEntity> result) {
|
public void complete(List<ProjectEntity> result) {
|
||||||
setTitle(TITLE + " - " + result.size() + " Uploads Found");
|
// setTitle(TITLE + " - " + result.size() + " Uploads Found");
|
||||||
getResultsScrollPane().startSearch(result);
|
getResultsScrollPane().startSearch(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1366,6 +1366,10 @@
|
|||||||
<changeType>BUG_FIX</changeType>
|
<changeType>BUG_FIX</changeType>
|
||||||
<description>Solder pad component should not allow negative size</description>
|
<description>Solder pad component should not allow negative size</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>BUG_FIX</changeType>
|
||||||
|
<description>Fixed silent error when having a resistor without a valid value (e.g. missing units)</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
</changes>
|
</changes>
|
||||||
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
<url>https://github.com/bancika/diy-layout-creator/releases</url>
|
||||||
</org.diylc.appframework.update.Version>
|
</org.diylc.appframework.update.Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user