Author: mes
Date: 2010-11-15 17:42:53 -0800 (Mon, 15 Nov 2010)
New Revision: 22862

Added:
   csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/assembly/
   csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/assembly/src.xml
   
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/DeleteFileInGenomeSpace.java
   
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/DownloadFileFromGenomeSpace.java
   
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/ListFilesInGenomeSpace.java
Modified:
   csplugins/trunk/ucsd/mes/genomespace-plugin/pom.xml
   
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/GenomeSpacePlugin.java
   
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/UploadFileToGenomeSpace.java
Log:
added a bunch of new actions

Modified: csplugins/trunk/ucsd/mes/genomespace-plugin/pom.xml
===================================================================
--- csplugins/trunk/ucsd/mes/genomespace-plugin/pom.xml 2010-11-15 23:30:05 UTC 
(rev 22861)
+++ csplugins/trunk/ucsd/mes/genomespace-plugin/pom.xml 2010-11-16 01:42:53 UTC 
(rev 22862)
@@ -6,7 +6,7 @@
   <artifactId>genomespace-plugin</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>jar</packaging>
-  <name>sample-plugin</name>
+  <name>GenomeSpace Plugin</name>
 
   <build>
     <plugins>
@@ -22,24 +22,18 @@
         </configuration>
       </plugin>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.2-beta-5</version>
         <configuration>
           <archive>
             <manifestEntries>
               
<Cytoscape-Plugin>cytoscape.genomespace.GenomeSpacePlugin</Cytoscape-Plugin>
             </manifestEntries>
           </archive>
+          <descriptors>
+            <descriptor>src/main/assembly/src.xml</descriptor>
+          </descriptors>
         </configuration>
-      </plugin>
-      <plugin>
-        <artifactId>maven-assembly-plugin</artifactId>
-        <version>2.2-beta-5</version>
-        <configuration>
-          <descriptorRefs>
-            <descriptorRef>jar-with-dependencies</descriptorRef>
-          </descriptorRefs>
-        </configuration>
         <executions>
           <execution>
             <id>make-assembly</id>
@@ -109,7 +103,7 @@
     <dependency>
       <groupId>org.codehaus.jettison</groupId>
       <artifactId>jettison</artifactId>
-      <version>1.2</version>
+      <version>1.1</version>
     </dependency>
     <dependency>
       <groupId>com.sun.jersey</groupId>

Added: csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/assembly/src.xml
===================================================================
--- csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/assembly/src.xml       
                        (rev 0)
+++ csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/assembly/src.xml       
2010-11-16 01:42:53 UTC (rev 22862)
@@ -0,0 +1,18 @@
+<assembly 
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
 http://maven.apache.org/xsd/assembly-1.1.0.xsd";>
+  <id>jar-with-dependencies</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>/</outputDirectory>
+      <useProjectArtifact>true</useProjectArtifact>
+      <unpack>true</unpack>
+      <scope>runtime</scope>
+         <useTransitiveDependencies>false</useTransitiveDependencies>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Added: 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/DeleteFileInGenomeSpace.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/DeleteFileInGenomeSpace.java
                                (rev 0)
+++ 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/DeleteFileInGenomeSpace.java
        2010-11-16 01:42:53 UTC (rev 22862)
@@ -0,0 +1,61 @@
+package cytoscape.genomespace;
+
+import cytoscape.Cytoscape;
+import cytoscape.util.CytoscapeAction;
+import cytoscape.util.FileUtil;
+import cytoscape.logger.CyLogger;
+import java.awt.event.ActionEvent;
+import javax.swing.JOptionPane;
+
+import java.io.File;
+import java.awt.FileDialog;
+import java.util.List;
+
+import org.genomespace.client.GsFile;
+import org.genomespace.client.GsSession;
+import org.genomespace.client.User;
+
+/**
+ * A simple action.  Change the names as appropriate and
+ * then fill in your expected behavior in the actionPerformed()
+ * method.
+ */
+public class DeleteFileInGenomeSpace extends CytoscapeAction {
+
+       private static final long serialVersionUID = 4234432889999989L;
+       private static final CyLogger logger = 
CyLogger.getLogger(DeleteFileInGenomeSpace.class);
+
+       public DeleteFileInGenomeSpace() {
+               // Give your action a name here
+               super("Delete File");
+
+               // Set the menu you'd like here.  Plugins don't need
+               // to live in the Plugins menu, so choose whatever
+               // is appropriate!
+        setPreferredMenu("Plugins.GenomeSpace");
+       }
+
+       public void actionPerformed(ActionEvent e) {
+
+               try {
+
+               // login to GenomeSpace
+               GsSession client = new GsSession();
+               String username = "test";
+               String password = "password";
+               User user = client.login(username, password);
+               logger.info("Logged in to GenomeSpace: " + client.isLoggedIn() 
+ " as " + user.getUsername());
+
+               // list the files present for this user
+               List<GsFile> myFiles = client.list();
+               if (myFiles.size() > 0){
+                       logger.info("Deleting " + myFiles.get(0).getFilename());
+                       client.delete(myFiles.get(0));
+               }
+
+               } catch (Exception ex) {
+                       logger.error("GenomeSpace failed",ex);
+               }
+       }
+
+}

