Author: paperwing
Date: 2012-04-17 15:30:08 -0700 (Tue, 17 Apr 2012)
New Revision: 28868
Added:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanelOld.java
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallAppsPanel.java
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
Log:
App Manager now uses the Cytoscape filechooser from FileUtil, "Install from
Store" panel now uses a JTree instead of a JTable to contain available apps
from the app store; panel now resembles the plugin manager from Cytoscape 2.8.
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-04-17 21:48:33 UTC (rev 28867)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-04-17 22:30:08 UTC (rev 28868)
@@ -3,6 +3,8 @@
import org.cytoscape.app.AbstractCyApp;
import org.cytoscape.app.CyAppAdapter;
import org.cytoscape.app.internal.CyAppAdapterImpl;
+import org.cytoscape.app.internal.action.AppManagerAction;
+import org.cytoscape.app.internal.manager.AppManager;
import org.cytoscape.app.internal.net.WebQuerier;
import org.cytoscape.application.CyVersion;
import org.cytoscape.session.CySessionManager;
@@ -15,6 +17,7 @@
import org.cytoscape.io.read.CyPropertyReaderManager;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableFactory;
+import org.cytoscape.util.swing.FileUtil;
import org.cytoscape.view.layout.CyLayoutAlgorithmManager;
import org.cytoscape.datasource.DataSourceManager;
import org.cytoscape.event.CyEventHelper;
@@ -64,7 +67,7 @@
}
public void start(BundleContext bc) {
-
+
CyApplicationManager cyApplicationManagerRef =
getService(bc,CyApplicationManager.class);
CyEventHelper cyEventHelperRef =
getService(bc,CyEventHelper.class);
CyLayoutAlgorithmManager cyLayoutAlgorithmManagerRef =
getService(bc,CyLayoutAlgorithmManager.class);
@@ -106,6 +109,7 @@
DataSourceManager dataSourceManager = getService(bc,
DataSourceManager.class);
StreamUtil streamUtilServiceRef = getService(bc,
StreamUtil.class);
+ FileUtil fileUtilServiceRef = getService(bc, FileUtil.class);
CyAppAdapterImpl cyAppAdapter = new
CyAppAdapterImpl(cyApplicationManagerRef,cyEventHelperRef,cyLayoutAlgorithmManagerRef,cyNetworkFactoryRef,cyNetworkManagerRef,cyNetworkViewFactoryRef,cyNetworkViewManagerRef,cyNetworkViewReaderManagerRef,cyNetworkViewWriterManagerRef,cyPropertyRef,cyPropertyReaderManagerRef,cyPropertyWriterManagerRef,cyRootNetworkFactoryRef,cyServiceRegistrarRef,cySessionManagerRef,cySessionReaderManagerRef,cySessionWriterManagerRef,cySwingApplicationRef,cyTableFactoryRef,cyTableManagerRef,cyTableReaderManagerRef,cytoscapeVersionService,
dialogTaskManagerRef,panelTaskManagerRef,submenuTaskManagerRef,presentationWriterManagerRef,renderingEngineManagerRef,taskManagerRef,undoSupportRef,
vmfFactoryC, vmfFactoryD, vmfFactoryP,
visualMappingManagerRef,visualStyleFactoryRef, dataSourceManager);
registerService(bc,cyAppAdapter,CyAppAdapter.class, new
Properties());
@@ -114,12 +118,12 @@
registerService(bc, webQuerier, WebQuerier.class, new
Properties());
// Attempt to instantiate new manager
- org.cytoscape.app.internal.manager.AppManager appManager = new
org.cytoscape.app.internal.manager.AppManager(
+ AppManager appManager = new AppManager(
cyAppAdapter,
cyApplicationConfigurationServiceRef, webQuerier);
- registerService(bc, appManager,
org.cytoscape.app.internal.manager.AppManager.class, new Properties());
+ registerService(bc, appManager, AppManager.class, new
Properties());
// AbstractCyAction implementation for updated app manager
- org.cytoscape.app.internal.action.AppManagerAction
appManagerAction2 = new
org.cytoscape.app.internal.action.AppManagerAction(appManager,
cySwingApplicationRef);;
+ AppManagerAction appManagerAction2 = new
AppManagerAction(appManager, cySwingApplicationRef, fileUtilServiceRef);
registerService(bc, appManagerAction2, CyAction.class, new
Properties());
}
}
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
2012-04-17 21:48:33 UTC (rev 28867)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/action/AppManagerAction.java
2012-04-17 22:30:08 UTC (rev 28868)
@@ -6,6 +6,7 @@
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;
public class AppManagerAction extends AbstractCyAction {
@@ -22,7 +23,12 @@
*/
private AppManager appManager;
- public AppManagerAction(AppManager appManager, CySwingApplication
swingApplication) {
+ /**
+ * A reference to the {@link FileUtil} OSGi service used for displaying
a filechooser dialog
+ */
+ private FileUtil fileUtil;
+
+ public AppManagerAction(AppManager appManager, CySwingApplication
swingApplication, FileUtil fileUtil) {
super("App Manager 2");
setPreferredMenu("Apps");
@@ -30,12 +36,13 @@
this.appManager = appManager;
this.swingApplication = swingApplication;
+ this.fileUtil = fileUtil;
}
@Override
public void actionPerformed(ActionEvent event) {
// Create and display the App Manager dialog
- AppManagerDialog appManagerDialog = new
AppManagerDialog(appManager, swingApplication.getJFrame(), false);
+ AppManagerDialog appManagerDialog = new
AppManagerDialog(appManager, fileUtil, swingApplication.getJFrame(), false);
}
}
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
2012-04-17 21:48:33 UTC (rev 28867)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/net/WebQuerier.java
2012-04-17 22:30:08 UTC (rev 28868)
@@ -215,4 +215,27 @@
this.apps = result;
return result;
}
+
+ public String getAppDescription(String appName) {
+ // Obtain information about the app from the website
+ String jsonResult = null;
+ JSONObject jsonObject = null;
+
+ try {
+ jsonResult = query(APP_STORE_URL + "apps/" + appName);
+
+ // Parse the JSON result
+ jsonObject = new JSONObject(jsonResult);
+ return jsonObject.get("description").toString();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ System.out.println("Error parsing JSON: " +
e.getMessage());
+ e.printStackTrace();
+ }
+
+ return "";
+ }
}
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
2012-04-17 21:48:33 UTC (rev 28867)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/AppManagerDialog.java
2012-04-17 22:30:08 UTC (rev 28868)
@@ -1,6 +1,7 @@
package org.cytoscape.app.internal.ui;
import org.cytoscape.app.internal.manager.AppManager;
+import org.cytoscape.util.swing.FileUtil;
/**
* This class represents the App Manager dialog window. Its UI setup code is
generated by the Netbeans 7 GUI builder.
@@ -10,27 +11,28 @@
private CheckForUpdatesPanel checkForUpdatesPanel1;
private CurrentlyInstalledAppsPanel currentlyInstalledAppsPanel1;
private InstallAppsPanel installAppsPanel2;
- private InstallFromStorePanel installNewAppsPanel1;
+ private InstallFromStorePanelOld installNewAppsPanel1;
private javax.swing.JTabbedPane mainTabbedPane;
private AppManager appManager;
-
- public AppManagerDialog(AppManager appManager, java.awt.Frame parent,
boolean modal) {
+ private FileUtil fileUtil;
+
+ public AppManagerDialog(AppManager appManager, FileUtil fileUtil,
java.awt.Frame parent, boolean modal) {
super(parent, modal);
this.appManager = appManager;
+ this.fileUtil = fileUtil;
initComponents();
this.setLocationRelativeTo(parent);
this.setVisible(true);
}
-
private void initComponents() {
mainTabbedPane = new javax.swing.JTabbedPane();
- installNewAppsPanel1 = new InstallFromStorePanel(appManager);
- installAppsPanel2 = new InstallAppsPanel(appManager);
+ installNewAppsPanel1 = new InstallFromStorePanelOld(appManager);
+ installAppsPanel2 = new InstallAppsPanel(appManager, fileUtil, this);
currentlyInstalledAppsPanel1 = new
CurrentlyInstalledAppsPanel(appManager);
checkForUpdatesPanel1 = new CheckForUpdatesPanel();
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallAppsPanel.java
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallAppsPanel.java
2012-04-17 21:48:33 UTC (rev 28867)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallAppsPanel.java
2012-04-17 22:30:08 UTC (rev 28868)
@@ -1,15 +1,21 @@
package org.cytoscape.app.internal.ui;
+import java.awt.Container;
import java.io.File;
+import java.util.Collection;
+import java.util.LinkedList;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;
+import org.apache.commons.io.FileUtils;
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.util.swing.FileChooserFilter;
+import org.cytoscape.util.swing.FileUtil;
public class InstallAppsPanel extends javax.swing.JPanel {
@@ -21,14 +27,22 @@
private javax.swing.JButton installFromUrlButton;
private AppManager appManager;
+ private FileUtil fileUtil;
private JFileChooser fileChooser;
/**
+ * A reference to the parent of this panel used to create the filechooser
dialog.
+ */
+ private Container parent;
+
+ /**
* Creates new form InstallAppsPanel
+ * @param fileUtil
*/
- public InstallAppsPanel(AppManager appManager) {
+ public InstallAppsPanel(AppManager appManager, FileUtil fileUtil,
Container parent) {
this.appManager = appManager;
-
+ this.fileUtil = fileUtil;
+ this.parent = parent;
initComponents();
setupFileChooser();
@@ -102,10 +116,19 @@
}
private void
installFromFileButtonActionPerformed(java.awt.event.ActionEvent evt) {
- int returnValue = fileChooser.showOpenDialog(this);
-
- if (returnValue == JFileChooser.APPROVE_OPTION) {
- File[] files = fileChooser.getSelectedFiles();
+
+ // 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();
@@ -121,7 +144,7 @@
// TODO: Replace System.out.println()
messages with exception or a pop-up message box
System.out.println("Error parsing app:
" + e.getMessage());
- JOptionPane.showMessageDialog(this,
"Error opening app: " + e.getMessage(),
+ JOptionPane.showMessageDialog(parent,
"Error opening app: " + e.getMessage(),
"Error", JOptionPane.ERROR_MESSAGE);
} finally {
Modified:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-04-17 21:48:33 UTC (rev 28867)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-04-17 22:30:08 UTC (rev 28868)
@@ -20,6 +20,9 @@
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeModel;
import org.cytoscape.app.internal.exception.AppMoveException;
import org.cytoscape.app.internal.exception.AppParsingException;
@@ -33,24 +36,22 @@
* 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 = -4975281017724945506L;
+ private static final long serialVersionUID = -1208176142084829272L;
- private javax.swing.JCheckBox appTagCheckBox;
- private javax.swing.JCheckBox authorCheckBox;
- private javax.swing.JCheckBox descriptionChekBox;
- private javax.swing.JLabel descriptionLabel;
- private javax.swing.JScrollPane descriptionScrollPane;
+ private javax.swing.JScrollPane descriptionScrollPane;
private javax.swing.JTextArea descriptionTextArea;
private javax.swing.JButton installSelectedButton;
- private javax.swing.JCheckBox nameCheckBox;
+ private javax.swing.JButton resetButton;
private javax.swing.JLabel resultsLabel;
private javax.swing.JScrollPane resultsScrollPane;
- private javax.swing.JTable resultsTable;
+ private javax.swing.JSplitPane resultsSplitPane;
+ private javax.swing.JTree resultsTree;
private javax.swing.JLabel searchAppsLabel;
private javax.swing.JButton searchButton;
private javax.swing.JComboBox searchComboBox;
+ private javax.swing.JCheckBox showCompatibleCheckBox;
private javax.swing.JButton viewOnWebStoreButton;
private JFileChooser fileChooser;
@@ -61,36 +62,24 @@
this.appManager = appManager;
initComponents();
- setupFileChooser();
- setupResultsTable();
setupDescriptionListener();
-
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- populateTable();
- }
- });
-
}
private void initComponents() {
- searchComboBox = new javax.swing.JComboBox();
+
+ searchComboBox = new javax.swing.JComboBox();
searchButton = new javax.swing.JButton();
- resultsLabel = new javax.swing.JLabel();
- resultsScrollPane = new javax.swing.JScrollPane();
- resultsTable = new javax.swing.JTable();
installSelectedButton = new javax.swing.JButton();
viewOnWebStoreButton = new javax.swing.JButton();
- nameCheckBox = new javax.swing.JCheckBox();
- authorCheckBox = new javax.swing.JCheckBox();
- appTagCheckBox = new javax.swing.JCheckBox();
searchAppsLabel = new javax.swing.JLabel();
- descriptionChekBox = new javax.swing.JCheckBox();
- descriptionLabel = new javax.swing.JLabel();
+ resultsSplitPane = new javax.swing.JSplitPane();
+ resultsScrollPane = new javax.swing.JScrollPane();
+ resultsTree = new javax.swing.JTree();
descriptionScrollPane = new javax.swing.JScrollPane();
descriptionTextArea = new javax.swing.JTextArea();
+ showCompatibleCheckBox = new javax.swing.JCheckBox();
+ resetButton = new javax.swing.JButton();
+ resultsLabel = new javax.swing.JLabel();
searchComboBox.setEditable(true);
@@ -101,31 +90,6 @@
}
});
- resultsLabel.setText("Search Results:");
-
- resultsTable.setModel(new javax.swing.table.DefaultTableModel(
- new Object [][] {
-
- },
- new String [] {
- "App", "Name", "Author", "Version", "Rating", "Downloads"
- }
- ) {
- boolean[] canEdit = new boolean [] {
- false, false, false, false, false, false
- };
-
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return canEdit [columnIndex];
- }
- });
- resultsTable.setShowGrid(false);
- resultsScrollPane.setViewportView(resultsTable);
- resultsTable.getColumnModel().getColumn(1).setPreferredWidth(190);
-
- // Hide the "App" column which is used to provide a reference to the
object providing data for that row
- resultsTable.removeColumn(resultsTable.getColumn("App"));
-
installSelectedButton.setText("Install Selected");
installSelectedButton.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
@@ -134,28 +98,32 @@
});
viewOnWebStoreButton.setText("View on Web Store");
+
+ searchAppsLabel.setText("Search by Keyword:");
- nameCheckBox.setSelected(true);
- nameCheckBox.setText("Name");
+ resultsSplitPane.setDividerLocation(215);
- authorCheckBox.setText("Author");
+ resultsScrollPane.setViewportView(resultsTree);
- appTagCheckBox.setText("App Tags");
+ resultsSplitPane.setLeftComponent(resultsScrollPane);
- searchAppsLabel.setText("Search for Apps:");
-
- descriptionChekBox.setText("Description");
-
- descriptionLabel.setText("App Information:");
-
descriptionScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- descriptionTextArea.setEditable(false);
+ descriptionTextArea.setColumns(20);
descriptionTextArea.setLineWrap(true);
+ descriptionTextArea.setRows(5);
+ descriptionTextArea.setText("App information is displayed here.");
descriptionTextArea.setWrapStyleWord(true);
- descriptionTextArea.setFocusable(false);
descriptionScrollPane.setViewportView(descriptionTextArea);
+ resultsSplitPane.setRightComponent(descriptionScrollPane);
+
+ showCompatibleCheckBox.setText("Only Show Apps Known to be
Compatible");
+
+ resetButton.setText("Reset");
+
+ resultsLabel.setText("Search Results:");
+
org.jdesktop.layout.GroupLayout layout = new
org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -163,29 +131,22 @@
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(resultsScrollPane)
- .add(descriptionScrollPane)
+ .add(resultsSplitPane)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(installSelectedButton)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(viewOnWebStoreButton))
- .add(resultsLabel)
- .add(layout.createSequentialGroup()
- .add(nameCheckBox)
-
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(authorCheckBox)
-
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(appTagCheckBox)
-
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(descriptionChekBox))
.add(searchAppsLabel)
.add(layout.createSequentialGroup()
- .add(searchComboBox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 288,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(searchComboBox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 269,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(searchButton))
- .add(descriptionLabel))
+ .add(searchButton)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(resetButton))
+ .add(resultsLabel)
+ .add(showCompatibleCheckBox))
.add(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
@@ -196,22 +157,15 @@
.add(searchAppsLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(nameCheckBox)
- .add(authorCheckBox)
- .add(appTagCheckBox)
- .add(descriptionChekBox))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
-
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(searchComboBox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(searchButton))
+ .add(searchButton)
+ .add(resetButton))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(resultsLabel)
+ .add(showCompatibleCheckBox)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(resultsScrollPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(descriptionLabel)
+ .add(resultsLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(descriptionScrollPane,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 96,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(resultsSplitPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 260, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(installSelectedButton)
@@ -220,134 +174,48 @@
);
}
- private void
installFromFileButtonActionPerformed(java.awt.event.ActionEvent evt) {
- int returnValue = fileChooser.showOpenDialog(this);
-
- if (returnValue == JFileChooser.APPROVE_OPTION) {
- File[] files = fileChooser.getSelectedFiles();
-
- 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 System.out.println()
messages with exception or a pop-up message box
- System.out.println("Error parsing app:
" + e.getMessage());
-
- JOptionPane.showMessageDialog(this,
"Error opening app: " + e.getMessage(),
- "Error", JOptionPane.ERROR_MESSAGE);
- } finally {
-
- // Install the app if parsing was
successful
- if (app != null) {
- appManager.installApp(app);
- }
- }
- }
- }
- }
+ private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
- private void
installFromURLButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ private void
installSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
- }
+ }
- private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
- private void
installSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ private void
viewOnWebStoreButtonActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
-
- private void setupFileChooser() {
- fileChooser = new JFileChooser();
- fileChooser.setDialogTitle("Select App Files");
- fileChooser.setApproveButtonText("Install");
- fileChooser.setApproveButtonMnemonic('I');
- fileChooser.setMultiSelectionEnabled(true);
-
- fileChooser.addChoosableFileFilter(new FileFilter(){
-
- @Override
- public boolean accept(File file) {
- if (file.getName().endsWith("jar") ||
file.isDirectory()) {
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public String getDescription() {
- return "Jar-packaged App Files (*.jar)";
- }
-
- });
- }
- private void setupResultsTable() {
- // resultsTable.setCellSelectionEnabled(false);
-
- // resultsTable.setDefaultEditor(null, null);
- resultsTable.setOpaque(true);
- }
-
/**
- * Populate the current table of results with the available apps from the
web store.
+ * Populate the current tree of results with the available apps from the
web store.
*/
- private void populateTable() {
- Set<WebApp> apps = appManager.getWebQuerier().getAllApps();
+ private void populateTree() {
+ TreeModel treeModel = resultsTree.getModel();
- DefaultTableModel tableModel = (DefaultTableModel)
resultsTable.getModel();
+ DefaultMutableTreeNode root = new DefaultMutableTreeNode();
- // Table columns in order: "App", "Name", "Author", "Version",
"Rating", "Downloads"
- for (WebApp app : apps) {
- tableModel.addRow(new Object[]{
- app,
- app.getFullName(),
- "",
- "",
- "",
- ""
- });
- }
+ // TODO: Query, populate tree
+
+ resultsTree.setModel(new DefaultTreeModel(root));
}
/**
- * Obtain the set of {@link WebApp} objects corresponding to currently
selected entries in the table of apps
- * @return A set of {@link WebApp} objects corresponding to selected apps
in the table
+ * 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() {
- Set<WebApp> selectedApps = new HashSet<WebApp>();
- int[] selectedRows = resultsTable.getSelectedRows();
-
- for (int index = 0; index < selectedRows.length; index++) {
- WebApp app = (WebApp)
resultsTable.getModel().getValueAt(selectedRows[index], 0);
-
- selectedApps.add(app);
- }
-
- return selectedApps;
+ return null;
}
/**
- * Setup and register a listener to the table to listen for selection
changed events in order to update the
+ * 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() {
- resultsTable.getSelectionModel().addListSelectionListener(new
ListSelectionListener() {
-
- @Override
- public void valueChanged(ListSelectionEvent e) {
- updateDescriptionBox();
- }
- });
}
private void updateDescriptionBox() {
Copied:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanelOld.java
(from rev 28845,
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java)
===================================================================
---
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanelOld.java
(rev 0)
+++
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanelOld.java
2012-04-17 22:30:08 UTC (rev 28868)
@@ -0,0 +1,373 @@
+package org.cytoscape.app.internal.ui;
+
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+import javax.swing.RowSorter;
+import javax.swing.ScrollPaneConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TableModelListener;
+import javax.swing.filechooser.FileFilter;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableModel;
+
+import org.cytoscape.app.internal.exception.AppMoveException;
+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.WebApp;
+
+/**
+ * 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 InstallFromStorePanelOld extends javax.swing.JPanel {
+
+ /** Long serial version identifier required by the Serializable class */
+ private static final long serialVersionUID = -4975281017724945506L;
+
+ private javax.swing.JCheckBox appTagCheckBox;
+ private javax.swing.JCheckBox authorCheckBox;
+ private javax.swing.JCheckBox descriptionChekBox;
+ private javax.swing.JLabel descriptionLabel;
+ private javax.swing.JScrollPane descriptionScrollPane;
+ private javax.swing.JTextArea descriptionTextArea;
+ private javax.swing.JButton installSelectedButton;
+ private javax.swing.JCheckBox nameCheckBox;
+ private javax.swing.JLabel resultsLabel;
+ private javax.swing.JScrollPane resultsScrollPane;
+ private javax.swing.JTable resultsTable;
+ private javax.swing.JLabel searchAppsLabel;
+ private javax.swing.JButton searchButton;
+ private javax.swing.JComboBox searchComboBox;
+ private javax.swing.JButton viewOnWebStoreButton;
+
+ private JFileChooser fileChooser;
+
+ private AppManager appManager;
+
+ public InstallFromStorePanelOld(AppManager appManager) {
+ this.appManager = appManager;
+ initComponents();
+
+ setupFileChooser();
+ setupResultsTable();
+ setupDescriptionListener();
+
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ populateTable();
+ }
+ });
+
+ }
+
+ private void initComponents() {
+ searchComboBox = new javax.swing.JComboBox();
+ searchButton = new javax.swing.JButton();
+ resultsLabel = new javax.swing.JLabel();
+ resultsScrollPane = new javax.swing.JScrollPane();
+ resultsTable = new javax.swing.JTable();
+ installSelectedButton = new javax.swing.JButton();
+ viewOnWebStoreButton = new javax.swing.JButton();
+ nameCheckBox = new javax.swing.JCheckBox();
+ authorCheckBox = new javax.swing.JCheckBox();
+ appTagCheckBox = new javax.swing.JCheckBox();
+ searchAppsLabel = new javax.swing.JLabel();
+ descriptionChekBox = new javax.swing.JCheckBox();
+ descriptionLabel = new javax.swing.JLabel();
+ descriptionScrollPane = new javax.swing.JScrollPane();
+ descriptionTextArea = new javax.swing.JTextArea();
+
+ searchComboBox.setEditable(true);
+
+ searchButton.setText("Search");
+ searchButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ searchButtonActionPerformed(evt);
+ }
+ });
+
+ resultsLabel.setText("Search Results:");
+
+ resultsTable.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+
+ },
+ new String [] {
+ "App", "Name", "Author", "Version", "Rating", "Downloads"
+ }
+ ) {
+ boolean[] canEdit = new boolean [] {
+ false, false, false, false, false, false
+ };
+
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return canEdit [columnIndex];
+ }
+ });
+ resultsTable.setShowGrid(false);
+ resultsScrollPane.setViewportView(resultsTable);
+ resultsTable.getColumnModel().getColumn(1).setPreferredWidth(190);
+
+ // Hide the "App" column which is used to provide a reference to the
object providing data for that row
+ resultsTable.removeColumn(resultsTable.getColumn("App"));
+
+ installSelectedButton.setText("Install Selected");
+ installSelectedButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ installSelectedButtonActionPerformed(evt);
+ }
+ });
+
+ viewOnWebStoreButton.setText("View on Web Store");
+
+ nameCheckBox.setSelected(true);
+ nameCheckBox.setText("Name");
+
+ authorCheckBox.setText("Author");
+
+ appTagCheckBox.setText("App Tags");
+
+ searchAppsLabel.setText("Search for Apps:");
+
+ descriptionChekBox.setText("Description");
+
+ descriptionLabel.setText("App Information:");
+
+
descriptionScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+
+ descriptionTextArea.setEditable(false);
+ descriptionTextArea.setLineWrap(true);
+ descriptionTextArea.setWrapStyleWord(true);
+ 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(resultsScrollPane)
+ .add(descriptionScrollPane)
+ .add(layout.createSequentialGroup()
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(installSelectedButton)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(viewOnWebStoreButton))
+ .add(resultsLabel)
+ .add(layout.createSequentialGroup()
+ .add(nameCheckBox)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(authorCheckBox)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(appTagCheckBox)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(descriptionChekBox))
+ .add(searchAppsLabel)
+ .add(layout.createSequentialGroup()
+ .add(searchComboBox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 288,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(searchButton))
+ .add(descriptionLabel))
+ .add(0, 0, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(searchAppsLabel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(nameCheckBox)
+ .add(authorCheckBox)
+ .add(appTagCheckBox)
+ .add(descriptionChekBox))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(searchComboBox,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(searchButton))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(resultsLabel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(resultsScrollPane,
org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+ .add(descriptionLabel)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(descriptionScrollPane,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 96,
org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(installSelectedButton)
+ .add(viewOnWebStoreButton))
+ .addContainerGap())
+ );
+ }
+
+ private void
installFromFileButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ int returnValue = fileChooser.showOpenDialog(this);
+
+ if (returnValue == JFileChooser.APPROVE_OPTION) {
+ File[] files = fileChooser.getSelectedFiles();
+
+ 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 System.out.println()
messages with exception or a pop-up message box
+ System.out.println("Error parsing app:
" + e.getMessage());
+
+ JOptionPane.showMessageDialog(this,
"Error opening app: " + e.getMessage(),
+ "Error", JOptionPane.ERROR_MESSAGE);
+ } finally {
+
+ // Install the app if parsing was
successful
+ if (app != null) {
+ appManager.installApp(app);
+ }
+ }
+ }
+ }
+ }
+
+ private void
installFromURLButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void
installSelectedButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void setupFileChooser() {
+ fileChooser = new JFileChooser();
+ fileChooser.setDialogTitle("Select App Files");
+ fileChooser.setApproveButtonText("Install");
+ fileChooser.setApproveButtonMnemonic('I');
+ fileChooser.setMultiSelectionEnabled(true);
+
+ fileChooser.addChoosableFileFilter(new FileFilter(){
+
+ @Override
+ public boolean accept(File file) {
+ if (file.getName().endsWith("jar") ||
file.isDirectory()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public String getDescription() {
+ return "Jar-packaged App Files (*.jar)";
+ }
+
+ });
+ }
+
+ private void setupResultsTable() {
+ // resultsTable.setCellSelectionEnabled(false);
+
+ // resultsTable.setDefaultEditor(null, null);
+ resultsTable.setOpaque(true);
+ }
+
+ /**
+ * Populate the current table of results with the available apps from the
web store.
+ */
+ private void populateTable() {
+ Set<WebApp> apps = appManager.getWebQuerier().getAllApps();
+
+ DefaultTableModel tableModel = (DefaultTableModel)
resultsTable.getModel();
+
+ // Table columns in order: "App", "Name", "Author", "Version",
"Rating", "Downloads"
+ for (WebApp app : apps) {
+ tableModel.addRow(new Object[]{
+ app,
+ app.getFullName(),
+ "",
+ "",
+ "",
+ ""
+ });
+ }
+ }
+
+ /**
+ * Obtain the set of {@link WebApp} objects corresponding to currently
selected entries in the table of apps
+ * @return A set of {@link WebApp} objects corresponding to selected apps
in the table
+ */
+ private Set<WebApp> getSelectedApps() {
+ Set<WebApp> selectedApps = new HashSet<WebApp>();
+ int[] selectedRows = resultsTable.getSelectedRows();
+
+ for (int index = 0; index < selectedRows.length; index++) {
+ WebApp app = (WebApp)
resultsTable.getModel().getValueAt(selectedRows[index], 0);
+
+ selectedApps.add(app);
+ }
+
+ return selectedApps;
+ }
+
+ /**
+ * 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() {
+ resultsTable.getSelectionModel().addListSelectionListener(new
ListSelectionListener() {
+
+ @Override
+ public void valueChanged(ListSelectionEvent e) {
+ updateDescriptionBox();
+ }
+ });
+ }
+
+ private void updateDescriptionBox() {
+ Set<WebApp> selectedApps = getSelectedApps();
+ int numSelected = selectedApps.size();
+
+ // If no apps are selected, clear the description box
+ if (numSelected == 0) {
+ descriptionTextArea.setText("");
+
+ // If a single app is selected, show its app description
+ } else if (numSelected == 1){
+ WebApp selectedApp = selectedApps.iterator().next();
+
+ String text = "App Description: " +
selectedApp.getDescription();
+ // String text = "App Description: " +
appManager.getWebQuerier().getAppDescription(selectedApp.getName()); //
selectedApp.getDescription();
+ text += "\n";
+ descriptionTextArea.setText(text);
+ } else {
+ descriptionTextArea.setText("");
+ }
+ }
+}
Property changes on:
csplugins/trunk/toronto/yuedong/app_manager/impl/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanelOld.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.