Skip to content

Commit

Permalink
added some progress bars to different situations and updated some err…
Browse files Browse the repository at this point in the history
…or messages
  • Loading branch information
mkutmon committed Dec 20, 2013
1 parent bbccfb0 commit 2939f7d
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 93 deletions.
10 changes: 5 additions & 5 deletions build.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<project name="org.pathvisio.wpclient" default="install" basedir=".">

<property name="pathvisio.dir" value="../../../pv-35/"/>
<property name="pathvisio.dir" value="../../pathvisio"/>
<property name="bundle.dest" value="dist"/>
<property name="jar.name" value="org.pathvisio.wpclient.jar"/>

Expand All @@ -19,10 +19,10 @@
<include name="com.springsource.org.jdom-1.1.0.jar"/>
<include name="org.pathvisio.jgoodies.forms.jar"/>
</fileset>
<fileset dir="lib">
<include name="org.wikipathways.client.jar"/>
<include name="com.springsource.javax.xml.rpc-1.1.0.jar"/>
</fileset>
<fileset dir="lib">
<include name="org.wikipathways.client.jar"/>
<!--<include name="com.springsource.javax.xml.rpc-1.1.0.jar"/>-->
</fileset>
</path>


Expand Down
Binary file modified lib/org.wikipathways.client.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/org/pathvisio/wpclient/WikiPathwaysClientPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
86 changes: 48 additions & 38 deletions src/org/pathvisio/wpclient/dialogs/BrowseDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Exception, Void> sw = new SwingWorker<Exception, Void>() {
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);
}

/**
Expand Down
64 changes: 47 additions & 17 deletions src/org/pathvisio/wpclient/dialogs/SearchDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Exception, Void> sw = new SwingWorker<Exception, Void>() {
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);
}

/**
Expand Down
37 changes: 28 additions & 9 deletions src/org/pathvisio/wpclient/dialogs/UpdatePathwayDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<Void, Void> sw = new SwingWorker<Void, Void>() {

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())) {
Expand Down
42 changes: 27 additions & 15 deletions src/org/pathvisio/wpclient/panels/CreatePathwayPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<Void, Void> sw = new SwingWorker<Void, Void>() {

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();
Expand Down
1 change: 0 additions & 1 deletion src/org/pathvisio/wpclient/panels/KeywordSearchPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 10 additions & 6 deletions src/org/pathvisio/wpclient/panels/LoginPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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());
Expand All @@ -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 [email protected]",
"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 [email protected]",
"WikiPathways Login Error",
JOptionPane.ERROR_MESSAGE);
Logger.log.error("Login was unsuccessfull\n" + ex.getStackTrace() + "\n");
username = "";
password = "";
return false;
}
return true;
}
}
1 change: 0 additions & 1 deletion src/org/pathvisio/wpclient/panels/XrefSearchPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2939f7d

Please sign in to comment.