Skip to content

Commit 2939f7d

Browse files
committed
added some progress bars to different situations and updated some error messages
1 parent bbccfb0 commit 2939f7d

10 files changed

+166
-93
lines changed

build.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<project name="org.pathvisio.wpclient" default="install" basedir=".">
33

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

@@ -19,10 +19,10 @@
1919
<include name="com.springsource.org.jdom-1.1.0.jar"/>
2020
<include name="org.pathvisio.jgoodies.forms.jar"/>
2121
</fileset>
22-
<fileset dir="lib">
23-
<include name="org.wikipathways.client.jar"/>
24-
<include name="com.springsource.javax.xml.rpc-1.1.0.jar"/>
25-
</fileset>
22+
<fileset dir="lib">
23+
<include name="org.wikipathways.client.jar"/>
24+
<!--<include name="com.springsource.javax.xml.rpc-1.1.0.jar"/>-->
25+
</fileset>
2626
</path>
2727

2828

lib/org.wikipathways.client.jar

1.8 MB
Binary file not shown.

src/org/pathvisio/wpclient/WikiPathwaysClientPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class WikiPathwaysClientPlugin implements Plugin, ApplicationEventListene
8282

8383
private PvDesktop desktop;
8484
private File tmpDir = new File(GlobalPreference.getPluginDir(), "wpclient-cache");
85-
private JMenu uploadMenu, wikipathwaysMenu;
85+
private JMenu wikipathwaysMenu;
8686
private JMenuItem createMenu,updateMenu;
8787

8888
public static String revisionno = "";

src/org/pathvisio/wpclient/dialogs/BrowseDialog.java

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@
2525
import javax.swing.JDialog;
2626
import javax.swing.JOptionPane;
2727
import javax.swing.JPanel;
28+
import javax.swing.SwingWorker;
2829
import javax.swing.border.Border;
2930
import javax.xml.rpc.ServiceException;
3031

32+
import org.pathvisio.core.debug.Logger;
33+
import org.pathvisio.core.util.ProgressKeeper;
34+
import org.pathvisio.gui.ProgressDialog;
3135
import org.pathvisio.wpclient.FailedConnectionException;
3236
import org.pathvisio.wpclient.WikiPathwaysClientPlugin;
3337
import org.pathvisio.wpclient.panels.BrowsePanel;
@@ -37,47 +41,53 @@ public class BrowseDialog {
3741
private JDialog dialog;
3842
private Browse browsePanel;
3943

40-
public BrowseDialog(WikiPathwaysClientPlugin plugin) {
44+
public BrowseDialog(final WikiPathwaysClientPlugin plugin) {
4145
dialog = new JDialog(plugin.getDesktop().getFrame(), "Browse WikiPathways", false);
4246

43-
try {
44-
browsePanel = new Browse(plugin);
45-
dialog.setLayout(new BorderLayout());
46-
Border padBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
47-
browsePanel.setLayout(new CardLayout());
48-
browsePanel.setBorder(padBorder);
49-
50-
dialog.add(browsePanel);
51-
dialog.pack();
52-
//loading dialog at the centre of the frame
53-
dialog.setLocationRelativeTo(plugin.getDesktop().getSwingEngine().getFrame());
54-
dialog.setVisible(true);
47+
final ProgressKeeper pk = new ProgressKeeper();
48+
final ProgressDialog d = new ProgressDialog(plugin.getDesktop().getFrame(), "", pk, true, true);
49+
50+
SwingWorker<Exception, Void> sw = new SwingWorker<Exception, Void>() {
51+
protected Exception doInBackground() throws Exception {
52+
pk.setTaskName("Connecting to WikiPathways");
53+
try {
54+
browsePanel = new Browse(plugin);
55+
dialog.setLayout(new BorderLayout());
56+
Border padBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
57+
browsePanel.setLayout(new CardLayout());
58+
browsePanel.setBorder(padBorder);
59+
60+
dialog.add(browsePanel);
61+
dialog.pack();
62+
//loading dialog at the centre of the frame
63+
dialog.setLocationRelativeTo(plugin.getDesktop().getSwingEngine().getFrame());
64+
dialog.setVisible(true);
65+
66+
return null;
67+
} catch(Exception e) {
68+
return e;
69+
}
70+
}
5571

56-
} catch (RemoteException e) {
57-
JOptionPane.showMessageDialog(dialog,
58-
"Can not connect to WikiPathways webservice.",
59-
"Connection error",
60-
JOptionPane.ERROR_MESSAGE);
61-
dialog.setVisible(false);
62-
} catch (MalformedURLException e) {
63-
JOptionPane.showMessageDialog(dialog,
64-
"Can not connect to WikiPathways webservice.\nInvalid URL.",
65-
"Connection error",
66-
JOptionPane.ERROR_MESSAGE);
67-
dialog.setVisible(false);
68-
} catch (ServiceException e) {
69-
JOptionPane.showMessageDialog(dialog,
70-
"Can not connect to WikiPathways webservice.",
71-
"Connection error",
72-
JOptionPane.ERROR_MESSAGE);
73-
dialog.setVisible(false);
74-
} catch (FailedConnectionException e) {
75-
JOptionPane.showMessageDialog(dialog,
76-
"Can not connect to WikiPathways webservice.",
77-
"Connection error",
78-
JOptionPane.ERROR_MESSAGE);
79-
dialog.setVisible(false);
80-
}
72+
protected void done() {
73+
if(!pk.isCancelled()) {
74+
try {
75+
if(get() == null) {
76+
dialog.setVisible(true);
77+
pk.finished();
78+
} else {
79+
JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE);
80+
Logger.log.error("Unable to conntect to WikiPathways\n" + get().getMessage() + "\n");
81+
}
82+
} catch (Exception e) {
83+
JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE);
84+
Logger.log.error("Unable to conntect to WikiPathways\n" + e.getMessage() + "\n");
85+
}
86+
}
87+
}
88+
};
89+
sw.execute();
90+
d.setVisible(true);
8191
}
8292

