diff --git a/build.xml b/build.xml index a90e1cf..7e6bf2a 100644 --- a/build.xml +++ b/build.xml @@ -1,7 +1,7 @@ - + @@ -19,10 +19,10 @@ - - - - + + + + diff --git a/lib/org.wikipathways.client.jar b/lib/org.wikipathways.client.jar index 463f4f8..ccbb400 100644 Binary files a/lib/org.wikipathways.client.jar and b/lib/org.wikipathways.client.jar differ diff --git a/src/org/pathvisio/wpclient/WikiPathwaysClientPlugin.java b/src/org/pathvisio/wpclient/WikiPathwaysClientPlugin.java index ae3eae0..8f82cba 100644 --- a/src/org/pathvisio/wpclient/WikiPathwaysClientPlugin.java +++ b/src/org/pathvisio/wpclient/WikiPathwaysClientPlugin.java @@ -82,7 +82,7 @@ public class WikiPathwaysClientPlugin implements Plugin, ApplicationEventListene private PvDesktop desktop; private File tmpDir = new File(GlobalPreference.getPluginDir(), "wpclient-cache"); - private JMenu uploadMenu, wikipathwaysMenu; + private JMenu wikipathwaysMenu; private JMenuItem createMenu,updateMenu; public static String revisionno = ""; diff --git a/src/org/pathvisio/wpclient/dialogs/BrowseDialog.java b/src/org/pathvisio/wpclient/dialogs/BrowseDialog.java index 2b502da..94bd8f3 100644 --- a/src/org/pathvisio/wpclient/dialogs/BrowseDialog.java +++ b/src/org/pathvisio/wpclient/dialogs/BrowseDialog.java @@ -25,9 +25,13 @@ import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.SwingWorker; import javax.swing.border.Border; import javax.xml.rpc.ServiceException; +import org.pathvisio.core.debug.Logger; +import org.pathvisio.core.util.ProgressKeeper; +import org.pathvisio.gui.ProgressDialog; import org.pathvisio.wpclient.FailedConnectionException; import org.pathvisio.wpclient.WikiPathwaysClientPlugin; import org.pathvisio.wpclient.panels.BrowsePanel; @@ -37,47 +41,53 @@ public class BrowseDialog { private JDialog dialog; private Browse browsePanel; - public BrowseDialog(WikiPathwaysClientPlugin plugin) { + public BrowseDialog(final WikiPathwaysClientPlugin plugin) { dialog = new JDialog(plugin.getDesktop().getFrame(), "Browse WikiPathways", false); - try { - browsePanel = new Browse(plugin); - dialog.setLayout(new BorderLayout()); - Border padBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5); - browsePanel.setLayout(new CardLayout()); - browsePanel.setBorder(padBorder); - - dialog.add(browsePanel); - dialog.pack(); - //loading dialog at the centre of the frame - dialog.setLocationRelativeTo(plugin.getDesktop().getSwingEngine().getFrame()); - dialog.setVisible(true); + final ProgressKeeper pk = new ProgressKeeper(); + final ProgressDialog d = new ProgressDialog(plugin.getDesktop().getFrame(), "", pk, true, true); + + SwingWorker sw = new SwingWorker() { + protected Exception doInBackground() throws Exception { + pk.setTaskName("Connecting to WikiPathways"); + try { + browsePanel = new Browse(plugin); + dialog.setLayout(new BorderLayout()); + Border padBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5); + browsePanel.setLayout(new CardLayout()); + browsePanel.setBorder(padBorder); + + dialog.add(browsePanel); + dialog.pack(); + //loading dialog at the centre of the frame + dialog.setLocationRelativeTo(plugin.getDesktop().getSwingEngine().getFrame()); + dialog.setVisible(true); + + return null; + } catch(Exception e) { + return e; + } + } - } catch (RemoteException e) { - JOptionPane.showMessageDialog(dialog, - "Can not connect to WikiPathways webservice.", - "Connection error", - JOptionPane.ERROR_MESSAGE); - dialog.setVisible(false); - } catch (MalformedURLException e) { - JOptionPane.showMessageDialog(dialog, - "Can not connect to WikiPathways webservice.\nInvalid URL.", - "Connection error", - JOptionPane.ERROR_MESSAGE); - dialog.setVisible(false); - } catch (ServiceException e) { - JOptionPane.showMessageDialog(dialog, - "Can not connect to WikiPathways webservice.", - "Connection error", - JOptionPane.ERROR_MESSAGE); - dialog.setVisible(false); - } catch (FailedConnectionException e) { - JOptionPane.showMessageDialog(dialog, - "Can not connect to WikiPathways webservice.", - "Connection error", - JOptionPane.ERROR_MESSAGE); - dialog.setVisible(false); - } + protected void done() { + if(!pk.isCancelled()) { + try { + if(get() == null) { + dialog.setVisible(true); + pk.finished(); + } else { + JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE); + Logger.log.error("Unable to conntect to WikiPathways\n" + get().getMessage() + "\n"); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE); + Logger.log.error("Unable to conntect to WikiPathways\n" + e.getMessage() + "\n"); + } + } + } + }; + sw.execute(); + d.setVisible(true); } /** diff --git a/src/org/pathvisio/wpclient/dialogs/SearchDialog.java b/src/org/pathvisio/wpclient/dialogs/SearchDialog.java index dbc3bc9..2473aa3 100644 --- a/src/org/pathvisio/wpclient/dialogs/SearchDialog.java +++ b/src/org/pathvisio/wpclient/dialogs/SearchDialog.java @@ -26,9 +26,13 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTabbedPane; +import javax.swing.SwingWorker; import javax.swing.border.Border; import javax.xml.rpc.ServiceException; +import org.pathvisio.core.debug.Logger; +import org.pathvisio.core.util.ProgressKeeper; +import org.pathvisio.gui.ProgressDialog; import org.pathvisio.wpclient.FailedConnectionException; import org.pathvisio.wpclient.WikiPathwaysClientPlugin; import org.pathvisio.wpclient.panels.KeywordSearchPanel; @@ -38,25 +42,51 @@ public class SearchDialog extends JDialog { - public SearchDialog(WikiPathwaysClientPlugin plugin) { - JDialog d = new JDialog(plugin.getDesktop().getFrame(), "Search WikiPathways",false); + public SearchDialog(final WikiPathwaysClientPlugin plugin) { + final JDialog dialog = new JDialog(plugin.getDesktop().getFrame(), "Search WikiPathways",false); + final ProgressKeeper pk = new ProgressKeeper(); + final ProgressDialog d = new ProgressDialog(plugin.getDesktop().getFrame(), "", pk, true, true); - try { - Search p = new Search(plugin); - d.setLayout(new BorderLayout()); - Border padBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5); - p.setLayout(new CardLayout()); - p.setBorder(padBorder); + SwingWorker sw = new SwingWorker() { + protected Exception doInBackground() throws Exception { + pk.setTaskName("Connecting to WikiPathways"); + try { + Search p = new Search(plugin); + dialog.setLayout(new BorderLayout()); + Border padBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5); + p.setLayout(new CardLayout()); + p.setBorder(padBorder); + + dialog.add(p); + dialog.pack(); + //loading dialog at the centre of the frame + dialog.setLocationRelativeTo(plugin.getDesktop().getSwingEngine().getFrame()); + + return null; + } catch (Exception e) { + return e; + } + } - d.add(p); - d.pack(); - //loading dialog at the centre of the frame - d.setLocationRelativeTo(plugin.getDesktop().getSwingEngine().getFrame()); - d.setVisible(true); - - } catch (Exception e) { - JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE); - } + protected void done() { + if(!pk.isCancelled()) { + try { + if(get() == null) { + dialog.setVisible(true); + pk.finished(); + } else { + JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE); + Logger.log.error("Unable to conntect to WikiPathways\n" + get().getMessage() + "\n"); + } + } catch (Exception e) { + JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE); + Logger.log.error("Unable to conntect to WikiPathways\n" + e.getMessage() + "\n"); + } + } + } + }; + sw.execute(); + d.setVisible(true); } /** diff --git a/src/org/pathvisio/wpclient/dialogs/UpdatePathwayDialog.java b/src/org/pathvisio/wpclient/dialogs/UpdatePathwayDialog.java index d36bf19..1fd1646 100644 --- a/src/org/pathvisio/wpclient/dialogs/UpdatePathwayDialog.java +++ b/src/org/pathvisio/wpclient/dialogs/UpdatePathwayDialog.java @@ -140,7 +140,6 @@ private void showLoginPanel() { } public void UpdatePathway() throws RemoteException, MalformedURLException, ServiceException, FailedConnectionException { - plugin.getWpQueries().login(LoginPanel.username,LoginPanel.password); try { final ProgressKeeper pk = new ProgressKeeper(); final ProgressDialog d = new ProgressDialog( @@ -257,15 +256,35 @@ protected void done() { public void actionPerformed(ActionEvent e) { if ("Login".equals(e.getActionCommand())) { - d.dispose(); - try { - p.login(); - } catch (Exception e1) { - e1.printStackTrace(); - } + final ProgressKeeper pk = new ProgressKeeper(); + final ProgressDialog dialog = new ProgressDialog(plugin.getDesktop().getFrame(), "", pk, true, true); - if(LoginPanel.loggedin) - showDescriptionPanel(); + SwingWorker sw = new SwingWorker() { + + Boolean value = false; + + protected Void doInBackground() throws Exception { + pk.setTaskName("Checking login details."); + d.dispose(); + try { + if(p.login()) { + value = true; + } + } catch (Exception e1) {} + return null; + } + + protected void done() { + if(!pk.isCancelled()) { + if(value) { + showDescriptionPanel(); + pk.finished(); + } + } + } + }; + sw.execute(); + dialog.setVisible(true); } if ("Update".equals(e.getActionCommand())) { diff --git a/src/org/pathvisio/wpclient/panels/CreatePathwayPanel.java b/src/org/pathvisio/wpclient/panels/CreatePathwayPanel.java index 66ac198..4a56415 100644 --- a/src/org/pathvisio/wpclient/panels/CreatePathwayPanel.java +++ b/src/org/pathvisio/wpclient/panels/CreatePathwayPanel.java @@ -22,8 +22,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; -import java.net.MalformedURLException; -import java.rmi.RemoteException; import javax.swing.JButton; import javax.swing.JDialog; @@ -33,7 +31,6 @@ import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.SwingWorker; -import javax.xml.rpc.ServiceException; import org.pathvisio.core.debug.Logger; import org.pathvisio.core.model.Pathway; @@ -188,20 +185,35 @@ protected void done() { public void actionPerformed(ActionEvent e) { if ("Login".equals(e.getActionCommand())) { - dialog.dispose(); - try { - p.login(); + final ProgressKeeper pk = new ProgressKeeper(); + final ProgressDialog d = new ProgressDialog(plugin.getDesktop().getFrame(), "", pk, true, true); + + SwingWorker sw = new SwingWorker() { + + Boolean value = false; - if(LoginPanel.loggedin) { - showDescriptionPanel(); + protected Void doInBackground() throws Exception { + pk.setTaskName("Checking login details."); + dialog.dispose(); + try { + if(p.login()) { + value = true; + } + } catch (Exception e1) {} + return null; } - } catch (RemoteException e1) { - e1.printStackTrace(); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } catch (ServiceException e1) { - e1.printStackTrace(); - } + + protected void done() { + if(!pk.isCancelled()) { + if(value) { + showDescriptionPanel(); + pk.finished(); + } + } + } + }; + sw.execute(); + d.setVisible(true); } else if ("Create".equals(e.getActionCommand())) { createPathway(); descriptionDialog.dispose(); diff --git a/src/org/pathvisio/wpclient/panels/KeywordSearchPanel.java b/src/org/pathvisio/wpclient/panels/KeywordSearchPanel.java index f1b6a9f..55d5638 100644 --- a/src/org/pathvisio/wpclient/panels/KeywordSearchPanel.java +++ b/src/org/pathvisio/wpclient/panels/KeywordSearchPanel.java @@ -18,7 +18,6 @@ import java.awt.BorderLayout; import java.awt.CardLayout; -import java.awt.FocusTraversalPolicy; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; diff --git a/src/org/pathvisio/wpclient/panels/LoginPanel.java b/src/org/pathvisio/wpclient/panels/LoginPanel.java index 9ec09d8..6eb2c92 100644 --- a/src/org/pathvisio/wpclient/panels/LoginPanel.java +++ b/src/org/pathvisio/wpclient/panels/LoginPanel.java @@ -35,6 +35,7 @@ import javax.swing.JTextField; import javax.xml.rpc.ServiceException; +import org.pathvisio.core.debug.Logger; import org.pathvisio.wpclient.WikiPathwaysClientPlugin; import org.pathvisio.wpclient.validators.Validator; @@ -59,7 +60,7 @@ public LoginPanel(WikiPathwaysClientPlugin plugin) { loggedin = false; } - public void login() throws RemoteException, MalformedURLException, ServiceException { + public boolean login() throws RemoteException, MalformedURLException, ServiceException { try { username = UserField.getText(); password = new String(PassField.getPassword()); @@ -76,17 +77,20 @@ public void login() throws RemoteException, MalformedURLException, ServiceExcept JOptionPane.ERROR_MESSAGE); username = ""; password = ""; + Logger.log.error("Wrong username. \n"); + return false; } } catch (Exception ex) { - System.out.println(ex.getMessage()); - JOptionPane - .showMessageDialog( + JOptionPane.showMessageDialog( plugin.getDesktop().getFrame(), - "You do not have permissions. \n Please Send an email to:\n wikipathways-devel@googlegroups.com", - "WikiPathways Login ERROR", + "Login was unsuccessful. Please check your username and password.\n Do you have webservice write permissions? If not, please contact the develoeprs:\n wikipathways-devel@googlegroups.com", + "WikiPathways Login Error", JOptionPane.ERROR_MESSAGE); + Logger.log.error("Login was unsuccessfull\n" + ex.getStackTrace() + "\n"); username = ""; password = ""; + return false; } + return true; } } diff --git a/src/org/pathvisio/wpclient/panels/XrefSearchPanel.java b/src/org/pathvisio/wpclient/panels/XrefSearchPanel.java index f4c57e2..139c850 100644 --- a/src/org/pathvisio/wpclient/panels/XrefSearchPanel.java +++ b/src/org/pathvisio/wpclient/panels/XrefSearchPanel.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.concurrent.ExecutionException; import javax.swing.AbstractAction;