Added: 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/DownloadFileFromGenomeSpace.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/DownloadFileFromGenomeSpace.java
                            (rev 0)
+++ 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/DownloadFileFromGenomeSpace.java
    2010-11-16 01:42:53 UTC (rev 22862)
@@ -0,0 +1,64 @@
+package cytoscape.genomespace;
+
+import cytoscape.Cytoscape;
+import cytoscape.util.CytoscapeAction;
+import cytoscape.util.FileUtil;
+import cytoscape.logger.CyLogger;
+import java.awt.event.ActionEvent;
+import javax.swing.JOptionPane;
+
+import java.io.File;
+import java.awt.FileDialog;
+import java.util.List;
+
+import org.genomespace.client.GsFile;
+import org.genomespace.client.GsSession;
+import org.genomespace.client.User;
+
+/**
+ * A simple action.  Change the names as appropriate and
+ * then fill in your expected behavior in the actionPerformed()
+ * method.
+ */
+public class DownloadFileFromGenomeSpace extends CytoscapeAction {
+
+       private static final long serialVersionUID = 7777788473487659L;
+       private static final CyLogger logger = 
CyLogger.getLogger(DownloadFileFromGenomeSpace.class);
+
+       public DownloadFileFromGenomeSpace() {
+               // Give your action a name here
+               super("Download File");
+
+               // Set the menu you'd like here.  Plugins don't need
+               // to live in the Plugins menu, so choose whatever
+               // is appropriate!
+        setPreferredMenu("Plugins.GenomeSpace");
+       }
+
+       public void actionPerformed(ActionEvent e) {
+
+               try {
+
+               // login to GenomeSpace
+               GsSession client = new GsSession();
+               String username = "test";
+               String password = "password";
+               User user = client.login(username, password);
+               logger.info("Logged in to GenomeSpace: " + client.isLoggedIn() 
+ " as " + user.getUsername());
+
+               // list the files present for this user
+               List<GsFile> myFiles = client.list();
+
+               // Download the file back from GenomeSpace
+               myFiles = client.list();
+               if (myFiles.size() > 0){
+                       logger.info("Downloading " + 
myFiles.get(0).getFilename());
+                       GsFile localCopy = client.downloadFile(myFiles.get(0));
+                       logger.info("\t saved to: " + 
localCopy.getFile().getAbsolutePath());
+               }
+       
+               } catch (Exception ex) {
+                       logger.error("GenomeSpace failed",ex);
+               }
+       }
+}

Modified: 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/GenomeSpacePlugin.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/GenomeSpacePlugin.java
      2010-11-15 23:30:05 UTC (rev 22861)
+++ 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/GenomeSpacePlugin.java
      2010-11-16 01:42:53 UTC (rev 22862)
@@ -17,7 +17,17 @@
                super();
 
                // This action represents the actual behavior of the plugin.
-               UploadFileToGenomeSpace action = new UploadFileToGenomeSpace();
-               Cytoscape.getDesktop().getCyMenus().addAction(action);
+               UploadFileToGenomeSpace uploadAction = new 
UploadFileToGenomeSpace();
+               Cytoscape.getDesktop().getCyMenus().addAction(uploadAction);
+
+               DeleteFileInGenomeSpace deleteAction = new 
DeleteFileInGenomeSpace();
+               Cytoscape.getDesktop().getCyMenus().addAction(deleteAction);
+
+               DownloadFileFromGenomeSpace downloadAction = new 
DownloadFileFromGenomeSpace();
+               Cytoscape.getDesktop().getCyMenus().addAction(downloadAction);
+
+               ListFilesInGenomeSpace listAction = new 
ListFilesInGenomeSpace();
+               Cytoscape.getDesktop().getCyMenus().addAction(listAction);
+       
        }
 }      

Added: 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/ListFilesInGenomeSpace.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/ListFilesInGenomeSpace.java
                         (rev 0)
+++ 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/ListFilesInGenomeSpace.java
 2010-11-16 01:42:53 UTC (rev 22862)
