Author: kono
Date: 2012-06-15 16:29:35 -0700 (Fri, 15 Jun 2012)
New Revision: 29587

Added:
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetBypassTask.java
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetEdgeBypassTaskFactory.java
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetNodeBypassTaskFactory.java
Removed:
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/EdgeBypassMenuListener.java
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/NodeBypassMenuListener.java
Modified:
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/BypassManager.java
Log:
refs #1118 Clear all bypass menu implemented.

Modified: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
      2012-06-15 22:11:26 UTC (rev 29586)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
      2012-06-15 23:29:35 UTC (rev 29587)
@@ -143,7 +143,7 @@
                DefaultTableCellRenderer emptyBoxRenderer = new 
DefaultTableCellRenderer();
                DefaultTableCellRenderer filledBoxRenderer = new 
DefaultTableCellRenderer();
                VizMapEventHandlerManagerImpl vizMapEventHandlerManager = new 
VizMapEventHandlerManagerImpl(vmmServiceRef, 
editorManager,vizMapPropertySheetBuilder,propertySheetPanel,vizMapperMainPanel,cyNetworkTableManagerServiceRef,cyApplicationManagerServiceRef,attributeSetManager,vizMapperUtil);
-               BypassManager bypassManager = new 
BypassManager(cyServiceRegistrarServiceRef,editorManager, vmmServiceRef);
+               BypassManager bypassManager = new 
BypassManager(cyServiceRegistrarServiceRef,editorManager, vmmServiceRef, 
cyApplicationManagerServiceRef);
                
                // Context menu for edge bend
                BendFactory bf = getService(bc, BendFactory.class);

Modified: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/BypassManager.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/BypassManager.java
     2012-06-15 22:11:26 UTC (rev 29586)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/BypassManager.java
     2012-06-15 23:29:35 UTC (rev 29587)
@@ -8,7 +8,9 @@
 import java.util.Properties;
 import java.util.Vector;
 
+import org.cytoscape.application.CyApplicationManager;
 import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyIdentifiable;
 import org.cytoscape.model.CyNode;
 import org.cytoscape.service.util.CyServiceRegistrar;
 import org.cytoscape.task.EdgeViewTaskFactory;
@@ -38,12 +40,14 @@
        private final CyServiceRegistrar registrar;
        private final EditorManager editorManager;
        private final VisualMappingManager vmm;
+       private final CyApplicationManager appManager;
 
        public BypassManager(final CyServiceRegistrar registrar, final 
EditorManager editorManager,
-                       final VisualMappingManager vmm) {
+                       final VisualMappingManager vmm, final 
CyApplicationManager appManager) {
                this.registrar = registrar;
                this.editorManager = editorManager;
                this.vmm = vmm;
+               this.appManager = appManager;
        }
 
        public void addBypass(RenderingEngineFactory<?> factory, Map props) {
@@ -60,13 +64,32 @@
                final VisualLexiconNode nodeRootNode = 
lexicon.getVisualLexiconNode(nodeRoot);
                final VisualLexiconNode edgeRootNode = 
lexicon.getVisualLexiconNode(edgeRoot);
 
+               
+               registerResetTask(CyNode.class);
+               registerResetTask(CyEdge.class);
                depthFirst(PARENT_MENU_ITEM, nodeRootNode);
                depthFirst(PARENT_MENU_ITEM, edgeRootNode);
+               
+               
        }
 
        public void removeBypass(RenderingEngineFactory<?> factory, Map props) {
                // TODO: implement this
        }
