Author: oriol
Date: 2012-07-05 08:45:55 -0700 (Thu, 05 Jul 2012)
New Revision: 29766

Modified:
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/session/NewSessionTask.java
   
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/session/NewSessionTaskFactoryImpl.java
   
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/session/NewSessionTaskTest.java
Log:
Fix Bug #1207. The tunable has been removed since in this case doesn't make 
sense. A dialog has been added to allow user to confirm the action.

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/session/NewSessionTask.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/session/NewSessionTask.java
       2012-07-05 06:49:53 UTC (rev 29765)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/session/NewSessionTask.java
       2012-07-05 15:45:55 UTC (rev 29766)
@@ -30,6 +30,8 @@
 package org.cytoscape.task.internal.session; 
 
 
+import javax.swing.JOptionPane;
+
 import org.cytoscape.session.CySessionManager;
 import org.cytoscape.work.AbstractTask;
 import org.cytoscape.work.ProvidesTitle;
@@ -39,24 +41,44 @@
 
 public class NewSessionTask extends AbstractTask {
 
-       @ProvidesTitle
+       /*@ProvidesTitle
        public String getTitle() {
                return "New Session";
        }
        
        @Tunable(description="<html>Current session (all networks/attributes) 
will be lost.<br />Do you want to continue?</html>")
-       public boolean destroyCurrentSession = true;
+       //public boolean destroyCurrentSession = true;*/
 
        private CySessionManager mgr;
+       private Boolean test;
        
        
-       public NewSessionTask(CySessionManager mgr) {
+       public NewSessionTask(CySessionManager mgr,Boolean test) {
                this.mgr = mgr;
+               this.test = test;
        }
 
        public void run(TaskMonitor taskMonitor) {
-               if (destroyCurrentSession) {
-                       mgr.setCurrentSession(null,null);                       
+               // Ask user whether to delete current session or not.
+               final String msg = "<html>Current session (all 
networks/attributes) will be lost.<br />Do you want to continue?</html>";
+               final String header ="New Session";
+               final Object[] options = { "Ok","Cancel" };
+               final int n ;
+               
+               if (test ) {
+                       mgr.setCurrentSession(null,null);
                }
+               else
+               {
+                       n = JOptionPane.showOptionDialog(null, msg, header,
+                                                                    
JOptionPane.OK_CANCEL_OPTION,
+                                                                    
JOptionPane.QUESTION_MESSAGE, 
+                                                                               
                         null, options, options[0]);
+                       if (n == JOptionPane.YES_OPTION  ) {
+                               mgr.setCurrentSession(null,null);
+                       }
+               }
+
+       
        }
 }

Modified: 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/session/NewSessionTaskFactoryImpl.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/session/NewSessionTaskFactoryImpl.java
    2012-07-05 06:49:53 UTC (rev 29765)
+++ 
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/session/NewSessionTaskFactoryImpl.java
    2012-07-05 15:45:55 UTC (rev 29766)
@@ -52,7 +52,7 @@
        }
 
        public TaskIterator createTaskIterator() {
-               return new TaskIterator(new NewSessionTask(mgr));
+               return new TaskIterator(new NewSessionTask(mgr,false));
        }
 
        @Override

Modified: 
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/session/NewSessionTaskTest.java
===================================================================
--- 
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/session/NewSessionTaskTest.java
   2012-07-05 06:49:53 UTC (rev 29765)
+++ 
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/session/NewSessionTaskTest.java
   2012-07-05 15:45:55 UTC (rev 29766)
@@ -22,7 +22,7 @@
 
        @Test
        public void testRun() throws Exception {
-               final NewSessionTask t = new NewSessionTask(mgr);
+               final NewSessionTask t = new NewSessionTask(mgr,true);
 
                t.run(tm);
                verify(mgr, times(1)).setCurrentSession(null, null);

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