Author: clopes
Date: 2012-11-01 11:55:20 -0700 (Thu, 01 Nov 2012)
New Revision: 30728
Modified:
core3/impl/trunk/welcome-impl/src/main/java/org/cytoscape/welcome/internal/panel/OpenPanel.java
Log:
Fixes #1559 (QuickStart: NullPointerException when session file is not found):
It now shows a "file not found" message.
Modified:
core3/impl/trunk/welcome-impl/src/main/java/org/cytoscape/welcome/internal/panel/OpenPanel.java
===================================================================
---
core3/impl/trunk/welcome-impl/src/main/java/org/cytoscape/welcome/internal/panel/OpenPanel.java
2012-11-01 03:04:16 UTC (rev 30727)
+++
core3/impl/trunk/welcome-impl/src/main/java/org/cytoscape/welcome/internal/panel/OpenPanel.java
2012-11-01 18:55:20 UTC (rev 30728)
@@ -18,6 +18,7 @@
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
+import javax.swing.JOptionPane;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
@@ -66,14 +67,15 @@
final List<URL> recentFiles =
fileTracker.getRecentlyOpenedURLs();
int fileCount = recentFiles.size();
- if(fileCount>MAX_FILES)
+
+ if (fileCount > MAX_FILES)
fileCount = MAX_FILES;
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
final Border padLine = BorderFactory.createEmptyBorder(3, 5, 3,
0);
- for (int i = 0; i<fileCount; i++) {
+ for (int i = 0; i < fileCount; i++) {
final URL target = recentFiles.get(i);
URI fileURI = null;
@@ -83,6 +85,7 @@
logger.error("Invalid file URL.", e2);
continue;
}
+
final File targetFile = new File(fileURI);
final JLabel fileLabel = new JLabel();
FontMetrics fm = fileLabel.getFontMetrics(REGULAR_FONT);
@@ -97,8 +100,15 @@
fileLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
-
taskManager.execute(openSessionTaskFactory.createTaskIterator(targetFile));
- closeParentWindow();
+ if (targetFile.exists()) {
+
taskManager.execute(openSessionTaskFactory.createTaskIterator(targetFile));
+ closeParentWindow();
+ } else {
+
JOptionPane.showMessageDialog(OpenPanel.this.getTopLevelAncestor(),
+ "Session file
not found:\n" + targetFile.getAbsolutePath(),
+ "File not
Found",
+
JOptionPane.WARNING_MESSAGE);
+ }
}
});
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.