mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
download and open files from the cloud
This commit is contained in:
+1
-1
@@ -158,5 +158,5 @@ public interface ServiceAPI {
|
|||||||
/**
|
/**
|
||||||
* @return a {@link List} of available sortings.
|
* @return a {@link List} of available sortings.
|
||||||
*/
|
*/
|
||||||
List<String> getAvailableSortings();
|
List<String> getSortings();
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -248,6 +248,14 @@ public class CloudPresenter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getSortings() throws CloudException {
|
||||||
|
try {
|
||||||
|
return service.getSortings().toArray(new String[0]);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CloudException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getMachineId() {
|
private String getMachineId() {
|
||||||
if (machineId == null) {
|
if (machineId == null) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
+4
-4
@@ -381,7 +381,7 @@ public class ActionFactory {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
LOG.info("SaveAction triggered");
|
LOG.info("SaveAction triggered");
|
||||||
if (plugInPort.getCurrentFileName() == null) {
|
if (plugInPort.getCurrentFileName() == null) {
|
||||||
final File file = DialogFactory.getInstance().showSaveDialog(
|
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||||
FileFilterEnum.DIY.getFilter(), null,
|
FileFilterEnum.DIY.getFilter(), null,
|
||||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
@@ -455,7 +455,7 @@ public class ActionFactory {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
LOG.info("SaveAsAction triggered");
|
LOG.info("SaveAsAction triggered");
|
||||||
final File file = DialogFactory.getInstance().showSaveDialog(
|
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||||
FileFilterEnum.DIY.getFilter(), null,
|
FileFilterEnum.DIY.getFilter(), null,
|
||||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
@@ -526,7 +526,7 @@ public class ActionFactory {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
LOG.info("ExportPDFAction triggered");
|
LOG.info("ExportPDFAction triggered");
|
||||||
final File file = DialogFactory.getInstance().showSaveDialog(
|
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||||
FileFilterEnum.PDF.getFilter(), null,
|
FileFilterEnum.PDF.getFilter(), null,
|
||||||
FileFilterEnum.PDF.getExtensions()[0], null);
|
FileFilterEnum.PDF.getExtensions()[0], null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
@@ -574,7 +574,7 @@ public class ActionFactory {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
LOG.info("ExportPNGAction triggered");
|
LOG.info("ExportPNGAction triggered");
|
||||||
final File file = DialogFactory.getInstance().showSaveDialog(
|
final File file = DialogFactory.getInstance().showSaveDialog(swingUI.getOwnerFrame(),
|
||||||
FileFilterEnum.PNG.getFilter(), null,
|
FileFilterEnum.PNG.getFilter(), null,
|
||||||
FileFilterEnum.PNG.getExtensions()[0], null);
|
FileFilterEnum.PNG.getExtensions()[0], null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
|
|||||||
+14
-1
@@ -3,6 +3,7 @@ package org.diylc.swing;
|
|||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
import javax.swing.JPopupMenu.Separator;
|
import javax.swing.JPopupMenu.Separator;
|
||||||
|
|
||||||
@@ -35,7 +36,8 @@ public interface ISwingUI extends IView {
|
|||||||
* @throws BadPositionException
|
* @throws BadPositionException
|
||||||
* in case invalid position is specified
|
* in case invalid position is specified
|
||||||
*/
|
*/
|
||||||
void injectGUIComponent(JComponent component, int position) throws BadPositionException;
|
void injectGUIComponent(JComponent component, int position)
|
||||||
|
throws BadPositionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Injects a custom menu action into application's main menu. If
|
* Injects a custom menu action into application's main menu. If
|
||||||
@@ -60,5 +62,16 @@ public interface ISwingUI extends IView {
|
|||||||
*/
|
*/
|
||||||
void injectSubmenu(String name, Icon icon, String parentMenuName);
|
void injectSubmenu(String name, Icon icon, String parentMenuName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a task in background while showing busy cursor and a glass pane.
|
||||||
|
*
|
||||||
|
* @param task
|
||||||
|
*/
|
||||||
<T extends Object> void executeBackgroundTask(ITask<T> task);
|
<T extends Object> void executeBackgroundTask(ITask<T> task);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {@link JFrame} that can be used to reference secondary dialogs
|
||||||
|
* and frames
|
||||||
|
*/
|
||||||
|
JFrame getOwnerFrame();
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-11
@@ -1,5 +1,6 @@
|
|||||||
package org.diylc.swing.gui;
|
package org.diylc.swing.gui;
|
||||||
|
|
||||||
|
import java.awt.Window;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -16,10 +17,9 @@ import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
|||||||
import org.diylc.swing.gui.components.OverwritePromptFileChooser;
|
import org.diylc.swing.gui.components.OverwritePromptFileChooser;
|
||||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
|
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.CloudBrowserFrame;
|
|
||||||
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
|
||||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||||
|
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
||||||
import org.diylc.swing.plugins.file.BomDialog;
|
import org.diylc.swing.plugins.file.BomDialog;
|
||||||
import org.diylc.swingframework.AboutDialog;
|
import org.diylc.swingframework.AboutDialog;
|
||||||
import org.diylc.swingframework.IFileChooserAccessory;
|
import org.diylc.swingframework.IFileChooserAccessory;
|
||||||
@@ -84,13 +84,13 @@ public class DialogFactory {
|
|||||||
defaultExtension);
|
defaultExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File showSaveDialog(FileFilter fileFilter, File initialFile,
|
public File showSaveDialog(Window owner, FileFilter fileFilter, File initialFile,
|
||||||
String defaultExtension, IFileChooserAccessory accessory) {
|
String defaultExtension, IFileChooserAccessory accessory) {
|
||||||
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
||||||
initializeFileChooser(saveFileChooser, fileFilter, initialFile,
|
initializeFileChooser(saveFileChooser, fileFilter, initialFile,
|
||||||
defaultExtension, accessory);
|
defaultExtension, accessory);
|
||||||
|
|
||||||
int result = saveFileChooser.showSaveDialog(mainFrame);
|
int result = saveFileChooser.showSaveDialog(owner);
|
||||||
|
|
||||||
return processFileChooserResult(result, saveFileChooser,
|
return processFileChooserResult(result, saveFileChooser,
|
||||||
defaultExtension);
|
defaultExtension);
|
||||||
@@ -165,13 +165,6 @@ public class DialogFactory {
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CloudBrowserFrame createCloudBrowserFrame(IPlugInPort plugInPort,
|
|
||||||
CloudPresenter cloudPresenter) {
|
|
||||||
CloudBrowserFrame frame = new CloudBrowserFrame(mainFrame, plugInPort,
|
|
||||||
cloudPresenter);
|
|
||||||
return frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProgressDialog createProgressDialog(String title,
|
public ProgressDialog createProgressDialog(String title,
|
||||||
String[] buttonCaptions, String description, boolean useProgress) {
|
String[] buttonCaptions, String description, boolean useProgress) {
|
||||||
ProgressDialog dialog = new ProgressDialog(mainFrame, title,
|
ProgressDialog dialog = new ProgressDialog(mainFrame, title,
|
||||||
|
|||||||
+13
-9
@@ -88,8 +88,8 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
createBasePanels();
|
createBasePanels();
|
||||||
menuMap = new HashMap<String, JMenu>();
|
menuMap = new HashMap<String, JMenu>();
|
||||||
buttonGroupMap = new HashMap<String, ButtonGroup>();
|
buttonGroupMap = new HashMap<String, ButtonGroup>();
|
||||||
setIconImages(Arrays.asList(IconLoader.IconSmall.getImage(), IconLoader.IconMedium
|
setIconImages(Arrays.asList(IconLoader.IconSmall.getImage(),
|
||||||
.getImage(), IconLoader.IconLarge.getImage()));
|
IconLoader.IconMedium.getImage(), IconLoader.IconLarge.getImage()));
|
||||||
DialogFactory.getInstance().initialize(this);
|
DialogFactory.getInstance().initialize(this);
|
||||||
|
|
||||||
this.presenter = new Presenter(this);
|
this.presenter = new Presenter(this);
|
||||||
@@ -278,8 +278,8 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void injectMenuAction(Action action, String menuName) {
|
public void injectMenuAction(Action action, String menuName) {
|
||||||
LOG.info(String.format("injectMenuAction(%s, %s)", action == null ? "Separator" : action
|
LOG.info(String.format("injectMenuAction(%s, %s)",
|
||||||
.getValue(Action.NAME), menuName));
|
action == null ? "Separator" : action.getValue(Action.NAME), menuName));
|
||||||
JMenu menu = findOrCreateMenu(menuName);
|
JMenu menu = findOrCreateMenu(menuName);
|
||||||
if (action == null) {
|
if (action == null) {
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
@@ -343,11 +343,15 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
worker.execute();
|
worker.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JFrame getOwnerFrame() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File promptFileSave() {
|
public File promptFileSave() {
|
||||||
return DialogFactory.getInstance().showSaveDialog(
|
return DialogFactory.getInstance().showSaveDialog(this, FileFilterEnum.DIY.getFilter(),
|
||||||
FileFilterEnum.DIY.getFilter(), null,
|
null, FileFilterEnum.DIY.getExtensions()[0], null);
|
||||||
FileFilterEnum.DIY.getExtensions()[0], null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class FramePlugin implements IPlugIn {
|
class FramePlugin implements IPlugIn {
|
||||||
@@ -372,8 +376,8 @@ public class MainFrame extends JFrame implements ISwingUI {
|
|||||||
fileName = "Untitled";
|
fileName = "Untitled";
|
||||||
}
|
}
|
||||||
String modified = (Boolean) params[1] ? " (modified)" : "";
|
String modified = (Boolean) params[1] ? " (modified)" : "";
|
||||||
setTitle(String.format("DIYLC %s - %s %s", plugInPort
|
setTitle(String.format("DIYLC %s - %s %s", plugInPort.getCurrentVersionNumber(),
|
||||||
.getCurrentVersionNumber(), fileName, modified));
|
fileName, modified));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-5
@@ -14,7 +14,6 @@ import org.diylc.common.IPlugInPort;
|
|||||||
import org.diylc.common.ITask;
|
import org.diylc.common.ITask;
|
||||||
import org.diylc.core.IView;
|
import org.diylc.core.IView;
|
||||||
import org.diylc.images.IconLoader;
|
import org.diylc.images.IconLoader;
|
||||||
import org.diylc.plugins.cloud.model.UserEntity;
|
|
||||||
import org.diylc.plugins.cloud.presenter.CloudException;
|
import org.diylc.plugins.cloud.presenter.CloudException;
|
||||||
import org.diylc.plugins.cloud.presenter.CloudListener;
|
import org.diylc.plugins.cloud.presenter.CloudListener;
|
||||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||||
@@ -25,8 +24,8 @@ import org.diylc.swing.gui.DummyView;
|
|||||||
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
|
import org.diylc.swing.plugins.cloud.view.ChangePasswordDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.CloudBrowserFrame;
|
import org.diylc.swing.plugins.cloud.view.CloudBrowserFrame;
|
||||||
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
||||||
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
|
||||||
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||||
|
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
|
||||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||||
import org.diylc.swingframework.ButtonDialog;
|
import org.diylc.swingframework.ButtonDialog;
|
||||||
import org.diylc.swingframework.ProgressDialog;
|
import org.diylc.swingframework.ProgressDialog;
|
||||||
@@ -53,6 +52,8 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
private ChangePasswordAction changePasswordAction;
|
private ChangePasswordAction changePasswordAction;
|
||||||
private ManageProjectsAction manageProjectsAction;
|
private ManageProjectsAction manageProjectsAction;
|
||||||
|
|
||||||
|
private CloudBrowserFrame cloudBrowser;
|
||||||
|
|
||||||
public CloudPlugIn(ISwingUI swingUI) {
|
public CloudPlugIn(ISwingUI swingUI) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@@ -110,6 +111,14 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CloudBrowserFrame getCloudBrowser() {
|
||||||
|
if (cloudBrowser == null) {
|
||||||
|
cloudBrowser = new CloudBrowserFrame(swingUI.getOwnerFrame(),
|
||||||
|
plugInPort, cloudPresenter);
|
||||||
|
}
|
||||||
|
return cloudBrowser;
|
||||||
|
}
|
||||||
|
|
||||||
public LibraryAction getLibraryAction() {
|
public LibraryAction getLibraryAction() {
|
||||||
if (libraryAction == null) {
|
if (libraryAction == null) {
|
||||||
libraryAction = new LibraryAction();
|
libraryAction = new LibraryAction();
|
||||||
@@ -187,9 +196,8 @@ public class CloudPlugIn implements IPlugIn, CloudListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
CloudBrowserFrame frame = DialogFactory.getInstance()
|
getCloudBrowser().setVisible(true);
|
||||||
.createCloudBrowserFrame(plugInPort, cloudPresenter);
|
getCloudBrowser().requestFocus();
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-11
@@ -90,8 +90,7 @@ public class ChangePasswordDialog extends ButtonDialog {
|
|||||||
this.oldPassword = new String(getOldPasswordField().getPassword());
|
this.oldPassword = new String(getOldPasswordField().getPassword());
|
||||||
|
|
||||||
String newPassword = new String(getNewPasswordField().getPassword());
|
String newPassword = new String(getNewPasswordField().getPassword());
|
||||||
String confirmPassword = new String(getConfirmPasswordField()
|
String confirmPassword = new String(getConfirmPasswordField().getPassword());
|
||||||
.getPassword());
|
|
||||||
if (newPassword.equals(confirmPassword)) {
|
if (newPassword.equals(confirmPassword)) {
|
||||||
this.newPassword = newPassword;
|
this.newPassword = newPassword;
|
||||||
} else {
|
} else {
|
||||||
@@ -99,17 +98,14 @@ public class ChangePasswordDialog extends ButtonDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JButton okButton = getButton(OK);
|
JButton okButton = getButton(OK);
|
||||||
okButton.setEnabled((this.newPassword != null)
|
okButton.setEnabled((this.newPassword != null) && (this.newPassword.length() > 0) && (this.oldPassword != null)
|
||||||
&& (this.newPassword.length() > 0)
|
|
||||||
&& (this.oldPassword != null)
|
|
||||||
&& (this.oldPassword.length() > 0));
|
&& (this.oldPassword.length() > 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPasswordField getOldPasswordField() {
|
private JPasswordField getOldPasswordField() {
|
||||||
if (oldPasswordField == null) {
|
if (oldPasswordField == null) {
|
||||||
oldPasswordField = new JPasswordField();
|
oldPasswordField = new JPasswordField();
|
||||||
oldPasswordField.getDocument().addDocumentListener(
|
oldPasswordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
new DocumentListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
@@ -133,8 +129,7 @@ public class ChangePasswordDialog extends ButtonDialog {
|
|||||||
private JPasswordField getNewPasswordField() {
|
private JPasswordField getNewPasswordField() {
|
||||||
if (newPasswordField == null) {
|
if (newPasswordField == null) {
|
||||||
newPasswordField = new JPasswordField();
|
newPasswordField = new JPasswordField();
|
||||||
newPasswordField.getDocument().addDocumentListener(
|
newPasswordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
new DocumentListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
@@ -158,8 +153,7 @@ public class ChangePasswordDialog extends ButtonDialog {
|
|||||||
private JPasswordField getConfirmPasswordField() {
|
private JPasswordField getConfirmPasswordField() {
|
||||||
if (confirmPasswordField == null) {
|
if (confirmPasswordField == null) {
|
||||||
confirmPasswordField = new JPasswordField();
|
confirmPasswordField = new JPasswordField();
|
||||||
confirmPasswordField.getDocument().addDocumentListener(
|
confirmPasswordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
new DocumentListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
|
|||||||
+124
-40
@@ -9,8 +9,12 @@ import java.awt.Image;
|
|||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.channels.Channels;
|
||||||
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
@@ -29,6 +33,8 @@ import javax.swing.JSeparator;
|
|||||||
import javax.swing.JTabbedPane;
|
import javax.swing.JTabbedPane;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
@@ -38,7 +44,10 @@ import org.diylc.images.IconLoader;
|
|||||||
import org.diylc.plugins.cloud.model.ProjectEntity;
|
import org.diylc.plugins.cloud.model.ProjectEntity;
|
||||||
import org.diylc.plugins.cloud.presenter.CloudException;
|
import org.diylc.plugins.cloud.presenter.CloudException;
|
||||||
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
import org.diylc.plugins.cloud.presenter.CloudPresenter;
|
||||||
|
import org.diylc.swing.ISwingUI;
|
||||||
import org.diylc.swing.gui.CustomGlassPane;
|
import org.diylc.swing.gui.CustomGlassPane;
|
||||||
|
import org.diylc.swing.gui.DialogFactory;
|
||||||
|
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||||
|
|
||||||
public class CloudBrowserFrame extends JFrame {
|
public class CloudBrowserFrame extends JFrame {
|
||||||
|
|
||||||
@@ -66,8 +75,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
private int pageNumber;
|
private int pageNumber;
|
||||||
private int itemsPerPage = 10;
|
private int itemsPerPage = 10;
|
||||||
|
|
||||||
public CloudBrowserFrame(JFrame owner, IPlugInPort plugInPort,
|
public CloudBrowserFrame(JFrame owner, IPlugInPort plugInPort, CloudPresenter cloudPresenter) {
|
||||||
CloudPresenter cloudPresenter) {
|
|
||||||
super("DIY Cloud Browser");
|
super("DIY Cloud Browser");
|
||||||
this.setIconImage(IconLoader.Cloud.getImage());
|
this.setIconImage(IconLoader.Cloud.getImage());
|
||||||
this.setPreferredSize(new Dimension(800, 600));
|
this.setPreferredSize(new Dimension(800, 600));
|
||||||
@@ -100,10 +108,16 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
private JTabbedPane getTabbedPane() {
|
private JTabbedPane getTabbedPane() {
|
||||||
if (tabbedPane == null) {
|
if (tabbedPane == null) {
|
||||||
tabbedPane = new JTabbedPane();
|
tabbedPane = new JTabbedPane();
|
||||||
tabbedPane.addTab("Dashboard", IconLoader.Dashboard.getIcon(),
|
tabbedPane.addTab("Dashboard", IconLoader.Dashboard.getIcon(), getDashboardPanel());
|
||||||
getDashboardPanel());
|
tabbedPane.addTab("Search For Projects", IconLoader.Find.getIcon(), getBrowsePanel());
|
||||||
tabbedPane.addTab("Search For Projects", IconLoader.Find.getIcon(),
|
tabbedPane.addChangeListener(new ChangeListener() {
|
||||||
getBrowsePanel());
|
|
||||||
|
@Override
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
if (getTabbedPane().getSelectedIndex() == 1)
|
||||||
|
getSearchField().requestFocus();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return tabbedPane;
|
return tabbedPane;
|
||||||
}
|
}
|
||||||
@@ -119,6 +133,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
if (browsePanel == null) {
|
if (browsePanel == null) {
|
||||||
browsePanel = new JPanel(new GridBagLayout());
|
browsePanel = new JPanel(new GridBagLayout());
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
browsePanel.setBackground(Color.white);
|
||||||
gbc.anchor = GridBagConstraints.NORTH;
|
gbc.anchor = GridBagConstraints.NORTH;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
gbc.gridx = 0;
|
gbc.gridx = 0;
|
||||||
@@ -127,6 +142,10 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
browsePanel.add(getSearchPanel(), gbc);
|
browsePanel.add(getSearchPanel(), gbc);
|
||||||
|
|
||||||
|
// gbc.gridy = 1;
|
||||||
|
// gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
// browsePanel.add(new JSeparator(), gbc);
|
||||||
|
|
||||||
gbc.gridy = 1;
|
gbc.gridy = 1;
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
@@ -138,6 +157,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
private JPanel getSearchPanel() {
|
private JPanel getSearchPanel() {
|
||||||
if (searchPanel == null) {
|
if (searchPanel == null) {
|
||||||
searchPanel = new JPanel(new GridBagLayout());
|
searchPanel = new JPanel(new GridBagLayout());
|
||||||
|
searchPanel.setBackground(Color.white);
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
gbc.anchor = GridBagConstraints.LINE_START;
|
gbc.anchor = GridBagConstraints.LINE_START;
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
@@ -194,7 +214,12 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
|
|
||||||
private JComboBox getSortBox() {
|
private JComboBox getSortBox() {
|
||||||
if (sortBox == null) {
|
if (sortBox == null) {
|
||||||
sortBox = new JComboBox();
|
try {
|
||||||
|
sortBox = new JComboBox(cloudPresenter.getSortings());
|
||||||
|
} catch (CloudException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sortBox;
|
return sortBox;
|
||||||
}
|
}
|
||||||
@@ -203,6 +228,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
if (resultsScrollPane == null) {
|
if (resultsScrollPane == null) {
|
||||||
resultsScrollPane = new JScrollPane(getResultsPanel());
|
resultsScrollPane = new JScrollPane(getResultsPanel());
|
||||||
resultsScrollPane.getVerticalScrollBar().setUnitIncrement(16);
|
resultsScrollPane.getVerticalScrollBar().setUnitIncrement(16);
|
||||||
|
resultsScrollPane.setBorder(null);
|
||||||
}
|
}
|
||||||
return resultsScrollPane;
|
return resultsScrollPane;
|
||||||
}
|
}
|
||||||
@@ -227,36 +253,26 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
executeBackgroundTask(new ITask<List<ProjectEntity>>() {
|
executeBackgroundTask(new ITask<List<ProjectEntity>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ProjectEntity> doInBackground()
|
public List<ProjectEntity> doInBackground() throws Exception {
|
||||||
throws Exception {
|
return cloudPresenter.search(getSearchField().getText(),
|
||||||
return cloudPresenter.search(getSearchField()
|
getCategoryBox().getSelectedItem() == null ? "" : getCategoryBox()
|
||||||
.getText(), getCategoryBox()
|
.getSelectedItem().toString(), getSortBox().getSelectedItem() == null ? ""
|
||||||
.getSelectedItem() == null ? ""
|
: getSortBox().getSelectedItem().toString(),
|
||||||
: getCategoryBox().getSelectedItem()
|
CloudBrowserFrame.this.pageNumber, CloudBrowserFrame.this.itemsPerPage);
|
||||||
.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(
|
showMessage("Search failed. Error: " + e.getMessage(), "Search Failed", IView.ERROR_MESSAGE);
|
||||||
"Search failed. Error: " + e.getMessage(),
|
|
||||||
"Search Failed", IView.ERROR_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void complete(List<ProjectEntity> result) {
|
public void complete(List<ProjectEntity> result) {
|
||||||
getResultsPanel().removeAll();
|
getResultsPanel().removeAll();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Iterator<ProjectEntity> i = result.iterator(); i
|
for (Iterator<ProjectEntity> i = result.iterator(); i.hasNext();) {
|
||||||
.hasNext();) {
|
|
||||||
ProjectEntity project = i.next();
|
ProjectEntity project = i.next();
|
||||||
addProjectToDisplay(project, count++,
|
addProjectToDisplay(project, count++, i.hasNext());
|
||||||
i.hasNext());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -293,27 +309,81 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
worker.execute();
|
worker.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addProjectToDisplay(ProjectEntity project, int location,
|
private void addProjectToDisplay(final ProjectEntity project, int location, boolean hasNext) {
|
||||||
boolean hasNext) {
|
JLabel thumbnailLabel = new JLabel(downloadImage(project.getThumbnailUrl()));
|
||||||
JLabel thumbnailLabel = new JLabel(
|
JLabel nameLabel = new JLabel("<html><b>" + project.getName() + "</b></html>");
|
||||||
downloadImage(project.getThumbnailUrl()));
|
|
||||||
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>"
|
JLabel descriptionLabel = new JLabel("<html>" + project.getDescription() + "</html>");
|
||||||
+ project.getDescription() + "</html>");
|
|
||||||
JLabel categoryLabel = new JLabel("Category: " + project.getCategory());
|
JLabel categoryLabel = new JLabel("Category: " + project.getCategory());
|
||||||
JLabel authorLabel = new JLabel("<html>by: <b>" + project.getOwner()
|
JLabel authorLabel = new JLabel("<html>by: <b>" + project.getOwner() + "</b></html>");
|
||||||
+ "</b></html>");
|
JLabel updatedLabel = new JLabel("Last updated: " + project.getUpdated());
|
||||||
JLabel updatedLabel = new JLabel("Last updated: "
|
|
||||||
+ project.getUpdated());
|
|
||||||
JButton downloadButton = new JButton(IconLoader.CloudDownload.getIcon());
|
JButton downloadButton = new JButton(IconLoader.CloudDownload.getIcon());
|
||||||
|
|
||||||
downloadButton.setBorderPainted(false);
|
downloadButton.setBorderPainted(false);
|
||||||
// downloadButton.setFocusPainted(false);
|
// downloadButton.setFocusPainted(false);
|
||||||
downloadButton.setContentAreaFilled(false);
|
downloadButton.setContentAreaFilled(false);
|
||||||
downloadButton
|
downloadButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
downloadButton.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
final File file = DialogFactory.getInstance().showSaveDialog(CloudBrowserFrame.this,
|
||||||
|
FileFilterEnum.DIY.getFilter(), new File(project.getName() + ".diy"),
|
||||||
|
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||||
|
if (file != null) {
|
||||||
|
CloudBrowserFrame.this.executeBackgroundTask(new ITask<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void doInBackground() throws Exception {
|
||||||
|
LOG.debug("Downloading project to to " + file.getAbsolutePath());
|
||||||
|
URL website = new URL(project.getDownloadUrl());
|
||||||
|
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
|
||||||
|
FileOutputStream fos = new FileOutputStream(file.getAbsolutePath());
|
||||||
|
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||||
|
fos.close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void complete(Void result) {
|
||||||
|
if (CloudBrowserFrame.this.showConfirmDialog(
|
||||||
|
"Project downloaded to " + file.getAbsolutePath() + ".\nDo you want to open it?",
|
||||||
|
"Cloud", ISwingUI.YES_NO_OPTION, ISwingUI.INFORMATION_MESSAGE) == IView.YES_OPTION) {
|
||||||
|
if (!plugInPort.allowFileAction()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloudBrowserFrame.this.executeBackgroundTask(new ITask<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void doInBackground() throws Exception {
|
||||||
|
LOG.debug("Opening from " + file.getAbsolutePath());
|
||||||
|
plugInPort.loadProjectFromFile(file.getAbsolutePath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void complete(Void result) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(Exception e) {
|
||||||
|
CloudBrowserFrame.this.showMessage("Could not open file. " + e.getMessage(),
|
||||||
|
"Error", ISwingUI.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(Exception e) {
|
||||||
|
CloudBrowserFrame.this.showMessage("Could not save to file. " + e.getMessage(), "Error",
|
||||||
|
ISwingUI.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
gbc.anchor = GridBagConstraints.NORTHWEST;
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
@@ -328,14 +398,19 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
gbc.gridheight = 1;
|
gbc.gridheight = 1;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
|
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.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;
|
||||||
gbc.weighty = 1;
|
gbc.weighty = 1;
|
||||||
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
|
gbc.insets = new Insets(2, 6, 2, 2);
|
||||||
getResultsPanel().add(descriptionLabel, gbc);
|
getResultsPanel().add(descriptionLabel, gbc);
|
||||||
|
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
@@ -345,11 +420,15 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
|
|
||||||
gbc.gridx = 2;
|
gbc.gridx = 2;
|
||||||
gbc.gridheight = 2;
|
gbc.gridheight = 2;
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
|
gbc.anchor = GridBagConstraints.SOUTHEAST;
|
||||||
getResultsPanel().add(downloadButton, gbc);
|
getResultsPanel().add(downloadButton, gbc);
|
||||||
|
|
||||||
gbc.gridy++;
|
gbc.gridy++;
|
||||||
gbc.gridx = 1;
|
gbc.gridx = 1;
|
||||||
gbc.gridheight = 1;
|
gbc.gridheight = 1;
|
||||||
|
gbc.insets = new Insets(2, 6, 2, 2);
|
||||||
|
gbc.anchor = GridBagConstraints.NORTHWEST;
|
||||||
getResultsPanel().add(updatedLabel, gbc);
|
getResultsPanel().add(updatedLabel, gbc);
|
||||||
|
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
@@ -358,6 +437,7 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
gbc.gridwidth = 3;
|
gbc.gridwidth = 3;
|
||||||
gbc.fill = GridBagConstraints.HORIZONTAL;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc.weightx = 1;
|
gbc.weightx = 1;
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
getResultsPanel().add(new JSeparator(), gbc);
|
getResultsPanel().add(new JSeparator(), gbc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -366,6 +446,10 @@ public class CloudBrowserFrame extends JFrame {
|
|||||||
JOptionPane.showMessageDialog(this, message, title, messageType);
|
JOptionPane.showMessageDialog(this, message, title, messageType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int showConfirmDialog(String message, String title, int optionType, int messageType) {
|
||||||
|
return JOptionPane.showConfirmDialog(this, message, title, optionType, messageType);
|
||||||
|
}
|
||||||
|
|
||||||
private Icon downloadImage(String imageUrl) {
|
private Icon downloadImage(String imageUrl) {
|
||||||
Image image = null;
|
Image image = null;
|
||||||
try {
|
try {
|
||||||
|
|||||||
+13
-25
@@ -60,8 +60,7 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
private CloudPresenter cloudPresenter;
|
private CloudPresenter cloudPresenter;
|
||||||
|
|
||||||
public UploadDialog(JFrame owner, IPlugInPort plugInPort,
|
public UploadDialog(JFrame owner, IPlugInPort plugInPort, CloudPresenter cloudPresenter) {
|
||||||
CloudPresenter cloudPresenter) {
|
|
||||||
super(owner, "Upload A Project", new String[] { OK, CANCEL });
|
super(owner, "Upload A Project", new String[] { OK, CANCEL });
|
||||||
this.plugInPort = plugInPort;
|
this.plugInPort = plugInPort;
|
||||||
this.cloudPresenter = cloudPresenter;
|
this.cloudPresenter = cloudPresenter;
|
||||||
@@ -158,8 +157,7 @@ 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(
|
termsLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
|
||||||
BorderFactory.createEtchedBorder(),
|
|
||||||
BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
||||||
termsLabel.setText(TERMS_HTML);
|
termsLabel.setText(TERMS_HTML);
|
||||||
}
|
}
|
||||||
@@ -189,14 +187,11 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
paintThumbnail(g, getBounds());
|
paintThumbnail(g, getBounds());
|
||||||
}
|
}
|
||||||
}, gbc);
|
}, gbc);
|
||||||
Dimension d = UploadDialog.this.plugInPort
|
Dimension d = UploadDialog.this.plugInPort.getCanvasDimensions(false);
|
||||||
.getCanvasDimensions(false);
|
|
||||||
if (d.height > d.width)
|
if (d.height > d.width)
|
||||||
thumbnailPanel.setPreferredSize(new Dimension(192 * d.width
|
thumbnailPanel.setPreferredSize(new Dimension(192 * d.width / d.height, 192));
|
||||||
/ d.height, 192));
|
|
||||||
else
|
else
|
||||||
thumbnailPanel.setPreferredSize(new Dimension(192, 192
|
thumbnailPanel.setPreferredSize(new Dimension(192, 192 * d.height / d.width));
|
||||||
* d.height / d.width));
|
|
||||||
thumbnailPanel.setBorder(BorderFactory.createEtchedBorder());
|
thumbnailPanel.setBorder(BorderFactory.createEtchedBorder());
|
||||||
}
|
}
|
||||||
return thumbnailPanel;
|
return thumbnailPanel;
|
||||||
@@ -208,10 +203,8 @@ 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()
|
if (plugInPort.getProjectProperties().get(i).getName().equals("Title"))
|
||||||
.equals("Title"))
|
nameField.setText(plugInPort.getProjectProperties().get(i).getValue().toString());
|
||||||
nameField.setText(plugInPort.getProjectProperties().get(i)
|
|
||||||
.getValue().toString());
|
|
||||||
}
|
}
|
||||||
return nameField;
|
return nameField;
|
||||||
}
|
}
|
||||||
@@ -234,10 +227,8 @@ 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()
|
if (plugInPort.getProjectProperties().get(i).getName().equals("Description"))
|
||||||
.equals("Description"))
|
descriptionArea.setText(plugInPort.getProjectProperties().get(i).getValue().toString());
|
||||||
descriptionArea.setText(plugInPort.getProjectProperties()
|
|
||||||
.get(i).getValue().toString());
|
|
||||||
descriptionArea.setBorder(getNameField().getBorder());
|
descriptionArea.setBorder(getNameField().getBorder());
|
||||||
descriptionArea.setFont(getNameField().getFont());
|
descriptionArea.setFont(getNameField().getFont());
|
||||||
}
|
}
|
||||||
@@ -264,13 +255,11 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BufferedImage getThumbnail() {
|
public BufferedImage getThumbnail() {
|
||||||
BufferedImage thumbnailImage = new BufferedImage(getThumbnailPanel()
|
BufferedImage thumbnailImage = new BufferedImage(getThumbnailPanel().getWidth(), getThumbnailPanel()
|
||||||
.getWidth(), getThumbnailPanel().getHeight(),
|
.getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||||
BufferedImage.TYPE_INT_RGB);
|
|
||||||
Graphics2D cg = thumbnailImage.createGraphics();
|
Graphics2D cg = thumbnailImage.createGraphics();
|
||||||
|
|
||||||
paintThumbnail(cg, new Rectangle(thumbnailImage.getWidth(),
|
paintThumbnail(cg, new Rectangle(thumbnailImage.getWidth(), thumbnailImage.getHeight()));
|
||||||
thumbnailImage.getHeight()));
|
|
||||||
return thumbnailImage;
|
return thumbnailImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,8 +280,7 @@ public class UploadDialog extends ButtonDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
g2d.scale(zoomRatio, zoomRatio);
|
g2d.scale(zoomRatio, zoomRatio);
|
||||||
UploadDialog.this.plugInPort.draw(g2d,
|
UploadDialog.this.plugInPort.draw(g2d, EnumSet.of(DrawOption.ANTIALIASING), null);
|
||||||
EnumSet.of(DrawOption.ANTIALIASING), null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKeywords() {
|
public String getKeywords() {
|
||||||
|
|||||||
+8
-16
@@ -42,8 +42,7 @@ public class UserEditDialog extends ButtonDialog {
|
|||||||
private UserEntity existingEntity;
|
private UserEntity existingEntity;
|
||||||
|
|
||||||
public UserEditDialog(JFrame owner, UserEntity existingEntity) {
|
public UserEditDialog(JFrame owner, UserEntity existingEntity) {
|
||||||
super(owner, existingEntity == null ? "New Account" : "Manage Account",
|
super(owner, existingEntity == null ? "New Account" : "Manage Account", new String[] { OK, CANCEL });
|
||||||
new String[] { OK, CANCEL });
|
|
||||||
|
|
||||||
this.existingEntity = existingEntity;
|
this.existingEntity = existingEntity;
|
||||||
|
|
||||||
@@ -136,8 +135,7 @@ public class UserEditDialog extends ButtonDialog {
|
|||||||
private void refreshState() {
|
private void refreshState() {
|
||||||
this.userName = getUserNameField().getText();
|
this.userName = getUserNameField().getText();
|
||||||
String password = new String(getPasswordField().getPassword());
|
String password = new String(getPasswordField().getPassword());
|
||||||
String confirmPassword = new String(getConfirmPasswordField()
|
String confirmPassword = new String(getConfirmPasswordField().getPassword());
|
||||||
.getPassword());
|
|
||||||
if (password.equals(confirmPassword)) {
|
if (password.equals(confirmPassword)) {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
} else {
|
} else {
|
||||||
@@ -148,8 +146,7 @@ public class UserEditDialog extends ButtonDialog {
|
|||||||
this.bio = getBioArea().getText();
|
this.bio = getBioArea().getText();
|
||||||
JButton okButton = getButton(OK);
|
JButton okButton = getButton(OK);
|
||||||
okButton.setEnabled((this.userName.length() > 0)
|
okButton.setEnabled((this.userName.length() > 0)
|
||||||
&& (this.existingEntity != null || ((this.password != null) && (this.password
|
&& (this.existingEntity != null || ((this.password != null) && (this.password.length() > 0))));
|
||||||
.length() > 0))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JTextField getUserNameField() {
|
private JTextField getUserNameField() {
|
||||||
@@ -159,8 +156,7 @@ public class UserEditDialog extends ButtonDialog {
|
|||||||
userNameField.setText(existingEntity.getUsername());
|
userNameField.setText(existingEntity.getUsername());
|
||||||
userNameField.setEditable(false);
|
userNameField.setEditable(false);
|
||||||
}
|
}
|
||||||
userNameField.getDocument().addDocumentListener(
|
userNameField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
new DocumentListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
@@ -184,8 +180,7 @@ public class UserEditDialog extends ButtonDialog {
|
|||||||
private JPasswordField getPasswordField() {
|
private JPasswordField getPasswordField() {
|
||||||
if (passwordField == null) {
|
if (passwordField == null) {
|
||||||
passwordField = new JPasswordField();
|
passwordField = new JPasswordField();
|
||||||
passwordField.getDocument().addDocumentListener(
|
passwordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
new DocumentListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
@@ -209,8 +204,7 @@ public class UserEditDialog extends ButtonDialog {
|
|||||||
private JPasswordField getConfirmPasswordField() {
|
private JPasswordField getConfirmPasswordField() {
|
||||||
if (confirmPasswordField == null) {
|
if (confirmPasswordField == null) {
|
||||||
confirmPasswordField = new JPasswordField();
|
confirmPasswordField = new JPasswordField();
|
||||||
confirmPasswordField.getDocument().addDocumentListener(
|
confirmPasswordField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
new DocumentListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
@@ -236,8 +230,7 @@ public class UserEditDialog extends ButtonDialog {
|
|||||||
emailField = new JTextField();
|
emailField = new JTextField();
|
||||||
if (existingEntity != null)
|
if (existingEntity != null)
|
||||||
emailField.setText(existingEntity.getEmail());
|
emailField.setText(existingEntity.getEmail());
|
||||||
emailField.getDocument().addDocumentListener(
|
emailField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
new DocumentListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
@@ -263,8 +256,7 @@ public class UserEditDialog extends ButtonDialog {
|
|||||||
websiteField = new JTextField();
|
websiteField = new JTextField();
|
||||||
if (existingEntity != null)
|
if (existingEntity != null)
|
||||||
websiteField.setText(existingEntity.getWebsite());
|
websiteField.setText(existingEntity.getWebsite());
|
||||||
websiteField.getDocument().addDocumentListener(
|
websiteField.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
new DocumentListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
|
|||||||
+10
-11
@@ -55,8 +55,8 @@ public class BomDialog extends JDialog {
|
|||||||
private ObjectListTable<BomEntry> getTable() {
|
private ObjectListTable<BomEntry> getTable() {
|
||||||
if (table == null) {
|
if (table == null) {
|
||||||
try {
|
try {
|
||||||
table = new ObjectListTable<BomEntry>(BomEntry.class, new String[] { "getName",
|
table = new ObjectListTable<BomEntry>(BomEntry.class, new String[] { "getName", "getValue",
|
||||||
"getValue", "getQuantity", "getNotes/setNotes" }, null);
|
"getQuantity", "getNotes/setNotes" }, null);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
@@ -89,9 +89,8 @@ public class BomDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
File file = DialogFactory.getInstance().showSaveDialog(
|
File file = DialogFactory.getInstance().showSaveDialog(BomDialog.this.getOwner(),
|
||||||
FileFilterEnum.EXCEL.getFilter(), null,
|
FileFilterEnum.EXCEL.getFilter(), null, FileFilterEnum.EXCEL.getExtensions()[0], null);
|
||||||
FileFilterEnum.EXCEL.getExtensions()[0], null);
|
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
try {
|
try {
|
||||||
TableExporter.getInstance().exportToExcel(getTable(), file);
|
TableExporter.getInstance().exportToExcel(getTable(), file);
|
||||||
@@ -115,8 +114,8 @@ public class BomDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.CSV.getFilter(),
|
File file = DialogFactory.getInstance().showSaveDialog(BomDialog.this.getOwner(),
|
||||||
null, FileFilterEnum.CSV.getExtensions()[0], null);
|
FileFilterEnum.CSV.getFilter(), null, FileFilterEnum.CSV.getExtensions()[0], null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
try {
|
try {
|
||||||
TableExporter.getInstance().exportToCSV(getTable(), file);
|
TableExporter.getInstance().exportToCSV(getTable(), file);
|
||||||
@@ -140,8 +139,8 @@ public class BomDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.HTML.getFilter(),
|
File file = DialogFactory.getInstance().showSaveDialog(BomDialog.this.getOwner(),
|
||||||
null, FileFilterEnum.HTML.getExtensions()[0], null);
|
FileFilterEnum.HTML.getFilter(), null, FileFilterEnum.HTML.getExtensions()[0], null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
try {
|
try {
|
||||||
TableExporter.getInstance().exportToHTML(getTable(), file);
|
TableExporter.getInstance().exportToHTML(getTable(), file);
|
||||||
@@ -165,8 +164,8 @@ public class BomDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
File file = DialogFactory.getInstance().showSaveDialog(FileFilterEnum.PNG.getFilter(),
|
File file = DialogFactory.getInstance().showSaveDialog(BomDialog.this.getOwner(),
|
||||||
null, FileFilterEnum.PNG.getExtensions()[0], null);
|
FileFilterEnum.PNG.getFilter(), null, FileFilterEnum.PNG.getExtensions()[0], null);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
try {
|
try {
|
||||||
TableExporter.getInstance().exportToPNG(getTable(), file);
|
TableExporter.getInstance().exportToPNG(getTable(), file);
|
||||||
|
|||||||
Reference in New Issue
Block a user