@@ -0,0 +1,79 @@
+package cytoscape.genomespace;
+
+import cytoscape.Cytoscape;
+import cytoscape.util.CytoscapeAction;
+import cytoscape.util.FileUtil;
+import cytoscape.logger.CyLogger;
+import java.awt.event.ActionEvent;
+import javax.swing.JOptionPane;
+import javax.swing.JList;
+import javax.swing.JScrollPane;
+import javax.swing.JPanel;
+import javax.swing.ListSelectionModel;
+
+import java.io.File;
+import java.awt.FileDialog;
+import java.awt.Dimension;
+import java.util.List;
+import java.util.Vector;
+
+import org.genomespace.client.GsFile;
+import org.genomespace.client.GsSession;
+import org.genomespace.client.User;
+
+/**
+ * A simple action.  Change the names as appropriate and
+ * then fill in your expected behavior in the actionPerformed()
+ * method.
+ */
+public class ListFilesInGenomeSpace extends CytoscapeAction {
+
+       private static final long serialVersionUID = 1234487711999989L;
+       private static final CyLogger logger = 
CyLogger.getLogger(ListFilesInGenomeSpace.class);
+
+       public ListFilesInGenomeSpace() {
+               // Give your action a name here
+               super("List Available Files");
+
+               // Set the menu you'd like here.  Plugins don't need
+               // to live in the Plugins menu, so choose whatever
+               // is appropriate!
+        setPreferredMenu("Plugins.GenomeSpace");
+       }
+
+       public void actionPerformed(ActionEvent e) {
+
+               try {
+
+               // login to GenomeSpace
+               GsSession client = new GsSession();
+               String username = "test";
+               String password = "password";
+               User user = client.login(username, password);
+               logger.info("Logged in to GenomeSpace: " + client.isLoggedIn() 
+ " as " + user.getUsername());
+
+               // list the files present for this user
+               List<GsFile> myFiles = client.list();
+               logger.info("Files on GenomeSpace for " + user.getUsername());
+               Vector<String> fileNames = new Vector<String>();
+               for (GsFile aFile: myFiles) {
+                       fileNames.add(aFile.getFilename());
+               }
+
+               displayFiles(fileNames);
+       
+               } catch (Exception ex) {
+                       logger.error("GenomeSpace failed",ex);
+               }
+       }
+
+       private void displayFiles(Vector<String> fileNames) {
+               JList jl = new JList( fileNames );
+               jl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+               JScrollPane scrollPane = new JScrollPane(jl);
+               scrollPane.setPreferredSize(new Dimension(250, 80));
+               JPanel jp = new JPanel();
+               jp.add(scrollPane);
+               JOptionPane.showMessageDialog(Cytoscape.getDesktop(),jp);
+       }
+}

Modified: 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/UploadFileToGenomeSpace.java
===================================================================
--- 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/UploadFileToGenomeSpace.java
        2010-11-15 23:30:05 UTC (rev 22861)
+++ 
csplugins/trunk/ucsd/mes/genomespace-plugin/src/main/java/cytoscape/genomespace/UploadFileToGenomeSpace.java
        2010-11-16 01:42:53 UTC (rev 22862)
@@ -42,55 +42,15 @@
                if ( f == null )
                        return;
 
-               // login to GenomeSpace
                GsSession client = new GsSession();
                String username = "test";
                String password = "password";
                User user = client.login(username, password);
-               System.out.println("Logged in to GenomeSpace: " + 
client.isLoggedIn() + " as " + user.getUsername());
+               logger.info("Logged in to GenomeSpace: " + client.isLoggedIn() 
+ " as " + user.getUsername());
 
-       
-       
-
                GsFile gsf = new GsFile(f); 
                client.uploadFile(gsf);
        
-               // list the files present for this user
-               List<GsFile> myFiles = client.list();
-               System.out.println("Files on GenomeSpace for " + 
user.getUsername());
-               for (GsFile aFile: myFiles){
-                       System.out.println("\t" + aFile.getFilename());
-               }
-       
-               // Download the file back from GenomeSpace
-               myFiles = client.list();
-               if (myFiles.size() > 0){
-                       System.out.println("Downloading " + 
myFiles.get(0).getFilename());
-                       GsFile localCopy = client.downloadFile(myFiles.get(0));
-                       System.out.println("\t saved to: " + 
localCopy.getFile().getAbsolutePath());
-               }
-       
-
-               // Delete a file from GenomeSpace
-               myFiles = client.list();
-               if (myFiles.size() > 0){
-                       System.out.println("Deleting " + 
myFiles.get(0).getFilename());
-                       client.delete(myFiles.get(0));
-               }
-               myFiles = client.list();
-               System.out.println("After deletion, files on GenomeSpace for " 
+ user.getUsername());
-               for (GsFile aFile: myFiles){
-                       System.out.println("\t" + aFile.getFilename());
-               }
-       
-       
-               // register a new user account
-               // (note this will fail for a duplicate username since there 
can only be one account for each name)
-               String newUsername = "test_cdk_" + System.currentTimeMillis();
-               GsSession newClient = new GsSession();
-
-               User newUser = newClient.registerUser(newUsername, "password", 
"[email protected]");
-               System.out.println("Logged in to GenomeSpace: " + 
newClient.isLoggedIn() +" as " + newUser.getUsername());
                } catch (Exception ex) {
                        logger.error("GenomeSpace failed",ex);
                }

-- 
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.

Reply via email to