Author: paperwing
Date: 2012-07-30 14:22:43 -0700 (Mon, 30 Jul 2012)
New Revision: 30040
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/SimpleApp.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
Log:
Added drop-down box to choose app store sites, removing files from the
installed/disabled/uninstalled apps directories is now reflected in the app's
status tab as having its file moved. Moving the app file back to one of the 3
directories restores its status. Recent refactoring involving
FileAlterationObservers have allowed this flexibility. Switched locations of
view on app store and install buttons.
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
2012-07-30 20:54:47 UTC (rev 30039)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
2012-07-30 21:22:43 UTC (rev 30040)
@@ -82,7 +82,10 @@
TO_BE_UNINSTALLED("Uninstalled-on-restart"),
TO_BE_DISABLED("Disable-on-restart"),
DISABLED("Disabled"),
- UNINSTALLED("Uninstalled");
+ UNINSTALLED("Uninstalled"),
+ FILE_MOVED_UNINSTALLED("File Moved (Uninstalled)"),
+ // Currently, simple apps require a restart for uninstall, so
we require a restart even if file is moved
+ FILE_MOVED_INSTALLED("File Moved (Uninstall-on-restart)");
String readableStatus;
@@ -479,10 +482,12 @@
return false;
}
-
+
+ /*
/**
* Returns true only if the argument is an {@link App} with the same
app name and version.
*/
+ /*
@Override
public boolean equals(Object other) {
if (other == null) {
@@ -495,6 +500,7 @@
return false;
}
+ */
public String getAppName() {
return appName;
@@ -693,11 +699,15 @@
if (moveDirectories.contains(parentPath)) {
FileUtils.moveFile(this.getAppFile(),
targetFile);
//System.out.println("Moving: " +
this.getAppFile() + " -> " + targetFile);
- this.setAppFile(targetFile);
+
+ // ** Disabled to let directory observers
assign file reference
+ // this.setAppFile(targetFile);
} else {
FileUtils.copyFile(this.getAppFile(),
targetFile);
//System.out.println("Copying: " +
this.getAppFile() + " -> " + targetFile);
- this.setAppFile(targetFile);
+
+ // ** Disabled to let directory observers
assign file reference
+ // this.setAppFile(targetFile);
}
}
}
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
2012-07-30 20:54:47 UTC (rev 30039)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
2012-07-30 21:22:43 UTC (rev 30040)
@@ -128,16 +128,14 @@
this.featuresService = featuresService;
apps = new HashSet<App>();
-
appParser = new AppParser();
+ appListeners = new HashSet<AppsChangedListener>();
// cleanKarafDeployDirectory();
purgeTemporaryDirectories();
initializeAppsDirectories();
setupAlterationMonitor();
-
- this.appListeners = new HashSet<AppsChangedListener>();
// Install previously enabled apps
@@ -253,7 +251,28 @@
fireAppsChangedEvent();
} catch (AppInstallException e) {
}
+
+ // System.out.println(file + " on create");
}
+
+ @Override
+ public void onFileDelete(File file) {
+ // System.out.println(file + " on delete");
+
+ for (App app : apps) {
+ // System.out.println("checking " +
app.getAppFile().getAbsolutePath());
+ if (app.getAppFile().equals(file)) {
+ // System.out.println(app + "
moved");
+ if (app instanceof SimpleApp) {
+
app.setStatus(AppStatus.FILE_MOVED_INSTALLED);
+ } else {
+
app.setStatus(AppStatus.FILE_MOVED_UNINSTALLED);
+ }
+ }
+ }
+
+ fireAppsChangedEvent();
+ }
});
FileAlterationObserver disableAlterationObserver = new
FileAlterationObserver(
@@ -291,7 +310,28 @@
fireAppsChangedEvent();
} catch (AppDisableException e) {
}
+
+ // System.out.println(file + " on create");
}
+
+ @Override
+ public void onFileDelete(File file) {
+ // System.out.println(file + " on delete");
+
+ for (App app : apps) {
+ // System.out.println("checking " +
app.getAppFile().getAbsolutePath());
+ if (app.getAppFile().equals(file)) {
+ // System.out.println(app + "
moved");
+ if (app instanceof SimpleApp) {
+
app.setStatus(AppStatus.FILE_MOVED_INSTALLED);
+ } else {
+
app.setStatus(AppStatus.FILE_MOVED_UNINSTALLED);
+ }
+ }
+ }
+
+ fireAppsChangedEvent();
+ }
});
@@ -330,7 +370,28 @@
fireAppsChangedEvent();
} catch (AppUninstallException e) {
}
+
+ // System.out.println(file + " on create");
}
+
+ @Override
+ public void onFileDelete(File file) {
+ // System.out.println(file + " on delete");
+
+ for (App app : apps) {
+ // System.out.println("checking " +
app.getAppFile().getAbsolutePath());
+ if (app.getAppFile().equals(file)) {
+ // System.out.println(app + "
moved");
+ if (app instanceof SimpleApp) {
+
app.setStatus(AppStatus.FILE_MOVED_INSTALLED);
+ } else {
+
app.setStatus(AppStatus.FILE_MOVED_UNINSTALLED);
+ }
+ }
+ }
+
+ fireAppsChangedEvent();
+ }
});
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/SimpleApp.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/SimpleApp.java
2012-07-30 20:54:47 UTC (rev 30039)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/SimpleApp.java
2012-07-30 21:22:43 UTC (rev 30040)
@@ -117,6 +117,7 @@
}
try {
+ // Only create new instance if none created
if (this.getAppInstance() == null) {
Object appInstance =
this.createAppInstance(appManager.getSwingAppAdapter());
this.setAppInstance((AbstractCyApp)
appInstance);
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-07-30 20:54:47 UTC (rev 30039)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-07-30 21:22:43 UTC (rev 30040)
@@ -4,48 +4,31 @@
import java.awt.Container;
import java.awt.Desktop;
import java.awt.Font;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
import javax.swing.JFileChooser;
-import javax.swing.JOptionPane;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkEvent.EventType;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
-import javax.swing.event.HyperlinkListener;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeCellRenderer;
-import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
-import org.cytoscape.app.internal.exception.AppDownloadException;
-import org.cytoscape.app.internal.exception.AppInstallException;
-import org.cytoscape.app.internal.exception.AppParsingException;
import org.cytoscape.app.internal.manager.App;
import org.cytoscape.app.internal.manager.AppManager;
import org.cytoscape.app.internal.manager.AppParser;
@@ -70,13 +53,15 @@
/** Long serial version identifier required by the Serializable class */
private static final long serialVersionUID = -1208176142084829272L;
- private javax.swing.JPanel descriptionPanel;
+ private javax.swing.JButton closeButton;
+ private javax.swing.JPanel descriptionPanel;
private javax.swing.JScrollPane descriptionScrollPane;
private javax.swing.JSplitPane descriptionSplitPane;
private javax.swing.JTextPane descriptionTextPane;
+ private javax.swing.JComboBox downloadSiteComboBox;
+ private javax.swing.JLabel downloadSiteLabel;
private javax.swing.JTextField filterTextField;
private javax.swing.JButton installButton;
- private javax.swing.JButton closeButton;
private javax.swing.JButton installFromFileButton;
private javax.swing.JScrollPane resultsScrollPane;
private javax.swing.JTree resultsTree;
@@ -172,8 +157,10 @@
descriptionTextPane = new javax.swing.JTextPane();
viewOnAppStoreButton = new javax.swing.JButton();
installButton = new javax.swing.JButton();
+ downloadSiteLabel = new javax.swing.JLabel();
+ downloadSiteComboBox = new javax.swing.JComboBox();
closeButton = new javax.swing.JButton();
-
+
searchAppsLabel.setText("Search:");
installFromFileButton.setText("Install from File...");
@@ -218,11 +205,11 @@
descriptionPanel.setLayout(descriptionPanelLayout);
descriptionPanelLayout.setHorizontalGroup(
descriptionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(descriptionScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
+ .addComponent(descriptionScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
);
descriptionPanelLayout.setVerticalGroup(
descriptionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(descriptionScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
+ .addComponent(descriptionScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE)
);
descriptionSplitPane.setRightComponent(descriptionPanel);
@@ -243,14 +230,18 @@
}
});
+ downloadSiteLabel.setText("Download Site:");
+
+ downloadSiteComboBox.setEditable(true);
+ downloadSiteComboBox.setModel(new javax.swing.DefaultComboBoxModel(new
String[] { "http://apps3.nrnb.org/" }));
+
closeButton.setText("Close");
- closeButton.setEnabled(true);
closeButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
-
((javax.swing.JDialog)InstallFromStorePanel.this.parent).dispose();
+ closeButtonActionPerformed(evt);
}
});
-
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -258,23 +249,27 @@
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(descriptionSplitPane)
.addGroup(layout.createSequentialGroup()
- .addComponent(descriptionSplitPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 635, Short.MAX_VALUE)
- .addContainerGap())
- .addGroup(layout.createSequentialGroup()
- .addComponent(searchAppsLabel)
+ .addComponent(installFromFileButton)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80,
Short.MAX_VALUE)
+ .addComponent(viewOnAppStoreButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(filterTextField)
- .addGap(247, 247, 247))
- .addGroup(layout.createSequentialGroup()
- .addComponent(installFromFileButton)
-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(installButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(viewOnAppStoreButton)
-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(closeButton)
- .addContainerGap())))
+ .addComponent(closeButton))
+ .addGroup(layout.createSequentialGroup()
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(downloadSiteLabel)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(downloadSiteComboBox,
javax.swing.GroupLayout.PREFERRED_SIZE, 274,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(searchAppsLabel)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(filterTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, 241,
javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addGap(0, 0, Short.MAX_VALUE)))
+ .addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -284,8 +279,12 @@
.addComponent(searchAppsLabel)
.addComponent(filterTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(descriptionSplitPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(downloadSiteLabel)
+ .addComponent(downloadSiteComboBox,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(descriptionSplitPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(installFromFileButton)
.addComponent(viewOnAppStoreButton)
@@ -619,5 +618,9 @@
e.printStackTrace();
}
}
- }
+ }
+
+ private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ ((javax.swing.JDialog)InstallFromStorePanel.this.parent).dispose();
+ }
}
--
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.