Author: kono
Date: 2010-10-01 16:55:19 -0700 (Fri, 01 Oct 2010)
New Revision: 22130

Added:
   
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/
   
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/CreateNewVisualStyleTask.java
   
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/CreateNewVisualStyleTaskFactory.java
   
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/RemoveVisualStyleTask.java
   
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/RemoveVisualStyleTaskFactory.java
Modified:
   core3/vizmap-gui-impl/branches/vp-tree/pom.xml
   
core3/vizmap-gui-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi-vizmapper.xml
   
core3/vizmap-gui-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-vizmapper.xml
Log:
Start converting Actions to general Task framework.

Modified: core3/vizmap-gui-impl/branches/vp-tree/pom.xml
===================================================================
--- core3/vizmap-gui-impl/branches/vp-tree/pom.xml      2010-10-01 23:26:20 UTC 
(rev 22129)
+++ core3/vizmap-gui-impl/branches/vp-tree/pom.xml      2010-10-01 23:55:19 UTC 
(rev 22130)
@@ -84,6 +84,12 @@
                        <artifactId>presentation-api</artifactId>
                        <version>1.0-SNAPSHOT</version>
                </dependency>
+               
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>work-api</artifactId>
+                       <version>1.0-SNAPSHOT</version>
+               </dependency>
 
                <dependency>
                        <groupId>cytoscape</groupId>

Added: 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/CreateNewVisualStyleTask.java
===================================================================
--- 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/CreateNewVisualStyleTask.java
                              (rev 0)
+++ 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/CreateNewVisualStyleTask.java
      2010-10-01 23:55:19 UTC (rev 22130)
