Author: paperwing
Date: 2012-08-22 13:52:39 -0700 (Wed, 22 Aug 2012)
New Revision: 30252
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/DownloadSite.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/DownloadSitesManager.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/ManageDownloadSitesDialog.java
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
core3/impl/trunk/app-impl/src/test/java/org/cytoscape/app/internal/net/WebQuerierTest.java
Log:
refs #1272 Added dialog for editing app store sites, added class responsible
for loading, saving, keeping track of current list of app store sites
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-08-22 20:50:01 UTC (rev 30251)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-08-22 20:52:39 UTC (rev 30252)
@@ -21,6 +21,7 @@
import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.property.bookmark.Bookmarks;
import org.cytoscape.property.bookmark.BookmarksUtil;
+import org.cytoscape.property.bookmark.DataSource;
import org.cytoscape.model.CyNetworkFactory;
import org.cytoscape.group.CyGroupFactory;
import org.cytoscape.group.CyGroupManager;
@@ -125,6 +126,7 @@
import org.cytoscape.task.write.ExportVizmapTaskFactory;
import org.cytoscape.task.write.SaveSessionAsTaskFactory;
+import java.util.List;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.concurrent.Executors;
@@ -382,7 +384,8 @@
httpd.addResponder(appGetResponder.new StatusResponder());
httpd.addResponder(appGetResponder.new InstallResponder());
httpd.start();
-
+
+ Object o = cyPropertyRef;
// cyPropertyRef.getProperties().put("testkey1", "testval1");
// cyPropertyRef.getProperties().setProperty("testkey2",
"testval2");
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/DownloadSite.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/DownloadSite.java
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/DownloadSite.java
2012-08-22 20:52:39 UTC (rev 30252)
@@ -0,0 +1,37 @@
+package org.cytoscape.app.internal.ui.downloadsites;
+
+/**
+ * A class representing an app store, or a download site that can be used to
obtain
+ * apps and app information.
+ */
+public class DownloadSite {
+
+ /** The name of the site, does not have to be an official name, mainly
used for convenient displaying
+ */
+ private String siteName;
+
+ /** The site's url.
+ */
+ private String siteUrl;
+
+ public String getSiteName() {
+ return siteName;
+ }
+
+ public void setSiteName(String siteName) {
+ this.siteName = siteName;
+ }
+
+ public String getSiteUrl() {
+ return siteUrl;
+ }
+
+ public void setSiteUrl(String siteUrl) {
+ this.siteUrl = siteUrl;
+ }
+
+ @Override
+ public String toString() {
+ return this.siteName;
+ }
+}
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/DownloadSitesManager.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/DownloadSitesManager.java
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/DownloadSitesManager.java
2012-08-22 20:52:39 UTC (rev 30252)
@@ -0,0 +1,113 @@
+package org.cytoscape.app.internal.ui.downloadsites;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.cytoscape.property.CyProperty;
+
+/**
+ * A manager for app store urls or download sites, responsible for
loading/saving the
+ * list of download sites, and keeping track of the current list of download
sites.
+ */
+public class DownloadSitesManager {
+
+ private List<DownloadSite> downloadSites = new
LinkedList<DownloadSite>();
+
+ /** A reference to the {@link CyProperty} object
+ */
+ private CyProperty<Properties> cyProperty;
+
+ /** The set of listeners listening for download sites changed events,
such as for updating
+ * a GUI component containing the list of download sites.
+ */
+ private Set<DownloadSitesChangedListener> downloadSitesChangedListeners;
+
+ public DownloadSitesManager(CyProperty<Properties> cyProperty) {
+ this.cyProperty = cyProperty;
+ }
+
+ /**
+ * Load the list of download sites
+ * @return <code>true</code> on success, <code>false</code> on failure.
+ */
+ public boolean loadDownloadSites() {
+ List<DownloadSite> newDownloadSites = new
LinkedList<DownloadSite>();
+ boolean loadFailed = false;
+
+ String downloadSiteCountString =
+
cyProperty.getProperties().getProperty("appStoreDownloadSiteCount");
+
+ int downloadSiteCount = 0;
+
+ if (downloadSiteCountString != null) {
+ try {
+ downloadSiteCount =
Integer.parseInt(downloadSiteCountString);
+ } catch (NumberFormatException e) {
+ loadFailed = true;
+ }
+ } else {
+ loadFailed = true;
+ }
+
+ if (!loadFailed) {
+ int siteNumber;
+ String siteName, siteUrl;
+ for (int i = 0; i < downloadSiteCount; i++) {
+ siteNumber = i + 1;
+
+ siteName =
cyProperty.getProperties().getProperty("appStoreDownloadSite" + siteNumber +
"Name");
+ siteUrl =
cyProperty.getProperties().getProperty("appStoreDownloadSite" + siteNumber);
+
+ if (siteName != null && siteUrl != null) {
+ DownloadSite downloadSite = new
DownloadSite();
+ downloadSite.setSiteName(siteName);
+ downloadSite.setSiteUrl(siteUrl);
+ newDownloadSites.add(downloadSite);
+ }
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void saveDownloadSites() {
+ // Save format:
+ // Example, have 2 sites a and b. Use following properties.
+ //
+ // appStoreDownloadSiteCount=2
+ // appStoreDownloadSite1=http://a
+ // appStoreDownloadSite1Name=test
+ // appStoreDownloadSite2=http://b
+ // appStoreDownloadSite2Name=test_2
+
+
+
+ }
+
+ public List<DownloadSite> getDownloadSites() {
+ return downloadSites;
+ }
+
+ public class DownloadSitesChangedEvent {
+
+ private DownloadSitesManager source;
+
+ public DownloadSitesChangedEvent(DownloadSitesManager source) {
+ this.source = source;
+ }
+
+ public DownloadSitesManager getSource() {
+ return source;
+ }
+ }
+
+ public interface DownloadSitesChangedListener {
+
+ public void downloadSitesChanged(DownloadSitesChangedEvent
downloadSitesChangedEvent);
+ }
+}
Added:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/ManageDownloadSitesDialog.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/ManageDownloadSitesDialog.java
(rev 0)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/downloadsites/ManageDownloadSitesDialog.java
2012-08-22 20:52:39 UTC (rev 30252)
@@ -0,0 +1,220 @@
+package org.cytoscape.app.internal.ui.downloadsites;
+
+public class ManageDownloadSitesDialog extends javax.swing.JDialog {
+
+ private javax.swing.JButton addSiteButton;
+ private javax.swing.JButton editSiteButton;
+ private javax.swing.JButton removeSiteButton;
+ private javax.swing.JButton resetToDefaultButton;
+ private javax.swing.JLabel siteNameLabel;
+ private javax.swing.JTextField siteNameTextField;
+ private javax.swing.JLabel siteUrlLabel;
+ private javax.swing.JTextField siteUrlTextField;
+ private javax.swing.JScrollPane sitesScrollPane;
+ private javax.swing.JTable sitesTable;
+
+ /**
+ * Creates new form ManageDownloadSitesDialog
+ */
+ public ManageDownloadSitesDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the
form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">
+ private void initComponents() {
+
+ sitesScrollPane = new javax.swing.JScrollPane();
+ sitesTable = new javax.swing.JTable();
+ addSiteButton = new javax.swing.JButton();
+ editSiteButton = new javax.swing.JButton();
+ removeSiteButton = new javax.swing.JButton();
+ siteNameLabel = new javax.swing.JLabel();
+ siteNameTextField = new javax.swing.JTextField();
+ siteUrlLabel = new javax.swing.JLabel();
+ siteUrlTextField = new javax.swing.JTextField();
+ resetToDefaultButton = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("Download Sites");
+
+ sitesTable.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+
+ },
+ new String [] {
+ "Name", "URL"
+ }
+ ) {
+ boolean[] canEdit = new boolean [] {
+ false, false
+ };
+
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return canEdit [columnIndex];
+ }
+ });
+
sitesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+ sitesScrollPane.setViewportView(sitesTable);
+ sitesTable.getColumnModel().getColumn(0).setPreferredWidth(60);
+ sitesTable.getColumnModel().getColumn(1).setPreferredWidth(170);
+
+ addSiteButton.setText("Add");
+ addSiteButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ addSiteButtonActionPerformed(evt);
+ }
+ });
+
+ editSiteButton.setText("Edit");
+ editSiteButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ editSiteButtonActionPerformed(evt);
+ }
+ });
+
+ removeSiteButton.setText("Remove");
+ removeSiteButton.addActionListener(new java.awt.event.ActionListener()
{
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ removeSiteButtonActionPerformed(evt);
+ }
+ });
+
+ siteNameLabel.setText("Site Name");
+
+ siteUrlLabel.setText("URL");
+
+ siteUrlTextField.addActionListener(new java.awt.event.ActionListener()
{
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ siteUrlTextFieldActionPerformed(evt);
+ }
+ });
+
+ resetToDefaultButton.setText("Reset All to Default");
+
+ 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()
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(sitesScrollPane)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(addSiteButton)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(editSiteButton)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(removeSiteButton)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(resetToDefaultButton))
+ .addGroup(layout.createSequentialGroup()
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(siteUrlLabel)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(siteUrlTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, 258,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(siteNameLabel)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(siteNameTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, 139,
javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addGap(0, 0, Short.MAX_VALUE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(sitesScrollPane,
javax.swing.GroupLayout.PREFERRED_SIZE, 183,
javax.swing.GroupLayout.PREFERRED_SIZE)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(siteNameLabel)
+ .addComponent(siteNameTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(siteUrlLabel)
+ .addComponent(siteUrlTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE,
false)
+ .addComponent(addSiteButton,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addComponent(editSiteButton,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addComponent(removeSiteButton,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
+ .addComponent(resetToDefaultButton))
+ .addContainerGap())
+ );
+
+ pack();
+ }// </editor-fold>
+
+ private void addSiteButtonActionPerformed(java.awt.event.ActionEvent evt) {
+ // TODO add your handling code here:
+ }
+
+ private void editSiteButtonActionPerformed(java.awt.event.ActionEvent evt)
{
+ // TODO add your handling code here:
+ }
+
+ private void removeSiteButtonActionPerformed(java.awt.event.ActionEvent
evt) {
+ // TODO add your handling code here:
+ }
+
+ private void siteUrlTextFieldActionPerformed(java.awt.event.ActionEvent
evt) {
+ // TODO add your handling code here:
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ /*
+ * Set the Nimbus look and feel
+ */
+ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting
code (optional) ">
+ /*
+ * If Nimbus (introduced in Java SE 6) is not available, stay with the
+ * default look and feel. For details see
+ *
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
+ */
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+
java.util.logging.Logger.getLogger(ManageDownloadSitesDialog.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
+ } catch (InstantiationException ex) {
+
java.util.logging.Logger.getLogger(ManageDownloadSitesDialog.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
+ } catch (IllegalAccessException ex) {
+
java.util.logging.Logger.getLogger(ManageDownloadSitesDialog.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+
java.util.logging.Logger.getLogger(ManageDownloadSitesDialog.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
+ }
+ //</editor-fold>
+
+ /*
+ * Create and display the dialog
+ */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ public void run() {
+ ManageDownloadSitesDialog dialog = new
ManageDownloadSitesDialog(new javax.swing.JFrame(), true);
+ dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+
+ @Override
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ dialog.setVisible(true);
+ }
+ });
+ }
+}
\ No newline at end of file
Modified:
core3/impl/trunk/app-impl/src/test/java/org/cytoscape/app/internal/net/WebQuerierTest.java
===================================================================
---
core3/impl/trunk/app-impl/src/test/java/org/cytoscape/app/internal/net/WebQuerierTest.java
2012-08-22 20:50:01 UTC (rev 30251)
+++
core3/impl/trunk/app-impl/src/test/java/org/cytoscape/app/internal/net/WebQuerierTest.java
2012-08-22 20:52:39 UTC (rev 30252)
@@ -37,6 +37,8 @@
assertTrue(webQuerier.compareVersions("3.1", "") == 0);
assertTrue(webQuerier.compareVersions("", "3.1") == 0);
assertTrue(webQuerier.compareVersions("", "") == 0);
+
+ assertTrue(webQuerier.compareVersions("1.7",
"3.0.0.alpha9-SNAPSHOT") > 0);
}
@Test
--
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.