Author: kono
Date: 2010-12-07 16:46:46 -0800 (Tue, 07 Dec 2010)
New Revision: 23124
Added:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/DeleteMappingFunctionTask.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/DeleteMappingFunctionTaskFactory.java
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/AbstractVizMapperPanel.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetBuilder.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetMouseAdapter.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
core3/vizmap-gui-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi-vizmapper.xml
core3/vizmap-gui-impl/trunk/src/main/resources/META-INF/spring/bundle-context-vizmapper.xml
Log:
ContextMenu is partially working. Need to convert color manipulation functions.
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/AbstractVizMapperPanel.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/AbstractVizMapperPanel.java
2010-12-08 00:15:47 UTC (rev 23123)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/AbstractVizMapperPanel.java
2010-12-08 00:46:46 UTC (rev 23124)
@@ -171,6 +171,9 @@
CyApplicationManager applicationManager, CyEventHelper
eventHelper,
final SelectedVisualStyleManager manager) {
+ if(menuMgr == null)
+ throw new NullPointerException("Menu manager is
missing.");
+
this.manager = manager;
this.vsFactory = vsFactory;
this.defViewEditor = defViewEditor;
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetBuilder.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetBuilder.java
2010-12-08 00:15:47 UTC (rev 23123)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetBuilder.java
2010-12-08 00:46:46 UTC (rev 23124)
@@ -64,7 +64,7 @@
private ColorManager colorMgr;
- private VizMapperMenuManager menuMgr;
+ private final VizMapperMenuManager menuMgr;
private CyNetworkManager cyNetworkManager;
@@ -79,10 +79,11 @@
private List<VisualProperty<?>> unusedVisualPropType;
- public VizMapPropertySheetBuilder(CyNetworkManager cyNetworkManager,
+ public VizMapPropertySheetBuilder(final VizMapperMenuManager menuMgr,
CyNetworkManager cyNetworkManager,
PropertySheetPanel propertySheetPanel, EditorManager
editorManager,
DefaultViewPanel defViewPanel, CyTableManager tableMgr,
final VizMapperUtil util, final VisualMappingManager vmm) {
+ this.menuMgr = menuMgr;
this.cyNetworkManager = cyNetworkManager;
this.propertySheetPanel = propertySheetPanel;
this.util = util;
@@ -141,12 +142,11 @@
propertySheetPanel.setMode(PropertySheetPanel.VIEW_AS_CATEGORIES);
// TODO: fix context menu
- // propertySheetPanel.getTable().setComponentPopupMenu(
- // menuMgr.getContextMenu());
+
//propertySheetPanel.getTable().setComponentPopupMenu(menuMgr.getContextMenu());
// TODO: fix listener
propertySheetPanel.getTable().addMouseListener(
- new VizMapPropertySheetMouseAdapter(this,
propertySheetPanel,
+ new
VizMapPropertySheetMouseAdapter(this.menuMgr, this, propertySheetPanel,
style, editorManager));
PropertySheetTable table = propertySheetPanel.getTable();
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetMouseAdapter.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetMouseAdapter.java
2010-12-08 00:15:47 UTC (rev 23123)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapPropertySheetMouseAdapter.java
2010-12-08 00:46:46 UTC (rev 23124)
@@ -37,6 +37,7 @@
import static org.cytoscape.model.CyTableEntry.*;
+import java.awt.Component;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -45,6 +46,7 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyEditor;
+import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import org.cytoscape.model.CyEdge;
@@ -81,6 +83,8 @@
private VizMapPropertySheetBuilder vizMapPropertySheetBuilder;
private PropertySheetPanel propertySheetPanel;
private EditorManager editorManager;
+
+ private final VizMapperMenuManager menuManager;
private VisualStyle selectedStyle;
@@ -102,14 +106,18 @@
* @param editorWindowManager
* DOCUMENT ME!
*/
- public VizMapPropertySheetMouseAdapter(
+ public VizMapPropertySheetMouseAdapter(final VizMapperMenuManager
menuManager,
VizMapPropertySheetBuilder sheetBuilder,
PropertySheetPanel propertySheetPanel, VisualStyle
selectedStyle, EditorManager editorManager) {
+
+ if(menuManager == null)
+ throw new NullPointerException("VizMapperMenuManager is
null.");
this.vizMapPropertySheetBuilder = sheetBuilder;
this.propertySheetPanel = propertySheetPanel;
this.selectedStyle = selectedStyle;
this.editorManager = editorManager;
+ this.menuManager = menuManager;
this.nodeAttributeEditor =
editorManager.getDataTableComboBoxEditor(CyNode.class);
this.edgeAttributeEditor =
editorManager.getDataTableComboBoxEditor(CyEdge.class);
@@ -133,8 +141,12 @@
* Adjust height if it's an legend icon.
*/
vizMapPropertySheetBuilder.updateTableView();
-
- if (SwingUtilities.isLeftMouseButton(e) && (0 <= selected)) {
+
+ if(SwingUtilities.isRightMouseButton(e)) {
+
+ this.handleContextMenuEvent(e);
+
+ } else if (SwingUtilities.isLeftMouseButton(e) && (0 <=
selected)) {
final Item item = (Item)
propertySheetPanel.getTable().getValueAt(selected, 0);
final VizMapperProperty<?, ?, ?> curProp =
(VizMapperProperty<?, ?, ?>) item.getProperty();
@@ -230,6 +242,12 @@
}
}
}
+
+ private void handleContextMenuEvent(MouseEvent e) {
+ final JPopupMenu contextMenu = menuManager.getContextMenu();
+ final Component parent = (Component) e.getSource();
+ contextMenu.show(parent, e.getX(), e.getY());
+ }
public void handleEvent(SelectedVisualStyleSwitchedEvent e) {
this.selectedStyle = e.getNewVisualStyle();
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
2010-12-08 00:15:47 UTC (rev 23123)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMainPanel.java
2010-12-08 00:46:46 UTC (rev 23124)
@@ -27,7 +27,6 @@
*/
package org.cytoscape.view.vizmap.gui.internal;
-
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -86,7 +85,6 @@
import com.l2fprod.common.propertysheet.PropertySheetTableModel.Item;
import com.l2fprod.common.swing.plaf.blue.BlueishButtonUI;
-
/**
* New VizMapper UI main panel. Refactored for Cytoscape 3.
*
@@ -97,22 +95,20 @@
* <li>Visual Mapping Browser
* </ul>
*
- * @version 0.8
- * @since Cytoscape 2.5
- * @param <syncronized>
*/
public class VizMapperMainPanel extends AbstractVizMapperPanel implements
- VisualStyleAddedListener, VisualStyleAboutToBeRemovedListener,
PopupMenuListener, NetworkViewAddedListener, NetworkAddedListener,
CytoPanelComponent, SelectedVisualStyleSwitchedListener {
+ VisualStyleAddedListener, VisualStyleAboutToBeRemovedListener,
+ PopupMenuListener, NetworkViewAddedListener,
NetworkAddedListener,
+ CytoPanelComponent, SelectedVisualStyleSwitchedListener {
private final static long serialVersionUID = 1202339867854959L;
-
+
private static final Logger logger =
LoggerFactory.getLogger(VizMapperMainPanel.class);
-
+
+ // Title for the tab.
private static final String TAB_TITLE = "VizMapper\u2122";
- private boolean ignore = false;
-
- private DefaultViewMouseListener defaultViewMouseListener;
+ private final DefaultViewMouseListener defaultViewMouseListener;
/**
* Create new instance of VizMapperMainPanel object. GUI layout is
handled
@@ -125,8 +121,7 @@
* @param menuMgr
* @param editorFactory
*/
- public VizMapperMainPanel(
- final VisualStyleFactory vsFactory,
+ public VizMapperMainPanel(final VisualStyleFactory vsFactory,
DefaultViewEditor defViewEditor, IconManager iconMgr,
ColorManager colorMgr, VisualMappingManager vmm,
VizMapperMenuManager menuMgr, EditorManager
editorFactory,
@@ -138,69 +133,63 @@
super(vsFactory, defViewEditor, iconMgr, colorMgr, vmm, menuMgr,
editorFactory, propertySheetPanel,
vizMapPropertySheetBuilder,
- editorWindowManager,
- applicationManager, eventHelper, manager);
+ editorWindowManager, applicationManager,
eventHelper, manager);
// Initialize all components
- initPanel(manager);
+ this.defaultViewMouseListener = new
DefaultViewMouseListener(defViewEditor, this, manager);
+ initPanel();
}
- private void initPanel(final SelectedVisualStyleManager manager) {
-
- defaultViewMouseListener = new
DefaultViewMouseListener(defViewEditor, this, manager);
-
+ private void initPanel() {
addVisualStyleChangeAction();
// By default, force to sort property by prop name.
propertySheetPanel.setSorting(true);
-
refreshUI();
// Switch to the default style.
switchVS(manager.getDefaultStyle(), true);
-
}
-
+
private void addVisualStyleChangeAction() {
visualStyleComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
final VisualStyle lastStyle =
manager.getCurrentVisualStyle();
- final VisualStyle style = (VisualStyle)
visualStyleComboBox.getSelectedItem();
- if(style.equals(lastStyle))
+ final VisualStyle style = (VisualStyle)
visualStyleComboBox
+ .getSelectedItem();
+ if (style.equals(lastStyle))
return;
-
+
switchVS(style);
- eventHelper.fireSynchronousEvent(new
SelectedVisualStyleSwitchedEvent(this, lastStyle, style));
+ eventHelper
+ .fireSynchronousEvent(new
SelectedVisualStyleSwitchedEvent(
+ this,
lastStyle, style));
logger.debug("######## Event: new selected
style: " + style);
}
});
}
-
private void switchVS(final VisualStyle style) {
switchVS(style, false);
}
-
-
+
private void switchVS(final VisualStyle style, boolean forceUpdate) {
- logger.debug("######## Switching start: " + style.getTitle() );
+ logger.debug("######## Switching start: " + style.getTitle());
// If new VS name is the same, ignore.
if (!forceUpdate &&
style.equals(manager.getCurrentVisualStyle()))
return;
- logger.debug("######## Switching: " + style.getTitle() );
-
// Close editor windows
editorWindowManager.closeAllEditorWindows();
-
- final List<Property> props =
vizMapPropertySheetBuilder.getPropertyList(style);
+
+ final List<Property> props = vizMapPropertySheetBuilder
+ .getPropertyList(style);
if (props.size() != 0) {
- logger.debug("######## Style exists in buffer: " +
style.getTitle() );
-
+ logger.debug("######## Style exists in buffer: " +
style.getTitle());
final Map<String, Property> unused = new
TreeMap<String, Property>();
@@ -212,7 +201,7 @@
* Add properties to current property sheet.
*/
for (Property prop : props) {
- logger.debug("<Prop> " + prop.getDisplayName()
);
+ logger.debug("<Prop> " + prop.getDisplayName());
if
(prop.getCategory().startsWith(CATEGORY_UNUSED) == false) {
propertySheetPanel.addProperty(prop);
} else {
@@ -225,9 +214,10 @@
for (Object key : keys)
propertySheetPanel.addProperty(unused.get(key));
-
+
} else {
- logger.debug("######## Need to create new prop sheet: "
+ style.getTitle());
+ logger.debug("######## Need to create new prop sheet: "
+ + style.getTitle());
vizMapPropertySheetBuilder.setPropertyTable(style);
updateAttributeList();
}
@@ -243,7 +233,7 @@
// Update view
currentView.updateView();
}
-
+
/*
* Draw default view
*/
@@ -251,8 +241,10 @@
if (defImg == null) {
// Default image is not available in the buffer. Create
a new one.
- updateDefaultImage(style,
((DefaultViewPanel)defViewEditor.getDefaultView(style)).getRenderingEngine(),
- defaultViewImagePanel.getSize());
+ updateDefaultImage(style,
+ ((DefaultViewPanel)
defViewEditor.getDefaultView(style))
+ .getRenderingEngine(),
+ defaultViewImagePanel.getSize());
defImg = defaultImageManager.get(style);
}
@@ -270,8 +262,8 @@
public void refreshUI() {
- final List<VisualStyle> visualStyles = new
ArrayList<VisualStyle>(vmm
- .getAllVisualStyles());
+ final List<VisualStyle> visualStyles = new
ArrayList<VisualStyle>(
+ vmm.getAllVisualStyles());
// final VisualStyle selectedStyle = (VisualStyle)
// vsComboBox.getModel().getSelectedItem();
@@ -295,7 +287,8 @@
logger.info("Adding VS: " + vs.getTitle());
vsComboBoxModel.addElement(vs);
defPanel = defViewEditor.getDefaultView(vs);
- RenderingEngine<CyNetwork> engine = ((DefaultViewPanel)
defPanel).getRenderingEngine();
+ RenderingEngine<CyNetwork> engine = ((DefaultViewPanel)
defPanel)
+ .getRenderingEngine();
updateDefaultImage(vs, engine, panelSize);
}
@@ -313,16 +306,10 @@
visualStyleComboBox.addActionListener(li[i]);
}
- /**
- * Create image of a default dummy network and save in a Map object.
- *
- * @param vsName
- * @param view
- * @param size
- */
- // TODO: this should be called by listeners.
- public void updateDefaultImage(final VisualStyle vs, final
RenderingEngine<CyNetwork> engine, final Dimension size) {
-
+
+ void updateDefaultImage(final VisualStyle vs,
+ final RenderingEngine<CyNetwork> engine, final
Dimension size) {
+
Image image = defaultImageManager.remove(vs);
if (image != null) {
@@ -330,22 +317,26 @@
image = null;
}
- defaultImageManager.put(vs, engine.createImage((int)
size.getWidth(), (int) size.getHeight()));
+ defaultImageManager.put(
+ vs,
+ engine.createImage((int) size.getWidth(),
+ (int) size.getHeight()));
}
public void updateAttributeList() {
// TODO: use new event listener to do this.
- vizMapPropertySheetBuilder.setAttrComboBox();
-// final Set mappingTypes =
vmm.getCalculatorCatalog().getMappingNames();
-//
-// //
mappingTypeEditor.setAvailableValues(mappingTypes.toArray());
-// spcs.firePropertyChange("UPDATE_AVAILABLE_VAL",
"mappingTypeEditor",
-// mappingTypes.toArray());
+ vizMapPropertySheetBuilder.setAttrComboBox();
+ // final Set mappingTypes =
+ // vmm.getCalculatorCatalog().getMappingNames();
+ //
+ // //
mappingTypeEditor.setAvailableValues(mappingTypes.toArray());
+ // spcs.firePropertyChange("UPDATE_AVAILABLE_VAL",
"mappingTypeEditor",
+ // mappingTypes.toArray());
}
/*
- * private Set<Object> loadKeys(final String attrName, final CyTable
- * attrs, final MappingCalculator mapping, final int nOre) { if
+ * private Set<Object> loadKeys(final String attrName, final CyTable
attrs,
+ * final MappingCalculator mapping, final int nOre) { if
* (attrName.equals("ID")) { return loadID(nOre); }
*
* Map mapAttrs; mapAttrs = CyAttributesUtils.getAttribute(attrName,
attrs);
@@ -393,20 +384,17 @@
defaultImageButton.setUI(new BlueishButtonUI());
defaultImageButton.setCursor(Cursor
.getPredefinedCursor(Cursor.HAND_CURSOR));
-
+
defaultImageButton.setIcon(new ImageIcon(defImage));
final VisualStyle currentStyle =
manager.getCurrentVisualStyle();
- defaultImageButton.setBackground((Color)
currentStyle.getDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT));
+ defaultImageButton.setBackground((Color) currentStyle
+
.getDefaultValue(TwoDVisualLexicon.NETWORK_BACKGROUND_PAINT));
defaultViewImagePanel.add(defaultImageButton,
BorderLayout.CENTER);
defaultImageButton.addMouseListener(defaultViewMouseListener);
this.repaint();
}
- public JPanel getDefaultPanel() {
- return defaultViewImagePanel;
- }
-
/**
* On/Off listeners. This is for performance.
*
@@ -423,10 +411,6 @@
// }
}
-
-
-
-
/**
* DOCUMENT ME!
*
@@ -471,46 +455,46 @@
VizMapperProperty prop = ((VizMapperProperty) curProp);
-
- //FIXME
-// if (prop.getHiddenObject() instanceof VisualProperty
-// && (prop.getDisplayName().contains("Mapping
Type") == false)
-// && (prop.getValue() != null)
-// &&
(prop.getValue().toString().startsWith("Please select") == false)) {
-// // Enble delete menu
-// // delete.setEnabled(true);
-// Property[] children = prop.getSubProperties();
-//
-// for (Property p : children) {
-// if ((p.getDisplayName() != null)
-// &&
p.getDisplayName().contains("Mapping Type")) {
-// if ((p.getValue() == null)
-// ||
(p.getValue().equals("Discrete Mapping") == false)) {
-// return;
-// }
-// }
-// }
-//
-// VisualProperty type = ((VisualProperty)
prop.getHiddenObject());
-//
-// Class dataType = type.getType();
-//
-// // if (dataType == Color.class) {
-// // rainbow1.setEnabled(true);
-// // rainbow2.setEnabled(true);
-// // randomize.setEnabled(true);
-// // brighter.setEnabled(true);
-// // darker.setEnabled(true);
-// // } else if (dataType == Number.class) {
-// // randomize.setEnabled(true);
-// // series.setEnabled(true);
-// // }
-// //
-// // if ((type == VisualProperty.NODE_WIDTH)
-// // || (type == VisualProperty.NODE_HEIGHT)) {
-// // fit.setEnabled(true);
-// // }
-// }
+ // FIXME
+ // if (prop.getHiddenObject() instanceof VisualProperty
+ // && (prop.getDisplayName().contains("Mapping Type") == false)
+ // && (prop.getValue() != null)
+ // && (prop.getValue().toString().startsWith("Please select")
== false))
+ // {
+ // // Enble delete menu
+ // // delete.setEnabled(true);
+ // Property[] children = prop.getSubProperties();
+ //
+ // for (Property p : children) {
+ // if ((p.getDisplayName() != null)
+ // && p.getDisplayName().contains("Mapping Type")) {
+ // if ((p.getValue() == null)
+ // || (p.getValue().equals("Discrete Mapping") == false)) {
+ // return;
+ // }
+ // }
+ // }
+ //
+ // VisualProperty type = ((VisualProperty)
prop.getHiddenObject());
+ //
+ // Class dataType = type.getType();
+ //
+ // // if (dataType == Color.class) {
+ // // rainbow1.setEnabled(true);
+ // // rainbow2.setEnabled(true);
+ // // randomize.setEnabled(true);
+ // // brighter.setEnabled(true);
+ // // darker.setEnabled(true);
+ // // } else if (dataType == Number.class) {
+ // // randomize.setEnabled(true);
+ // // series.setEnabled(true);
+ // // }
+ // //
+ // // if ((type == VisualProperty.NODE_WIDTH)
+ // // || (type == VisualProperty.NODE_HEIGHT)) {
+ // // fit.setEnabled(true);
+ // // }
+ // }
return;
}
@@ -536,8 +520,8 @@
* applicationManager.getCurrentNetworkView
* ().getGraphPerspective().getEdgeList(); }
*
- * for (CyTableEntry o : obj) { ids.add(o.attrs().get("name",
String.class));
- * }
+ * for (CyTableEntry o : obj) { ids.add(o.attrs().get("name",
+ * String.class)); }
*
* return ids; }
*/
@@ -550,8 +534,8 @@
// public void stateChanged(ChangeEvent e) {
// final VisualStyle selected = vsComboBox
// .getSelectedItem();
- //
//
+ //
// final GraphView curView = applicationManager.getCurrentNetworkView();
//
// if (ignore)
@@ -668,28 +652,31 @@
// TODO Auto-generated method stub
}
-
+
/**
* Update GUI components when new Visual Style is created.
*/
- @Override public void handleEvent(final VisualStyleAddedEvent e) {
+ @Override
+ public void handleEvent(final VisualStyleAddedEvent e) {
final VisualStyle currentStyle =
manager.getCurrentVisualStyle();
final VisualStyle newStyle = e.getVisualStyleAdded();
if (newStyle == null || newStyle.equals(currentStyle))
return;
-
+
vsComboBoxModel.addElement(newStyle);
visualStyleComboBox.setSelectedItem(newStyle);
-
- final CyNetworkView currentView =
applicationManager.getCurrentNetworkView();
-
+
+ final CyNetworkView currentView = applicationManager
+ .getCurrentNetworkView();
+
if (currentView != null)
vmm.setVisualStyle(newStyle, currentView);
// Update default panel
final Component defPanel =
defViewEditor.getDefaultView(newStyle);
- final RenderingEngine<CyNetwork> engine =
((DefaultViewPanelImpl) defPanel).getRenderingEngine();
- final Dimension panelSize = getDefaultPanel().getSize();
+ final RenderingEngine<CyNetwork> engine =
((DefaultViewPanelImpl) defPanel)
+ .getRenderingEngine();
+ final Dimension panelSize = defaultViewImagePanel.getSize();
if (engine != null) {
logger.debug("Creating Default Image for new visual
style "
@@ -699,44 +686,46 @@
}
switchVS(newStyle);
- eventHelper.fireSynchronousEvent(new
SelectedVisualStyleSwitchedEvent(this, currentStyle, newStyle));
+ eventHelper.fireSynchronousEvent(new
SelectedVisualStyleSwitchedEvent(
+ this, currentStyle, newStyle));
logger.debug("######## Event: Got new style: " + newStyle);
}
-
+
@Override
public void handleEvent(NetworkViewAddedEvent e) {
-
+
final CyNetworkView newView = e.getNetworkView();
final VisualStyle targetStyle = manager.getCurrentVisualStyle();
-
+
logger.debug("@@@@@@ Network View added. Apply " + targetStyle);
-
+
vmm.setVisualStyle(targetStyle, newView);
targetStyle.apply(newView);
newView.updateView();
}
-
- @Override public void handleEvent(NetworkAddedEvent e) {
+ @Override
+ public void handleEvent(NetworkAddedEvent e) {
// TODO: is this necessary?
- logger.debug("!!!!!!!!!! Network added. Need to update prop
sheet: " + e.getNetwork().getSUID());
-
+ logger.debug("!!!!!!!!!! Network added. Need to update prop
sheet: "
+ + e.getNetwork().getSUID());
+
}
-
/**
* Update panel when removed
*/
@Override
public void handleEvent(VisualStyleAboutToBeRemovedEvent e) {
-
+
final VisualStyle toBeRemoved = e.getVisualStyleToBeRemoved();
-
+
// Update image
getDefaultImageManager().remove(e.getVisualStyleToBeRemoved());
-
vizMapPropertySheetBuilder.removePropertyList(e.getVisualStyleToBeRemoved());
+ vizMapPropertySheetBuilder.removePropertyList(e
+ .getVisualStyleToBeRemoved());
this.visualStyleComboBox.removeItem(toBeRemoved);
-
+
// Switch to the default style
final VisualStyle defaultStyle = manager.getDefaultStyle();
@@ -745,23 +734,28 @@
final CyNetworkView view =
applicationManager.getCurrentNetworkView();
if (view != null)
vmm.setVisualStyle(defaultStyle, view);
- eventHelper.fireSynchronousEvent(new
SelectedVisualStyleSwitchedEvent(this, toBeRemoved, defaultStyle));
+ eventHelper.fireSynchronousEvent(new
SelectedVisualStyleSwitchedEvent(
+ this, toBeRemoved, defaultStyle));
logger.debug("######## Event: removed style: " + toBeRemoved);
}
- @Override public String getTitle() {
+ @Override
+ public String getTitle() {
return TAB_TITLE;
}
- @Override public CytoPanelName getCytoPanelName() {
+ @Override
+ public CytoPanelName getCytoPanelName() {
return CytoPanelName.WEST;
}
- @Override public Component getComponent() {
+ @Override
+ public Component getComponent() {
return this;
}
- @Override public Icon getIcon() {
+ @Override
+ public Icon getIcon() {
return null;
}
Modified:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
2010-12-08 00:15:47 UTC (rev 23123)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/VizMapperMenuManager.java
2010-12-08 00:46:46 UTC (rev 23124)
@@ -17,30 +17,30 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* Manager for all Vizmap-local tasks (commands).
*
* @author kono
- *
+ *
*/
public class VizMapperMenuManager {
-
- private static final Logger logger =
LoggerFactory.getLogger(VizMapperMenuManager.class);
-
+
+ private static final Logger logger = LoggerFactory
+ .getLogger(VizMapperMenuManager.class);
+
// Metadata
private static final String METADATA_MENU_KEY = "menu";
private static final String METADATA_TITLE_KEY = "title";
-
+
private static final String MAIN_MENU = "main";
private static final String CONTEXT_MENU = "context";
// Menu items under the tool button
- private JPopupMenu mainMenu;
-
+ private final JPopupMenu mainMenu;
+
// Context menu
- private JPopupMenu rightClickMenu;
-
+ private final JPopupMenu rightClickMenu;
+
private JMenu generateValues;
private IconManager iconManager;
@@ -53,11 +53,14 @@
private String modifyIconId;
private JMenu modifyValues;
-
-
+
private final TaskManager taskManager;
-
+
public VizMapperMenuManager(final TaskManager taskManager) {
+
+ if (taskManager == null)
+ throw new NullPointerException("TaskManager is null.");
+
this.taskManager = taskManager;
// Will be shown under the button next to Visual Style Name
@@ -66,26 +69,21 @@
// Context menu
rightClickMenu = new JPopupMenu();
+ // modifyValues = new JMenu(modifyMenuLabel);
+ }
- //modifyValues = new JMenu(modifyMenuLabel);
- }
-
-
-
public void setIconManager(IconManager iconManager) {
this.iconManager = iconManager;
}
-
+
public void setGenerateMenuLabel(String generateMenuLabel) {
this.generateMenuLabel = generateMenuLabel;
}
-
+
public void setGenerateIconId(String generateIconId) {
this.generateIconId = generateIconId;
}
-
-
public JPopupMenu getMainMenu() {
return mainMenu;
}
@@ -94,25 +92,26 @@
return rightClickMenu;
}
-
/*
* Custom listener for dynamic menu management
*
* (non-Javadoc)
- * @see cytoscape.view.ServiceListener#onBind(java.lang.Object,
java.util.Map)
+ *
+ * @see cytoscape.view.ServiceListener#onBind(java.lang.Object,
+ * java.util.Map)
*/
public void onBind(VizMapUIAction action, Map properties) {
- if(generateValues == null && iconManager != null) {
+ if (generateValues == null && iconManager != null) {
// for value generators.
generateValues = new JMenu(generateMenuLabel);
generateValues.setIcon(iconManager.getIcon(generateIconId));
rightClickMenu.add(generateValues);
}
-
final Object serviceType = properties.get("service.type");
- if( serviceType != null &&
serviceType.toString().equals("vizmapUI.contextMenu")) {
- rightClickMenu.add(action.getMenu());
+ if (serviceType != null
+ &&
serviceType.toString().equals("vizmapUI.contextMenu")) {
+ rightClickMenu.add(action.getMenu());
} else {
mainMenu.add(action.getMenu());
}
@@ -120,38 +119,45 @@
public void onUnbind(VizMapUIAction service, Map properties) {
}
-
-
+
/**
+ * Add menu items to proper locations.
*
* @param taskFactory
* @param properties
*/
- public void addTaskFactory(final TaskFactory taskFactory, Map
properties) {
+ public void addTaskFactory(final TaskFactory taskFactory,
+ @SuppressWarnings("rawtypes") Map properties) {
+
final Object serviceType = properties.get(METADATA_MENU_KEY);
- if( serviceType != null &&
serviceType.toString().equals(MAIN_MENU)) {
- // This is a menu item for Main Command Button.
- final Object title = properties.get(METADATA_TITLE_KEY);
- if(title == null)
- throw new NullPointerException("Title metadata
is missing.");
-
-
- // Add new menu to the pull-down
- final JMenuItem menuItem = new
JMenuItem(title.toString());
- //menuItem.setIcon(iconManager.getIcon(iconId));
- menuItem.addActionListener(new ActionListener() {
+ if (serviceType == null)
+ throw new NullPointerException(
+ "Service Type metadata is null. This
value is required.");
- @Override
- public void actionPerformed(ActionEvent e) {
- taskManager.execute(taskFactory);
- }
- });
-
+ // This is a menu item for Main Command Button.
+ final Object title = properties.get(METADATA_TITLE_KEY);
+ if (title == null)
+ throw new NullPointerException("Title metadata is
missing.");
+
+ // Add new menu to the pull-down
+ final JMenuItem menuItem = new JMenuItem(title.toString());
+ // menuItem.setIcon(iconManager.getIcon(iconId));
+ menuItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ taskManager.execute(taskFactory);
+ }
+ });
+
+ if(serviceType.toString().equals(MAIN_MENU))
mainMenu.add(menuItem);
- }
+ else if(serviceType.toString().equals(CONTEXT_MENU))
+ rightClickMenu.add(menuItem);
+
}
-
+
public void removeTaskFactory(final TaskFactory taskFactory, Map
properties) {
-
+
}
+
}
Added:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/DeleteMappingFunctionTask.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/DeleteMappingFunctionTask.java
(rev 0)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/DeleteMappingFunctionTask.java
2010-12-08 00:46:46 UTC (rev 23124)
@@ -0,0 +1,85 @@
+package org.cytoscape.view.vizmap.gui.internal.task;
+
+import org.cytoscape.session.CyApplicationManager;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.VisualProperty;
+import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.gui.SelectedVisualStyleManager;
+import org.cytoscape.view.vizmap.gui.internal.AbstractVizMapperPanel;
+import org.cytoscape.view.vizmap.gui.internal.VizMapperProperty;
+import org.cytoscape.view.vizmap.gui.internal.event.CellType;
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+
+import com.l2fprod.common.propertysheet.Property;
+import com.l2fprod.common.propertysheet.PropertySheetTable;
+import com.l2fprod.common.propertysheet.PropertySheetTableModel;
+import com.l2fprod.common.propertysheet.PropertySheetTableModel.Item;
+
+public class DeleteMappingFunctionTask extends AbstractTask {
+
+ private final PropertySheetTable table;
+ private final SelectedVisualStyleManager manager;
+ private final CyApplicationManager appManager;
+
+ public DeleteMappingFunctionTask(final PropertySheetTable table, final
SelectedVisualStyleManager manager, final CyApplicationManager appManager) {
+ this.table = table;
+ this.manager = manager;
+ this.appManager = appManager;
+ }
+
+ @Override
+ public void run(TaskMonitor monitor) throws Exception {
+ int selectedRow = table.getSelectedRow();
+
+ // If not selected, do nothing.
+ if(selectedRow < 0)
+ return;
+
+ final Item value = (Item) table.getValueAt(selectedRow, 0);
+
+
+ if(value.isProperty()) {
+ final VizMapperProperty<?, ?, ?> prop =
(VizMapperProperty<?, ?, ?>) value.getProperty();
+
+ if(prop.getCellType() == CellType.VISUAL_PROPERTY_TYPE)
{
+ final VisualProperty<?> vp =
(VisualProperty<?>) prop.getKey();
+ removeMapping(manager.getCurrentVisualStyle(),
vp);
+
+ updatePropertySheet(prop, vp);
+ }
+ }
+ }
+
+ private void removeMapping(final VisualStyle style, final
VisualProperty<?> vp) {
+ style.removeVisualMappingFunction(vp);
+ final CyNetworkView currentView =
appManager.getCurrentNetworkView();
+ style.apply(currentView);
+ currentView.updateView();
+ }
+
+ private void updatePropertySheet(final VizMapperProperty<?, ?, ?> prop,
final VisualProperty<?> vp) {
+
+ final PropertySheetTableModel sheetModel =
table.getSheetModel();
+ final Property[] children = prop.getSubProperties();
+
+ // Remove all children
+ for(Property p: children)
+ sheetModel.removeProperty(p);
+
+ // Remove itself
+ sheetModel.removeProperty(prop);
+
+ // Create new unused prop
+ final VizMapperProperty<VisualProperty<?>, String, ?> unuded =
new VizMapperProperty<VisualProperty<?>, String, Object>(CellType.UNUSED, vp,
String.class);
+ unuded.setCategory(AbstractVizMapperPanel.CATEGORY_UNUSED);
+ unuded.setDisplayName(vp.getDisplayName());
+ unuded.setValue("Double-Click to create...");
+ prop.setEditable(false);
+
+ sheetModel.addProperty(unuded);
+ table.repaint();
+ }
+
+
+}
Added:
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/DeleteMappingFunctionTaskFactory.java
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/DeleteMappingFunctionTaskFactory.java
(rev 0)
+++
core3/vizmap-gui-impl/trunk/src/main/java/org/cytoscape/view/vizmap/gui/internal/task/DeleteMappingFunctionTaskFactory.java
2010-12-08 00:46:46 UTC (rev 23124)
@@ -0,0 +1,27 @@
+package org.cytoscape.view.vizmap.gui.internal.task;
+
+import org.cytoscape.session.CyApplicationManager;
+import org.cytoscape.view.vizmap.gui.SelectedVisualStyleManager;
+import org.cytoscape.work.TaskFactory;
+import org.cytoscape.work.TaskIterator;
+
+import com.l2fprod.common.propertysheet.PropertySheetPanel;
+
+public class DeleteMappingFunctionTaskFactory implements TaskFactory {
+
+ private final PropertySheetPanel panel;
+ private final SelectedVisualStyleManager manager;
+ private final CyApplicationManager appManager;
+
+ public DeleteMappingFunctionTaskFactory(final PropertySheetPanel panel,
final SelectedVisualStyleManager manager, final CyApplicationManager
appManager) {
+ this.panel = panel;
+ this.manager = manager;
+ this.appManager = appManager;
+ }
+
+ @Override
+ public TaskIterator getTaskIterator() {
+ return new TaskIterator(new
DeleteMappingFunctionTask(panel.getTable(), manager, appManager));
+ }
+
+}
Modified:
core3/vizmap-gui-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi-vizmapper.xml
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi-vizmapper.xml
2010-12-08 00:15:47 UTC (rev 23123)
+++
core3/vizmap-gui-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi-vizmapper.xml
2010-12-08 00:46:46 UTC (rev 23124)
@@ -131,7 +131,17 @@
</osgi:service-properties>
</osgi:service>
+ <!-- Context Menu Items -->
+ <osgi:service id="deleteMappingFunctionTaskFactoryService"
+ ref="deleteMappingFunctionTaskFactory" auto-export="interfaces">
+ <osgi:service-properties>
+ <entry key="service.type" value="vizmapUI.taskFactory"
/>
+ <entry key="menu" value="context" />
+ <entry key="title" value="Delete Selected Mapping" />
+ </osgi:service-properties>
+ </osgi:service>
+
<!-- Mapping generator services -->
Modified:
core3/vizmap-gui-impl/trunk/src/main/resources/META-INF/spring/bundle-context-vizmapper.xml
===================================================================
---
core3/vizmap-gui-impl/trunk/src/main/resources/META-INF/spring/bundle-context-vizmapper.xml
2010-12-08 00:15:47 UTC (rev 23123)
+++
core3/vizmap-gui-impl/trunk/src/main/resources/META-INF/spring/bundle-context-vizmapper.xml
2010-12-08 00:46:46 UTC (rev 23124)
@@ -161,9 +161,7 @@
<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}" />
+ scope="singleton">
<constructor-arg ref="taskManagerServiceRef" />
</bean>
@@ -230,6 +228,14 @@
<constructor-arg ref="selectedVisualStyleManager" />
<constructor-arg ref="vizMapperMainPanel" />
</bean>
+
+ <!-- Context Menu -->
+ <bean name="deleteMappingFunctionTaskFactory"
+
class="org.cytoscape.view.vizmap.gui.internal.task.DeleteMappingFunctionTaskFactory">
+ <constructor-arg ref="propertySheetPanel" />
+ <constructor-arg ref="selectedVisualStyleManager" />
+ <constructor-arg ref="cyApplicationManagerServiceRef" />
+ </bean>
<!-- Value generators: generate discrete mapping from simple
algorithms. -->
@@ -256,6 +262,7 @@
<bean id="vizMapPropertySheetBuilder"
class="org.cytoscape.view.vizmap.gui.internal.VizMapPropertySheetBuilder">
+ <constructor-arg ref="menuManager" />
<constructor-arg ref="propertySheetPanel" />
<constructor-arg ref="cyNetworkManagerServiceRef" />
<constructor-arg ref="editorManager" />
--
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.