From 6152c82d79e90c4a759b4be6eff929d102c47272 Mon Sep 17 00:00:00 2001 From: li Date: Sat, 16 Jun 2018 17:55:56 -0400 Subject: [PATCH 01/12] Refs #20: Creates empty result panel component. --- .../cygraphspace/internal/CyActivator.java | 94 ++++++++++--------- .../internal/gui/CyGraphSpaceResultPanel.java | 40 ++++++++ 2 files changed, 89 insertions(+), 45 deletions(-) create mode 100644 CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java index acbbacf..d1d8792 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java @@ -12,6 +12,7 @@ import org.cytoscape.model.CyNetworkFactory; import org.cytoscape.model.CyNetworkManager; import org.cytoscape.model.subnetwork.CyRootNetworkManager; +import org.cytoscape.graphspace.cygraphspace.internal.gui.CyGraphSpaceResultPanel; import org.cytoscape.graphspace.cygraphspace.internal.gui.GetGraphsPanel; import org.cytoscape.graphspace.cygraphspace.internal.gui.PostGraphToolBarComponent; import org.cytoscape.graphspace.cygraphspace.internal.singletons.CyObjectManager; @@ -34,60 +35,63 @@ */ public class CyActivator extends AbstractCyActivator { - @SuppressWarnings("rawtypes") + @SuppressWarnings("rawtypes") @Override - public void start(BundleContext context) throws Exception { - CyApplicationManager applicationManager = getService(context, CyApplicationManager.class); + public void start(BundleContext context) throws Exception { + CyApplicationManager applicationManager = getService(context, CyApplicationManager.class); - AbstractCyAction action = null; - Properties properties = null; - BundleContext bc = context; + AbstractCyAction action = null; + Properties properties = null; + BundleContext bc = context; - //register Post Graph Action - action = new CyGraphSpaceMenuAction(MessageConfig.MenuActionTitle); - properties = new Properties(); - registerService(context, action, CyAction.class, properties); + //register Post Graph Action + action = new CyGraphSpaceMenuAction(MessageConfig.MenuActionTitle); + properties = new Properties(); + registerService(context, action, CyAction.class, properties); - //getting cytoscape services - CyApplicationConfiguration config = getService(context,CyApplicationConfiguration.class); - CySwingAppAdapter appAdapter = getService(context, CySwingAppAdapter.class); - CySwingApplication desktop = getService(bc,CySwingApplication.class); - LoadNetworkFileTaskFactory loadNetworkFileTaskFactory = getService(bc, LoadNetworkFileTaskFactory.class); - ExportNetworkTaskFactory exportNetworkTaskFactory = getService(bc, ExportNetworkTaskFactory.class); - ExportNetworkViewTaskFactory exportNetworkViewTaskFactory = getService(bc, ExportNetworkViewTaskFactory.class); - LoadVizmapFileTaskFactory loadVizmapFileTaskFactory = getService(bc, LoadVizmapFileTaskFactory.class); - ExportVizmapTaskFactory exportVizmapTaskFactory = getService(bc, ExportVizmapTaskFactory.class); - TaskManager taskManager = getService(context, DialogTaskManager.class); - final CyNetworkFactory cyNetworkFactory = getService(bc, CyNetworkFactory.class); + //getting cytoscape services + CyApplicationConfiguration config = getService(context,CyApplicationConfiguration.class); + CySwingAppAdapter appAdapter = getService(context, CySwingAppAdapter.class); + CySwingApplication desktop = getService(bc,CySwingApplication.class); + LoadNetworkFileTaskFactory loadNetworkFileTaskFactory = getService(bc, LoadNetworkFileTaskFactory.class); + ExportNetworkTaskFactory exportNetworkTaskFactory = getService(bc, ExportNetworkTaskFactory.class); + ExportNetworkViewTaskFactory exportNetworkViewTaskFactory = getService(bc, ExportNetworkViewTaskFactory.class); + LoadVizmapFileTaskFactory loadVizmapFileTaskFactory = getService(bc, LoadVizmapFileTaskFactory.class); + ExportVizmapTaskFactory exportVizmapTaskFactory = getService(bc, ExportVizmapTaskFactory.class); + TaskManager taskManager = getService(context, DialogTaskManager.class); + final CyNetworkFactory cyNetworkFactory = getService(bc, CyNetworkFactory.class); final CyNetworkManager cyNetworkManager = getService(bc, CyNetworkManager.class); final CyRootNetworkManager cyRootNetworkManager = getService(bc, CyRootNetworkManager.class); - - //Register these with the CyObjectManager singleton. - CyObjectManager manager = CyObjectManager.INSTANCE; - File configDir = config.getAppConfigurationDirectoryLocation(CyActivator.class); - configDir.mkdirs(); - - //setting services to manager singleton - manager.setCyApplicationManager(applicationManager); - manager.setConfigDir(configDir); - manager.setCySwingAppAdapter(appAdapter); - manager.setCySwingApplition(desktop); - manager.setLoadNetworkFileTaskFactory(loadNetworkFileTaskFactory); - manager.setExportNetworkTaskFactory(exportNetworkTaskFactory); - manager.setExportNetworkViewTaskFactory(exportNetworkViewTaskFactory); - manager.setLoadVizmapTaskFactory(loadVizmapFileTaskFactory); - manager.setExportVizmapTaskFactory(exportVizmapTaskFactory); + + //Register these with the CyObjectManager singleton. + CyObjectManager manager = CyObjectManager.INSTANCE; + File configDir = config.getAppConfigurationDirectoryLocation(CyActivator.class); + configDir.mkdirs(); + + //setting services to manager singleton + manager.setCyApplicationManager(applicationManager); + manager.setConfigDir(configDir); + manager.setCySwingAppAdapter(appAdapter); + manager.setCySwingApplition(desktop); + manager.setLoadNetworkFileTaskFactory(loadNetworkFileTaskFactory); + manager.setExportNetworkTaskFactory(exportNetworkTaskFactory); + manager.setExportNetworkViewTaskFactory(exportNetworkViewTaskFactory); + manager.setLoadVizmapTaskFactory(loadVizmapFileTaskFactory); + manager.setExportVizmapTaskFactory(exportVizmapTaskFactory); manager.setCyNetworkFactory(cyNetworkFactory); manager.setCyNetworkManager(cyNetworkManager); manager.setCyRootNetworkManager(cyRootNetworkManager); - - //registering Toolbar component - PostGraphToolBarComponent toolBarComponent = new PostGraphToolBarComponent(); - registerAllServices(bc, toolBarComponent, new Properties()); - + + //registering Toolbar component + PostGraphToolBarComponent toolBarComponent = new PostGraphToolBarComponent(); + registerAllServices(bc, toolBarComponent, new Properties()); + + CyGraphSpaceResultPanel resultPanel = new CyGraphSpaceResultPanel("CyGraphSpace taskbar"); + registerAllServices(context, resultPanel, new Properties()); + //registering openBrowser for opening graph in GraphSpace OpenBrowser openBrowser = getService(context, OpenBrowser.class); - GetGraphsPanel getGraphsPanel = new GetGraphsPanel(taskManager, openBrowser); - registerAllServices(context, getGraphsPanel, new Properties()); - } + GetGraphsPanel getGraphsPanel = new GetGraphsPanel(taskManager, openBrowser); + registerAllServices(context, getGraphsPanel, new Properties()); + } } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java new file mode 100644 index 0000000..6e5a612 --- /dev/null +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -0,0 +1,40 @@ +package org.cytoscape.graphspace.cygraphspace.internal.gui; + +import java.awt.Component; + +import javax.swing.Icon; +import javax.swing.JPanel; + +import org.cytoscape.application.swing.CytoPanelComponent; +import org.cytoscape.application.swing.CytoPanelName; + +@SuppressWarnings("serial") +public class CyGraphSpaceResultPanel extends JPanel implements CytoPanelComponent { + + private String title; + + public CyGraphSpaceResultPanel(String title) { + this.title = title; + } + + @Override + public Component getComponent() { + return this; + } + + @Override + public CytoPanelName getCytoPanelName() { + return CytoPanelName.EAST; + } + + @Override + public Icon getIcon() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getTitle() { + return title; + } +} From a04b36cfc48e1a5cb82f931dd70227f4e81c1169 Mon Sep 17 00:00:00 2001 From: li Date: Tue, 19 Jun 2018 20:58:31 -0400 Subject: [PATCH 02/12] Refs #20: Create basic panel structure to hold cygraphspace tasks. --- .../internal/gui/CyGraphSpaceResultPanel.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index 6e5a612..c671a28 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -1,9 +1,13 @@ package org.cytoscape.graphspace.cygraphspace.internal.gui; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import javax.swing.Icon; import javax.swing.JPanel; +import javax.swing.JScrollPane; import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelName; @@ -12,9 +16,25 @@ public class CyGraphSpaceResultPanel extends JPanel implements CytoPanelComponent { private String title; + private JPanel mainList; public CyGraphSpaceResultPanel(String title) { this.title = title; + initializePanel(); + } + + private void initializePanel() { + setLayout(new BorderLayout()); + + // based on https://stackoverflow.com/questions/14615888/list-of-jpanels-that-eventually-uses-a-scrollbar + this.mainList = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.weightx = 1; + gbc.weighty = 1; + mainList.add(new JPanel(), gbc); + + add(new JScrollPane(mainList)); } @Override From eb9ce81677146510b82e67facb6ca66aabea72ad Mon Sep 17 00:00:00 2001 From: li Date: Thu, 21 Jun 2018 21:17:01 -0400 Subject: [PATCH 03/12] Refs #20: Add test event handler for adding components to result panel when posting new graphs. --- .../cygraphspace/internal/CyActivator.java | 19 ++-- .../internal/CyGraphSpaceMenuAction.java | 6 +- .../internal/PostGraphMenuActionListener.java | 11 ++- .../internal/gui/AuthenticationDialog.java | 9 +- .../internal/gui/CyGraphSpaceResultPanel.java | 47 ++++++++- .../internal/gui/PostGraphDialog.java | 9 +- .../gui/PostGraphToolBarComponent.java | 6 +- .../gui/ResultPanelEventListener.java | 6 ++ .../internal/task/PostGraphTask.java | 97 ++++++++++--------- .../internal/util/PostGraphExportUtils.java | 5 +- 10 files changed, 147 insertions(+), 68 deletions(-) create mode 100644 CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java index d1d8792..194c53f 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java @@ -44,11 +44,6 @@ public void start(BundleContext context) throws Exception { Properties properties = null; BundleContext bc = context; - //register Post Graph Action - action = new CyGraphSpaceMenuAction(MessageConfig.MenuActionTitle); - properties = new Properties(); - registerService(context, action, CyAction.class, properties); - //getting cytoscape services CyApplicationConfiguration config = getService(context,CyApplicationConfiguration.class); CySwingAppAdapter appAdapter = getService(context, CySwingAppAdapter.class); @@ -82,13 +77,19 @@ public void start(BundleContext context) throws Exception { manager.setCyNetworkManager(cyNetworkManager); manager.setCyRootNetworkManager(cyRootNetworkManager); - //registering Toolbar component - PostGraphToolBarComponent toolBarComponent = new PostGraphToolBarComponent(); - registerAllServices(bc, toolBarComponent, new Properties()); - + //register result panel CyGraphSpaceResultPanel resultPanel = new CyGraphSpaceResultPanel("CyGraphSpace taskbar"); registerAllServices(context, resultPanel, new Properties()); + //registering Toolbar component + PostGraphToolBarComponent toolBarComponent = new PostGraphToolBarComponent(resultPanel); + registerAllServices(bc, toolBarComponent, new Properties()); + + //register Post Graph Action + action = new CyGraphSpaceMenuAction(MessageConfig.MenuActionTitle, resultPanel); + properties = new Properties(); + registerService(context, action, CyAction.class, properties); + //registering openBrowser for opening graph in GraphSpace OpenBrowser openBrowser = getService(context, OpenBrowser.class); GetGraphsPanel getGraphsPanel = new GetGraphsPanel(taskManager, openBrowser); diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyGraphSpaceMenuAction.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyGraphSpaceMenuAction.java index 17acdcf..3c0f7b8 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyGraphSpaceMenuAction.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyGraphSpaceMenuAction.java @@ -5,6 +5,7 @@ import javax.swing.event.MenuEvent; import org.cytoscape.application.swing.AbstractCyAction; +import org.cytoscape.graphspace.cygraphspace.internal.gui.CyGraphSpaceResultPanel; import org.cytoscape.graphspace.cygraphspace.internal.singletons.CyObjectManager; public class CyGraphSpaceMenuAction extends AbstractCyAction { @@ -12,14 +13,13 @@ public class CyGraphSpaceMenuAction extends AbstractCyAction { private static final long serialVersionUID = 1L; private PostGraphMenuActionListener actionListener; - public CyGraphSpaceMenuAction(String menuTitle) { - + public CyGraphSpaceMenuAction(String menuTitle, CyGraphSpaceResultPanel resultPanel) { super(menuTitle, CyObjectManager.INSTANCE.getApplicationManager(), null, null); // Menu under File>Export setPreferredMenu("File.Export"); - actionListener = new PostGraphMenuActionListener(); + actionListener = new PostGraphMenuActionListener(resultPanel); } @Override diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/PostGraphMenuActionListener.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/PostGraphMenuActionListener.java index 0c7b695..f925a0d 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/PostGraphMenuActionListener.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/PostGraphMenuActionListener.java @@ -4,6 +4,7 @@ import java.awt.event.ActionListener; import org.cytoscape.graphspace.cygraphspace.internal.gui.AuthenticationDialog; +import org.cytoscape.graphspace.cygraphspace.internal.gui.CyGraphSpaceResultPanel; import org.cytoscape.graphspace.cygraphspace.internal.singletons.CyObjectManager; import org.cytoscape.graphspace.cygraphspace.internal.singletons.Server; import org.cytoscape.graphspace.cygraphspace.internal.util.MessageConfig; @@ -22,8 +23,12 @@ public class PostGraphMenuActionListener implements ActionListener { private static ImageIcon loading; private static JLabel loadingLabel; private static AuthenticationDialog dialog; + private CyGraphSpaceResultPanel resultPanel; + + public PostGraphMenuActionListener(CyGraphSpaceResultPanel resultPanel) { + + this.resultPanel = resultPanel; - public PostGraphMenuActionListener() { loadingFrame = new JFrame("Checking if the graph already exists"); loading = new ImageIcon(this.getClass().getClassLoader().getResource("loading.gif")); loadingLabel = new JLabel("", loading, JLabel.CENTER); @@ -59,7 +64,7 @@ public void run() { new Thread() { public void run() { try { - PostGraphExportUtils.populate(CyObjectManager.INSTANCE.getApplicationFrame(), loadingFrame); + PostGraphExportUtils.populate(CyObjectManager.INSTANCE.getApplicationFrame(), loadingFrame, resultPanel); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -71,7 +76,7 @@ public void run() { //if there is a network but the user is not authenticated, open the login dialog for the user to log in. Once logged in, open the post graph dialog else { if (dialog == null) - dialog = new AuthenticationDialog(loadingFrame); + dialog = new AuthenticationDialog(loadingFrame, resultPanel); dialog.setLocationRelativeTo(CyObjectManager.INSTANCE.getApplicationFrame()); dialog.setVisible(true); diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/AuthenticationDialog.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/AuthenticationDialog.java index 7c05fb8..ca3434d 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/AuthenticationDialog.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/AuthenticationDialog.java @@ -43,9 +43,14 @@ public class AuthenticationDialog extends JDialog { private JButton loginButton; JButton cancelButton; private JFrame loadingFrame; + + private CyGraphSpaceResultPanel resultPanel; - public AuthenticationDialog(JFrame loadingFrame) { + public AuthenticationDialog(JFrame loadingFrame, CyGraphSpaceResultPanel resultPanel) { super(CyObjectManager.INSTANCE.getApplicationFrame(), "Log in to the Server", ModalityType.APPLICATION_MODAL); + + this.resultPanel = resultPanel; + JLabel hostLabel = new JLabel("Host"); AuthTextFieldListener textFieldListener = new AuthTextFieldListener(); @@ -184,7 +189,7 @@ public void run() { new Thread() { public void run() { try { - PostGraphExportUtils.populate(CyObjectManager.INSTANCE.getApplicationFrame(), loadingFrame); + PostGraphExportUtils.populate(CyObjectManager.INSTANCE.getApplicationFrame(), loadingFrame, resultPanel); } catch (Exception e) { e.printStackTrace(); } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index c671a28..f230e21 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -1,25 +1,34 @@ package org.cytoscape.graphspace.cygraphspace.internal.gui; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.util.HashMap; +import java.util.Map; import javax.swing.Icon; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.border.MatteBorder; import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelName; @SuppressWarnings("serial") -public class CyGraphSpaceResultPanel extends JPanel implements CytoPanelComponent { +public class CyGraphSpaceResultPanel extends JPanel implements CytoPanelComponent, ResultPanelEventListener { private String title; private JPanel mainList; + private int count; + private Map map; public CyGraphSpaceResultPanel(String title) { this.title = title; + this.count = 0; + this.map = new HashMap<>(); initializePanel(); } @@ -57,4 +66,40 @@ public Icon getIcon() { public String getTitle() { return title; } + + private class PanelItem extends JPanel { + private int index; + private String name; + private String status; + + public PanelItem(int index, String name, String status) { + this.index = index; + this.name = name; + this.status = status; + initPanelItem(); + } + + private void initPanelItem() { + this.add(new JLabel(name)); + this.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); + } + } + + @Override + public void postGraphEvent() { + PanelItem item = new PanelItem(count, "test", "test"); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.weightx = 1; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainList.add(item, gbc, 0); + + validate(); + repaint(); + } + + @Override + public void updateGraphEvent() { + // TODO Auto-generated method stub + } } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphDialog.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphDialog.java index 20eafdf..6329121 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphDialog.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphDialog.java @@ -39,9 +39,15 @@ public class PostGraphDialog extends JDialog { private GroupLayout groupLayout; private JLabel graphNameLabel; private JLabel graphNameValue; + + private CyGraphSpaceResultPanel resultPanel; - public PostGraphDialog(String graphName, JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tags) { + public PostGraphDialog(String graphName, JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tags, + CyGraphSpaceResultPanel resultPanel) { super(CyObjectManager.INSTANCE.getApplicationFrame(), "Upload the graph/netork GraphSpace", ModalityType.APPLICATION_MODAL); + + this.resultPanel = resultPanel; + JLabel hostLabel = new JLabel("Host:"); hostValueLabel = new JLabel("www.graphspace.org"); usernameValueLabel = new JLabel("Anonymous"); @@ -127,6 +133,7 @@ private void exportActionPerformed(JSONObject graphJSON, JSONObject styleJSON, b this.dispose(); SynchronousTaskManager synTaskMan = CyObjectManager.INSTANCE.getSynchrounousTaskManager(); PostGraphTask postGraphTask = new PostGraphTask(graphJSON, styleJSON, isGraphPublic); + postGraphTask.setResultPanelEventListener(resultPanel); synTaskMan.execute(new TaskIterator(postGraphTask)); } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphToolBarComponent.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphToolBarComponent.java index d8b5462..f7147fb 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphToolBarComponent.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphToolBarComponent.java @@ -20,8 +20,8 @@ public class PostGraphToolBarComponent extends AbstractToolBarComponent implemen private JButton button; private PostGraphMenuActionListener actionListener; - - public PostGraphToolBarComponent() { + + public PostGraphToolBarComponent(CyGraphSpaceResultPanel resultPanel) { super(); button = new JButton(); @@ -36,7 +36,7 @@ public PostGraphToolBarComponent() { button.setEnabled(false); //action attached to the button - actionListener = new PostGraphMenuActionListener(); + actionListener = new PostGraphMenuActionListener(resultPanel); button.addActionListener(actionListener); } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java new file mode 100644 index 0000000..fed32ce --- /dev/null +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java @@ -0,0 +1,6 @@ +package org.cytoscape.graphspace.cygraphspace.internal.gui; + +public interface ResultPanelEventListener { + public void postGraphEvent(); + public void updateGraphEvent(); +} diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java index 16d5efe..591b061 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java @@ -4,6 +4,7 @@ import javax.swing.JOptionPane; +import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEventListener; import org.cytoscape.graphspace.cygraphspace.internal.singletons.Server; import org.cytoscape.graphspace.cygraphspace.internal.util.MessageConfig; import org.cytoscape.work.AbstractTask; @@ -14,48 +15,56 @@ * Task class that posts graph to the GraphSpace and update related status */ public class PostGraphTask extends AbstractTask { - private JSONObject graphJSON; - private JSONObject styleJSON; - private boolean isGraphPublic; - private TaskMonitor taskMonitor; - - public PostGraphTask(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic) { - this.graphJSON = graphJSON; - this.styleJSON = styleJSON; - this.isGraphPublic = isGraphPublic; - } - - @Override - public void run(TaskMonitor taskMonitor) throws Exception { - - this.taskMonitor = taskMonitor; - taskMonitor.setTitle(MessageConfig.POST_GRAPH_TASK_TITLE); - taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_IN_PROGRESS); - - // run task in background - new Thread() { - public void run() { - postGraph(); - } - }.start(); - } - - private void postGraph() { - try { - postGraph(graphJSON, styleJSON, isGraphPublic, null); - } catch (Exception e1) { - taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_FAIL); - JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_FAIL, - "Error", JOptionPane.ERROR_MESSAGE); - return; - } - taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_SUCCESS); - JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_SUCCESS, - "Message", JOptionPane.INFORMATION_MESSAGE); - } - - //post the current network to GraphSpace - private void postGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tagsList) throws Exception{ - Server.INSTANCE.postGraph(graphJSON, styleJSON, isGraphPublic, tagsList); - } + private JSONObject graphJSON; + private JSONObject styleJSON; + private boolean isGraphPublic; + private TaskMonitor taskMonitor; + private ResultPanelEventListener listener; + + public PostGraphTask(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic) { + this.graphJSON = graphJSON; + this.styleJSON = styleJSON; + this.isGraphPublic = isGraphPublic; + } + + @Override + public void run(TaskMonitor taskMonitor) throws Exception { + + this.taskMonitor = taskMonitor; + taskMonitor.setTitle(MessageConfig.POST_GRAPH_TASK_TITLE); + taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_IN_PROGRESS); + + // run task in background + new Thread() { + public void run() { + postGraph(); + } + }.start(); + } + + private void postGraph() { + try { + postGraph(graphJSON, styleJSON, isGraphPublic, null); + } catch (Exception e1) { + taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_FAIL); + JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_FAIL, + "Error", JOptionPane.ERROR_MESSAGE); + return; + } + if (listener != null) + listener.postGraphEvent(); + + taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_SUCCESS); + JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_SUCCESS, + "Message", JOptionPane.INFORMATION_MESSAGE); + } + + //post the current network to GraphSpace + private void postGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tagsList) throws Exception{ + Server.INSTANCE.postGraph(graphJSON, styleJSON, isGraphPublic, tagsList); + } + + public void setResultPanelEventListener(ResultPanelEventListener listener) { + this.listener = listener; + } } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/PostGraphExportUtils.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/PostGraphExportUtils.java index fcdb4b3..c0ab648 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/PostGraphExportUtils.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/PostGraphExportUtils.java @@ -8,6 +8,7 @@ import javax.swing.SwingUtilities; import org.apache.commons.io.FileUtils; +import org.cytoscape.graphspace.cygraphspace.internal.gui.CyGraphSpaceResultPanel; import org.cytoscape.graphspace.cygraphspace.internal.gui.PostGraphDialog; import org.cytoscape.graphspace.cygraphspace.internal.gui.UpdateGraphDialog; import org.cytoscape.graphspace.cygraphspace.internal.singletons.CyObjectManager; @@ -30,7 +31,7 @@ public class PostGraphExportUtils { * @param loadingFrame the loading frame * @throws Exception */ - public static void populate(Frame parent, JFrame loadingFrame) throws Exception { + public static void populate(Frame parent, JFrame loadingFrame, CyGraphSpaceResultPanel resultPanel) throws Exception { JSONObject graphJSON = exportNetworkToJSON(); JSONObject styleJSON = exportStyleToJSON(); String graphName = graphJSON.getJSONObject("data").getString("name"); @@ -59,7 +60,7 @@ public void run() { } }); - PostGraphDialog postDialog = new PostGraphDialog(graphName, graphJSON, styleJSON, isGraphPublic, null); + PostGraphDialog postDialog = new PostGraphDialog(graphName, graphJSON, styleJSON, isGraphPublic, null, resultPanel); postDialog.setLocationRelativeTo(parent); postDialog.setVisible(true); } From 85735f3e4aa09566b0ba1cef0982d5ff59f24c8b Mon Sep 17 00:00:00 2001 From: li Date: Sun, 24 Jun 2018 19:57:39 -0400 Subject: [PATCH 04/12] Refs #20: Implemented basic functionality of tracking task status. --- .../internal/gui/CyGraphSpaceResultPanel.java | 186 ++++++++++-------- .../internal/gui/PostGraphDialog.java | 6 +- .../internal/gui/ResultPanelEvent.java | 32 +++ .../gui/ResultPanelEventListener.java | 6 +- .../internal/gui/UpdateGraphDialog.java | 9 +- .../internal/task/PostGraphTask.java | 119 ++++++----- .../internal/task/UpdateGraphTask.java | 24 ++- .../internal/util/MessageConfig.java | 5 + .../internal/util/PostGraphExportUtils.java | 2 +- 9 files changed, 246 insertions(+), 143 deletions(-) create mode 100644 CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEvent.java diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index f230e21..1296252 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -20,86 +20,108 @@ @SuppressWarnings("serial") public class CyGraphSpaceResultPanel extends JPanel implements CytoPanelComponent, ResultPanelEventListener { - private String title; - private JPanel mainList; - private int count; - private Map map; - - public CyGraphSpaceResultPanel(String title) { - this.title = title; - this.count = 0; - this.map = new HashMap<>(); - initializePanel(); - } - - private void initializePanel() { - setLayout(new BorderLayout()); - - // based on https://stackoverflow.com/questions/14615888/list-of-jpanels-that-eventually-uses-a-scrollbar - this.mainList = new JPanel(new GridBagLayout()); - GridBagConstraints gbc = new GridBagConstraints(); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.weightx = 1; - gbc.weighty = 1; - mainList.add(new JPanel(), gbc); - - add(new JScrollPane(mainList)); - } - - @Override - public Component getComponent() { - return this; - } - - @Override - public CytoPanelName getCytoPanelName() { - return CytoPanelName.EAST; - } - - @Override - public Icon getIcon() { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getTitle() { - return title; - } - - private class PanelItem extends JPanel { - private int index; - private String name; - private String status; - - public PanelItem(int index, String name, String status) { - this.index = index; - this.name = name; - this.status = status; - initPanelItem(); - } - - private void initPanelItem() { - this.add(new JLabel(name)); - this.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); - } - } - - @Override - public void postGraphEvent() { - PanelItem item = new PanelItem(count, "test", "test"); - GridBagConstraints gbc = new GridBagConstraints(); - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.weightx = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - mainList.add(item, gbc, 0); - - validate(); - repaint(); - } - - @Override - public void updateGraphEvent() { - // TODO Auto-generated method stub - } + private String title; + private JPanel mainList; + private int itemCount; + private Map itemMap; + + public CyGraphSpaceResultPanel(String title) { + this.title = title; + this.itemCount = 1; + this.itemMap = new HashMap<>(); + initializePanel(); + } + + private void initializePanel() { + setLayout(new BorderLayout()); + + // based on https://stackoverflow.com/questions/14615888/list-of-jpanels-that-eventually-uses-a-scrollbar + this.mainList = new JPanel(new GridBagLayout()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.weightx = 1; + gbc.weighty = 1; + mainList.add(new JPanel(), gbc); + + add(new JScrollPane(mainList)); + } + + @Override + public Component getComponent() { + return this; + } + + @Override + public CytoPanelName getCytoPanelName() { + return CytoPanelName.EAST; + } + + @Override + public Icon getIcon() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getTitle() { + return title; + } + + + @Override + public int postGraphEvent(ResultPanelEvent e) { + PanelItem item = new PanelItem(itemCount, e.getGraphName(), e.getGraphStatus()); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridwidth = GridBagConstraints.REMAINDER; + gbc.weightx = 1; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainList.add(item, gbc, 0); + + itemMap.put(itemCount, item); + + validate(); + repaint(); + + return itemCount++; + } + + @Override + public void updateGraphStatusEvent(ResultPanelEvent e) { + itemMap.get(e.getGraphIndex()).updateStatus(e.getGraphStatus()); + validate(); + repaint(); + } + + private class PanelItem extends JPanel { + private int index; + private String name; + private String status; + + private JLabel taskLabel; + private JLabel graphNameLabel; + private JLabel statusLabel; + + public PanelItem(int index, String name, String status) { + this.index = index; + this.name = name; + this.status = status; + initPanelItem(); + } + + private void initPanelItem() { + taskLabel = new JLabel("Task: " + index); + graphNameLabel = new JLabel("Graph: " + name); + statusLabel = new JLabel("Status: " + status); + + this.add(taskLabel); + this.add(graphNameLabel); + this.add(statusLabel); + this.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); + } + + public void updateStatus(String status) { + this.status = status; + statusLabel.setText("Status: " + status); + } + } } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphDialog.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphDialog.java index 6329121..4a9c088 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphDialog.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/PostGraphDialog.java @@ -39,15 +39,15 @@ public class PostGraphDialog extends JDialog { private GroupLayout groupLayout; private JLabel graphNameLabel; private JLabel graphNameValue; - + private CyGraphSpaceResultPanel resultPanel; public PostGraphDialog(String graphName, JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tags, CyGraphSpaceResultPanel resultPanel) { super(CyObjectManager.INSTANCE.getApplicationFrame(), "Upload the graph/netork GraphSpace", ModalityType.APPLICATION_MODAL); - + this.resultPanel = resultPanel; - + JLabel hostLabel = new JLabel("Host:"); hostValueLabel = new JLabel("www.graphspace.org"); usernameValueLabel = new JLabel("Anonymous"); diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEvent.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEvent.java new file mode 100644 index 0000000..cdf04c7 --- /dev/null +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEvent.java @@ -0,0 +1,32 @@ +package org.cytoscape.graphspace.cygraphspace.internal.gui; + +public class ResultPanelEvent { + + private int graphIndex; + private String graphName; + private String graphStatus; + + public ResultPanelEvent(String graphName, String graphStatus) { + this.graphIndex = -1; + this.graphName = graphName; + this.graphStatus = graphStatus; + } + + public ResultPanelEvent(int graphIndex, String graphName, String graphStatus) { + this.graphIndex = graphIndex; + this.graphName = graphName; + this.graphStatus = graphStatus; + } + + public int getGraphIndex() { + return this.graphIndex; + } + + public String getGraphName() { + return this.graphName; + } + + public String getGraphStatus() { + return this.graphStatus; + } +} diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java index fed32ce..9c57e57 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java @@ -1,6 +1,6 @@ package org.cytoscape.graphspace.cygraphspace.internal.gui; public interface ResultPanelEventListener { - public void postGraphEvent(); - public void updateGraphEvent(); -} + public int postGraphEvent(ResultPanelEvent e); + public void updateGraphStatusEvent(ResultPanelEvent e); +} \ No newline at end of file diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/UpdateGraphDialog.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/UpdateGraphDialog.java index ea82fb3..a2f8151 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/UpdateGraphDialog.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/UpdateGraphDialog.java @@ -39,9 +39,15 @@ public class UpdateGraphDialog extends JDialog { private JLabel graphNameValue; private JLabel graphNameLabel; private JLabel updateMessage; + + private CyGraphSpaceResultPanel resultPanel; - public UpdateGraphDialog(String graphName, JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tags) { + public UpdateGraphDialog(String graphName, JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tags, + CyGraphSpaceResultPanel resultPanel) { super(CyObjectManager.INSTANCE.getApplicationFrame(), "Update the graph/network on GraphSpace", ModalityType.APPLICATION_MODAL); + + this.resultPanel = resultPanel; + JLabel hostLabel = new JLabel("Host:"); hostValueLabel = new JLabel("www.graphspace.org"); usernameValueLabel = new JLabel("Anonymous"); @@ -136,6 +142,7 @@ private void updateActionPerformed(JSONObject graphJSON, JSONObject styleJSON, b this.dispose(); SynchronousTaskManager synTaskMan = CyObjectManager.INSTANCE.getSynchrounousTaskManager(); UpdateGraphTask updateGraphTask = new UpdateGraphTask(graphJSON, styleJSON, isPublic); + updateGraphTask.setResultPanelEventListener(resultPanel); synTaskMan.execute(new TaskIterator(updateGraphTask)); } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java index 591b061..11c1773 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java @@ -4,6 +4,7 @@ import javax.swing.JOptionPane; +import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEvent; import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEventListener; import org.cytoscape.graphspace.cygraphspace.internal.singletons.Server; import org.cytoscape.graphspace.cygraphspace.internal.util.MessageConfig; @@ -15,56 +16,70 @@ * Task class that posts graph to the GraphSpace and update related status */ public class PostGraphTask extends AbstractTask { - private JSONObject graphJSON; - private JSONObject styleJSON; - private boolean isGraphPublic; - private TaskMonitor taskMonitor; - private ResultPanelEventListener listener; - - public PostGraphTask(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic) { - this.graphJSON = graphJSON; - this.styleJSON = styleJSON; - this.isGraphPublic = isGraphPublic; - } - - @Override - public void run(TaskMonitor taskMonitor) throws Exception { - - this.taskMonitor = taskMonitor; - taskMonitor.setTitle(MessageConfig.POST_GRAPH_TASK_TITLE); - taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_IN_PROGRESS); - - // run task in background - new Thread() { - public void run() { - postGraph(); - } - }.start(); - } - - private void postGraph() { - try { - postGraph(graphJSON, styleJSON, isGraphPublic, null); - } catch (Exception e1) { - taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_FAIL); - JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_FAIL, - "Error", JOptionPane.ERROR_MESSAGE); - return; - } - if (listener != null) - listener.postGraphEvent(); - - taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_SUCCESS); - JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_SUCCESS, - "Message", JOptionPane.INFORMATION_MESSAGE); - } - - //post the current network to GraphSpace - private void postGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tagsList) throws Exception{ - Server.INSTANCE.postGraph(graphJSON, styleJSON, isGraphPublic, tagsList); - } - - public void setResultPanelEventListener(ResultPanelEventListener listener) { - this.listener = listener; - } + private JSONObject graphJSON; + private JSONObject styleJSON; + private boolean isGraphPublic; + private TaskMonitor taskMonitor; + private ResultPanelEventListener listener; + + public PostGraphTask(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic) { + this.graphJSON = graphJSON; + this.styleJSON = styleJSON; + this.isGraphPublic = isGraphPublic; + this.listener = null; + } + + @Override + public void run(TaskMonitor taskMonitor) throws Exception { + + this.taskMonitor = taskMonitor; + taskMonitor.setTitle(MessageConfig.POST_GRAPH_TASK_TITLE); + taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_IN_PROGRESS); + + // run task in background + new Thread() { + public void run() { + postGraph(); + } + }.start(); + } + + private void postGraph() { + int panelIndex = -1; + + try { + if (listener != null) + panelIndex = listener.postGraphEvent( + new ResultPanelEvent(graphJSON.getJSONObject("data").getString("name"),MessageConfig.TASK_IN_PROGRESS)); + + postGraph(graphJSON, styleJSON, isGraphPublic, null); + } catch (Exception e1) { + taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_FAIL); + JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_FAIL, + "Error", JOptionPane.ERROR_MESSAGE); + + if (listener != null) + listener.updateGraphStatusEvent( + new ResultPanelEvent(panelIndex, "", MessageConfig.TASK_FAIL)); + + return; + } + + if (listener != null) + listener.updateGraphStatusEvent( + new ResultPanelEvent(panelIndex, "", MessageConfig.TASK_COMPLETE)); + + taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_SUCCESS); + JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_SUCCESS, + "Message", JOptionPane.INFORMATION_MESSAGE); + } + + //post the current network to GraphSpace + private void postGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tagsList) throws Exception { + Server.INSTANCE.postGraph(graphJSON, styleJSON, isGraphPublic, tagsList); + } + + public void setResultPanelEventListener(ResultPanelEventListener listener) { + this.listener = listener; + } } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java index f70a792..f13186c 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java @@ -4,6 +4,8 @@ import javax.swing.JOptionPane; +import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEvent; +import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEventListener; import org.cytoscape.graphspace.cygraphspace.internal.singletons.Server; import org.cytoscape.graphspace.cygraphspace.internal.util.MessageConfig; import org.cytoscape.work.AbstractTask; @@ -14,16 +16,17 @@ * Task class that update graph to the GraphSpace and update related status */ public class UpdateGraphTask extends AbstractTask { - private JSONObject graphJSON; private JSONObject styleJSON; private boolean isGraphPublic; private TaskMonitor taskMonitor; + private ResultPanelEventListener listener; public UpdateGraphTask(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic) { this.graphJSON = graphJSON; this.styleJSON = styleJSON; this.isGraphPublic = isGraphPublic; + this.listener = null; } @Override @@ -42,14 +45,29 @@ public void run() { } private void postGraph() { + int panelIndex = -1; try { + if (listener != null) + panelIndex = listener.postGraphEvent( + new ResultPanelEvent(graphJSON.getJSONObject("data").getString("name"),MessageConfig.TASK_IN_PROGRESS)); + updateGraph(graphJSON, styleJSON, isGraphPublic, null); } catch (Exception e1) { taskMonitor.setStatusMessage(MessageConfig.UPDATE_GRAPH_TASK_STATUS_FAIL); JOptionPane.showMessageDialog(null, MessageConfig.UPDATE_GRAPH_TASK_DIALOG_FAIL, "Error", JOptionPane.ERROR_MESSAGE); + + if (listener != null) + listener.updateGraphStatusEvent( + new ResultPanelEvent(panelIndex, "", MessageConfig.TASK_FAIL)); + return; } + + if (listener != null) + listener.updateGraphStatusEvent( + new ResultPanelEvent(panelIndex, "", MessageConfig.TASK_COMPLETE)); + taskMonitor.setStatusMessage(MessageConfig.UPDATE_GRAPH_TASK_STATUS_SUCCESS); JOptionPane.showMessageDialog(null, MessageConfig.UPDATE_GRAPH_TASK_DIALOG_SUCCESS, "Message", JOptionPane.INFORMATION_MESSAGE); @@ -60,4 +78,8 @@ private void updateGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isP String name = graphJSON.getJSONObject("data").getString("name"); Server.INSTANCE.updateGraph(name, graphJSON, isPublic, tagsList); } + + public void setResultPanelEventListener(ResultPanelEventListener listener) { + this.listener = listener; + } } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java index fb1397c..d232ad4 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java @@ -43,4 +43,9 @@ public class MessageConfig { // Error message for event where user tries to upload large network public final static String NETWORK_TOO_LARGE_MSG = "Currently GraphSpace cannot handle networks with more than 400 nodes and/or 1000 edges.\n" + "Please select a smaller network or subnetwork to upload."; + + // Result panel status messages + public static final String TASK_COMPLETE = "Complete"; + public static final String TASK_IN_PROGRESS = "In progress"; + public static final String TASK_FAIL = "Fail"; } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/PostGraphExportUtils.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/PostGraphExportUtils.java index c0ab648..be86bfb 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/PostGraphExportUtils.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/PostGraphExportUtils.java @@ -47,7 +47,7 @@ public void run() { Graph graph = Server.INSTANCE.getGraphByName(graphName); isGraphPublic = graph.isPublic(); - UpdateGraphDialog updateDialog = new UpdateGraphDialog(graphName, graphJSON, styleJSON, isGraphPublic, null); + UpdateGraphDialog updateDialog = new UpdateGraphDialog(graphName, graphJSON, styleJSON, isGraphPublic, null, resultPanel); updateDialog.setLocationRelativeTo(parent); updateDialog.setVisible(true); } From e7df7cd489dc9bf6d1dc702c51f3989055e6e4da Mon Sep 17 00:00:00 2001 From: li Date: Mon, 25 Jun 2018 21:25:55 -0400 Subject: [PATCH 05/12] Refs #20: result panel supports auto pop-up on post and update events. --- .../internal/gui/CyGraphSpaceResultPanel.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index 1296252..415a013 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -14,8 +14,11 @@ import javax.swing.JScrollPane; import javax.swing.border.MatteBorder; +import org.cytoscape.application.swing.CytoPanel; import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelName; +import org.cytoscape.application.swing.CytoPanelState; +import org.cytoscape.graphspace.cygraphspace.internal.singletons.CyObjectManager; @SuppressWarnings("serial") public class CyGraphSpaceResultPanel extends JPanel implements CytoPanelComponent, ResultPanelEventListener { @@ -24,11 +27,13 @@ public class CyGraphSpaceResultPanel extends JPanel implements CytoPanelComponen private JPanel mainList; private int itemCount; private Map itemMap; + private CytoPanel cytoPanel; public CyGraphSpaceResultPanel(String title) { this.title = title; this.itemCount = 1; this.itemMap = new HashMap<>(); + this.cytoPanel = CyObjectManager.INSTANCE.getCySwingApplition().getCytoPanel(getCytoPanelName()); initializePanel(); } @@ -67,7 +72,6 @@ public String getTitle() { return title; } - @Override public int postGraphEvent(ResultPanelEvent e) { PanelItem item = new PanelItem(itemCount, e.getGraphName(), e.getGraphStatus()); @@ -81,6 +85,7 @@ public int postGraphEvent(ResultPanelEvent e) { validate(); repaint(); + showPanel(); return itemCount++; } @@ -90,6 +95,16 @@ public void updateGraphStatusEvent(ResultPanelEvent e) { itemMap.get(e.getGraphIndex()).updateStatus(e.getGraphStatus()); validate(); repaint(); + showPanel(); + } + + private void showPanel() { + if (cytoPanel.getState() == CytoPanelState.HIDE) + cytoPanel.setState(CytoPanelState.DOCK); + + // set visible and selected + this.setVisible(true); + cytoPanel.setSelectedIndex(cytoPanel.indexOfComponent(this.getComponent())); } private class PanelItem extends JPanel { From 44c08d570d991d18feec2d00077b3ce3d51ff0a3 Mon Sep 17 00:00:00 2001 From: li Date: Sat, 7 Jul 2018 21:32:00 -0400 Subject: [PATCH 06/12] Refs #20: Let JavaClient return graph ID of the uploaded graph for constructing URL. --- .../src/main/java/org/graphspace/javaclient/Graph.java | 5 ++--- .../java/org/graphspace/javaclient/GraphSpaceClient.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/Graph.java b/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/Graph.java index c88b32f..3a2df7a 100644 --- a/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/Graph.java +++ b/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/Graph.java @@ -339,7 +339,7 @@ public static ArrayList getMyGraphs(RestClient restClient, ArrayList getMyGraphs(int limit, int offset) throws Exception{ /** * Reference: {@link org.graphspace.javaclient.Graph#postGraph()} */ - public String postGraph(JSONObject graphJson, JSONObject styleJson, boolean isGraphPublic, ArrayList tagsList) throws Exception{ + public Response postGraph(JSONObject graphJson, JSONObject styleJson, boolean isGraphPublic, ArrayList tagsList) throws Exception{ Graph graph = new Graph(restClient, isGraphPublic); graph.setGraphJson(graphJson); graph.setStyleJson(styleJson); From 06728d1f05111b7353897d281c60901dd1b5031d Mon Sep 17 00:00:00 2001 From: li Date: Sat, 7 Jul 2018 21:32:32 -0400 Subject: [PATCH 07/12] Refs #20: Implement feature to display graph URL after upload success. --- .../internal/gui/CyGraphSpaceResultPanel.java | 33 +++++++++++++++++-- .../internal/gui/ResultPanelEvent.java | 14 ++++++-- .../internal/singletons/Server.java | 5 +-- .../internal/task/PostGraphTask.java | 13 ++++---- .../internal/task/UpdateGraphTask.java | 6 ++-- .../internal/util/MessageConfig.java | 5 ++- 6 files changed, 59 insertions(+), 17 deletions(-) diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index 415a013..eea08df 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -5,10 +5,17 @@ import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; import java.util.HashMap; import java.util.Map; import javax.swing.Icon; +import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -19,6 +26,7 @@ import org.cytoscape.application.swing.CytoPanelName; import org.cytoscape.application.swing.CytoPanelState; import org.cytoscape.graphspace.cygraphspace.internal.singletons.CyObjectManager; +import org.cytoscape.graphspace.cygraphspace.internal.util.MessageConfig; @SuppressWarnings("serial") public class CyGraphSpaceResultPanel extends JPanel implements CytoPanelComponent, ResultPanelEventListener { @@ -92,7 +100,7 @@ public int postGraphEvent(ResultPanelEvent e) { @Override public void updateGraphStatusEvent(ResultPanelEvent e) { - itemMap.get(e.getGraphIndex()).updateStatus(e.getGraphStatus()); + itemMap.get(e.getGraphIndex()).updateStatus(e.getGraphStatus(), e.getGraphId()); validate(); repaint(); showPanel(); @@ -115,6 +123,7 @@ private class PanelItem extends JPanel { private JLabel taskLabel; private JLabel graphNameLabel; private JLabel statusLabel; + private JButton urlBtn; public PanelItem(int index, String name, String status) { this.index = index; @@ -134,9 +143,29 @@ private void initPanelItem() { this.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); } - public void updateStatus(String status) { + public void updateStatus(String status, int graphId) { this.status = status; statusLabel.setText("Status: " + status); + + if (graphId != -1) { + urlBtn = new JButton("Link"); + urlBtn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { + java.awt.Desktop.getDesktop().browse(new URI(MessageConfig.GRAPHSPACE_LINK + graphId)); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (URISyntaxException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); + + this.add(urlBtn); + } } } } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEvent.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEvent.java index cdf04c7..f3feeb1 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEvent.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEvent.java @@ -3,29 +3,37 @@ public class ResultPanelEvent { private int graphIndex; + private int graphId; private String graphName; private String graphStatus; public ResultPanelEvent(String graphName, String graphStatus) { this.graphIndex = -1; + this.graphId = -1; this.graphName = graphName; this.graphStatus = graphStatus; } - - public ResultPanelEvent(int graphIndex, String graphName, String graphStatus) { + + public ResultPanelEvent(int graphIndex, int graphId, String graphName, String graphStatus) { this.graphIndex = graphIndex; + this.graphId = graphId; this.graphName = graphName; this.graphStatus = graphStatus; } - + public int getGraphIndex() { return this.graphIndex; } + public int getGraphId() { + return this.graphId; + } + public String getGraphName() { return this.graphName; } + public String getGraphStatus() { return this.graphStatus; } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/singletons/Server.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/singletons/Server.java index a8121bf..85c834b 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/singletons/Server.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/singletons/Server.java @@ -11,6 +11,7 @@ import org.graphspace.javaclient.Graph; import org.graphspace.javaclient.GraphSpaceClient; +import org.graphspace.javaclient.Response; import org.json.JSONObject; /** @@ -112,8 +113,8 @@ public void updateGraph(String name, JSONObject graphJson, boolean isGraphPublic } //post a graph to GraphSpace - public void postGraph(JSONObject graphJson, JSONObject styleJson, boolean isGraphPublic, ArrayList tagsList) throws Exception{ - client.postGraph(graphJson, styleJson, isGraphPublic, tagsList); + public Response postGraph(JSONObject graphJson, JSONObject styleJson, boolean isGraphPublic, ArrayList tagsList) throws Exception{ + return client.postGraph(graphJson, styleJson, isGraphPublic, tagsList); } //check if a graph to be exported can be updated diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java index 11c1773..c0f379d 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java @@ -10,6 +10,7 @@ import org.cytoscape.graphspace.cygraphspace.internal.util.MessageConfig; import org.cytoscape.work.AbstractTask; import org.cytoscape.work.TaskMonitor; +import org.graphspace.javaclient.Response; import org.json.JSONObject; /** @@ -45,14 +46,14 @@ public void run() { } private void postGraph() { - int panelIndex = -1; + int panelIndex = -1, graphId = -1; try { if (listener != null) panelIndex = listener.postGraphEvent( new ResultPanelEvent(graphJSON.getJSONObject("data").getString("name"),MessageConfig.TASK_IN_PROGRESS)); - postGraph(graphJSON, styleJSON, isGraphPublic, null); + graphId = postGraph(graphJSON, styleJSON, isGraphPublic, null).getGraph().getId(); } catch (Exception e1) { taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_FAIL); JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_FAIL, @@ -60,14 +61,14 @@ private void postGraph() { if (listener != null) listener.updateGraphStatusEvent( - new ResultPanelEvent(panelIndex, "", MessageConfig.TASK_FAIL)); + new ResultPanelEvent(panelIndex, graphId, "", MessageConfig.TASK_FAIL)); return; } if (listener != null) listener.updateGraphStatusEvent( - new ResultPanelEvent(panelIndex, "", MessageConfig.TASK_COMPLETE)); + new ResultPanelEvent(panelIndex, graphId, "", MessageConfig.TASK_COMPLETE)); taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_SUCCESS); JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_SUCCESS, @@ -75,8 +76,8 @@ private void postGraph() { } //post the current network to GraphSpace - private void postGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tagsList) throws Exception { - Server.INSTANCE.postGraph(graphJSON, styleJSON, isGraphPublic, tagsList); + private Response postGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isGraphPublic, ArrayList tagsList) throws Exception { + return Server.INSTANCE.postGraph(graphJSON, styleJSON, isGraphPublic, tagsList); } public void setResultPanelEventListener(ResultPanelEventListener listener) { diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java index f13186c..cf550eb 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java @@ -45,7 +45,7 @@ public void run() { } private void postGraph() { - int panelIndex = -1; + int panelIndex = -1, graphId = -1; try { if (listener != null) panelIndex = listener.postGraphEvent( @@ -59,14 +59,14 @@ private void postGraph() { if (listener != null) listener.updateGraphStatusEvent( - new ResultPanelEvent(panelIndex, "", MessageConfig.TASK_FAIL)); + new ResultPanelEvent(panelIndex, graphId, "", MessageConfig.TASK_FAIL)); return; } if (listener != null) listener.updateGraphStatusEvent( - new ResultPanelEvent(panelIndex, "", MessageConfig.TASK_COMPLETE)); + new ResultPanelEvent(panelIndex, graphId, "", MessageConfig.TASK_COMPLETE)); taskMonitor.setStatusMessage(MessageConfig.UPDATE_GRAPH_TASK_STATUS_SUCCESS); JOptionPane.showMessageDialog(null, diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java index d232ad4..47e50b8 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java @@ -12,6 +12,9 @@ public class MessageConfig { public final static String APP_DESCRIPTION = "" + "The CyGraphSpace App is used to upload graphs to " + "GraphSpace. "; + // GraphSpace link + public final static String GRAPHSPACE_LINK = "http://graphspace.org/graphs/"; + // error messages related to authentication dialog public final static String AUTH_NOT_FILL_ERROR_MSG = "Please enter all the values."; public final static String AUTH_INVALID_URL = "IP address of the entered host could not be determined.\n" @@ -43,7 +46,7 @@ public class MessageConfig { // Error message for event where user tries to upload large network public final static String NETWORK_TOO_LARGE_MSG = "Currently GraphSpace cannot handle networks with more than 400 nodes and/or 1000 edges.\n" + "Please select a smaller network or subnetwork to upload."; - + // Result panel status messages public static final String TASK_COMPLETE = "Complete"; public static final String TASK_IN_PROGRESS = "In progress"; From 49d4d17c8d7009f8681fb2980ba7dff9eb733824 Mon Sep 17 00:00:00 2001 From: li Date: Sat, 21 Jul 2018 15:37:03 -0400 Subject: [PATCH 08/12] Refs #20: Update graph method now returns response instead of response status. Add basic UI for task bar. --- .../internal/gui/CyGraphSpaceResultPanel.java | 58 +++++++++++++------ .../gui/ResultPanelEventListener.java | 2 +- .../internal/singletons/Server.java | 4 +- .../internal/task/PostGraphTask.java | 2 +- .../internal/task/UpdateGraphTask.java | 13 +++-- .../java/org/graphspace/javaclient/Graph.java | 9 ++- .../javaclient/GraphSpaceClient.java | 2 +- 7 files changed, 57 insertions(+), 33 deletions(-) diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index eea08df..7a6700f 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -1,8 +1,8 @@ package org.cytoscape.graphspace.cygraphspace.internal.gui; import java.awt.BorderLayout; -import java.awt.Color; import java.awt.Component; +import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; @@ -10,16 +10,18 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.util.HashMap; import java.util.Map; +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.border.MatteBorder; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; import org.cytoscape.application.swing.CytoPanel; import org.cytoscape.application.swing.CytoPanelComponent; @@ -81,7 +83,7 @@ public String getTitle() { } @Override - public int postGraphEvent(ResultPanelEvent e) { + public int graphSpaceEvent(ResultPanelEvent e) { PanelItem item = new PanelItem(itemCount, e.getGraphName(), e.getGraphStatus()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; @@ -120,9 +122,14 @@ private class PanelItem extends JPanel { private String name; private String status; - private JLabel taskLabel; + private JPanel graphPanel; private JLabel graphNameLabel; + private JTextField graphNameText; + + private JPanel statusPanel; private JLabel statusLabel; + private JLabel statusText; + private JButton urlBtn; public PanelItem(int index, String name, String status) { @@ -133,22 +140,41 @@ public PanelItem(int index, String name, String status) { } private void initPanelItem() { - taskLabel = new JLabel("Task: " + index); - graphNameLabel = new JLabel("Graph: " + name); - statusLabel = new JLabel("Status: " + status); - - this.add(taskLabel); - this.add(graphNameLabel); - this.add(statusLabel); - this.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY)); + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + TitledBorder taskBorder = BorderFactory.createTitledBorder("Task " + index); + this.setBorder(taskBorder); + + graphNameLabel = new JLabel("Graph: "); + + graphNameText = new JTextField(name); + graphNameText.setEditable(false); + graphNameText.setOpaque(false); + + graphPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + graphPanel.add(graphNameLabel); + graphPanel.add(graphNameText); + this.add(graphPanel); + + statusLabel = new JLabel("Status: "); + statusText = new JLabel(status); + + statusPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + statusPanel.add(statusLabel); + statusPanel.add(statusText); + + urlBtn = new JButton("Link"); + urlBtn.setVisible(false); + statusPanel.add(urlBtn); + this.add(statusPanel); } public void updateStatus(String status, int graphId) { this.status = status; - statusLabel.setText("Status: " + status); + statusText.setText(status); if (graphId != -1) { - urlBtn = new JButton("Link"); + urlBtn.setVisible(true); urlBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -163,8 +189,6 @@ public void actionPerformed(ActionEvent e) { } } }); - - this.add(urlBtn); } } } diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java index 9c57e57..f3a235c 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/ResultPanelEventListener.java @@ -1,6 +1,6 @@ package org.cytoscape.graphspace.cygraphspace.internal.gui; public interface ResultPanelEventListener { - public int postGraphEvent(ResultPanelEvent e); + public int graphSpaceEvent(ResultPanelEvent e); public void updateGraphStatusEvent(ResultPanelEvent e); } \ No newline at end of file diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/singletons/Server.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/singletons/Server.java index 85c834b..f6fa99f 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/singletons/Server.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/singletons/Server.java @@ -107,9 +107,9 @@ public Graph getGraphByName(String name) throws Exception{ } //update an existing graph on GraphSpace - public void updateGraph(String name, JSONObject graphJson, boolean isGraphPublic, ArrayList tagsList) throws Exception{ + public Response updateGraph(String name, JSONObject graphJson, boolean isGraphPublic, ArrayList tagsList) throws Exception{ Graph graph = client.getGraph(name, this.username); - client.updateGraph(name, graphJson, graph.getStyleJson(), isGraphPublic, tagsList); + return client.updateGraph(name, graphJson, graph.getStyleJson(), isGraphPublic, tagsList); } //post a graph to GraphSpace diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java index c0f379d..ea12ae1 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java @@ -50,7 +50,7 @@ private void postGraph() { try { if (listener != null) - panelIndex = listener.postGraphEvent( + panelIndex = listener.graphSpaceEvent( new ResultPanelEvent(graphJSON.getJSONObject("data").getString("name"),MessageConfig.TASK_IN_PROGRESS)); graphId = postGraph(graphJSON, styleJSON, isGraphPublic, null).getGraph().getId(); diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java index cf550eb..4676a92 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java @@ -10,6 +10,7 @@ import org.cytoscape.graphspace.cygraphspace.internal.util.MessageConfig; import org.cytoscape.work.AbstractTask; import org.cytoscape.work.TaskMonitor; +import org.graphspace.javaclient.Response; import org.json.JSONObject; /** @@ -39,19 +40,19 @@ public void run(TaskMonitor taskMonitor) throws Exception { // run task in background new Thread() { public void run() { - postGraph(); + updateGraph(); } }.start(); } - private void postGraph() { + private void updateGraph() { int panelIndex = -1, graphId = -1; try { if (listener != null) - panelIndex = listener.postGraphEvent( + panelIndex = listener.graphSpaceEvent( new ResultPanelEvent(graphJSON.getJSONObject("data").getString("name"),MessageConfig.TASK_IN_PROGRESS)); - updateGraph(graphJSON, styleJSON, isGraphPublic, null); + graphId = updateGraph(graphJSON, styleJSON, isGraphPublic, null).getGraph().getId(); } catch (Exception e1) { taskMonitor.setStatusMessage(MessageConfig.UPDATE_GRAPH_TASK_STATUS_FAIL); JOptionPane.showMessageDialog(null, @@ -74,9 +75,9 @@ private void postGraph() { } //post the current network to GraphSpace - private void updateGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isPublic, ArrayList tagsList) throws Exception{ + private Response updateGraph(JSONObject graphJSON, JSONObject styleJSON, boolean isPublic, ArrayList tagsList) throws Exception{ String name = graphJSON.getJSONObject("data").getString("name"); - Server.INSTANCE.updateGraph(name, graphJSON, isPublic, tagsList); + return Server.INSTANCE.updateGraph(name, graphJSON, isPublic, tagsList); } public void setResultPanelEventListener(ResultPanelEventListener listener) { diff --git a/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/Graph.java b/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/Graph.java index 3a2df7a..dce4ca3 100644 --- a/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/Graph.java +++ b/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/Graph.java @@ -366,7 +366,7 @@ public Response postGraph() throws Exception{ * @return response status on update request to GraphSpace * @throws Exception */ - public String updateGraph() throws Exception{ + public Response updateGraph() throws Exception{ if(this.graphJson == null) { throw new GraphException(ExceptionCode.BAD_REQUEST_FORMAT, ExceptionMessage.BAD_REQUEST_FORMAT_EXCEPTION, "Graph JSON is not set."); @@ -394,8 +394,7 @@ public String updateGraph() throws Exception{ int graphId = graphToBeUpdated.getId(); String path = Config.GRAPHS_PATH + graphId; JSONObject jsonResponse = restClient.put(path, data); - Response response = new Response(jsonResponse); - return response.getResponseStatus(); + return new Response(jsonResponse); } throw new GraphException(ExceptionCode.GRAPH_NOT_FOUND_EXCEPTION, ExceptionMessage.GRAPH_NOT_FOUND_EXCEPTION, "This graph is not currently uploaded on GraphSpace. Please export the graph to GraphSpace first."); @@ -408,7 +407,7 @@ public String updateGraph() throws Exception{ */ public String makeGraphPublic() throws Exception { this.isGraphPublic = true; - return updateGraph(); + return updateGraph().getResponseStatus(); } /** @@ -418,7 +417,7 @@ public String makeGraphPublic() throws Exception { */ public String makeGraphPrivate() throws Exception { this.isGraphPublic = false; - return updateGraph(); + return updateGraph().getResponseStatus(); } /** diff --git a/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/GraphSpaceClient.java b/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/GraphSpaceClient.java index 2487207..7c056be 100644 --- a/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/GraphSpaceClient.java +++ b/GraphSpaceJavaClient/src/main/java/org/graphspace/javaclient/GraphSpaceClient.java @@ -163,7 +163,7 @@ public Response postGraph(JSONObject graphJson, JSONObject styleJson, boolean is /** * Reference: {@link org.graphspace.javaclient.Graph#updateGraph()} */ - public String updateGraph(String graphName, JSONObject graphJson, JSONObject styleJson, boolean isGraphPublic, ArrayList tagsList) throws Exception{ + public Response updateGraph(String graphName, JSONObject graphJson, JSONObject styleJson, boolean isGraphPublic, ArrayList tagsList) throws Exception{ Graph graph = new Graph(restClient, isGraphPublic); graph.setGraphJson(graphJson); graph.setStyleJson(styleJson); From b2223a726c80f36ead4c80af2c4a9a538b1f5d89 Mon Sep 17 00:00:00 2001 From: li Date: Sat, 21 Jul 2018 16:53:14 -0400 Subject: [PATCH 09/12] Refs #20: Remove pop-up windows for upload status; update UI. --- .../graphspace/cygraphspace/internal/CyActivator.java | 2 +- .../internal/gui/CyGraphSpaceResultPanel.java | 1 + .../cygraphspace/internal/task/PostGraphTask.java | 6 ------ .../cygraphspace/internal/task/UpdateGraphTask.java | 6 ------ .../cygraphspace/internal/util/MessageConfig.java | 11 +++-------- 5 files changed, 5 insertions(+), 21 deletions(-) diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java index 194c53f..ecb655b 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/CyActivator.java @@ -78,7 +78,7 @@ public void start(BundleContext context) throws Exception { manager.setCyRootNetworkManager(cyRootNetworkManager); //register result panel - CyGraphSpaceResultPanel resultPanel = new CyGraphSpaceResultPanel("CyGraphSpace taskbar"); + CyGraphSpaceResultPanel resultPanel = new CyGraphSpaceResultPanel(MessageConfig.RESULT_PANEL_TITLE); registerAllServices(context, resultPanel, new Properties()); //registering Toolbar component diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index 7a6700f..ec1077c 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -148,6 +148,7 @@ private void initPanelItem() { graphNameLabel = new JLabel("Graph: "); graphNameText = new JTextField(name); + graphNameText.setBorder(javax.swing.BorderFactory.createEmptyBorder()); graphNameText.setEditable(false); graphNameText.setOpaque(false); diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java index ea12ae1..bd56b24 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/PostGraphTask.java @@ -2,8 +2,6 @@ import java.util.ArrayList; -import javax.swing.JOptionPane; - import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEvent; import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEventListener; import org.cytoscape.graphspace.cygraphspace.internal.singletons.Server; @@ -56,8 +54,6 @@ private void postGraph() { graphId = postGraph(graphJSON, styleJSON, isGraphPublic, null).getGraph().getId(); } catch (Exception e1) { taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_FAIL); - JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_FAIL, - "Error", JOptionPane.ERROR_MESSAGE); if (listener != null) listener.updateGraphStatusEvent( @@ -71,8 +67,6 @@ private void postGraph() { new ResultPanelEvent(panelIndex, graphId, "", MessageConfig.TASK_COMPLETE)); taskMonitor.setStatusMessage(MessageConfig.POST_GRAPH_TASK_STATUS_SUCCESS); - JOptionPane.showMessageDialog(null, MessageConfig.POST_GRAPH_TASK_DIALOG_SUCCESS, - "Message", JOptionPane.INFORMATION_MESSAGE); } //post the current network to GraphSpace diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java index 4676a92..b2d06d6 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/task/UpdateGraphTask.java @@ -2,8 +2,6 @@ import java.util.ArrayList; -import javax.swing.JOptionPane; - import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEvent; import org.cytoscape.graphspace.cygraphspace.internal.gui.ResultPanelEventListener; import org.cytoscape.graphspace.cygraphspace.internal.singletons.Server; @@ -55,8 +53,6 @@ private void updateGraph() { graphId = updateGraph(graphJSON, styleJSON, isGraphPublic, null).getGraph().getId(); } catch (Exception e1) { taskMonitor.setStatusMessage(MessageConfig.UPDATE_GRAPH_TASK_STATUS_FAIL); - JOptionPane.showMessageDialog(null, - MessageConfig.UPDATE_GRAPH_TASK_DIALOG_FAIL, "Error", JOptionPane.ERROR_MESSAGE); if (listener != null) listener.updateGraphStatusEvent( @@ -70,8 +66,6 @@ private void updateGraph() { new ResultPanelEvent(panelIndex, graphId, "", MessageConfig.TASK_COMPLETE)); taskMonitor.setStatusMessage(MessageConfig.UPDATE_GRAPH_TASK_STATUS_SUCCESS); - JOptionPane.showMessageDialog(null, - MessageConfig.UPDATE_GRAPH_TASK_DIALOG_SUCCESS, "Message", JOptionPane.INFORMATION_MESSAGE); } //post the current network to GraphSpace diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java index 47e50b8..57dc1db 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java @@ -29,24 +29,19 @@ public class MessageConfig { public final static String UPDATE_GRAPH_TASK_STATUS_FAIL = "CyGraphSpace failed to update the graph."; public final static String UPDATE_GRAPH_TASK_STATUS_SUCCESS = "CyGraphSpace updated the graph successfully."; - // Update graph task dialog message, shown in the pop up window after update graph task is done - public final static String UPDATE_GRAPH_TASK_DIALOG_SUCCESS = "You have updated the graph successfully."; - public final static String UPDATE_GRAPH_TASK_DIALOG_FAIL = "CyGraphSpace failed to update the graph."; - // Post graph task status message, shown in the status bar of the Cytoscape public final static String POST_GRAPH_TASK_TITLE = "Upload Status"; public final static String POST_GRAPH_TASK_STATUS_IN_PROGRESS = "Uploading graph to GraphSpace. Please wait..."; public final static String POST_GRAPH_TASK_STATUS_FAIL = "CyGraphSpace failed to upload the graph."; public final static String POST_GRAPH_TASK_STATUS_SUCCESS = "CyGraphSpace uploaded the graph successfully."; - // Post graph task dialog message, shown in the pop up window after update graph task is done - public final static String POST_GRAPH_TASK_DIALOG_SUCCESS = "You have uploaded the graph successfully."; - public final static String POST_GRAPH_TASK_DIALOG_FAIL = "CyGraphSpace failed to upload the graph."; - // Error message for event where user tries to upload large network public final static String NETWORK_TOO_LARGE_MSG = "Currently GraphSpace cannot handle networks with more than 400 nodes and/or 1000 edges.\n" + "Please select a smaller network or subnetwork to upload."; + // Result panel title + public static final String RESULT_PANEL_TITLE = "CyGraphSpace Task"; + // Result panel status messages public static final String TASK_COMPLETE = "Complete"; public static final String TASK_IN_PROGRESS = "In progress"; From 52d156ba125e4dbb3dd17fe7553e27752aaa7e4c Mon Sep 17 00:00:00 2001 From: li Date: Sat, 21 Jul 2018 16:56:08 -0400 Subject: [PATCH 10/12] Refs #20: Update version number in pom.xml. --- CyGraphSpaceApp/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CyGraphSpaceApp/pom.xml b/CyGraphSpaceApp/pom.xml index 547f46c..214e37c 100644 --- a/CyGraphSpaceApp/pom.xml +++ b/CyGraphSpaceApp/pom.xml @@ -10,7 +10,7 @@ 4.0.0 org.cytoscape.graphspace CyGraphSpace - 1.0.0-beta + 1.0.1-beta CyGraphSpace From c0c7a052b89da08dd28dbfc0040c1c39ff81329c Mon Sep 17 00:00:00 2001 From: li Date: Mon, 23 Jul 2018 20:48:22 -0400 Subject: [PATCH 11/12] Refs #20: Modify link button for the UI. --- .../internal/gui/CyGraphSpaceResultPanel.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index ec1077c..d161e74 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -130,7 +130,9 @@ private class PanelItem extends JPanel { private JLabel statusLabel; private JLabel statusText; - private JButton urlBtn; + private JPanel linkPanel; + private JLabel linkLabel; + private JButton linkBtn; public PanelItem(int index, String name, String status) { this.index = index; @@ -163,10 +165,6 @@ private void initPanelItem() { statusPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); statusPanel.add(statusLabel); statusPanel.add(statusText); - - urlBtn = new JButton("Link"); - urlBtn.setVisible(false); - statusPanel.add(urlBtn); this.add(statusPanel); } @@ -175,8 +173,12 @@ public void updateStatus(String status, int graphId) { statusText.setText(status); if (graphId != -1) { - urlBtn.setVisible(true); - urlBtn.addActionListener(new ActionListener() { + linkBtn = new JButton(MessageConfig.GRAPHSPACE_LINK + graphId); + linkBtn.setOpaque(false); + linkBtn.setContentAreaFilled(false); + linkBtn.setBorderPainted(false); + + linkBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { @@ -190,6 +192,12 @@ public void actionPerformed(ActionEvent e) { } } }); + + linkLabel = new JLabel("Link: "); + linkPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + linkPanel.add(linkLabel); + linkPanel.add(linkBtn); + this.add(linkPanel); } } } From 2246589f16184f580c7ca0ec841c2a59012fd7e1 Mon Sep 17 00:00:00 2001 From: li Date: Tue, 24 Jul 2018 19:34:22 -0400 Subject: [PATCH 12/12] Refs #20: Make button text hyperlink like; update result panel title. --- CyGraphSpaceApp/.classpath | 2 +- .../.settings/org.eclipse.jdt.core.prefs | 8 ++++++++ .../internal/gui/CyGraphSpaceResultPanel.java | 2 +- .../cygraphspace/internal/util/MessageConfig.java | 2 +- GraphSpaceJavaClient/.classpath | 3 ++- .../.settings/org.eclipse.jdt.core.prefs | 14 +++++++++++--- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CyGraphSpaceApp/.classpath b/CyGraphSpaceApp/.classpath index cb1b816..3c783f4 100644 --- a/CyGraphSpaceApp/.classpath +++ b/CyGraphSpaceApp/.classpath @@ -14,6 +14,7 @@ + @@ -22,7 +23,6 @@ - diff --git a/CyGraphSpaceApp/.settings/org.eclipse.jdt.core.prefs b/CyGraphSpaceApp/.settings/org.eclipse.jdt.core.prefs index 714351a..13b3428 100644 --- a/CyGraphSpaceApp/.settings/org.eclipse.jdt.core.prefs +++ b/CyGraphSpaceApp/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,13 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.8 diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java index d161e74..77e9145 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/gui/CyGraphSpaceResultPanel.java @@ -173,7 +173,7 @@ public void updateStatus(String status, int graphId) { statusText.setText(status); if (graphId != -1) { - linkBtn = new JButton(MessageConfig.GRAPHSPACE_LINK + graphId); + linkBtn = new JButton("" + MessageConfig.GRAPHSPACE_LINK + graphId + ""); linkBtn.setOpaque(false); linkBtn.setContentAreaFilled(false); linkBtn.setBorderPainted(false); diff --git a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java index 57dc1db..3470dc6 100644 --- a/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java +++ b/CyGraphSpaceApp/src/main/java/org/cytoscape/graphspace/cygraphspace/internal/util/MessageConfig.java @@ -40,7 +40,7 @@ public class MessageConfig { + "Please select a smaller network or subnetwork to upload."; // Result panel title - public static final String RESULT_PANEL_TITLE = "CyGraphSpace Task"; + public static final String RESULT_PANEL_TITLE = "CyGraphSpace Status"; // Result panel status messages public static final String TASK_COMPLETE = "Complete"; diff --git a/GraphSpaceJavaClient/.classpath b/GraphSpaceJavaClient/.classpath index 64a2e6f..1e585a0 100644 --- a/GraphSpaceJavaClient/.classpath +++ b/GraphSpaceJavaClient/.classpath @@ -12,8 +12,9 @@ - + + diff --git a/GraphSpaceJavaClient/.settings/org.eclipse.jdt.core.prefs b/GraphSpaceJavaClient/.settings/org.eclipse.jdt.core.prefs index abec6ca..13b3428 100644 --- a/GraphSpaceJavaClient/.settings/org.eclipse.jdt.core.prefs +++ b/GraphSpaceJavaClient/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,13 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.8