@@ -0,0 +1,39 @@
+package org.cytoscape.view.vizmap.gui.internal.task;
+
+import org.cytoscape.view.model.VisualLexicon;
+import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.VisualStyleFactory;
+import org.cytoscape.view.vizmap.gui.internal.util.VizMapperUtil;
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CreateNewVisualStyleTask extends AbstractTask {
+
+       private static final Logger logger = 
LoggerFactory.getLogger(CreateNewVisualStyleTask.class);
+       
+       private final VisualStyleFactory vsFactory;
+       private final VizMapperUtil vizMapperUtil;
+       private final VisualLexicon lexicon;
+       
+       public CreateNewVisualStyleTask(final VizMapperUtil vizMapperUtil,
+                       final VisualStyleFactory vsFactory, final VisualLexicon 
lexicon) {
+               super();
+               this.vizMapperUtil = vizMapperUtil;
+               this.vsFactory = vsFactory;
+               this.lexicon = lexicon;
+       }
+
+       
+       public void run(TaskMonitor tm) {
+               final String title = vizMapperUtil.getStyleName(null, null);
+
+               if (title == null)
+                       return;
+
+               // Create new style
+               final VisualStyle newStyle = vsFactory.createVisualStyle(title, 
lexicon);
+               logger.info("CreateNewVisualStyleTask created new Visual Style: 
" + newStyle.getTitle());
+       }
+}
\ No newline at end of file

Added: 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/CreateNewVisualStyleTaskFactory.java
===================================================================
--- 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/CreateNewVisualStyleTaskFactory.java
                               (rev 0)
+++ 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/CreateNewVisualStyleTaskFactory.java
       2010-10-01 23:55:19 UTC (rev 22130)
@@ -0,0 +1,27 @@
+package org.cytoscape.view.vizmap.gui.internal.task;
+
+import org.cytoscape.view.model.VisualLexicon;
+import org.cytoscape.view.vizmap.VisualStyleFactory;
+import org.cytoscape.view.vizmap.gui.internal.util.VizMapperUtil;
+import org.cytoscape.work.TaskFactory;
+import org.cytoscape.work.TaskIterator;
+
+public class CreateNewVisualStyleTaskFactory implements TaskFactory {
+       
+       private final VizMapperUtil vizMapperUtil;
+       private final VisualStyleFactory vsFactory;
+       private final VisualLexicon lexicon;
+       
+       public CreateNewVisualStyleTaskFactory(final VizMapperUtil 
vizMapperUtil,
+       final VisualStyleFactory vsFactory, final VisualLexicon lexicon) {
+               this.lexicon = lexicon;
+               this.vizMapperUtil = vizMapperUtil;
+               this.vsFactory = vsFactory;
+       }
+
+       @Override
+       public TaskIterator getTaskIterator() {
+               return new TaskIterator(new 
CreateNewVisualStyleTask(vizMapperUtil, vsFactory, lexicon));
+       }
+
+}

Added: 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/RemoveVisualStyleTask.java
===================================================================
--- 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/RemoveVisualStyleTask.java
                         (rev 0)
+++ 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/RemoveVisualStyleTask.java
 2010-10-01 23:55:19 UTC (rev 22130)
@@ -0,0 +1,69 @@
+package org.cytoscape.view.vizmap.gui.internal.task;
+
+import javax.swing.JOptionPane;
+
+import org.cytoscape.session.CyNetworkManager;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.gui.internal.VizMapPropertySheetBuilder;
+import org.cytoscape.view.vizmap.gui.internal.VizMapperMainPanel;
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+
+public class RemoveVisualStyleTask extends AbstractTask {
+
+       private final VisualMappingManager vmm;
+       private final VizMapperMainPanel vizMapperMainPanel;
+       private final CyNetworkManager cyNetworkManager;
+       private final VizMapPropertySheetBuilder vizMapPropertySheetBuilder;
+
+       public RemoveVisualStyleTask(final VisualMappingManager vmm,
+                       final VizMapperMainPanel vizMapperMainPanel,
+                       final CyNetworkManager cyNetworkManager,
+                       final VizMapPropertySheetBuilder 
vizMapPropertySheetBuilder) {
+               this.vmm = vmm;
+               this.vizMapperMainPanel = vizMapperMainPanel;
+               this.cyNetworkManager = cyNetworkManager;
+               this.vizMapPropertySheetBuilder = vizMapPropertySheetBuilder;
+       }
+
+       @Override
+       public void run(TaskMonitor taskMonitor) throws Exception {
+
+               final VisualStyle currentStyle = this.vizMapperMainPanel
+                               .getSelectedVisualStyle();
+
+               if 
(currentStyle.equals(vizMapperMainPanel.getDefaultVisualStyle())) {
+                       JOptionPane.showMessageDialog(vizMapperMainPanel,
+                                       "You cannot delete default style.",
+                                       "Cannot remove defalut style!", 
JOptionPane.ERROR_MESSAGE);
+                       return;
+               }
+
+               // make sure the user really wants to do this
+               final String styleName = currentStyle.getTitle();
+               final String checkString = "Are you sure you want to 
permanently delete"
+                               + " the visual style '" + styleName + "'?";
+               int ich = JOptionPane.showConfirmDialog(vizMapperMainPanel,
+                               checkString, "Confirm Delete Style", 
JOptionPane.YES_NO_OPTION);
+
+               if (ich == JOptionPane.YES_OPTION) {
+
+                       vmm.removeVisualStyle(currentStyle);
+                       
vizMapperMainPanel.getDefaultImageManager().remove(currentStyle);
+                       
vizMapPropertySheetBuilder.getPropertyMap().remove(currentStyle);
+                       
+                       // Switch to the default style
+                       final VisualStyle defaultStyle = 
vizMapperMainPanel.getDefaultVisualStyle();
+
+                       vizMapperMainPanel.switchVS(defaultStyle);
+                       // Apply to the current view
+                       final CyNetworkView view = 
cyNetworkManager.getCurrentNetworkView();
+                       if (view != null)
+                               vmm.setVisualStyle(defaultStyle, view);
+               }
+
+       }
+
+}

Added: 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/RemoveVisualStyleTaskFactory.java
===================================================================
--- 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/RemoveVisualStyleTaskFactory.java
                          (rev 0)
+++ 
core3/vizmap-gui-impl/branches/vp-tree/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/RemoveVisualStyleTaskFactory.java
  2010-10-01 23:55:19 UTC (rev 22130)
@@ -0,0 +1,35 @@
+package org.cytoscape.view.vizmap.gui.internal.task;
+
+import org.cytoscape.session.CyNetworkManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.gui.internal.VizMapPropertySheetBuilder;
+import org.cytoscape.view.vizmap.gui.internal.VizMapperMainPanel;
+import org.cytoscape.work.TaskFactory;
+import org.cytoscape.work.TaskIterator;
+
+public class RemoveVisualStyleTaskFactory implements TaskFactory {
+
+       private final VisualMappingManager vmm;
+       private final VizMapperMainPanel vizMapperMainPanel;
+       private final CyNetworkManager cyNetworkManager;
+       private final VizMapPropertySheetBuilder vizMapPropertySheetBuilder;
+
+       public RemoveVisualStyleTaskFactory(final VisualMappingManager vmm,
+                       final VizMapperMainPanel vizMapperMainPanel,
+                       final CyNetworkManager cyNetworkManager,
+                       final VizMapPropertySheetBuilder 
vizMapPropertySheetBuilder) {
+               this.cyNetworkManager = cyNetworkManager;
+               this.vizMapperMainPanel = vizMapperMainPanel;
+               this.vizMapPropertySheetBuilder = vizMapPropertySheetBuilder;
+               this.vmm = vmm;
+
+       }
+
+       @Override
+       public TaskIterator getTaskIterator() {
+               return new TaskIterator(new RemoveVisualStyleTask(vmm,
+                               vizMapperMainPanel, cyNetworkManager,
+                               vizMapPropertySheetBuilder));
+       }
+
+}

Modified: 
core3/vizmap-gui-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi-vizmapper.xml
===================================================================
--- 
core3/vizmap-gui-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi-vizmapper.xml
 2010-10-01 23:26:20 UTC (rev 22129)
+++ 
core3/vizmap-gui-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-osgi-vizmapper.xml
 2010-10-01 23:55:19 UTC (rev 22130)
@@ -10,12 +10,15 @@
                auto-export="interfaces" />
        <osgi:service id="defaultViewEditorService" ref="defViewEditor"
                auto-export="interfaces" />
-               
-       <osgi:service id="nodeAttributeComboBoxEditorService" 
ref="nodeAttributeComboBoxEditor" auto-export="interfaces" />
-       <osgi:service id="edgeAttributeComboBoxEditorService" 
ref="edgeAttributeComboBoxEditor" auto-export="interfaces" />
-       <osgi:service id="networkAttributeComboBoxEditorService" 
ref="networkAttributeComboBoxEditor" auto-export="interfaces" />
-       
 
+       <osgi:service id="nodeAttributeComboBoxEditorService" 
ref="nodeAttributeComboBoxEditor"
+               auto-export="interfaces" />
+       <osgi:service id="edgeAttributeComboBoxEditorService" 
ref="edgeAttributeComboBoxEditor"
+               auto-export="interfaces" />
+       <osgi:service id="networkAttributeComboBoxEditorService"
+               ref="networkAttributeComboBoxEditor" auto-export="interfaces" />
+
+
        <!-- Value Editors -->
        <osgi:service id="colorEditorService" ref="colorEditor"
                auto-export="interfaces" />
@@ -35,13 +38,19 @@
                auto-export="interfaces" />
 
 
+       <osgi:reference id="taskManagerServiceRef" 
interface="org.cytoscape.work.swing.GUITaskManager" />
+       
        <osgi:reference id="visualStyleFactoryServiceRef"
                interface="org.cytoscape.view.vizmap.VisualStyleFactory" />
 
        <!-- For now, use DING rendering engine only. -->
        <osgi:reference id="dingVisualLexiconServiceRef"
-               interface="org.cytoscape.view.model.VisualLexicon" />
+               interface="org.cytoscape.view.model.VisualLexicon" 
filter="(id=ding)" />
 
+       <osgi:reference id="dingRenderingEngineFactoryServiceRef"
+               
interface="org.cytoscape.view.presentation.RenderingEngineFactory"
+               filter="(id=ding)" />
+
        <!-- Import Desktop Service -->
        <osgi:reference id="cytoscapeDesktopServiceRef"
                interface="cytoscape.view.CySwingApplication" />
@@ -73,10 +82,25 @@
        <osgi:reference id="cyTableManagerServiceRef" 
interface="org.cytoscape.model.CyTableManager" />
 
        <!-- Pull-down menu items -->
-       <!--<osgi:service id="createNewStyleActionService" 
ref="createNewStyleAction" 
-               interface="org.cytoscape.view.vizmap.gui.action.VizMapUIAction" 
/> -->
-       <osgi:service id="removeStyleActionService" ref="removeStyleAction"
-               interface="org.cytoscape.view.vizmap.gui.action.VizMapUIAction" 
/>
+
+       <osgi:service id="createNewVisualStyleTaskFactoryService"
+               ref="createNewVisualStyleTaskFactory" auto-export="interfaces">
+               <osgi:service-properties>
+                       <entry key="service.type" value="vizmapUI.taskFactory" 
/>
+                       <entry key="menu" value="main" />
+                       <entry key="title" value="Create New Visual Style" />
+               </osgi:service-properties>
+       </osgi:service>
+       <osgi:service id="removeVisualStyleTaskFactoryService"
+               ref="removeVisualStyleTaskFactory" auto-export="interfaces">
+               <osgi:service-properties>
+                       <entry key="service.type" value="vizmapUI.taskFactory" 
/>
+                       <entry key="menu" value="main" />
+                       <entry key="title" value="Remove Selected Visual Style" 
/>
+               </osgi:service-properties>
+       </osgi:service>
+
+       
        <osgi:service id="renameStyleActionService" ref="renameStyleAction"
                interface="org.cytoscape.view.vizmap.gui.action.VizMapUIAction" 
/>
        <osgi:service id="copyStyleActionService" ref="copyStyleAction"
@@ -144,6 +168,14 @@
                <osgi:listener bind-method="addValueEditor"
                        unbind-method="removeValueEditor" ref="editorManager" />
 
+       </osgi:set>
+
+       <osgi:set id="taskFactorySet"
+               interface="org.cytoscape.work.TaskFactory"
+               cardinality="0..N" filter="(service.type=vizmapUI.taskFactory)" 
>
+               <osgi:listener bind-method="addTaskFactory"
+                       unbind-method="removeTaskFactory" ref="menuManager" />
+
        </osgi:set>
 
 </beans>

Modified: 
core3/vizmap-gui-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-vizmapper.xml
===================================================================
--- 
core3/vizmap-gui-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-vizmapper.xml
      2010-10-01 23:26:20 UTC (rev 22129)
+++ 
core3/vizmap-gui-impl/branches/vp-tree/src/main/resources/META-INF/spring/bundle-context-vizmapper.xml
      2010-10-01 23:55:19 UTC (rev 22130)
@@ -135,11 +135,13 @@
        <bean id="iconManager"
                class="org.cytoscape.view.vizmap.gui.internal.theme.IconManager"
                scope="singleton" />
+               
        <bean id="menuManager"
                
class="org.cytoscape.view.vizmap.gui.internal.VizMapperMenuManager"
                scope="singleton" depends-on="iconManager" 
autowire="autodetect">
                <property name="generateMenuLabel" 
value="${vizMapperMainPanel.menu.generateMenu}" />
                <property name="generateIconId" 
value="${vizMapperMainPanel.menu.generateMenu.icon}" />
+               <constructor-arg ref="taskManagerServiceRef" />
        </bean>
 
        <bean name="defaultViewPanel"
@@ -170,16 +172,27 @@
        </bean>
 
 
-       <!-- Actions for Vizmapper. These actions will be exported as Service. 
<bean 
-               name="createNewStyleAction" 
class="org.cytoscape.view.vizmap.gui.internal.action.CreateNewStyleAction" 
-               autowire="autodetect" depends-on="vizMapperMainPanel"> 
<constructor-arg ref="vizMapperUtil" 
-               /> <constructor-arg ref="vmmServiceRef" /> <constructor-arg 
ref="cyNetworkManagerServiceRef" 
-               /> <property name="menuLabel" 
value="${vizMapperMainPanel.menu.createNewStyleAction}" 
-               /> <property name="iconId" 
value="${vizMapperMainPanel.menu.createNewStyleAction.icon}" 
-               /> </bean> -->
+       <!-- Task Factories for Vizmapper. These actions will be exported as 
Service. -->
 
+       <bean name="createNewVisualStyleTaskFactory"
+               
class="org.cytoscape.view.vizmap.gui.internal.task.CreateNewVisualStyleTaskFactory"
+               depends-on="vizMapperMainPanel">
+               <constructor-arg ref="visualStyleFactoryServiceRef" />
+               <constructor-arg ref="vizMapperUtil" />
+               <constructor-arg ref="dingVisualLexiconServiceRef" />
+       </bean>
+       
+       <bean name="removeVisualStyleTaskFactory"
+               
class="org.cytoscape.view.vizmap.gui.internal.task.RemoveVisualStyleTaskFactory"
+               depends-on="vizMapperMainPanel">
+               <constructor-arg ref="vmmServiceRef" />
+               <constructor-arg ref="vizMapperMainPanel" />
+               <constructor-arg ref="cyNetworkManagerServiceRef" />
+               <constructor-arg ref="vizMapPropertySheetBuilder" />
+       </bean>
 
-       <bean name="removeStyleAction"
+
+       <!--<bean name="removeStyleAction"
                
class="org.cytoscape.view.vizmap.gui.internal.action.RemoveStyleAction"
                autowire="autodetect" depends-on="vizMapperMainPanel">
                <property name="menuLabel" 
value="${vizMapperMainPanel.menu.removeStyleAction}" />
@@ -187,7 +200,7 @@
                        
value="${vizMapperMainPanel.menu.removeStyleAction.icon}" />
        </bean>
 
-       <bean name="renameStyleAction"
+       --><bean name="renameStyleAction"
                
class="org.cytoscape.view.vizmap.gui.internal.action.RenameStyleAction"
                autowire="autodetect" depends-on="vizMapperMainPanel">
                <property name="menuLabel" 
value="${vizMapperMainPanel.menu.renameStyleAction}" />
@@ -260,6 +273,8 @@
                <constructor-arg ref="vizMapPropertySheetBuilder" />
                <constructor-arg ref="propertySheetPanel" />
                <constructor-arg ref="vizMapperMainPanel" />
+               <constructor-arg ref="cyTableManagerServiceRef" />
+               <constructor-arg ref="cyNetworkManagerServiceRef" />
        </bean>
 
        <bean id="editorWindowManager"

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