Author: kono
Date: 2011-12-12 13:49:39 -0800 (Mon, 12 Dec 2011)
New Revision: 27770

Modified:
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/AbstractVizMapperPanel.java
   
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/SetViewModeAction.java
   
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
Log:
fixes #475 Show All Visual Properties Button had been added.  Need to create 
new icon for this button!

Modified: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/AbstractVizMapperPanel.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/AbstractVizMapperPanel.java
   2011-12-12 21:02:21 UTC (rev 27769)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/AbstractVizMapperPanel.java
   2011-12-12 21:49:39 UTC (rev 27770)
@@ -33,8 +33,10 @@
 import java.awt.GridBagLayout;
 import java.awt.Image;
 import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.beans.PropertyChangeSupport;
 import java.beans.PropertyEditor;
+import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -47,6 +49,7 @@
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
+import javax.swing.JToggleButton;
 import javax.swing.LayoutStyle;
 import javax.swing.event.SwingPropertyChangeSupport;
 import javax.swing.table.DefaultTableCellRenderer;
@@ -151,6 +154,9 @@
        protected SwingPropertyChangeSupport spcs;
 
        protected final VisualStyleFactory vsFactory;
+       
+       private JToggleButton showAllVPButton;
+       private final SetViewModeAction viewModeAction;
 
        protected static final long serialVersionUID = -6839011300709287662L;
 
@@ -162,7 +168,7 @@
                        VizMapPropertySheetBuilder vizMapPropertySheetBuilder,
                        EditorWindowManager editorWindowManager,
                        CyApplicationManager applicationManager, CyEventHelper 
