mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
cloud work
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.model;
|
package org.diylc.swing.plugins.cloud.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.model;
|
package org.diylc.swing.plugins.cloud.model;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.model;
|
package org.diylc.swing.plugins.cloud.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.presenter;
|
package org.diylc.swing.plugins.cloud.presenter;
|
||||||
|
|
||||||
public interface CloudListener {
|
public interface CloudListener {
|
||||||
|
|
||||||
+5
-5
@@ -1,21 +1,21 @@
|
|||||||
package org.diylc.swing.plugins.online.presenter;
|
package org.diylc.swing.plugins.cloud.presenter;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.swing.plugins.online.model.ServiceAPI;
|
import org.diylc.swing.plugins.cloud.model.ServiceAPI;
|
||||||
|
|
||||||
import com.diyfever.httpproxy.PhpFlatProxy;
|
import com.diyfever.httpproxy.PhpFlatProxy;
|
||||||
import com.diyfever.httpproxy.ProxyFactory;
|
import com.diyfever.httpproxy.ProxyFactory;
|
||||||
|
|
||||||
public class OnlinePresenter {
|
public class CloudPresenter {
|
||||||
|
|
||||||
private static String USERNAME_KEY = "cloud.Username";
|
private static String USERNAME_KEY = "cloud.Username";
|
||||||
private static String TOKEN_KEY = "cloud.token";
|
private static String TOKEN_KEY = "cloud.token";
|
||||||
|
|
||||||
private final static Logger LOG = Logger.getLogger(OnlinePresenter.class);
|
private final static Logger LOG = Logger.getLogger(CloudPresenter.class);
|
||||||
|
|
||||||
private ServiceAPI service;
|
private ServiceAPI service;
|
||||||
private String serviceUrl;
|
private String serviceUrl;
|
||||||
@@ -25,7 +25,7 @@ public class OnlinePresenter {
|
|||||||
|
|
||||||
private boolean loggedIn = false;
|
private boolean loggedIn = false;
|
||||||
|
|
||||||
public OnlinePresenter(CloudListener listener) {
|
public CloudPresenter(CloudListener listener) {
|
||||||
serviceUrl = ConfigurationManager.getInstance().readString(
|
serviceUrl = ConfigurationManager.getInstance().readString(
|
||||||
ServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api");
|
ServiceAPI.URL_KEY, "http://www.diy-fever.com/diylc/api");
|
||||||
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
|
ProxyFactory factory = new ProxyFactory(new PhpFlatProxy());
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.presenter;
|
package org.diylc.swing.plugins.cloud.presenter;
|
||||||
|
|
||||||
public class DIYLCServiceException extends Exception {
|
public class DIYLCServiceException extends Exception {
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.presenter;
|
package org.diylc.swing.plugins.cloud.presenter;
|
||||||
|
|
||||||
public class NotConnectedException extends Exception {
|
public class NotConnectedException extends Exception {
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.presenter;
|
package org.diylc.swing.plugins.cloud.presenter;
|
||||||
|
|
||||||
public class NotExistsException extends Exception {
|
public class NotExistsException extends Exception {
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.presenter;
|
package org.diylc.swing.plugins.cloud.presenter;
|
||||||
|
|
||||||
public class NotLoggedInException extends Exception {
|
public class NotLoggedInException extends Exception {
|
||||||
|
|
||||||
+3
-1
@@ -39,7 +39,9 @@ public enum IconLoader {
|
|||||||
"sort.png"), ElementsSelection("elements_selection.png"), BranchAdd(
|
"sort.png"), ElementsSelection("elements_selection.png"), BranchAdd(
|
||||||
"branch_add.png"), BriefcaseAdd("briefcase_add.png"), BriefcaseInto(
|
"branch_add.png"), BriefcaseAdd("briefcase_add.png"), BriefcaseInto(
|
||||||
"briefcase_into.png"), RotateCW("rotate_cw.png"), RotateCCW(
|
"briefcase_into.png"), RotateCW("rotate_cw.png"), RotateCCW(
|
||||||
"rotate_ccw.png"), ElementInto("element_into.png"), Arrow("arrow.png");
|
"rotate_ccw.png"), ElementInto("element_into.png"), Arrow(
|
||||||
|
"arrow.png"), Cloud("cloud.png"), CloudUp("cloud_up.png"), CloudGear(
|
||||||
|
"cloud_gear.png"), IdCardEdit("id_card_edit.png");
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 707 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 835 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 730 B |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 933 B |
+40
-30
@@ -9,14 +9,16 @@ import javax.swing.JFrame;
|
|||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.PropertyWrapper;
|
import org.diylc.common.PropertyWrapper;
|
||||||
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.model.UserEntity;
|
||||||
|
import org.diylc.swing.plugins.cloud.presenter.CloudPresenter;
|
||||||
|
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
||||||
|
import org.diylc.swing.plugins.cloud.view.NewUserDialog;
|
||||||
|
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||||
import org.diylc.swing.plugins.file.BomDialog;
|
import org.diylc.swing.plugins.file.BomDialog;
|
||||||
import org.diylc.swing.plugins.online.model.UserEntity;
|
|
||||||
import org.diylc.swing.plugins.online.view.LoginDialog;
|
|
||||||
import org.diylc.swing.plugins.online.view.NewUserDialog;
|
|
||||||
import org.diylc.swing.plugins.online.view.UploadDialog;
|
|
||||||
import org.diylc.swingframework.AboutDialog;
|
import org.diylc.swingframework.AboutDialog;
|
||||||
import org.diylc.swingframework.IFileChooserAccessory;
|
import org.diylc.swingframework.IFileChooserAccessory;
|
||||||
import org.diylc.swingframework.ProgressDialog;
|
import org.diylc.swingframework.ProgressDialog;
|
||||||
@@ -56,9 +58,10 @@ public class DialogFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyEditorDialog createPropertyEditorDialog(List<PropertyWrapper> properties,
|
public PropertyEditorDialog createPropertyEditorDialog(
|
||||||
String title) {
|
List<PropertyWrapper> properties, String title) {
|
||||||
PropertyEditorDialog editor = new PropertyEditorDialog(mainFrame, properties, title);
|
PropertyEditorDialog editor = new PropertyEditorDialog(mainFrame,
|
||||||
|
properties, title);
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,28 +70,33 @@ public class DialogFactory {
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File showOpenDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
public File showOpenDialog(FileFilter fileFilter, File initialFile,
|
||||||
IFileChooserAccessory accessory) {
|
String defaultExtension, IFileChooserAccessory accessory) {
|
||||||
JFileChooser openFileChooser = new JFileChooser();
|
JFileChooser openFileChooser = new JFileChooser();
|
||||||
initializeFileChooser(openFileChooser, fileFilter, initialFile, defaultExtension, accessory);
|
initializeFileChooser(openFileChooser, fileFilter, initialFile,
|
||||||
|
defaultExtension, accessory);
|
||||||
|
|
||||||
int result = openFileChooser.showOpenDialog(mainFrame);
|
int result = openFileChooser.showOpenDialog(mainFrame);
|
||||||
|
|
||||||
return processFileChooserResult(result, openFileChooser, defaultExtension);
|
return processFileChooserResult(result, openFileChooser,
|
||||||
|
defaultExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File showSaveDialog(FileFilter fileFilter, File initialFile, String defaultExtension,
|
public File showSaveDialog(FileFilter fileFilter, File initialFile,
|
||||||
IFileChooserAccessory accessory) {
|
String defaultExtension, IFileChooserAccessory accessory) {
|
||||||
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
JFileChooser saveFileChooser = new OverwritePromptFileChooser();
|
||||||
initializeFileChooser(saveFileChooser, fileFilter, initialFile, defaultExtension, accessory);
|
initializeFileChooser(saveFileChooser, fileFilter, initialFile,
|
||||||
|
defaultExtension, accessory);
|
||||||
|
|
||||||
int result = saveFileChooser.showSaveDialog(mainFrame);
|
int result = saveFileChooser.showSaveDialog(mainFrame);
|
||||||
|
|
||||||
return processFileChooserResult(result, saveFileChooser, defaultExtension);
|
return processFileChooserResult(result, saveFileChooser,
|
||||||
|
defaultExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeFileChooser(JFileChooser fileChooser, FileFilter fileFilter,
|
private void initializeFileChooser(JFileChooser fileChooser,
|
||||||
File initialFile, String defaultExtension, IFileChooserAccessory accessory) {
|
FileFilter fileFilter, File initialFile, String defaultExtension,
|
||||||
|
IFileChooserAccessory accessory) {
|
||||||
if (accessory != null) {
|
if (accessory != null) {
|
||||||
accessory.install(fileChooser);
|
accessory.install(fileChooser);
|
||||||
}
|
}
|
||||||
@@ -96,7 +104,8 @@ public class DialogFactory {
|
|||||||
fileChooser.removeChoosableFileFilter(filter);
|
fileChooser.removeChoosableFileFilter(filter);
|
||||||
}
|
}
|
||||||
if (fileChooser instanceof OverwritePromptFileChooser) {
|
if (fileChooser instanceof OverwritePromptFileChooser) {
|
||||||
((OverwritePromptFileChooser) fileChooser).setFileFilter(fileFilter, defaultExtension);
|
((OverwritePromptFileChooser) fileChooser).setFileFilter(
|
||||||
|
fileFilter, defaultExtension);
|
||||||
} else {
|
} else {
|
||||||
fileChooser.setFileFilter(fileFilter);
|
fileChooser.setFileFilter(fileFilter);
|
||||||
}
|
}
|
||||||
@@ -116,18 +125,19 @@ public class DialogFactory {
|
|||||||
if (fileChooser.getSelectedFile().getAbsolutePath().contains(".")) {
|
if (fileChooser.getSelectedFile().getAbsolutePath().contains(".")) {
|
||||||
return fileChooser.getSelectedFile();
|
return fileChooser.getSelectedFile();
|
||||||
} else {
|
} else {
|
||||||
return new File(fileChooser.getSelectedFile().getAbsoluteFile() + "."
|
return new File(fileChooser.getSelectedFile().getAbsoluteFile()
|
||||||
+ defaultExtension);
|
+ "." + defaultExtension);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AboutDialog createAboutDialog(String appName, Icon icon, String version, String author,
|
public AboutDialog createAboutDialog(String appName, Icon icon,
|
||||||
String url, String mail, String htmlContent) {
|
String version, String author, String url, String mail,
|
||||||
AboutDialog dialog = new AboutDialog(mainFrame, appName, icon, version, author, url, mail,
|
String htmlContent) {
|
||||||
htmlContent);
|
AboutDialog dialog = new AboutDialog(mainFrame, appName, icon, version,
|
||||||
|
author, url, mail, htmlContent);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,15 +151,15 @@ public class DialogFactory {
|
|||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UploadDialog createUploadDialog() {
|
public UploadDialog createUploadDialog(IPlugInPort plugInPort, CloudPresenter presenter) {
|
||||||
UploadDialog dialog = new UploadDialog(mainFrame);
|
UploadDialog dialog = new UploadDialog(mainFrame, plugInPort, presenter);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProgressDialog createProgressDialog(String title, String[] buttonCaptions,
|
public ProgressDialog createProgressDialog(String title,
|
||||||
String description, boolean useProgress) {
|
String[] buttonCaptions, String description, boolean useProgress) {
|
||||||
ProgressDialog dialog = new ProgressDialog(mainFrame, title, buttonCaptions, description,
|
ProgressDialog dialog = new ProgressDialog(mainFrame, title,
|
||||||
useProgress);
|
buttonCaptions, description, useProgress);
|
||||||
return dialog;
|
return dialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package org.diylc.swing.gui;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.diylc.common.PropertyWrapper;
|
||||||
|
import org.diylc.core.IView;
|
||||||
|
|
||||||
|
public class DummyView implements IView {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int showConfirmDialog(String message, String title, int optionType,
|
||||||
|
int messageType) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showMessage(String message, String title, int messageType) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public File promptFileSave() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean editProperties(List<PropertyWrapper> properties,
|
||||||
|
Set<PropertyWrapper> defaultedProperties) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -50,13 +50,13 @@ import org.diylc.swing.ISwingUI;
|
|||||||
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
import org.diylc.swing.gui.editor.PropertyEditorDialog;
|
||||||
import org.diylc.swing.plugins.autosave.AutoSavePlugin;
|
import org.diylc.swing.plugins.autosave.AutoSavePlugin;
|
||||||
import org.diylc.swing.plugins.canvas.CanvasPlugin;
|
import org.diylc.swing.plugins.canvas.CanvasPlugin;
|
||||||
|
import org.diylc.swing.plugins.cloud.OnlineManager;
|
||||||
import org.diylc.swing.plugins.config.ConfigPlugin;
|
import org.diylc.swing.plugins.config.ConfigPlugin;
|
||||||
import org.diylc.swing.plugins.edit.EditMenuPlugin;
|
import org.diylc.swing.plugins.edit.EditMenuPlugin;
|
||||||
import org.diylc.swing.plugins.file.FileFilterEnum;
|
import org.diylc.swing.plugins.file.FileFilterEnum;
|
||||||
import org.diylc.swing.plugins.file.FileMenuPlugin;
|
import org.diylc.swing.plugins.file.FileMenuPlugin;
|
||||||
import org.diylc.swing.plugins.help.HelpMenuPlugin;
|
import org.diylc.swing.plugins.help.HelpMenuPlugin;
|
||||||
import org.diylc.swing.plugins.layers.LayersMenuPlugin;
|
import org.diylc.swing.plugins.layers.LayersMenuPlugin;
|
||||||
import org.diylc.swing.plugins.online.OnlineManager;
|
|
||||||
import org.diylc.swing.plugins.statusbar.StatusBar;
|
import org.diylc.swing.plugins.statusbar.StatusBar;
|
||||||
import org.diylc.swing.plugins.toolbox.ToolBox;
|
import org.diylc.swing.plugins.toolbox.ToolBox;
|
||||||
import org.diylc.swingframework.ButtonDialog;
|
import org.diylc.swingframework.ButtonDialog;
|
||||||
|
|||||||
+70
-26
@@ -1,37 +1,41 @@
|
|||||||
package org.diylc.swing.plugins.online;
|
package org.diylc.swing.plugins.cloud;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.io.File;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.SwingWorker;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.common.EventType;
|
import org.diylc.common.EventType;
|
||||||
import org.diylc.common.IPlugIn;
|
import org.diylc.common.IPlugIn;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
|
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.presenter.Presenter;
|
||||||
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.plugins.online.presenter.CloudListener;
|
import org.diylc.swing.gui.DummyView;
|
||||||
import org.diylc.swing.plugins.online.presenter.OnlinePresenter;
|
import org.diylc.swing.plugins.cloud.presenter.CloudListener;
|
||||||
import org.diylc.swing.plugins.online.view.LoginDialog;
|
import org.diylc.swing.plugins.cloud.presenter.CloudPresenter;
|
||||||
import org.diylc.swing.plugins.online.view.NewUserDialog;
|
import org.diylc.swing.plugins.cloud.view.LoginDialog;
|
||||||
import org.diylc.swing.plugins.online.view.UploadDialog;
|
import org.diylc.swing.plugins.cloud.view.NewUserDialog;
|
||||||
|
import org.diylc.swing.plugins.cloud.view.UploadDialog;
|
||||||
|
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;
|
||||||
|
|
||||||
public class OnlineManager implements IPlugIn, CloudListener {
|
public class OnlineManager implements IPlugIn, CloudListener {
|
||||||
|
|
||||||
private static final String ONLINE_TITLE = "Project Cloud";
|
private static final String ONLINE_TITLE = "DIY Cloud";
|
||||||
|
|
||||||
private final static Logger LOG = Logger.getLogger(OnlineManager.class);
|
private final static Logger LOG = Logger.getLogger(OnlineManager.class);
|
||||||
|
|
||||||
private ISwingUI swingUI;
|
private ISwingUI swingUI;
|
||||||
private IPlugInPort plugInPort;
|
private IPlugInPort plugInPort;
|
||||||
private OnlinePresenter onlinePresenter;
|
private IPlugInPort thumbnailPresenter;
|
||||||
|
private CloudPresenter onlinePresenter;
|
||||||
|
|
||||||
private LibraryAction libraryAction;
|
private LibraryAction libraryAction;
|
||||||
|
|
||||||
@@ -47,6 +51,8 @@ public class OnlineManager implements IPlugIn, CloudListener {
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
this.swingUI = swingUI;
|
this.swingUI = swingUI;
|
||||||
|
this.thumbnailPresenter = new Presenter(new DummyView());
|
||||||
|
|
||||||
swingUI.injectMenuAction(getLibraryAction(), ONLINE_TITLE);
|
swingUI.injectMenuAction(getLibraryAction(), ONLINE_TITLE);
|
||||||
swingUI.injectMenuAction(null, ONLINE_TITLE);
|
swingUI.injectMenuAction(null, ONLINE_TITLE);
|
||||||
swingUI.injectMenuAction(getLoginAction(), ONLINE_TITLE);
|
swingUI.injectMenuAction(getLoginAction(), ONLINE_TITLE);
|
||||||
@@ -67,30 +73,33 @@ public class OnlineManager implements IPlugIn, CloudListener {
|
|||||||
@Override
|
@Override
|
||||||
public void connect(IPlugInPort plugInPort) {
|
public void connect(IPlugInPort plugInPort) {
|
||||||
this.plugInPort = plugInPort;
|
this.plugInPort = plugInPort;
|
||||||
this.onlinePresenter = new OnlinePresenter(this);
|
this.onlinePresenter = new CloudPresenter(this);
|
||||||
|
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
|
this.swingUI.executeBackgroundTask(new ITask<Boolean>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground() throws Exception {
|
public Boolean doInBackground() throws Exception {
|
||||||
return onlinePresenter.tryLogInWithToken();
|
return onlinePresenter.tryLogInWithToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
public void failed(Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void complete(Boolean result) {
|
||||||
try {
|
try {
|
||||||
if (get())
|
if (result)
|
||||||
loggedIn();
|
loggedIn();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error while trying to login with token", e);
|
LOG.error("Error while trying to login with token", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
worker.execute();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LibraryAction getLibraryAction() {
|
public LibraryAction getLibraryAction() {
|
||||||
@@ -130,7 +139,8 @@ public class OnlineManager implements IPlugIn, CloudListener {
|
|||||||
|
|
||||||
public UploadAction getUploadAction() {
|
public UploadAction getUploadAction() {
|
||||||
if (uploadAction == null) {
|
if (uploadAction == null) {
|
||||||
uploadAction = new UploadAction();
|
uploadAction = new UploadAction(this.thumbnailPresenter,
|
||||||
|
this.swingUI, this.onlinePresenter);
|
||||||
}
|
}
|
||||||
return uploadAction;
|
return uploadAction;
|
||||||
}
|
}
|
||||||
@@ -158,7 +168,7 @@ public class OnlineManager implements IPlugIn, CloudListener {
|
|||||||
public LibraryAction() {
|
public LibraryAction() {
|
||||||
super();
|
super();
|
||||||
putValue(AbstractAction.NAME, "Browse The Cloud");
|
putValue(AbstractAction.NAME, "Browse The Cloud");
|
||||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Chest.getIcon());
|
putValue(AbstractAction.SMALL_ICON, IconLoader.Cloud.getIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -241,7 +251,7 @@ public class OnlineManager implements IPlugIn, CloudListener {
|
|||||||
public ManageAccountAction() {
|
public ManageAccountAction() {
|
||||||
super();
|
super();
|
||||||
putValue(AbstractAction.NAME, "Manage Account");
|
putValue(AbstractAction.NAME, "Manage Account");
|
||||||
putValue(AbstractAction.SMALL_ICON, IconLoader.IdCard.getIcon());
|
putValue(AbstractAction.SMALL_ICON, IconLoader.IdCardEdit.getIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -256,18 +266,52 @@ public class OnlineManager implements IPlugIn, CloudListener {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UploadAction() {
|
private IPlugInPort plugInPort;
|
||||||
|
private ISwingUI swingUI;
|
||||||
|
private CloudPresenter onlinePresenter;
|
||||||
|
|
||||||
|
public UploadAction(IPlugInPort plugInPort, ISwingUI swingUI, CloudPresenter onlinePresenter) {
|
||||||
super();
|
super();
|
||||||
putValue(AbstractAction.NAME, "Upload Project");
|
this.plugInPort = plugInPort;
|
||||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Upload.getIcon());
|
this.swingUI = swingUI;
|
||||||
|
this.onlinePresenter = onlinePresenter;
|
||||||
|
putValue(AbstractAction.NAME, "Upload A Project");
|
||||||
|
putValue(AbstractAction.SMALL_ICON, IconLoader.CloudUp.getIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
LOG.info("UploadAction triggered");
|
||||||
|
|
||||||
|
final File file = DialogFactory.getInstance().showOpenDialog(
|
||||||
|
FileFilterEnum.DIY.getFilter(), null,
|
||||||
|
FileFilterEnum.DIY.getExtensions()[0], null);
|
||||||
|
if (file != null) {
|
||||||
|
swingUI.executeBackgroundTask(new ITask<Void>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Void doInBackground() throws Exception {
|
||||||
|
LOG.debug("Uploading from " + file.getAbsolutePath());
|
||||||
|
plugInPort.loadProjectFromFile(file.getAbsolutePath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void complete(Void result) {
|
||||||
UploadDialog dialog = DialogFactory.getInstance()
|
UploadDialog dialog = DialogFactory.getInstance()
|
||||||
.createUploadDialog();
|
.createUploadDialog(UploadAction.this.plugInPort, UploadAction.this.onlinePresenter);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(Exception e) {
|
||||||
|
swingUI.showMessage(
|
||||||
|
"Could not open file. " + e.getMessage(),
|
||||||
|
"Error", ISwingUI.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ManageProjectsAction extends AbstractAction {
|
class ManageProjectsAction extends AbstractAction {
|
||||||
@@ -276,8 +320,8 @@ public class OnlineManager implements IPlugIn, CloudListener {
|
|||||||
|
|
||||||
public ManageProjectsAction() {
|
public ManageProjectsAction() {
|
||||||
super();
|
super();
|
||||||
putValue(AbstractAction.NAME, "Manage Projects");
|
putValue(AbstractAction.NAME, "Manage My Projects");
|
||||||
putValue(AbstractAction.SMALL_ICON, IconLoader.Wrench.getIcon());
|
putValue(AbstractAction.SMALL_ICON, IconLoader.CloudGear.getIcon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.view;
|
package org.diylc.swing.plugins.cloud.view;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.view;
|
package org.diylc.swing.plugins.cloud.view;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
package org.diylc.swing.plugins.online.view;
|
package org.diylc.swing.plugins.cloud.view;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
@@ -17,7 +17,7 @@ import javax.swing.JTextField;
|
|||||||
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentEvent;
|
||||||
import javax.swing.event.DocumentListener;
|
import javax.swing.event.DocumentListener;
|
||||||
|
|
||||||
import org.diylc.swing.plugins.online.model.UserEntity;
|
import org.diylc.swing.plugins.cloud.model.UserEntity;
|
||||||
import org.diylc.swingframework.ButtonDialog;
|
import org.diylc.swingframework.ButtonDialog;
|
||||||
|
|
||||||
public class NewUserDialog extends ButtonDialog {
|
public class NewUserDialog extends ButtonDialog {
|
||||||
+174
@@ -0,0 +1,174 @@
|
|||||||
|
package org.diylc.swing.plugins.cloud.view;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Rectangle;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
import org.diylc.common.DrawOption;
|
||||||
|
import org.diylc.common.IPlugInPort;
|
||||||
|
import org.diylc.swing.plugins.cloud.presenter.CloudPresenter;
|
||||||
|
import org.diylc.swingframework.ButtonDialog;
|
||||||
|
|
||||||
|
public class UploadDialog extends ButtonDialog {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private static final String BULLET = " • ";
|
||||||
|
private static final String TERMS_HTML = "<html><b>Terms of Service</b><br><br>"
|
||||||
|
+ BULLET
|
||||||
|
+ "All content uploaded to DIY Cloud is shared under Creative Commons 3.0 Licence.<br>"
|
||||||
|
+ BULLET
|
||||||
|
+ "Only finished and resonably verified projects may be uploaded to the library.<br>"
|
||||||
|
+ BULLET
|
||||||
|
+ "Uploaded content may be reviewed and/or removed by the administrators.<br>"
|
||||||
|
+ "</html>";
|
||||||
|
|
||||||
|
private JPanel mainPanel;
|
||||||
|
private JLabel termsLabel;
|
||||||
|
private JCheckBox agreeBox;
|
||||||
|
private JPanel thumbnailPanel;
|
||||||
|
|
||||||
|
private IPlugInPort plugInPort;
|
||||||
|
private CloudPresenter presenter;
|
||||||
|
|
||||||
|
public UploadDialog(JFrame owner, IPlugInPort plugInPort, CloudPresenter presenter) {
|
||||||
|
super(owner, "Upload A Project", new String[] { OK, CANCEL });
|
||||||
|
this.plugInPort = plugInPort;
|
||||||
|
this.presenter = presenter;
|
||||||
|
layoutGui();
|
||||||
|
refreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JComponent getMainComponent() {
|
||||||
|
if (mainPanel == null) {
|
||||||
|
mainPanel = new JPanel(new GridBagLayout());
|
||||||
|
mainPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
||||||
|
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.anchor = GridBagConstraints.LINE_START;
|
||||||
|
gbc.insets = new Insets(2, 2, 2, 2);
|
||||||
|
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 0;
|
||||||
|
mainPanel.add(getThumbnailPanel(), gbc);
|
||||||
|
|
||||||
|
gbc.gridy = 1;
|
||||||
|
gbc.weightx = 1;
|
||||||
|
gbc.weighty = 1;
|
||||||
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
|
mainPanel.add(getTermsLabel(), gbc);
|
||||||
|
|
||||||
|
gbc.gridy = 2;
|
||||||
|
gbc.anchor = GridBagConstraints.CENTER;
|
||||||
|
gbc.fill = GridBagConstraints.NONE;
|
||||||
|
gbc.weightx = 0;
|
||||||
|
gbc.weighty = 0;
|
||||||
|
mainPanel.add(getAgreeBox(), gbc);
|
||||||
|
}
|
||||||
|
return mainPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshState() {
|
||||||
|
getButton(OK).setEnabled(getAgreeBox().isSelected());
|
||||||
|
}
|
||||||
|
|
||||||
|
private JCheckBox getAgreeBox() {
|
||||||
|
if (agreeBox == null) {
|
||||||
|
agreeBox = new JCheckBox("I agree to these terms");
|
||||||
|
agreeBox.addChangeListener(new ChangeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
refreshState();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return agreeBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JLabel getTermsLabel() {
|
||||||
|
if (termsLabel == null) {
|
||||||
|
termsLabel = new JLabel();
|
||||||
|
termsLabel.setOpaque(true);
|
||||||
|
termsLabel.setBackground(UIManager.getColor("ToolTip.background"));
|
||||||
|
termsLabel.setBorder(BorderFactory.createCompoundBorder(
|
||||||
|
BorderFactory.createEtchedBorder(),
|
||||||
|
BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
||||||
|
termsLabel.setText(TERMS_HTML);
|
||||||
|
}
|
||||||
|
return termsLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JPanel getThumbnailPanel() {
|
||||||
|
if (thumbnailPanel == null) {
|
||||||
|
thumbnailPanel = new JPanel(new GridBagLayout());
|
||||||
|
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.anchor = GridBagConstraints.LINE_START;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 0;
|
||||||
|
gbc.weightx = 1;
|
||||||
|
gbc.weighty = 1;
|
||||||
|
gbc.fill = GridBagConstraints.BOTH;
|
||||||
|
|
||||||
|
thumbnailPanel.add(new JComponent() {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics g) {
|
||||||
|
super.paint(g);
|
||||||
|
|
||||||
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
|
Dimension d = UploadDialog.this.plugInPort
|
||||||
|
.getCanvasDimensions(false);
|
||||||
|
|
||||||
|
Rectangle rect = getBounds();
|
||||||
|
|
||||||
|
g2d.setColor(Color.white);
|
||||||
|
g2d.fill(rect);
|
||||||
|
|
||||||
|
double projectRatio = d.getWidth() / d.getHeight();
|
||||||
|
double actualRatio = rect.getWidth() / rect.getHeight();
|
||||||
|
double zoomRatio;
|
||||||
|
if (projectRatio > actualRatio) {
|
||||||
|
zoomRatio = rect.getWidth() / d.getWidth();
|
||||||
|
} else {
|
||||||
|
zoomRatio = rect.getHeight() / d.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
g2d.scale(zoomRatio, zoomRatio);
|
||||||
|
UploadDialog.this.plugInPort.draw(g2d,
|
||||||
|
EnumSet.noneOf(DrawOption.class), null);
|
||||||
|
}
|
||||||
|
}, gbc);
|
||||||
|
Dimension d = UploadDialog.this.plugInPort
|
||||||
|
.getCanvasDimensions(false);
|
||||||
|
if (d.height > d.width)
|
||||||
|
thumbnailPanel.setPreferredSize(new Dimension(192 * d.width
|
||||||
|
/ d.height, 192));
|
||||||
|
else
|
||||||
|
thumbnailPanel.setPreferredSize(new Dimension(192, 192
|
||||||
|
* d.height / d.width));
|
||||||
|
thumbnailPanel.setBorder(BorderFactory.createEtchedBorder());
|
||||||
|
}
|
||||||
|
return thumbnailPanel;
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-28
@@ -10,8 +10,6 @@ import java.beans.PropertyChangeListener;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
@@ -20,10 +18,9 @@ import javax.swing.JPanel;
|
|||||||
|
|
||||||
import org.diylc.common.DrawOption;
|
import org.diylc.common.DrawOption;
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.common.IPlugInPort;
|
||||||
import org.diylc.common.PropertyWrapper;
|
|
||||||
import org.diylc.core.IView;
|
|
||||||
import org.diylc.core.Project;
|
import org.diylc.core.Project;
|
||||||
import org.diylc.presenter.Presenter;
|
import org.diylc.presenter.Presenter;
|
||||||
|
import org.diylc.swing.gui.DummyView;
|
||||||
import org.diylc.swingframework.IFileChooserAccessory;
|
import org.diylc.swingframework.IFileChooserAccessory;
|
||||||
|
|
||||||
import com.thoughtworks.xstream.XStream;
|
import com.thoughtworks.xstream.XStream;
|
||||||
@@ -36,7 +33,8 @@ import com.thoughtworks.xstream.io.xml.DomDriver;
|
|||||||
*
|
*
|
||||||
* @author Branislav Stojkovic
|
* @author Branislav Stojkovic
|
||||||
*/
|
*/
|
||||||
public class ProjectPreview extends JPanel implements PropertyChangeListener, IFileChooserAccessory {
|
public class ProjectPreview extends JPanel implements PropertyChangeListener,
|
||||||
|
IFileChooserAccessory {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -50,28 +48,7 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
|
|||||||
super();
|
super();
|
||||||
|
|
||||||
setPreferredSize(new Dimension(140, 128));
|
setPreferredSize(new Dimension(140, 128));
|
||||||
presenter = new Presenter(new IView() {
|
presenter = new Presenter(new DummyView());
|
||||||
|
|
||||||
@Override
|
|
||||||
public int showConfirmDialog(String message, String title, int optionType,
|
|
||||||
int messageType) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showMessage(String message, String title, int messageType) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public File promptFileSave() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean editProperties(List<PropertyWrapper> properties, Set<PropertyWrapper> defaultedProperties) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
xStream = new XStream(new DomDriver());
|
xStream = new XStream(new DomDriver());
|
||||||
|
|
||||||
emptyProject = new Project();
|
emptyProject = new Project();
|
||||||
@@ -154,7 +131,8 @@ public class ProjectPreview extends JPanel implements PropertyChangeListener, IF
|
|||||||
presenter.draw(g2d, EnumSet.noneOf(DrawOption.class), null);
|
presenter.draw(g2d, EnumSet.noneOf(DrawOption.class), null);
|
||||||
|
|
||||||
g2d.setColor(Color.black);
|
g2d.setColor(Color.black);
|
||||||
g2d.drawRect(0, 0, d.width - (int) (1 / zoomRatio), d.height - (int) (1 / zoomRatio));
|
g2d.drawRect(0, 0, d.width - (int) (1 / zoomRatio), d.height
|
||||||
|
- (int) (1 / zoomRatio));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-105
@@ -1,105 +0,0 @@
|
|||||||
package org.diylc.swing.plugins.online.view;
|
|
||||||
|
|
||||||
import java.awt.GridBagConstraints;
|
|
||||||
import java.awt.GridBagLayout;
|
|
||||||
import java.awt.Insets;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
|
|
||||||
import org.diylc.swingframework.ButtonDialog;
|
|
||||||
|
|
||||||
public class UploadDialog extends ButtonDialog {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private static final String BULLET = " • ";
|
|
||||||
private static final String TERMS_HTML = "<html><b>Terms of Service</b><br><br>"
|
|
||||||
+ BULLET
|
|
||||||
+ "Online Library is provided free of charge for DIY Layout Creator users.<br>"
|
|
||||||
+ BULLET
|
|
||||||
+ "Only finished and verified projects may be uploaded to the library. Online Library is <b>not</b> a repository for unfinished projects and temprary work.<br>"
|
|
||||||
+ BULLET
|
|
||||||
+ "Projects uploaded to the library may be reviewed, modified or deleted by the administrator without notice.<br>"
|
|
||||||
+ BULLET
|
|
||||||
+ "Once uploaded, project becomes avaialble to all other users. Anyone may use the project, modify it and upload modified version. When modifying an existing projects credit for the original author must be left.<br>"
|
|
||||||
+ BULLET
|
|
||||||
+ "You can <b>not</b> use Online Library to advertise products or services.<br>"
|
|
||||||
+ BULLET
|
|
||||||
+ "Users that do not follow these terms may be banned from the server, with or without notice.<br>"
|
|
||||||
+ BULLET + "Administrator is not responsible for library contents.<br>" + "</html>";
|
|
||||||
|
|
||||||
private JPanel mainPanel;
|
|
||||||
private JLabel termsLabel;
|
|
||||||
private JCheckBox agreeBox;
|
|
||||||
|
|
||||||
public UploadDialog(JFrame owner) {
|
|
||||||
super(owner, "Upload", new String[] { OK, CANCEL });
|
|
||||||
layoutGui();
|
|
||||||
refreshState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected JComponent getMainComponent() {
|
|
||||||
if (mainPanel == null) {
|
|
||||||
mainPanel = new JPanel(new GridBagLayout());
|
|
||||||
mainPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
|
||||||
|
|
||||||
GridBagConstraints gbc = new GridBagConstraints();
|
|
||||||
gbc.anchor = GridBagConstraints.LINE_START;
|
|
||||||
gbc.fill = GridBagConstraints.BOTH;
|
|
||||||
gbc.weightx = 1;
|
|
||||||
gbc.weighty = 1;
|
|
||||||
gbc.insets = new Insets(2, 2, 2, 2);
|
|
||||||
|
|
||||||
gbc.gridx = 0;
|
|
||||||
gbc.gridy = 0;
|
|
||||||
mainPanel.add(getTermsLabel(), gbc);
|
|
||||||
|
|
||||||
gbc.gridy = 1;
|
|
||||||
gbc.anchor = GridBagConstraints.CENTER;
|
|
||||||
gbc.fill = GridBagConstraints.NONE;
|
|
||||||
gbc.weightx = 0;
|
|
||||||
gbc.weighty = 0;
|
|
||||||
mainPanel.add(getAgreeBox(), gbc);
|
|
||||||
}
|
|
||||||
return mainPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshState() {
|
|
||||||
getButton(OK).setEnabled(getAgreeBox().isSelected());
|
|
||||||
}
|
|
||||||
|
|
||||||
private JCheckBox getAgreeBox() {
|
|
||||||
if (agreeBox == null) {
|
|
||||||
agreeBox = new JCheckBox("I agree to these terms");
|
|
||||||
agreeBox.addChangeListener(new ChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
refreshState();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return agreeBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JLabel getTermsLabel() {
|
|
||||||
if (termsLabel == null) {
|
|
||||||
termsLabel = new JLabel();
|
|
||||||
termsLabel.setOpaque(true);
|
|
||||||
termsLabel.setBackground(UIManager.getColor("ToolTip.background"));
|
|
||||||
termsLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
|
|
||||||
.createEtchedBorder(), BorderFactory.createEmptyBorder(2, 2, 2, 2)));
|
|
||||||
termsLabel.setText(TERMS_HTML);
|
|
||||||
}
|
|
||||||
return termsLabel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-233
@@ -1,233 +0,0 @@
|
|||||||
//package org.diylc.swing.plugins.toolbox.openide;
|
|
||||||
//
|
|
||||||
//import java.util.ArrayList;
|
|
||||||
//import java.util.Collection;
|
|
||||||
//import java.util.Collections;
|
|
||||||
//import java.util.Iterator;
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.Set;
|
|
||||||
//
|
|
||||||
//public abstract class Lookup {
|
|
||||||
// public static final Lookup EMPTY = new Empty();
|
|
||||||
// private static Lookup defaultLookup;
|
|
||||||
//
|
|
||||||
// public static synchronized Lookup getDefault() {
|
|
||||||
// if (defaultLookup != null) {
|
|
||||||
// return defaultLookup;
|
|
||||||
// }
|
|
||||||
// String className = System.getProperty("org.openide.util.Lookup");
|
|
||||||
// if ("-".equals(className)) {
|
|
||||||
// return EMPTY;
|
|
||||||
// }
|
|
||||||
// ClassLoader l = Thread.currentThread().getContextClassLoader();
|
|
||||||
// try {
|
|
||||||
// if (className != null) {
|
|
||||||
// defaultLookup = (Lookup) Class.forName(className, true, l)
|
|
||||||
// .newInstance();
|
|
||||||
//
|
|
||||||
// return defaultLookup;
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// Lookup misl = Lookups.metaInfServices(l);
|
|
||||||
// defaultLookup = (Lookup) misl.lookup(Lookup.class);
|
|
||||||
// if (defaultLookup != null) {
|
|
||||||
// return defaultLookup;
|
|
||||||
// }
|
|
||||||
// Provider prov = (Provider) misl.lookup(Provider.class);
|
|
||||||
// if (prov != null) {
|
|
||||||
// defaultLookup = Lookups.proxy(prov);
|
|
||||||
//
|
|
||||||
// return defaultLookup;
|
|
||||||
// }
|
|
||||||
// DefLookup def = new DefLookup();
|
|
||||||
// def.init(l, misl, false);
|
|
||||||
// defaultLookup = def;
|
|
||||||
// def.init(l, misl, true);
|
|
||||||
// return defaultLookup;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static final class DefLookup extends ProxyLookup {
|
|
||||||
// public DefLookup() {
|
|
||||||
// super();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void init(ClassLoader loader, Lookup metaInfLookup,
|
|
||||||
// boolean addPath) {
|
|
||||||
// Lookup clLookup = Lookups.singleton(loader);
|
|
||||||
// List<Lookup> arr = new ArrayList();
|
|
||||||
// arr.add(metaInfLookup);
|
|
||||||
// arr.add(clLookup);
|
|
||||||
// String paths = System.getProperty("org.openide.util.Lookup.paths");
|
|
||||||
// if ((addPath) && (paths != null)) {
|
|
||||||
// for (String p : paths.split(":")) {
|
|
||||||
// arr.add(Lookups.forPath(p));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// setLookups((Lookup[]) arr.toArray(new Lookup[0]));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static void resetDefaultLookup() {
|
|
||||||
// if ((defaultLookup instanceof DefLookup)) {
|
|
||||||
// DefLookup def = (DefLookup) defaultLookup;
|
|
||||||
// ClassLoader l = Thread.currentThread().getContextClassLoader();
|
|
||||||
// def.init(l, Lookups.metaInfServices(l), true);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public abstract <T> T lookup(Class<T> paramClass);
|
|
||||||
//
|
|
||||||
// public abstract <T> Result<T> lookup(Template<T> paramTemplate);
|
|
||||||
//
|
|
||||||
// public <T> Item<T> lookupItem(Template<T> template) {
|
|
||||||
// Result<T> res = lookup(template);
|
|
||||||
// Iterator<? extends Item<T>> it = res.allItems().iterator();
|
|
||||||
// return it.hasNext() ? (Item) it.next() : null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public <T> Result<T> lookupResult(Class<T> clazz) {
|
|
||||||
// return lookup(new Template(clazz));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public <T> Collection<? extends T> lookupAll(Class<T> clazz) {
|
|
||||||
// return lookupResult(clazz).allInstances();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static final class Template<T> {
|
|
||||||
// private int hashCode;
|
|
||||||
// private Class<T> type;
|
|
||||||
// private String id;
|
|
||||||
// private T instance;
|
|
||||||
//
|
|
||||||
// @Deprecated
|
|
||||||
// public Template() {
|
|
||||||
// this(null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Template(Class<T> type) {
|
|
||||||
// this(type, null, null);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Template(Class<T> type, String id, T instance) {
|
|
||||||
// this.type = extractType(type);
|
|
||||||
// this.id = id;
|
|
||||||
// this.instance = instance;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private Class<T> extractType(Class<T> type) {
|
|
||||||
// return type == null ? Object.class : type;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Class<T> getType() {
|
|
||||||
// return this.type;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getId() {
|
|
||||||
// return this.id;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public T getInstance() {
|
|
||||||
// return (T) this.instance;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public int hashCode() {
|
|
||||||
// if (this.hashCode != 0) {
|
|
||||||
// return this.hashCode;
|
|
||||||
// }
|
|
||||||
// this.hashCode = ((this.type == null ? 1 : this.type.hashCode())
|
|
||||||
// + (this.id == null ? 2 : this.id.hashCode()) + (this.instance == null ? 3
|
|
||||||
// : 0));
|
|
||||||
//
|
|
||||||
// return this.hashCode;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public boolean equals(Object obj) {
|
|
||||||
// if (!(obj instanceof Template)) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// Template t = (Template) obj;
|
|
||||||
// if (hashCode() != t.hashCode()) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// if (this.type != t.type) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// if (this.id == null) {
|
|
||||||
// if (t.id != null) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// } else if (!this.id.equals(t.id)) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// if (this.instance == null) {
|
|
||||||
// return t.instance == null;
|
|
||||||
// }
|
|
||||||
// return this.instance.equals(t.instance);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String toString() {
|
|
||||||
// return "Lookup.Template[type=" + this.type + ",id=" + this.id
|
|
||||||
// + ",instance=" + this.instance + "]";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static abstract class Result<T> {
|
|
||||||
// public abstract void addLookupListener(
|
|
||||||
// LookupListener paramLookupListener);
|
|
||||||
//
|
|
||||||
// public abstract void removeLookupListener(
|
|
||||||
// LookupListener paramLookupListener);
|
|
||||||
//
|
|
||||||
// public abstract Collection<? extends T> allInstances();
|
|
||||||
//
|
|
||||||
// public Set<Class<? extends T>> allClasses() {
|
|
||||||
// return Collections.emptySet();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Collection<? extends Lookup.Item<T>> allItems() {
|
|
||||||
// return Collections.emptyList();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static abstract class Item<T> {
|
|
||||||
// public abstract T getInstance();
|
|
||||||
//
|
|
||||||
// public abstract Class<? extends T> getType();
|
|
||||||
//
|
|
||||||
// public abstract String getId();
|
|
||||||
//
|
|
||||||
// public abstract String getDisplayName();
|
|
||||||
//
|
|
||||||
// public String toString() {
|
|
||||||
// return getId();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static final class Empty extends Lookup {
|
|
||||||
// private static final Lookup.Result NO_RESULT = new Lookup.Result() {
|
|
||||||
// public void addLookupListener(LookupListener l) {
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void removeLookupListener(LookupListener l) {
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Collection allInstances() {
|
|
||||||
// return Collections.EMPTY_SET;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// public <T> T lookup(Class<T> clazz) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public <T> Lookup.Result<T> lookup(Lookup.Template<T> template) {
|
|
||||||
// return NO_RESULT;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static abstract interface Provider {
|
|
||||||
// public abstract Lookup getLookup();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
//package org.diylc.swing.plugins.toolbox.openide;
|
|
||||||
//
|
|
||||||
//import java.util.EventObject;
|
|
||||||
//
|
|
||||||
//public final class LookupEvent extends EventObject {
|
|
||||||
// public LookupEvent(Lookup.Result source) {
|
|
||||||
// super(source);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
//package org.diylc.swing.plugins.toolbox.openide;
|
|
||||||
//
|
|
||||||
//import java.util.EventListener;
|
|
||||||
//
|
|
||||||
//public abstract interface LookupListener
|
|
||||||
// extends EventListener
|
|
||||||
//{
|
|
||||||
// public abstract void resultChanged(LookupEvent paramLookupEvent);
|
|
||||||
//}
|
|
||||||
-96
@@ -1,96 +0,0 @@
|
|||||||
package org.diylc.swing.plugins.toolbox.openide;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
public class NbBundle {
|
|
||||||
|
|
||||||
private static String brandingToken = null;
|
|
||||||
|
|
||||||
public static String getBranding() {
|
|
||||||
return brandingToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Iterator<String> getLocalizingSuffixes() {
|
|
||||||
return new LocaleIterator(Locale.getDefault());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class LocaleIterator implements Iterator<String> {
|
|
||||||
private boolean defaultInProgress = false;
|
|
||||||
private boolean empty = false;
|
|
||||||
private Locale locale;
|
|
||||||
private Locale initLocale;
|
|
||||||
private String current;
|
|
||||||
private String branding;
|
|
||||||
|
|
||||||
public LocaleIterator(Locale locale) {
|
|
||||||
this.locale = (this.initLocale = locale);
|
|
||||||
if (locale.equals(Locale.getDefault())) {
|
|
||||||
this.defaultInProgress = true;
|
|
||||||
}
|
|
||||||
this.current = ('_' + locale.toString());
|
|
||||||
if (NbBundle.brandingToken == null) {
|
|
||||||
this.branding = null;
|
|
||||||
} else {
|
|
||||||
this.branding = ("_" + NbBundle.brandingToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String next() throws NoSuchElementException {
|
|
||||||
if (this.current == null) {
|
|
||||||
throw new NoSuchElementException();
|
|
||||||
}
|
|
||||||
String ret;
|
|
||||||
if (this.branding == null) {
|
|
||||||
ret = this.current;
|
|
||||||
} else {
|
|
||||||
ret = this.branding + this.current;
|
|
||||||
}
|
|
||||||
int lastUnderbar = this.current.lastIndexOf('_');
|
|
||||||
if (lastUnderbar == 0) {
|
|
||||||
if (this.empty) {
|
|
||||||
reset();
|
|
||||||
} else {
|
|
||||||
this.current = "";
|
|
||||||
this.empty = true;
|
|
||||||
}
|
|
||||||
} else if (lastUnderbar == -1) {
|
|
||||||
if (this.defaultInProgress) {
|
|
||||||
reset();
|
|
||||||
} else {
|
|
||||||
this.locale = Locale.getDefault();
|
|
||||||
this.current = ('_' + this.locale.toString());
|
|
||||||
this.defaultInProgress = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.current = this.current.substring(0, lastUnderbar);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reset() {
|
|
||||||
if (this.branding != null) {
|
|
||||||
this.current = ('_' + this.initLocale.toString());
|
|
||||||
|
|
||||||
int idx = this.branding.lastIndexOf('_');
|
|
||||||
if (idx == 0) {
|
|
||||||
this.branding = null;
|
|
||||||
} else {
|
|
||||||
this.branding = this.branding.substring(0, idx);
|
|
||||||
}
|
|
||||||
this.empty = false;
|
|
||||||
} else {
|
|
||||||
this.current = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasNext() {
|
|
||||||
return this.current != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove() throws UnsupportedOperationException {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+1
-1
@@ -8,7 +8,7 @@ import javax.swing.JFrame;
|
|||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
|
|
||||||
import org.apache.log4j.BasicConfigurator;
|
import org.apache.log4j.BasicConfigurator;
|
||||||
import org.diylc.swing.plugins.online.model.ProjectEntity;
|
import org.diylc.swing.plugins.cloud.model.ProjectEntity;
|
||||||
import org.diylc.swingframework.objecttable.IActionProcessor;
|
import org.diylc.swingframework.objecttable.IActionProcessor;
|
||||||
import org.diylc.swingframework.objecttable.ObjectListTable;
|
import org.diylc.swingframework.objecttable.ObjectListTable;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user