8393
/**

src/org/pathvisio/wpclient/dialogs/SearchDialog.java

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
import javax.swing.JOptionPane;
2727
import javax.swing.JPanel;
2828
import javax.swing.JTabbedPane;
29+
import javax.swing.SwingWorker;
2930
import javax.swing.border.Border;
3031
import javax.xml.rpc.ServiceException;
3132

33+
import org.pathvisio.core.debug.Logger;
34+
import org.pathvisio.core.util.ProgressKeeper;
35+
import org.pathvisio.gui.ProgressDialog;
3236
import org.pathvisio.wpclient.FailedConnectionException;
3337
import org.pathvisio.wpclient.WikiPathwaysClientPlugin;
3438
import org.pathvisio.wpclient.panels.KeywordSearchPanel;
@@ -38,25 +42,51 @@
3842

3943
public class SearchDialog extends JDialog {
4044

41-
public SearchDialog(WikiPathwaysClientPlugin plugin) {
42-
JDialog d = new JDialog(plugin.getDesktop().getFrame(), "Search WikiPathways",false);
45+
public SearchDialog(final WikiPathwaysClientPlugin plugin) {
46+
final JDialog dialog = new JDialog(plugin.getDesktop().getFrame(), "Search WikiPathways",false);
47+
final ProgressKeeper pk = new ProgressKeeper();
48+
final ProgressDialog d = new ProgressDialog(plugin.getDesktop().getFrame(), "", pk, true, true);
4349

44-
try {
45-
Search p = new Search(plugin);
46-
d.setLayout(new BorderLayout());
47-
Border padBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
48-
p.setLayout(new CardLayout());
49-
p.setBorder(padBorder);
50+
SwingWorker<Exception, Void> sw = new SwingWorker<Exception, Void>() {
51+
protected Exception doInBackground() throws Exception {
52+
pk.setTaskName("Connecting to WikiPathways");
53+
try {
54+
Search p = new Search(plugin);
55+
dialog.setLayout(new BorderLayout());
56+
Border padBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
57+
p.setLayout(new CardLayout());
58+
p.setBorder(padBorder);
59+
60+
dialog.add(p);
61+
dialog.pack();
62+
//loading dialog at the centre of the frame
63+
dialog.setLocationRelativeTo(plugin.getDesktop().getSwingEngine().getFrame());
64+
65+
return null;
66+
} catch (Exception e) {
67+
return e;
68+
}
69+
}
5070

51-
d.add(p);
52-
d.pack();
53-
//loading dialog at the centre of the frame
54-
d.setLocationRelativeTo(plugin.getDesktop().getSwingEngine().getFrame());
55-
d.setVisible(true);
56-
57-
} catch (Exception e) {
58-
JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE);
59-
}
71+
protected void done() {
72+
if(!pk.isCancelled()) {
73+
try {
74+
if(get() == null) {
75+
dialog.setVisible(true);
76+
pk.finished();
77+
} else {
78+
JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE);
79+
Logger.log.error("Unable to conntect to WikiPathways\n" + get().getMessage() + "\n");
80+
}
81+
} catch (Exception e) {
82+
JOptionPane.showMessageDialog(d, "Unable to connect to WikiPathways.", "Connection error", JOptionPane.ERROR_MESSAGE);
83+
Logger.log.error("Unable to conntect to WikiPathways\n" + e.getMessage() + "\n");
84+
}
85+
}
86+
}
87+
};
88+
sw.execute();
89+
d.setVisible(true);
6090
}
6191

6292
/**

src/org/pathvisio/wpclient/dialogs/UpdatePathwayDialog.java

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ private void showLoginPanel() {
140140
}
141141

142142
public void UpdatePathway() throws RemoteException, MalformedURLException, ServiceException, FailedConnectionException {
143-
plugin.getWpQueries().login(LoginPanel.username,LoginPanel.password);
144143
try {
145144
final ProgressKeeper pk = new ProgressKeeper();
146145
final ProgressDialog d = new ProgressDialog(
@@ -257,15 +256,35 @@ protected void done() {
257256
public void actionPerformed(ActionEvent e) {
258257

259258
if ("Login".equals(e.getActionCommand())) {
260-
d.dispose();
261-
try {
262-
p.login();
263-
} catch (Exception e1) {
264-
e1.printStackTrace();
265-
}
259+
final ProgressKeeper pk = new ProgressKeeper();
260+
final ProgressDialog dialog = new ProgressDialog(plugin.getDesktop().getFrame(), "", pk, true, true);
266261

267-
if(LoginPanel.loggedin)
268-
showDescriptionPanel();
262+
SwingWorker<Void, Void> sw = new SwingWorker<Void, Void>() {
263+
264+
Boolean value = false;
265+
266+
protected Void doInBackground() throws Exception {
267+
pk.setTaskName("Checking login details.");
268+
d.dispose();
269+
try {
270+
if(p.login()) {
271+
value = true;
272+
}
273+
} catch (Exception e1) {}
274+
return null;
275+
}
276+
277+
protected void done() {
278+
if(!pk.isCancelled()) {
279+
if(value) {
280+
showDescriptionPanel();
281+
pk.finished();
282+
}
283+
}
284+
}
285+
};
286+
sw.execute();
287+
dialog.setVisible(true);
269288
}
270289

271290
if ("Update".equals(e.getActionCommand())) {

src/org/pathvisio/wpclient/panels/CreatePathwayPanel.java

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import java.awt.event.ActionEvent;
2323
import java.awt.event.ActionListener;
2424
import java.io.File;
25-
import java.net.MalformedURLException;
26-
import java.rmi.RemoteException;
2725

2826
import javax.swing.JButton;
2927
import javax.swing.JDialog;
@@ -33,7 +31,6 @@
3331
import javax.swing.JScrollPane;
3432
import javax.swing.JTextArea;
3533
import javax.swing.SwingWorker;
36-
import javax.xml.rpc.ServiceException;
3734

3835
import org.pathvisio.core.debug.Logger;
3936
import org.pathvisio.core.model.Pathway;
@@ -188,20 +185,35 @@ protected void done() {
188185
public void actionPerformed(ActionEvent e) {
189186

190187
if ("Login".equals(e.getActionCommand())) {
191-
dialog.dispose();
192-
try {
193-
p.login();
188+
final ProgressKeeper pk = new ProgressKeeper();
189+
final ProgressDialog d = new ProgressDialog(plugin.getDesktop().getFrame(), "", pk, true, true);
190+
191+
SwingWorker<Void, Void> sw = new SwingWorker<Void, Void>() {
192+
193+
Boolean value = false;
194194

195-
if(LoginPanel.loggedin) {
196-
showDescriptionPanel();
195+
protected Void doInBackground() throws Exception {
196+
pk.setTaskName("Checking login details.");
197+
dialog.dispose();
198+
try {
199+
if(p.login()) {
200+
value = true;
201+
}
202+
} catch (Exception e1) {}
203+
return null;
197204
}
198-
} catch (RemoteException e1) {
199-
e1.printStackTrace();
200-
} catch (MalformedURLException e1) {
201-
e1.printStackTrace();
202-
} catch (ServiceException e1) {
203-
e1.printStackTrace();
204-
}
205+
206+
protected void done() {
207+
if(!pk.isCancelled()) {
208+
if(value) {
209+
showDescriptionPanel();
210+
pk.finished();
211+
}
212+
}
213+
}
214+
};
215+
sw.execute();
216+
d.setVisible(true);
205217
} else if ("Create".equals(e.getActionCommand())) {
206218
createPathway();
207219
descriptionDialog.dispose();

src/org/pathvisio/wpclient/panels/KeywordSearchPanel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.awt.BorderLayout;
2020
import java.awt.CardLayout;
21-
import java.awt.FocusTraversalPolicy;
2221
import java.awt.Font;
2322
import java.awt.event.ActionEvent;
2423
import java.awt.event.MouseAdapter;

src/org/pathvisio/wpclient/panels/LoginPanel.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import javax.swing.JTextField;
3636
import javax.xml.rpc.ServiceException;
3737

38+
import org.pathvisio.core.debug.Logger;
3839
import org.pathvisio.wpclient.WikiPathwaysClientPlugin;
3940
import org.pathvisio.wpclient.validators.Validator;
4041

@@ -59,7 +60,7 @@ public LoginPanel(WikiPathwaysClientPlugin plugin) {
5960
loggedin = false;
6061
}
6162

62-
public void login() throws RemoteException, MalformedURLException, ServiceException {
63+
public boolean login() throws RemoteException, MalformedURLException, ServiceException {
6364
try {
6465
username = UserField.getText();
6566
password = new String(PassField.getPassword());
@@ -76,17 +77,20 @@ public void login() throws RemoteException, MalformedURLException, ServiceExcept
7677
JOptionPane.ERROR_MESSAGE);
7778
username = "";
7879
password = "";
80+
Logger.log.error("Wrong username. \n");
81+
return false;
7982
}
8083
} catch (Exception ex) {
81-
System.out.println(ex.getMessage());
82-
JOptionPane
83-
.showMessageDialog(
84+
JOptionPane.showMessageDialog(
8485
plugin.getDesktop().getFrame(),
85-
"You do not have permissions. \n Please Send an email to:\n wikipathways-devel@googlegroups.com",
86-
"WikiPathways Login ERROR",
86+
"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",
87+
"WikiPathways Login Error",
8788
JOptionPane.ERROR_MESSAGE);
89+
Logger.log.error("Login was unsuccessfull\n" + ex.getStackTrace() + "\n");
8890
username = "";
8991
password = "";
92+
return false;
9093
}
94+
return true;
9195
}
9296
}

src/org/pathvisio/wpclient/panels/XrefSearchPanel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.ArrayList;
2828
import java.util.Collections;
2929
import java.util.List;
30-
import java.util.Map;
3130
import java.util.concurrent.ExecutionException;
3231

3332
import javax.swing.AbstractAction;

0 commit comments

Comments
 (0)