eventHelper,
-                       final SelectedVisualStyleManager manager) {
+                       final SelectedVisualStyleManager manager, final 
SetViewModeAction viewModeAction) {
                
                if(menuMgr == null)
                        throw new NullPointerException("Menu manager is 
missing.");
@@ -180,6 +186,7 @@
                this.editorWindowManager = editorWindowManager;
                this.applicationManager = applicationManager;
                this.eventHelper = eventHelper;
+               this.viewModeAction = viewModeAction;
 
                editorReg = new PropertyEditorRegistry();
                rendReg = new PropertyRendererRegistry();
@@ -193,13 +200,45 @@
 
                initComponents();
                initDefaultEditors();
+               
+               // This is a hack: Add extra button to the UI.
+               addButtonToPropertySheetPanel();
        }
+       
+       private void addButtonToPropertySheetPanel() {
+               showAllVPButton = new JToggleButton();
+               showAllVPButton.setText("Show All");
+               // This is a hack: get private component and add button.
+               Field[] fields = PropertySheetPanel.class.getDeclaredFields();
+               showAllVPButton.addActionListener(new ActionListener() {
+                       
+                       @Override
+                       public void actionPerformed(ActionEvent ae) {
+                               viewModeAction.menuSelected(null);
+                               viewModeAction.actionPerformed(null);
+                       }
+               });
+               
+               showAllVPButton.setUI(new BlueishButtonUI());
+               showAllVPButton.setText("Show All");
+               showAllVPButton.setToolTipText("Show all Visual Properties");
+               
+               for (Field f : fields) {
+                       if (f.getName().equals("actionPanel")) {
+                               f.setAccessible(true);
+                               try {
+                                       JPanel buttonPanel = (JPanel) 
f.get(propertySheetPanel);
+                                       buttonPanel.add(showAllVPButton);
+                               } catch (IllegalArgumentException e) {
+                                       e.printStackTrace();
+                               } catch (IllegalAccessException e) {
+                                       e.printStackTrace();
+                               }
+                       }
+               }
+       }
 
        private void initDefaultEditors() {
-               // nodeAttrEditor =
-               // editorManager.getDefaultComboBoxEditor("nodeAttrEditor");
-               // edgeAttrEditor =
-               // editorManager.getDefaultComboBoxEditor("edgeAttrEditor");
                nodeNumericalAttrEditor = editorManager
                                
.getDefaultComboBoxEditor("nodeNumericalAttrEditor");
                edgeNumericalAttrEditor = editorManager

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
      2011-12-12 21:02:21 UTC (rev 27769)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/CyActivator.java
      2011-12-12 21:49:39 UTC (rev 27770)
@@ -2,9 +2,13 @@
 package org.cytoscape.view.vizmap.gui.internal;
 
 import java.awt.Color;
+import java.awt.Component;
 import java.awt.Paint;
+import java.lang.reflect.Field;
 import java.util.Properties;
 
+import javax.swing.JButton;
+import javax.swing.JPanel;
 import javax.swing.table.DefaultTableCellRenderer;
 
 import org.cytoscape.application.CyApplicationConfiguration;
@@ -95,6 +99,7 @@
                MappingFunctionFactoryManagerImpl mappingFunctionFactoryManager 
= new MappingFunctionFactoryManagerImpl(editorManager);
                DefaultVisualStyleBuilder defaultVisualStyleBuilder = new 
DefaultVisualStyleBuilder(visualStyleFactoryServiceRef,passthroughMappingFactoryRef);
                PropertySheetPanel propertySheetPanel = new 
PropertySheetPanel();
+               
                CyColorChooser colorEditor = new CyColorChooser();
                FontEditor fontEditor = new FontEditor();
                NumericValueEditor doubleValueEditor = new 
NumericValueEditor(Double.class);
@@ -118,7 +123,9 @@
                ImportDefaultVizmapTaskFactory importDefaultVizmapTaskFactory = 
new 
ImportDefaultVizmapTaskFactory(vizmapReaderManagerServiceRef,vmmServiceRef,cyApplicationConfigurationServiceRef,
 cyEventHelperServiceRef);
                VizMapPropertySheetBuilder vizMapPropertySheetBuilder = new 
VizMapPropertySheetBuilder(menuManager,cyNetworkManagerServiceRef,propertySheetPanel,editorManager,defaultViewPanel,cyTableManagerServiceRef,vizMapperUtil,vmmServiceRef);
                EditorWindowManager editorWindowManager = new 
EditorWindowManager(editorManager,propertySheetPanel);
-               VizMapperMainPanel vizMapperMainPanel = new 
VizMapperMainPanel(visualStyleFactoryServiceRef,defViewEditor,iconManager,colorMgr,vmmServiceRef,menuManager,editorManager,propertySheetPanel,vizMapPropertySheetBuilder,editorWindowManager,cyApplicationManagerServiceRef,cyEventHelperServiceRef,selectedVisualStyleManager,importDefaultVizmapTaskFactory,dialogTaskManagerServiceRef);
+               
+               SetViewModeAction viewModeAction = new 
SetViewModeAction(cyApplicationManagerServiceRef);
+               VizMapperMainPanel vizMapperMainPanel = new 
VizMapperMainPanel(visualStyleFactoryServiceRef,defViewEditor,iconManager,colorMgr,vmmServiceRef,menuManager,editorManager,propertySheetPanel,vizMapPropertySheetBuilder,editorWindowManager,cyApplicationManagerServiceRef,cyEventHelperServiceRef,selectedVisualStyleManager,importDefaultVizmapTaskFactory,dialogTaskManagerServiceRef,viewModeAction
 );
                RenameVisualStyleTaskFactory renameVisualStyleTaskFactory = new 
RenameVisualStyleTaskFactory(vmmServiceRef,selectedVisualStyleManager,vizMapperUtil,vizMapperMainPanel);
                CopyVisualStyleTaskFactory copyVisualStyleTaskFactory = new 
CopyVisualStyleTaskFactory(vmmServiceRef,visualStyleFactoryServiceRef,selectedVisualStyleManager,vizMapperUtil,vizMapperMainPanel);
                CreateLegendTaskFactory createLegendTaskFactory = new 
CreateLegendTaskFactory(selectedVisualStyleManager,vizMapperMainPanel);
@@ -135,7 +142,7 @@
                VizMapEventHandlerManagerImpl vizMapEventHandlerManager = new 
VizMapEventHandlerManagerImpl(selectedVisualStyleManager,editorManager,vizMapPropertySheetBuilder,propertySheetPanel,vizMapperMainPanel,cyNetworkTableManagerServiceRef,cyApplicationManagerServiceRef,attributeSetManager,vizMapperUtil);
                BypassManager bypassManager = new 
BypassManager(cyServiceRegistrarServiceRef,editorManager,selectedVisualStyleManager);
                
-               SetViewModeAction viewModeAction = new 
SetViewModeAction(cyApplicationManagerServiceRef, vizMapperMainPanel, 
selectedVisualStyleManager);
+               
                registerAllServices(bc,viewModeAction, new Properties());
                
                registerAllServices(bc,selectedVisualStyleManager, new 
Properties());

Modified: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/SetViewModeAction.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/SetViewModeAction.java
        2011-12-12 21:02:21 UTC (rev 27769)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/SetViewModeAction.java
        2011-12-12 21:49:39 UTC (rev 27770)
@@ -7,21 +7,19 @@
 
 import org.cytoscape.application.CyApplicationManager;
 import org.cytoscape.application.swing.AbstractCyAction;
-import org.cytoscape.view.vizmap.gui.SelectedVisualStyleManager;
+import org.cytoscape.event.CyEventHelper;
 
 public class SetViewModeAction extends AbstractCyAction {
+       
+       // Local property changed event.
+       public static final String VIEW_MODE_CHANGED = "VIEW_MODE_CHANGED";
 
        private final static String BASIC = "Show All Visual Properties";
        private final static String ALL = "Hide Advanced Visual Proeprties";
        
-       private VizMapperMainPanel mainPanel;
-       final SelectedVisualStyleManager manager;
-
-       public SetViewModeAction(final CyApplicationManager applicationManager, 
VizMapperMainPanel mainPanel, final SelectedVisualStyleManager manager) {
+       public SetViewModeAction(final CyApplicationManager applicationManager) 
{
                super(BASIC, applicationManager);
-               this.mainPanel = mainPanel;
-               this.manager = manager;
-               
+
                PropertySheetUtil.setMode(false);
 
                setPreferredMenu("View");
@@ -35,13 +33,11 @@
         *            Triggering event - not used.
         */
        public void actionPerformed(ActionEvent ev) {
-               // TODO: DO NOT CALL apply
-               mainPanel.switchVS(manager.getCurrentVisualStyle(), true);
+               firePropertyChange(VIEW_MODE_CHANGED, null, null);
        }
 
        @Override
        public void menuSelected(MenuEvent me) {
-
                if (PropertySheetUtil.isAdvancedMode()) {
                        putValue(Action.NAME, ALL);
                        PropertySheetUtil.setMode(false);

Modified: 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
===================================================================
--- 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
       2011-12-12 21:02:21 UTC (rev 27769)
+++ 
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
       2011-12-12 21:49:39 UTC (rev 27770)
@@ -37,6 +37,8 @@
 import java.awt.event.ActionListener;
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -98,7 +100,7 @@
  */
 public class VizMapperMainPanel extends AbstractVizMapperPanel implements 
VisualStyleAddedListener,
                VisualStyleAboutToBeRemovedListener, PopupMenuListener, 
NetworkViewAddedListener, CytoPanelComponent,
-               SelectedVisualStyleSwitchedListener, 
SetCurrentRenderingEngineListener {
+               SelectedVisualStyleSwitchedListener, 
SetCurrentRenderingEngineListener, PropertyChangeListener {
 
        private final static long serialVersionUID = 1202339867854959L;
 
@@ -125,16 +127,17 @@
                        final PropertySheetPanel propertySheetPanel, 
VizMapPropertySheetBuilder vizMapPropertySheetBuilder,
                        EditorWindowManager editorWindowManager, 
CyApplicationManager applicationManager,
                        CyEventHelper eventHelper, final 
SelectedVisualStyleManager manager,
-                       final ImportDefaultVizmapTaskFactory taskFactory, final 
TaskManager<?, ?> tManager) {
+                       final ImportDefaultVizmapTaskFactory taskFactory, final 
TaskManager<?, ?> tManager, final SetViewModeAction viewModeAction) {
 
                super(vsFactory, defViewEditor, iconMgr, colorMgr, vmm, menuMgr,
                                editorFactory, propertySheetPanel, 
vizMapPropertySheetBuilder,
-                               editorWindowManager, applicationManager, 
eventHelper, manager);
+                               editorWindowManager, applicationManager, 
eventHelper, manager, viewModeAction);
 
                this.defaultViewMouseListener = new 
DefaultViewMouseListener(defViewEditor, this, manager);
                
                // Initialize all components
                initPanel();
+               viewModeAction.addPropertyChangeListener(this);
                
                // Load default styles
                tManager.execute(taskFactory);
@@ -461,4 +464,17 @@
                if(newStyle.equals(currentSelected) == false)
                        this.visualStyleComboBox.setSelectedItem(newStyle);
        }
+
+       
+       /**
+        * Handles local property change event.
+        * This will be used to switch view mode: show all VPs or basic VPs 
only.
+        */
+       @Override
+       public void propertyChange(PropertyChangeEvent fromSetViewMode) {
+               // Need to update property sheet.
+               
if(fromSetViewMode.getPropertyName().equals(SetViewModeAction.VIEW_MODE_CHANGED))
+                       switchVS(manager.getCurrentVisualStyle(), true);
+
+       }
 }

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