+       
+       private void registerResetTask(Class<? extends CyIdentifiable> type) {
+               final Properties vpProp = new Properties();
+               
+               if (type.equals(CyNode.class)) {
+                       vpProp.put(ServiceProperties.PREFERRED_MENU, 
PARENT_MENU_ITEM + ".Reset All Node Bypass");
+                       final NodeViewTaskFactory ntf = new 
ResetNodeBypassTaskFactory(appManager);
+                       registrar.registerService(ntf, 
NodeViewTaskFactory.class, vpProp);
+               } else if (type.equals(CyEdge.class)) {
+                       vpProp.put(ServiceProperties.PREFERRED_MENU, 
PARENT_MENU_ITEM + ".Reset All Edge Bypass");
+                       final EdgeViewTaskFactory etf = new 
ResetEdgeBypassTaskFactory(appManager);
+                       registrar.registerService(etf, 
EdgeViewTaskFactory.class, vpProp);
+               }
+       }
 
        private void depthFirst(String menuText, final VisualLexiconNode node) {
                

Deleted: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/EdgeBypassMenuListener.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/EdgeBypassMenuListener.java
    2012-06-15 22:11:26 UTC (rev 29586)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/EdgeBypassMenuListener.java
    2012-06-15 23:29:35 UTC (rev 29587)
@@ -1,68 +0,0 @@
-/*
- File: EdgeBypassMenuListener.java
-
- Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-package org.cytoscape.view.vizmap.gui.internal.bypass;
-
-import org.cytoscape.view.vizmap.gui.editor.EditorManager;
-
-
-/**
- * EdgeBypassMenuListener implements EdgeContextMenuListener
- * When a node is selected it calls bypass andd add
- */
-//class EdgeBypassMenuListener
-//    implements EdgeContextMenuListener {
-
-class EdgeBypassMenuListener {
-       private EditorManager ef;
-    EdgeBypassMenuListener(EditorManager ef) {
-               this.ef = ef;
-    }
-
-    //FIXME!!
-//    /**
-//     * @param nodeView The clicked EdgeView
-//     * @param menu popup menu to add the Bypass menu
-//     */
-//    public void addEdgeContextMenuItems(EdgeView edgeView, JPopupMenu menu) {
-//        EdgeBypass eb = new EdgeBypass(ef);
-//
-//        if (menu == null)
-//            menu = new JPopupMenu();
-//
-//        menu.add(eb.addMenu(edgeView.getEdge()));
-//    }
-}

Deleted: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/NodeBypassMenuListener.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/NodeBypassMenuListener.java
    2012-06-15 22:11:26 UTC (rev 29586)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/NodeBypassMenuListener.java
    2012-06-15 23:29:35 UTC (rev 29587)
@@ -1,57 +0,0 @@
-/*
- File: NodeBypassMenuListener.java
-
- Copyright (c) 2006, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-package org.cytoscape.view.vizmap.gui.internal.bypass;
-
-import org.cytoscape.view.vizmap.gui.editor.EditorManager;
-
-/**
- * NodeBypassMenuListener implements NodeContextMenuListener When a node is
- * selected it calls bypass andd add
- */
-
-
-
-//TODO: fix by using new task framework
-// class NodeBypassMenuListener implements NodeContextMenuListener {
-class NodeBypassMenuListener {
-
-       private EditorManager ef;
-
-       NodeBypassMenuListener(EditorManager ef) {
-               this.ef = ef;
-       }
-}

Added: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetBypassTask.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetBypassTask.java
                           (rev 0)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetBypassTask.java
   2012-06-15 23:29:35 UTC (rev 29587)
@@ -0,0 +1,52 @@
+package org.cytoscape.view.vizmap.gui.internal.bypass;
+
+import java.util.Collection;
+
+import org.cytoscape.model.CyIdentifiable;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.model.VisualLexicon;
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.presentation.property.BasicVisualLexicon;
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+
+public class ResetBypassTask extends AbstractTask {
+
+       private final View<? extends CyIdentifiable> view;
+       private final CyNetworkView networkView;
+
+       private final Collection<VisualProperty<?>> vpSet;
+
+       public ResetBypassTask(final VisualLexicon lexicon, final View<? 
extends CyIdentifiable> view,
+                       final CyNetworkView networkView) {
+               this.view = view;
+               this.networkView = networkView;
+
+               final CyIdentifiable model = view.getModel();
+               if (model instanceof CyNode) {
+                       vpSet = 
lexicon.getAllDescendants(BasicVisualLexicon.NODE);
+               } else {
+                       vpSet = 
lexicon.getAllDescendants(BasicVisualLexicon.EDGE);
+               }
+       }
+
+       @Override
+       public void run(TaskMonitor taskMonitor) throws Exception {
+
+               boolean needToUpdateView = false;
+               
+               for (VisualProperty<?> vp : vpSet) {
+                       final boolean lock = view.isValueLocked(vp);
+                       if (lock) {
+                               view.clearValueLock(vp);
+                               needToUpdateView = true;
+                       }
+               }
+               
+               if(needToUpdateView)
+                       networkView.updateView();
+       }
+
+}

Added: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetEdgeBypassTaskFactory.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetEdgeBypassTaskFactory.java
                                (rev 0)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetEdgeBypassTaskFactory.java
        2012-06-15 23:29:35 UTC (rev 29587)
@@ -0,0 +1,25 @@
+package org.cytoscape.view.vizmap.gui.internal.bypass;
+
+import org.cytoscape.application.CyApplicationManager;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.task.AbstractEdgeViewTaskFactory;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.work.TaskIterator;
+
+public class ResetEdgeBypassTaskFactory extends AbstractEdgeViewTaskFactory {
+
+       private final CyApplicationManager applicationManager;
+
+       public ResetEdgeBypassTaskFactory(final CyApplicationManager 
applicationManager) {
+               this.applicationManager = applicationManager;
+       }
+
+       @Override
+       public TaskIterator createTaskIterator(View<CyEdge> edgeView, 
CyNetworkView networkView) {
+               return new TaskIterator(new 
ResetBypassTask(applicationManager.getCurrentRenderingEngine().getVisualLexicon(),
+                               edgeView, networkView));
+       }
+
+}

Added: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetNodeBypassTaskFactory.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetNodeBypassTaskFactory.java
                                (rev 0)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/bypass/ResetNodeBypassTaskFactory.java
        2012-06-15 23:29:35 UTC (rev 29587)
@@ -0,0 +1,24 @@
+package org.cytoscape.view.vizmap.gui.internal.bypass;
+
+import org.cytoscape.application.CyApplicationManager;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.task.AbstractNodeViewTaskFactory;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.View;
+import org.cytoscape.work.TaskIterator;
+
+public class ResetNodeBypassTaskFactory extends AbstractNodeViewTaskFactory {
+
+       private final CyApplicationManager applicationManager;
+
+       public ResetNodeBypassTaskFactory(final CyApplicationManager 
applicationManager) {
+               this.applicationManager = applicationManager;
+       }
+
+       @Override
+       public TaskIterator createTaskIterator(View<CyNode> nodeView, 
CyNetworkView networkView) {
+               return new TaskIterator(new 
ResetBypassTask(applicationManager.getCurrentRenderingEngine().getVisualLexicon(),
+                               nodeView, networkView));
+       }
+
+}
\ No newline at end of file

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