Author: paperwing
Date: 2012-05-29 16:03:37 -0700 (Tue, 29 May 2012)
New Revision: 29385
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/action/
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CheckForUpdatesPanel.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
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/util/
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/util/DebugHelper.java
Log:
Replaced old app manager with new app manager (added missing files)
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
2012-05-29 23:03:37 UTC (rev 29385)
@@ -0,0 +1,71 @@
+package org.cytoscape.app.internal.action;
+
+import java.awt.event.ActionEvent;
+import java.util.Set;
+import java.util.concurrent.Executors;
+
+import javax.swing.SwingUtilities;
+
+import org.cytoscape.app.internal.manager.AppManager;
+import org.cytoscape.app.internal.net.WebApp;
+import org.cytoscape.app.internal.net.WebQuerier;
+import org.cytoscape.app.internal.net.server.LocalHttpServer;
+import org.cytoscape.app.internal.ui.AppManagerDialog;
+import org.cytoscape.application.swing.AbstractCyAction;
+import org.cytoscape.application.swing.CySwingApplication;
+import org.cytoscape.util.swing.FileUtil;
+import org.cytoscape.work.Task;
+import org.cytoscape.work.TaskIterator;
+import org.cytoscape.work.TaskManager;
+import org.cytoscape.work.TaskMonitor;
+
+public class AppManagerAction extends AbstractCyAction {
+
+ /** Long serial version identifier required by the Serializable class */
+ private static final long serialVersionUID = -9145570324785249730L;
+
+ /**
+ * A reference to the main Cytoscape window used to position the App
Manager dialog.
+ */
+ private CySwingApplication swingApplication;
+
+ /**
+ * A reference to the {@link AppManager} service.
+ */
+ private AppManager appManager;
+
+ /**
+ * A reference to the {@link FileUtil} OSGi service used for displaying
a filechooser dialog
+ */
+ private FileUtil fileUtil;
+
+ /**
+ * A reference to the {@link TaskManager} service used to execute
Cytoscape tasks
+ */
+ private TaskManager taskManager;
+
+ private LocalHttpServer server;
+
+ /**
+ * Creates and sets up the AbstractCyAction, placing an item into the
menu.
+ */
+ public AppManagerAction(AppManager appManager, CySwingApplication
swingApplication, FileUtil fileUtil, TaskManager taskManager) {
+ super("App Manager");
+
+ setPreferredMenu("Apps");
+ setMenuGravity(1.0f);
+
+ this.appManager = appManager;
+ this.swingApplication = swingApplication;
+ this.fileUtil = fileUtil;
+ this.taskManager = taskManager;
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent event) {
+
+ // Create and display the App Manager dialog
+ AppManagerDialog appManagerDialog = new
AppManagerDialog(appManager, fileUtil, taskManager,
swingApplication.getJFrame(), false);
+ }
+
+}
Property changes on:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
2012-05-29 23:03:37 UTC (rev 29385)
@@ -0,0 +1,98 @@
+package org.cytoscape.app.internal.ui;
+
+import org.cytoscape.app.internal.manager.AppManager;
+import org.cytoscape.util.swing.FileUtil;
+import org.cytoscape.work.TaskManager;
+
+/**
+ * This class represents the App Manager dialog window. Its UI setup code is
generated by the Netbeans 7 GUI builder.
+ */
+public class AppManagerDialog extends javax.swing.JDialog {
+
+ private CheckForUpdatesPanel checkForUpdatesPanel1;
+ private CurrentlyInstalledAppsPanel currentlyInstalledAppsPanel1;
+ private InstallFromStorePanel installNewAppsPanel1;
+ private javax.swing.JTabbedPane mainTabbedPane;
+
+ private AppManager appManager;
+ private FileUtil fileUtil;
+ private TaskManager taskManager;
+
+ public AppManagerDialog(AppManager appManager, FileUtil fileUtil,
TaskManager taskManager, java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+
+ this.appManager = appManager;
+ this.fileUtil = fileUtil;
+ this.taskManager = taskManager;
+ initComponents();
+
+ this.setLocationRelativeTo(parent);
+ this.setVisible(true);
+ }
+
+ private void initComponents() {
+ mainTabbedPane = new javax.swing.JTabbedPane();
+ installNewAppsPanel1 = new InstallFromStorePanel(appManager, fileUtil,
taskManager, this);
+ currentlyInstalledAppsPanel1 = new
CurrentlyInstalledAppsPanel(appManager);
+ checkForUpdatesPanel1 = new CheckForUpdatesPanel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ mainTabbedPane.addTab("Install from App Store", installNewAppsPanel1);
+ mainTabbedPane.addTab("Currently Installed",
currentlyInstalledAppsPanel1);
+ mainTabbedPane.addTab("Check for Updates", checkForUpdatesPanel1);
+
+ javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(mainTabbedPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(mainTabbedPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 490, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+
+ pack();
+
+ /*
+ // Older code generated from NetBeans using an external Swing
extension library to generate the layout
+
+ mainTabbedPane = new javax.swing.JTabbedPane();
+ installNewAppsPanel1 = new InstallFromStorePanel(appManager, fileUtil,
taskManager, this);
+ currentlyInstalledAppsPanel1 = new
CurrentlyInstalledAppsPanel(appManager);
+ checkForUpdatesPanel1 = new CheckForUpdatesPanel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+ mainTabbedPane.addTab("Install Apps", installNewAppsPanel1);
+ mainTabbedPane.addTab("Currently Installed",
currentlyInstalledAppsPanel1);
+ mainTabbedPane.addTab("Check for Updates", checkForUpdatesPanel1);
+
+ org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(mainTabbedPane,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 640,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(mainTabbedPane,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 490,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
+ );
+
+ pack();
+ */
+ }
+}
Property changes on:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CheckForUpdatesPanel.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CheckForUpdatesPanel.java
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CheckForUpdatesPanel.java
2012-05-29 23:03:37 UTC (rev 29385)
@@ -0,0 +1,143 @@
+package org.cytoscape.app.internal.ui;
+
+/**
+ * This class represents the panel in the App Manager dialog's tab used for
checking for app updates.
+ * Its UI setup code is generated by the Netbeans 7 GUI builder.
+ */
+public class CheckForUpdatesPanel extends javax.swing.JPanel {
+
+ /** Long serial version identifier required by the Serializable class */
+ private static final long serialVersionUID = -7895560768591483673L;
+
+ private javax.swing.JLabel descriptionLabel;
+ private javax.swing.JScrollPane descriptionScrollPane;
+ private javax.swing.JTextArea descriptionTextArea;
+ private javax.swing.JButton installAllTable;
+ private javax.swing.JButton installSelectedButton;
+ private javax.swing.JLabel lastCheckForUpdatesLabel;
+ private javax.swing.JLabel updateCheckTimeLabel;
+ private javax.swing.JLabel updatesAvailableLabel;
+ private javax.swing.JScrollPane updatesScrollPane;
+ private javax.swing.JTable updatesTable;
+
+ public CheckForUpdatesPanel() {
+ initComponents();
+ }
+
+ private void initComponents() {
+
+ updatesAvailableLabel = new javax.swing.JLabel();
+ installSelectedButton = new javax.swing.JButton();
+ installAllTable = new javax.swing.JButton();
+ updatesScrollPane = new javax.swing.JScrollPane();
+ updatesTable = new javax.swing.JTable();
+ lastCheckForUpdatesLabel = new javax.swing.JLabel();
+ updateCheckTimeLabel = new javax.swing.JLabel();
+ descriptionLabel = new javax.swing.JLabel();
+ descriptionScrollPane = new javax.swing.JScrollPane();
+ descriptionTextArea = new javax.swing.JTextArea();
+
+ updatesAvailableLabel.setText("0 updates available.");
+
+ installSelectedButton.setText("Update Selected");
+ installSelectedButton.setEnabled(false);
+ installSelectedButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ installSelectedButtonActionPerformed(evt);
+ }
+ });
+
+ installAllTable.setText("Update All");
+ installAllTable.setEnabled(false);
+ installAllTable.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ installAllTableActionPerformed(evt);
+ }
+ });
+
+ updatesTable.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+
+ },
+ new String [] {
+ "App Name", "Version"
+ }
+ ) {
+ boolean[] canEdit = new boolean [] {
+ false, false
+ };
+
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return canEdit [columnIndex];
+ }
+ });
+ updatesScrollPane.setViewportView(updatesTable);
+
+ lastCheckForUpdatesLabel.setText("Last check for updates:");
+
+ updateCheckTimeLabel.setText("Today, at 6:00 pm");
+
+ descriptionLabel.setText("Update Description:");
+
+ descriptionTextArea.setEditable(false);
+ descriptionTextArea.setFocusable(false);
+ descriptionScrollPane.setViewportView(descriptionTextArea);
+
+ org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(updatesAvailableLabel)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(lastCheckForUpdatesLabel)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(updateCheckTimeLabel)
+ .add(0, 0, Short.MAX_VALUE))
+ .add(updatesScrollPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 652, Short.MAX_VALUE)
+ .add(descriptionScrollPane))
+ .addContainerGap())
+ .add(layout.createSequentialGroup()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(installSelectedButton)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(installAllTable))
+ .add(descriptionLabel))
+ .add(0, 0, Short.MAX_VALUE))))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(updatesAvailableLabel)
+ .add(lastCheckForUpdatesLabel)
+ .add(updateCheckTimeLabel))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(updatesScrollPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 327, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(descriptionLabel,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(descriptionScrollPane,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 106,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(installSelectedButton)
+ .add(installAllTable))
+ .addContainerGap())
+ );
+ }
+
+ private void
installSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void installAllTableActionPerformed(java.awt.event.ActionEvent
evt) {
+ // TODO add your handling code here:
+ }
+}
Property changes on:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CheckForUpdatesPanel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
2012-05-29 23:03:37 UTC (rev 29385)
@@ -0,0 +1,358 @@
+package org.cytoscape.app.internal.ui;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.swing.SwingUtilities;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.table.DefaultTableModel;
+
+import org.cytoscape.app.internal.event.AppsChangedEvent;
+import org.cytoscape.app.internal.event.AppsChangedListener;
+import org.cytoscape.app.internal.exception.AppInstallException;
+import org.cytoscape.app.internal.exception.AppUninstallException;
+import org.cytoscape.app.internal.manager.App;
+import org.cytoscape.app.internal.manager.App.AppStatus;
+import org.cytoscape.app.internal.manager.AppManager;
+
+/**
+ * This class represents the panel in the App Manager dialog's tab used for
checking for currently installed apps.
+ * Its UI setup code is generated by the Netbeans 7 GUI builder.
+ */
+public class CurrentlyInstalledAppsPanel extends javax.swing.JPanel {
+
+ /** Long serial version identifier required by the Serializable class */
+ private static final long serialVersionUID = 7096775814942183176L;
+
+ private javax.swing.JScrollPane appsAvailableScrollPane;
+ private javax.swing.JTable appsAvailableTable;
+ private javax.swing.JLabel appsInstalledLabel;
+ private javax.swing.JLabel descriptionLabel;
+ private javax.swing.JScrollPane descriptionScrollPane;
+ private javax.swing.JTextArea descriptionTextArea;
+ private javax.swing.JButton disableSelectedButton;
+ private javax.swing.JButton enableSelectedButton;;
+
+ private AppManager appManager;
+ private AppsChangedListener appListener;
+
+ public CurrentlyInstalledAppsPanel(AppManager appManager) {
+ this.appManager = appManager;
+
+ initComponents();
+
+ setupAppListener();
+ setupDescriptionListener();
+ populateTable();
+ }
+
+ private void initComponents() {
+
+ appsAvailableScrollPane = new javax.swing.JScrollPane();
+ appsAvailableTable = new javax.swing.JTable();
+ appsInstalledLabel = new javax.swing.JLabel();
+ enableSelectedButton = new javax.swing.JButton();
+ disableSelectedButton = new javax.swing.JButton();
+ descriptionLabel = new javax.swing.JLabel();
+ descriptionScrollPane = new javax.swing.JScrollPane();
+ descriptionTextArea = new javax.swing.JTextArea();
+
+ appsAvailableTable.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+
+ },
+ new String [] {
+ "App", "Name", "Author", "Version", "Status"
+ }
+ ) {
+ boolean[] canEdit = new boolean [] {
+ false, false, false, false, false
+ };
+
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return canEdit [columnIndex];
+ }
+ });
+ appsAvailableScrollPane.setViewportView(appsAvailableTable);
+
appsAvailableTable.getColumnModel().getColumn(1).setPreferredWidth(195);
+ appsAvailableTable.removeColumn(appsAvailableTable.getColumn("App"));
+
+ appsInstalledLabel.setText("0 Apps installed.");
+
+ enableSelectedButton.setText("Reinstall");
+ enableSelectedButton.setEnabled(false);
+ enableSelectedButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ enableSelectedButtonActionPerformed(evt);
+ }
+ });
+
+ disableSelectedButton.setText("Uninstall");
+ disableSelectedButton.setEnabled(false);
+ disableSelectedButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ disableSelectedButtonActionPerformed(evt);
+ }
+ });
+
+ descriptionLabel.setText("App Information:");
+
+ descriptionTextArea.setEditable(false);
+ descriptionTextArea.setFocusable(false);
+ descriptionScrollPane.setViewportView(descriptionTextArea);
+
+ org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(appsAvailableScrollPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 634, Short.MAX_VALUE)
+ .add(descriptionScrollPane)
+ .add(layout.createSequentialGroup()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(descriptionLabel)
+ .add(layout.createSequentialGroup()
+ .add(disableSelectedButton)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(enableSelectedButton))
+ .add(appsInstalledLabel))
+ .add(0, 0, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(appsInstalledLabel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(appsAvailableScrollPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(descriptionLabel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(descriptionScrollPane,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 106,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(enableSelectedButton)
+ .add(disableSelectedButton))
+ .addContainerGap())
+ );
+ }
+
+
+ private void
enableSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // Obtain App objects corresponding to currently selected table entries
+ Set<App> selectedApps = getSelectedApps();
+
+ for (App app : selectedApps) {
+ // Only install apps that are not already installed
+ if (app.getStatus() != AppStatus.INSTALLED) {
+ try {
+ appManager.installApp(app);
+ } catch (AppInstallException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ enableSelectedButton.setEnabled(false);
+ disableSelectedButton.setEnabled(true);
+ }
+
+ private void
disableSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // Obtain App objects corresponding to currently selected table entries
+ Set<App> selectedApps = getSelectedApps();
+
+ for (App app : selectedApps) {
+ // Only uninstall apps that are installed
+ if (app.getStatus() == AppStatus.INSTALLED) {
+ try {
+ appManager.uninstallApp(app);
+ } catch (AppUninstallException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ disableSelectedButton.setEnabled(false);
+ enableSelectedButton.setEnabled(true);
+ }
+
+ private void showTypeComboxBoxActionPerformed(java.awt.event.ActionEvent
evt) {
+ }
+
+ /**
+ * Obtain the set of {@link App} objects corresponding to currently
selected entries in the table of apps
+ * @return A set of {@link App} objects corresponding to selected apps in
the table
+ */
+ private Set<App> getSelectedApps() {
+ Set<App> selectedApps = new HashSet<App>();
+ int[] selectedRows = appsAvailableTable.getSelectedRows();
+
+ for (int index = 0; index < selectedRows.length; index++) {
+
+ App app = (App) appsAvailableTable.getModel().getValueAt(
+
appsAvailableTable.convertRowIndexToModel(selectedRows[index]), 0);
+
+ selectedApps.add(app);
+ }
+
+ return selectedApps;
+ }
+
+ /**
+ * Registers a listener to the {@link AppManager} to listen for app change
events in order to rebuild the table
+ */
+ private void setupAppListener() {
+ appListener = new AppsChangedListener() {
+
+ @Override
+ public void appsChanged(AppsChangedEvent event) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ Set<App> selectedApps =
getSelectedApps();
+
+ // Clear table
+ DefaultTableModel tableModel =
(DefaultTableModel) appsAvailableTable.getModel();
+ for (int rowIndex =
tableModel.getRowCount() - 1; rowIndex >= 0; rowIndex--) {
+
tableModel.removeRow(rowIndex);
+ }
+
+ // Re-populate table
+ populateTable();
+
+ // Update labels
+ updateLabels();
+
+ // Re-select previously
selected apps
+ for (int rowIndex = 0; rowIndex
< tableModel.getRowCount(); rowIndex++) {
+ if
(selectedApps.contains(tableModel.getValueAt(rowIndex, 0))) {
+
appsAvailableTable.addRowSelectionInterval(rowIndex, rowIndex);
+ }
+ }
+ }
+ });
+
+ }
+ };
+
+ appManager.addAppListener(appListener);
+ }
+
+ /**
+ * Populate the table of apps by obtaining the list of currently available
apps from the AppManager object.
+ */
+ private void populateTable() {
+ DefaultTableModel tableModel = (DefaultTableModel)
appsAvailableTable.getModel();
+
+ for (App app : appManager.getApps()) {
+ tableModel.addRow(new Object[]{
+ app,
+ app.getAppFile() != null ?
app.getAppName() : app.getAppName() + " (File moved)",
+ app.getAuthors(),
+ app.getVersion(),
+ app.getStatus()
+ });
+ }
+
+ updateLabels();
+ }
+
+ /**
+ * Update the labels that display the number of currently installed and
available apps.
+ */
+ private void updateLabels() {
+ int installedCount = 0;
+
+ for (App app : appManager.getApps()) {
+ // Simple apps require a restart to be completely uninstalled;
count them as installed
+ // until the restart
+ if (app.getStatus() != AppStatus.UNINSTALLED) {
+ installedCount++;
+ }
+ }
+
+ appsInstalledLabel.setText(installedCount + " Apps installed.");
+ }
+
+ /**
+ * Setup and register a listener to the table to listen for selection
changed events in order to update the
+ * app description box
+ */
+ private void setupDescriptionListener() {
+ appsAvailableTable.getSelectionModel().addListSelectionListener(new
ListSelectionListener() {
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ updateDescriptionBox();
+ }
+ });
+ }
+
+ private void updateDescriptionBox() {
+ Set<App> selectedApps = getSelectedApps();
+ int numSelected = selectedApps.size();
+
+ // If no apps are selected, clear the description box
+ if (numSelected == 0) {
+ descriptionTextArea.setText("");
+
+ // Disable buttons
+ enableSelectedButton.setEnabled(false);
+ disableSelectedButton.setEnabled(false);
+
+ // If a single app is selected, show its app description
+ } else if (numSelected == 1){
+ App selectedApp = selectedApps.iterator().next();
+
+ String text = "App description not found.";
+ descriptionTextArea.setText(text);
+
+ // Enable/disable the appropriate button
+ if (selectedApp.getStatus() == AppStatus.INSTALLED) {
+ enableSelectedButton.setEnabled(false);
+ disableSelectedButton.setEnabled(true);
+ } else {
+ enableSelectedButton.setEnabled(true);
+ disableSelectedButton.setEnabled(false);
+ }
+ } else {
+ descriptionTextArea.setText(numSelected + " apps selected.");
+
+ // Enable/disable the appropriate buttons
+ boolean allInstalled = true;
+ boolean allUninstalled = true;
+
+ for (App selectedApp : selectedApps) {
+ if (selectedApp.getStatus() == AppStatus.INSTALLED) {
+ allUninstalled = false;
+ }
+
+ if (selectedApp.getStatus() != AppStatus.INSTALLED) {
+ allInstalled = false;
+ }
+ }
+
+ if (allInstalled) {
+ enableSelectedButton.setEnabled(false);
+ disableSelectedButton.setEnabled(true);
+ } else if (allUninstalled) {
+ enableSelectedButton.setEnabled(true);
+ disableSelectedButton.setEnabled(false);
+ } else {
+ // If some of the selected apps are installed and some
are uninstalled,
+ // enable both buttons
+ enableSelectedButton.setEnabled(true);
+ disableSelectedButton.setEnabled(true);
+ }
+ }
+ }
+}
Property changes on:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/CurrentlyInstalledAppsPanel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-05-29 23:03:37 UTC (rev 29385)
@@ -0,0 +1,638 @@
+package org.cytoscape.app.internal.ui;
+
+import java.awt.Component;
+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.URISyntaxException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+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.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;
+import org.cytoscape.app.internal.net.ResultsFilterer;
+import org.cytoscape.app.internal.net.WebApp;
+import org.cytoscape.app.internal.net.WebQuerier;
+import org.cytoscape.app.internal.util.DebugHelper;
+import org.cytoscape.util.swing.FileChooserFilter;
+import org.cytoscape.util.swing.FileUtil;
+import org.cytoscape.work.Task;
+import org.cytoscape.work.TaskIterator;
+import org.cytoscape.work.TaskManager;
+import org.cytoscape.work.TaskMonitor;
+
+/**
+ * This class represents the panel in the App Manager dialog's tab used for
installing new apps.
+ * Its UI setup code is generated by the Netbeans 7 GUI builder.
+ */
+public class InstallFromStorePanel extends javax.swing.JPanel {
+
+ /** Long serial version identifier required by the Serializable class */
+ private static final long serialVersionUID = -1208176142084829272L;
+
+ private javax.swing.JScrollPane descriptionScrollPane;
+ private javax.swing.JTextPane descriptionTextPane;
+ private javax.swing.JTextField filterTextField;
+ private javax.swing.JButton installSelectedButton;
+ private javax.swing.JButton jButton1;
+ private javax.swing.JScrollPane resultsScrollPane;
+ private javax.swing.JSplitPane resultsSplitPane;
+ private javax.swing.JTree resultsTree;
+ private javax.swing.JLabel searchAppsLabel;
+ private javax.swing.JCheckBox showCompatibleCheckBox;
+
+ private JFileChooser fileChooser;
+
+ private AppManager appManager;
+ private FileUtil fileUtil;
+ private TaskManager taskManager;
+ private Container parent;
+
+ public InstallFromStorePanel(final AppManager appManager, FileUtil
fileUtil, TaskManager taskManager, Container parent) {
+ this.appManager = appManager;
+ this.fileUtil = fileUtil;
+ this.taskManager = taskManager;
+ this.parent = parent;
+ initComponents();
+
+ taskManager.execute(new TaskIterator(new Task() {
+
+ // Obtain information for all available apps, then
append tag information
+ @Override
+ public void run(TaskMonitor taskMonitor) throws
Exception {
+ taskMonitor.setTitle("Obtaining Apps from App
Store");
+
+ WebQuerier webQuerier =
appManager.getWebQuerier();
+
+ taskMonitor.setStatusMessage("Getting available
apps");
+ Set<WebApp> availableApps =
webQuerier.getAllApps();
+
+ // Note: Code below not used because web store
now returns tag information when
+ // returning all apps
+
+ /*
+ // Obtain available tags
+ Set<WebQuerier.AppTag> availableTags =
webQuerier.getAllTags();
+
+ double progress = 0;
+
+ for (WebQuerier.AppTag appTag : availableTags) {
+
+ taskMonitor.setStatusMessage("Getting apps for
tag: " + appTag.getFullName());
+ progress += 1.0 / availableTags.size();
+ taskMonitor.setProgress(progress);
+
+ // Obtain apps for the current tag
+ Set<WebApp> tagApps =
webQuerier.getAppsByTag(appTag.getName());
+
+ // Assume the set of apps returned is a subset
of all available apps
+ for (WebApp tagApp : tagApps) {
+ tagApp.getAppTags().add(appTag);
+ }
+ }
+ */
+
+ // Once the information is obtained, update the
tree
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
populateTree(appManager.getWebQuerier().getAllApps());
+ }
+
+ });
+ }
+
+ @Override
+ public void cancel() {
+ }
+
+ }));
+
+ /*
+ addTagInformation();
+ populateTree(appManager.getWebQuerier().getAllApps());
+ */
+
+ setupDescriptionListener();
+ setupHyperlinkListener();
+ setupTextFieldListener();
+ }
+
+ private void initComponents() {
+
+ installSelectedButton = new javax.swing.JButton();
+ searchAppsLabel = new javax.swing.JLabel();
+ resultsSplitPane = new javax.swing.JSplitPane();
+ resultsScrollPane = new javax.swing.JScrollPane();
+ resultsTree = new javax.swing.JTree();
+ descriptionScrollPane = new javax.swing.JScrollPane();
+ descriptionTextPane = new javax.swing.JTextPane();
+ showCompatibleCheckBox = new javax.swing.JCheckBox();
+ jButton1 = new javax.swing.JButton();
+ filterTextField = new javax.swing.JTextField();
+
+ installSelectedButton.setText("Install Selected");
+ installSelectedButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ installSelectedButtonActionPerformed(evt);
+ }
+ });
+
+ searchAppsLabel.setText("Filter Apps:");
+
+ resultsSplitPane.setDividerLocation(245);
+
+ javax.swing.tree.DefaultMutableTreeNode treeNode1 = new
javax.swing.tree.DefaultMutableTreeNode("Available Apps (0)");
+ resultsTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
+ resultsScrollPane.setViewportView(resultsTree);
+
+ resultsSplitPane.setLeftComponent(resultsScrollPane);
+
+ descriptionTextPane.setContentType("text/html");
+ descriptionTextPane.setEditable(false);
+
+ // Make the JTextPane render HTML using the default UI font
+ Font font = UIManager.getFont("Label.font");
+ String bodyRule = "body { font-family: " + font.getFamily() + "; " +
+ "font-size: " + font.getSize() + "pt; }";
+ ((HTMLDocument)
descriptionTextPane.getDocument()).getStyleSheet().addRule(bodyRule);
+
+ descriptionTextPane.setText("<html> <head> </head> <body> <p
style=\"margin-top: 0\"> App information is displayed here. <a
href=\"http://www.w3schools.com/\">Test link</a> </p> </body>
</html> ");
+ descriptionTextPane.setText("");
+ descriptionScrollPane.setViewportView(descriptionTextPane);
+
+ resultsSplitPane.setRightComponent(descriptionScrollPane);
+
+ showCompatibleCheckBox.setText("Show only compatible apps");
+
+ jButton1.setText("Browse File");
+ jButton1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ browseButtonActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(resultsSplitPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE)
+ .addContainerGap())
+ .add(layout.createSequentialGroup()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(filterTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 269,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(showCompatibleCheckBox))
+ .add(layout.createSequentialGroup()
+ .add(installSelectedButton)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(jButton1))
+ .add(searchAppsLabel))
+ .add(0, 0, Short.MAX_VALUE))))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING,
layout.createSequentialGroup()
+ .addContainerGap()
+ .add(searchAppsLabel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(filterTextField,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(showCompatibleCheckBox))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(resultsSplitPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE, false)
+ .add(installSelectedButton,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .add(jButton1,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ }
+
+ private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // Setup a the file filter for the open file dialog
+ FileChooserFilter fileChooserFilter = new FileChooserFilter("Jar, Zip
Files (*.jar, *.zip)",
+ new String[]{"jar", "zip"});
+
+ Collection<FileChooserFilter> fileChooserFilters = new
LinkedList<FileChooserFilter>();
+ fileChooserFilters.add(fileChooserFilter);
+
+ // Show the dialog
+ File[] files = fileUtil.getFiles(parent,
+ "Choose file(s)", FileUtil.LOAD,
FileUtil.LAST_DIRECTORY, "Install", true, fileChooserFilters);
+
+ if (files != null) {
+
+ for (int index = 0; index < files.length; index++) {
+ AppParser appParser = appManager.getAppParser();
+
+ App app = null;
+
+ // Attempt to parse each file as an App object
+ try {
+ app = appParser.parseApp(files[index]);
+
+ } catch (AppParsingException e) {
+
+ // TODO: Replace DebugHelper.print()
messages with exception or a pop-up message box
+ DebugHelper.print("Error parsing app: "
+ e.getMessage());
+
+ JOptionPane.showMessageDialog(parent,
"Error opening app: " + e.getMessage(),
+ "Error", JOptionPane.ERROR_MESSAGE);
+ } finally {
+
+ // Install the app if parsing was
successful
+ if (app != null) {
+ try {
+
appManager.installApp(app);
+ } catch (AppInstallException e)
{
+
JOptionPane.showMessageDialog(parent, "Error installing app: " + e.getMessage(),
+ "Error",
JOptionPane.ERROR_MESSAGE);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Attempts to insert newlines into a given string such that each line has
no
+ * more than the specified number of characters.
+ */
+ private String splitIntoLines(String text, int charsPerLine) {
+ return null;
+ }
+
+ private void setupTextFieldListener() {
+ filterTextField.getDocument().addDocumentListener(new
DocumentListener() {
+
+ @Override
+ public void removeUpdate(DocumentEvent arg0) {
+ // TODO Auto-generated method stub
+ filterResults();
+ }
+
+ @Override
+ public void insertUpdate(DocumentEvent arg0) {
+ // TODO Auto-generated method stub
+ filterResults();
+ }
+
+ @Override
+ public void changedUpdate(DocumentEvent arg0) {
+ // TODO Auto-generated method stub
+ filterResults();
+ }
+ });
+ }
+
+ private void filterResults() {
+ String text = filterTextField.getText();
+
+ Set<WebApp> allApps = appManager.getWebQuerier().getAllApps();
+
+ if (text != null && text.length() > 0) {
+ ResultsFilterer filterer = new ResultsFilterer();
+
+ populateTree(filterer.findMatches(text, allApps));
+
+ } else {
+ populateTree(allApps);
+ }
+ }
+
+ private void searchComboBoxPropertyChange(java.beans.PropertyChangeEvent
evt) {
+
+ }
+
+ private void
installSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ final Set<WebApp> selectedApps = getSelectedApps();
+ final WebQuerier webQuerier = appManager.getWebQuerier();
+
+ DebugHelper.print("Download path: " +
appManager.getDownloadedAppsPath());
+
+ taskManager.execute(new TaskIterator(new Task() {
+
+ @Override
+ public void run(TaskMonitor taskMonitor) throws
Exception {
+ taskMonitor.setTitle("Installing App from App
Store");
+
+ double progress = 0;
+ double progressIncrement = 1.0 /
selectedApps.size();
+
+ for (WebApp webApp : selectedApps) {
+
+
taskMonitor.setStatusMessage("Installing app: " + webApp.getFullName());
+
+ // Download app
+ File appFile =
webQuerier.downloadApp(webApp.getName(), null, new
File(appManager.getDownloadedAppsPath()));
+
+ if (appFile != null) {
+ // Parse app
+ App parsedApp =
appManager.getAppParser().parseApp(appFile);
+
+ // Install app
+
appManager.installApp(parsedApp);
+ } else {
+ // Log error: no download links were
found for app
+ DebugHelper.print("Unable to find
download url for: " + webApp.getFullName());
+ }
+
+ progress += progressIncrement;
+ taskMonitor.setProgress(progress);
+ }
+
+
+ }
+
+ @Override
+ public void cancel() {
+ }
+
+ }));
+ }
+
+
+ private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void
viewOnWebStoreButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ /**
+ * Populate the current tree of results with the available apps from the
web store.
+ */
+ private void populateTreeOld() {
+ WebQuerier webQuerier = appManager.getWebQuerier();
+
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode("Available
Apps (" + webQuerier.getAllApps().size() + ")");
+
+ // Obtain available tags
+ Set<WebQuerier.AppTag> availableTags = webQuerier.getAllTags();
+
+ for (WebQuerier.AppTag appTag : availableTags) {
+ DefaultMutableTreeNode tagNode = new
DefaultMutableTreeNode(appTag.getFullName() + " (" + appTag.getCount() + ")");
+
+ // Obtain apps for the current tag
+ DebugHelper.print("Getting apps for tag: " + appTag.getName());
+ Set<WebApp> tagApps = webQuerier.getAppsByTag(appTag.getName());
+
+ for (WebApp tagApp : tagApps) {
+ tagNode.add(new DefaultMutableTreeNode(tagApp));
+ }
+
+ root.add(tagNode);
+ }
+
+ resultsTree.setModel(new DefaultTreeModel(root));
+ }
+
+ // Populate the tree using a given set of WebApp objects.
+ private void populateTree(Set<WebApp> webApps) {
+ WebQuerier webQuerier = appManager.getWebQuerier();
+
+ // Assume given apps have been labelled with tags
+ // Above assumption should be valid once web store is updated to
provide tag information when requesting all apps
+
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode("Matches (" +
webApps.size() + ")");
+
+ // Obtain available tags
+ Set<WebQuerier.AppTag> availableTags = webQuerier.getAllTags();
+
+ /*
+ // Obtain apps for each tag and add them to the tree
+ for (WebQuerier.AppTag appTag : availableTags) {
+ Set<WebApp> associatedApps =
webQuerier.getAppsByTag(appTag.getName());
+
+ if (associatedApps.size() > 0) {
+ DefaultMutableTreeNode tagNode = new
DefaultMutableTreeNode(appTag.getFullName() + " (" + associatedApps.size() +
")");
+
+ for (WebApp webApp : associatedApps) {
+ tagNode.add(new DefaultMutableTreeNode(webApp));
+ }
+
+ root.add(tagNode);
+ }
+ }
+ */
+
+
+ // Construct a dictionary that maps each tag to a set containing all
the apps associated with that tag
+ // in order to produce the tree
+ Map<WebQuerier.AppTag, Set<WebApp>> appsByTag = new
HashMap<WebQuerier.AppTag, Set<WebApp>>();
+ for (WebQuerier.AppTag appTag : availableTags) {
+ appsByTag.put(appTag, new HashSet<WebApp>());
+ }
+
+ for (WebApp webApp : webApps) {
+ // Add the app to the appropriate set(s) in the dictionary
+ for (WebQuerier.AppTag appTag : webApp.getAppTags()) {
+ appsByTag.get(appTag).add(webApp);
+ }
+ }
+
+ for (Entry<WebQuerier.AppTag, Set<WebApp>> entry :
appsByTag.entrySet()) {
+ WebQuerier.AppTag appTag = entry.getKey();
+ Set<WebApp> associatedApps = entry.getValue();
+
+ if (associatedApps.size() > 0) {
+ DefaultMutableTreeNode tagNode = new
DefaultMutableTreeNode(appTag.getFullName() + " (" + associatedApps.size() +
")");
+
+ for (WebApp webApp : associatedApps) {
+ DefaultMutableTreeNode appNode = new
DefaultMutableTreeNode(webApp);
+
+ tagNode.add(appNode);
+ }
+
+ root.add(tagNode);
+ }
+ }
+
+ resultsTree.setModel(new DefaultTreeModel(root));
+
+ for (int index = resultsTree.getRowCount() - 1; index >= 0; index--) {
+ resultsTree.expandRow(index);
+ }
+
+ /*
+ resultsTree.setCellRenderer(new DefaultTreeCellRenderer() {
+ private static final long serialVersionUID =
-2593107773334586019L;
+
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree,
Object value, boolean sel,
+ boolean expanded, boolean leaf, int row,
boolean hasFocus) {
+
+ super.getTreeCellRendererComponent(tree, value, sel,
expanded, leaf, row, hasFocus);
+
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)
value;
+
+ if (node.getUserObject() instanceof WebApp) {
+ setIcon(((WebApp)
node.getUserObject()).getImageIcon());
+ }
+
+ return this;
+ }
+ });
+ */
+ // resultsTree.setRowHeight(0);
+ }
+
+ /**
+ * Obtain the set of {@link WebApp} objects corresponding to currently
selected entries in the tree of apps
+ * @return A set of {@link WebApp} objects corresponding to selected apps
in the tree
+ */
+ private Set<WebApp> getSelectedApps() {
+ TreePath[] selectedPaths = resultsTree.getSelectionPaths();
+ if (selectedPaths == null) {
+ // Return an empty set if no selections were found
+ return new HashSet<WebApp>();
+ }
+
+ Set<WebApp> selectedApps = new HashSet<WebApp>();
+
+ for (int index = 0; index < selectedPaths.length; index++) {
+ TreePath selectedPath = selectedPaths[index];
+
+ DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)
selectedPath.getLastPathComponent();
+ Object selectedUserObject = selectedNode.getUserObject();
+
+ // Selecting tag category nodes are also added to the set of
selected paths; avoid
+ // adding them as selected apps by making this check
+ if (selectedUserObject instanceof WebApp) {
+ selectedApps.add((WebApp) selectedUserObject);
+ }
+ }
+
+ return selectedApps;
+ }
+
+ /**
+ * Setup and register a listener to the tree to listen for selection
changed events in order to update the
+ * app description box
+ */
+ private void setupDescriptionListener() {
+ resultsTree.addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent event) {
+ updateDescriptionBox();
+ }
+ });
+ }
+
+ private void setupHyperlinkListener() {
+ descriptionTextPane.addHyperlinkListener(new HyperlinkListener() {
+
+ @Override
+ public void hyperlinkUpdate(HyperlinkEvent event) {
+ if (Desktop.isDesktopSupported() &&
event.getEventType() == EventType.ACTIVATED) {
+ Desktop desktop = Desktop.getDesktop();
+
+ try {
+
desktop.browse(event.getURL().toURI());
+ } catch (IOException e) {
+ // TODO Auto-generated catch
block
+ e.printStackTrace();
+ } catch (URISyntaxException e) {
+ // TODO Auto-generated catch
block
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+
+ // Adds tag information to the set of available apps
+ private void addTagInformation() {
+ }
+
+ private void updateDescriptionBox() {
+ Set<WebApp> selectedApps = getSelectedApps();
+ int numSelected = selectedApps.size();
+
+ // If no apps are selected, clear the description box
+ if (numSelected == 0) {
+ descriptionTextPane.setText("<html> <head> TestHeader </head>
<body>" +
+ "<p style=\"margin-top: 0\"> App information is
displayed here. </p> </body> </html> ");
+ descriptionTextPane.setText("");
+ // If a single app is selected, show its app description
+ } else if (numSelected == 1) {
+ WebApp selectedApp = selectedApps.iterator().next();
+
+ String text = "<html><b>" + selectedApp.getFullName() +
"</b></html>";
+ text += "\n\n";
+ text += selectedApp.getDescription();
+
+ text = "";
+ text += "<html> <head> </head> <body>";
+
+ // App hyperlink to web store page
+ text += "<p style=\"margin-top: 0\"> <a href=\"" +
selectedApp.getPageUrl() + "\">" + selectedApp.getPageUrl() + "</a> </p>";
+
+ // App image
+ // text += "<img border=\"0\" src=\"" +
appManager.getWebQuerier().getAppStoreUrl() + selectedApp.getIconUrl() + "\"
alt=\"" + selectedApp.getFullName() + "\"/>";
+
+ // App name
+ text += "<p> <b>" + selectedApp.getFullName() + "</b> </p>";
+
+ // App description
+ text += "<p>" + selectedApp.getDescription() + "</p>";
+ text += "</body> </html>";
+ descriptionTextPane.setText(text);
+ } else {
+ String text = "<html> <head> </head> <body> <p
style=\"margin-top: 0\">";
+ text += numSelected + " apps selected: <br />";
+
+ for (WebApp webApp : selectedApps) {
+ text += "<br />" + webApp.getFullName();
+ };
+ text += "</p>";
+ text += "</body> </html>";
+ descriptionTextPane.setText(text);
+ }
+ }
+}
Property changes on:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/util/DebugHelper.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/util/DebugHelper.java
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/util/DebugHelper.java
2012-05-29 23:03:37 UTC (rev 29385)
@@ -0,0 +1,14 @@
+package org.cytoscape.app.internal.util;
+
+/**
+ * A class used to manage print commands for aiding in debugging
+ */
+public class DebugHelper {
+ public static void print(String message) {
+ boolean debug = true;
+
+ if (debug) {
+ System.out.println(message);
+ }
+ }
+}
Property changes on:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/util/DebugHelper.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
--
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.