Author: kono
Date: 2012-01-25 14:50:09 -0800 (Wed, 25 Jan 2012)
New Revision: 28109
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2CEditor.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2DEditor.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/GradientEditor.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/CyNumberPropertyEditor.java
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/CyStringPropertyEditor.java
Log:
fixes #638 Unnecessary propertyChange() method call will be filtered to avoid
NPE.
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2CEditor.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2CEditor.java
2012-01-25 22:29:31 UTC (rev 28108)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2CEditor.java
2012-01-25 22:50:09 UTC (rev 28109)
@@ -19,6 +19,10 @@
@Override public void setValue(Object value) {
if(value instanceof ContinuousMapping == false)
throw new IllegalArgumentException("Value should be
ContinuousMapping: this is " + value);
+ final CyNetwork currentNetwork = appManager.getCurrentNetwork();
+ if(currentNetwork == null)
+ return;
+
ContinuousMapping<?, ?> mTest = (ContinuousMapping<?, ?>) value;
// TODO: error chekcing
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2DEditor.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2DEditor.java
2012-01-25 22:29:31 UTC (rev 28108)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/C2DEditor.java
2012-01-25 22:50:09 UTC (rev 28109)
@@ -12,28 +12,30 @@
public class C2DEditor<V> extends AbstractContinuousMappingEditor<Number, V> {
- public C2DEditor(final CyNetworkTableManager manager,
- final CyApplicationManager appManager,
- final SelectedVisualStyleManager selectedManager,
- final EditorManager editorManager, final
VisualMappingManager vmm) {
+ public C2DEditor(final CyNetworkTableManager manager, final
CyApplicationManager appManager,
+ final SelectedVisualStyleManager selectedManager, final
EditorManager editorManager,
+ final VisualMappingManager vmm) {
super(manager, appManager, selectedManager, editorManager, vmm);
}
@Override
public void setValue(Object value) {
if (value instanceof ContinuousMapping == false)
- throw new IllegalArgumentException(
- "Value should be ContinuousMapping:
this is " + value);
-
+ throw new IllegalArgumentException("Value should be
ContinuousMapping: this is " + value);
+
+ final CyNetwork currentNetwork = appManager.getCurrentNetwork();
+ if (currentNetwork == null)
+ return;
+
ContinuousMapping<?, ?> mTest = (ContinuousMapping<?, ?>) value;
// TODO: error chekcing
mapping = (ContinuousMapping<Number, V>) value;
@SuppressWarnings("unchecked")
- Class<? extends CyTableEntry> type = (Class<? extends
CyTableEntry>) mapping.getVisualProperty().getTargetDataType();
+ Class<? extends CyTableEntry> type = (Class<? extends
CyTableEntry>) mapping.getVisualProperty()
+ .getTargetDataType();
final CyTable attr =
manager.getTable(appManager.getCurrentNetwork(), type, CyNetwork.DEFAULT_ATTRS);
- this.editorPanel = new C2DMappingEditor(
- selectedManager.getCurrentVisualStyle(),
mapping, attr,
- appManager, vmm, editorManager);
+ this.editorPanel = new
C2DMappingEditor(selectedManager.getCurrentVisualStyle(), mapping, attr,
appManager,
+ vmm, editorManager);
}
}
\ No newline at end of file
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
2012-01-25 22:29:31 UTC (rev 28108)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/ContinuousMappingEditorPanel.java
2012-01-25 22:50:09 UTC (rev 28109)
@@ -59,6 +59,7 @@
import javax.swing.event.ChangeListener;
import org.cytoscape.application.CyApplicationManager;
+import org.cytoscape.model.CyColumn;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTable;
import org.cytoscape.view.model.CyNetworkView;
@@ -128,10 +129,10 @@
*
* */
public ContinuousMappingEditorPanel(final VisualStyle style, final
ContinuousMapping<K, V> mapping,
- final CyTable attr, final CyApplicationManager
appManager, final VisualMappingManager vmm) {
+ final CyTable table, final CyApplicationManager
appManager, final VisualMappingManager vmm) {
if (mapping == null)
throw new NullPointerException("ContinuousMapping
should not be null.");
- if (attr == null)
+ if (table == null)
throw new NullPointerException("Data table should not
be null.");
if (appManager == null)
throw new NullPointerException("Application Manager
should not be null.");
@@ -146,14 +147,20 @@
this.mainPanel = new JPanel();
final String controllingAttrName =
mapping.getMappingColumnName();
- final Class<?> attrType =
attr.getColumn(controllingAttrName).getType();
+
+ //TODO more error checking
+ final CyColumn col = table.getColumn(controllingAttrName);
+ if(col == null)
+ throw new NullPointerException("No such column exists
in the given table.");
+
+ final Class<?> attrType = col.getType();
logger.debug("Selected attr type is " + attrType);
if (!Number.class.isAssignableFrom(attrType))
throw new IllegalArgumentException("Cannot support
attribute data type. Numerical values only: "
+ attrType);
- this.dataTable = attr;
+ this.dataTable = table;
this.dataType = (Class<K>) attrType;
initComponents();
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/GradientEditor.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/GradientEditor.java
2012-01-25 22:29:31 UTC (rev 28108)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/mappingeditor/GradientEditor.java
2012-01-25 22:50:09 UTC (rev 28109)
@@ -14,21 +14,30 @@
import org.cytoscape.view.vizmap.mappings.ContinuousMapping;
public class GradientEditor extends AbstractContinuousMappingEditor<Double,
Color> {
-
- public GradientEditor(final CyNetworkTableManager manager, final
CyApplicationManager appManager, final SelectedVisualStyleManager
selectedManager, final EditorManager editorManager, final VisualMappingManager
vmm) {
+
+ public GradientEditor(final CyNetworkTableManager manager, final
CyApplicationManager appManager,
+ final SelectedVisualStyleManager selectedManager, final
EditorManager editorManager,
+ final VisualMappingManager vmm) {
super(manager, appManager, selectedManager, editorManager, vmm);
}
-
- @Override public void setValue(Object value) {
- if(value instanceof ContinuousMapping == false)
+
+ @Override
+ public void setValue(Object value) {
+ if (value instanceof ContinuousMapping == false)
throw new IllegalArgumentException("Value should be
ContinuousMapping: this is " + value);
+ final CyNetwork currentNetwork = appManager.getCurrentNetwork();
+ if(currentNetwork == null)
+ return;
+
ContinuousMapping<?, ?> mTest = (ContinuousMapping<?, ?>) value;
// TODO: error chekcing
-
+
mapping = (ContinuousMapping<Double, Color>) value;
@SuppressWarnings("unchecked")
- Class<? extends CyTableEntry> type = (Class<? extends
CyTableEntry>) mapping.getVisualProperty().getTargetDataType();
+ Class<? extends CyTableEntry> type = (Class<? extends
CyTableEntry>) mapping.getVisualProperty()
+ .getTargetDataType();
final CyTable attr =
manager.getTable(appManager.getCurrentNetwork(), type, CyNetwork.DEFAULT_ATTRS);
- this.editorPanel = new
GradientEditorPanel(selectedManager.getCurrentVisualStyle(), mapping, attr,
appManager, editorManager.getValueEditor(Paint.class), vmm);
+ this.editorPanel = new
GradientEditorPanel(selectedManager.getCurrentVisualStyle(), mapping, attr,
appManager,
+ editorManager.getValueEditor(Paint.class), vmm);
}
}
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/CyNumberPropertyEditor.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/CyNumberPropertyEditor.java
2012-01-25 22:29:31 UTC (rev 28108)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/CyNumberPropertyEditor.java
2012-01-25 22:50:09 UTC (rev 28109)
@@ -51,50 +51,50 @@
*/
public class CyNumberPropertyEditor<T extends Number> extends
NumberPropertyEditor {
- private static final Logger logger =
LoggerFactory.getLogger(CyNumberPropertyEditor.class);
+ private static final Logger logger =
LoggerFactory.getLogger(CyNumberPropertyEditor.class);
- private final VizMapperMainPanel panel;
+ private final VizMapperMainPanel panel;
- private Object currentValue;
- private Object selected;
+ private Object currentValue;
+ private Object selected;
- /**
- * Creates a new CyStringPropertyEditor object.
- */
- public CyNumberPropertyEditor(Class<T> type, final VizMapperMainPanel vmp)
{
- super(type);
- panel = vmp;
+ /**
+ * Creates a new CyStringPropertyEditor object.
+ */
+ public CyNumberPropertyEditor(Class<T> type, final VizMapperMainPanel
vmp) {
+ super(type);
+ panel = vmp;
- ((JTextField) editor).addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
+ ((JTextField) editor).addFocusListener(new FocusListener() {
+ public void focusGained(FocusEvent e) {
- logger.debug("Number Editor got val: " + currentValue);
+ logger.debug("Number Editor got val: " +
currentValue);
- final Item item = (Item) panel.getSelectedItem();
- selected = item.getProperty().getDisplayName();
- setCurrentValue();
- }
+ final Item item = (Item)
panel.getSelectedItem();
+ selected = item.getProperty().getDisplayName();
+ setCurrentValue();
+ }
- public void focusLost(FocusEvent arg0) {
- checkChange();
- }
- });
- }
+ public void focusLost(FocusEvent arg0) {
+ checkChange();
+ }
+ });
+ }
- private void setCurrentValue() {
- this.currentValue = super.getValue();
- }
+ private void setCurrentValue() {
+ this.currentValue = super.getValue();
+ }
- private void checkChange() {
- Number newValue = (Number) super.getValue();
+ private void checkChange() {
+ Number newValue = (Number) super.getValue();
- if (newValue.doubleValue() <= 0) {
- newValue = 0;
- currentValue = 0;
- ((JTextField) editor).setText("0");
- editor.repaint();
+ if (newValue.doubleValue() <= 0) {
+ newValue = 0;
+ currentValue = 0;
+ ((JTextField) editor).setText("0");
+ editor.repaint();
+ }
+
+ firePropertyChange(selected, newValue);
}
-
- firePropertyChange(selected, newValue);
- }
}
Modified:
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/CyStringPropertyEditor.java
===================================================================
---
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/CyStringPropertyEditor.java
2012-01-25 22:29:31 UTC (rev 28108)
+++
core3/impl/trunk/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/editor/propertyeditor/CyStringPropertyEditor.java
2012-01-25 22:50:09 UTC (rev 28109)
@@ -1,4 +1,3 @@
-
/*
Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
@@ -32,7 +31,7 @@
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.editor.propertyeditor;
@@ -47,12 +46,6 @@
import com.l2fprod.common.propertysheet.PropertySheetTableModel.Item;
import com.l2fprod.common.swing.LookAndFeelTweaks;
-
-/**
- * DOCUMENT ME!
- *
- * @author $author$
- */
public class CyStringPropertyEditor extends StringPropertyEditor {
private Object currentValue;
private Object selected;
@@ -65,67 +58,66 @@
((JTextField) editor).setBorder(LookAndFeelTweaks.EMPTY_BORDER);
((JTextField) editor).addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- Method getM = null;
- Object val = null;
+ public void focusGained(FocusEvent e) {
+ Method getM = null;
+ Object val = null;
- try {
- getM =
e.getOppositeComponent().getClass().getMethod("getSelectedRow", new Class[] {});
- } catch (SecurityException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- } catch (NoSuchMethodException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- }
+ try {
+ getM =
e.getOppositeComponent().getClass().getMethod("getSelectedRow", new Class[] {});
+ } catch (SecurityException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (NoSuchMethodException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
- try {
- val =
getM.invoke(e.getOppositeComponent(), new Object[] {});
- } catch (IllegalArgumentException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- } catch (IllegalAccessException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- } catch (InvocationTargetException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- }
+ try {
+ val =
getM.invoke(e.getOppositeComponent(), new Object[] {});
+ } catch (IllegalArgumentException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (IllegalAccessException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (InvocationTargetException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
- try {
- getM =
e.getOppositeComponent().getClass()
-
.getMethod("getValueAt", new Class[] { int.class, int.class });
- } catch (SecurityException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- } catch (NoSuchMethodException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- }
+ try {
+ getM =
e.getOppositeComponent().getClass()
+
.getMethod("getValueAt", new Class[] { int.class, int.class });
+ } catch (SecurityException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (NoSuchMethodException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
- Object val2 = null;
+ Object val2 = null;
- try {
- val2 =
getM.invoke(e.getOppositeComponent(),
- new Object[]
{ (Integer) val, Integer.valueOf(0) });
- } catch (IllegalArgumentException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- } catch (IllegalAccessException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- } catch (InvocationTargetException e1) {
- // TODO Auto-generated catch
block
- e1.printStackTrace();
- }
-
- selected = ((Item)
val2).getProperty().getDisplayName();
- currentValue = ((JTextField)
editor).getText();
+ try {
+ val2 =
getM.invoke(e.getOppositeComponent(), new Object[] { (Integer) val,
Integer.valueOf(0) });
+ } catch (IllegalArgumentException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (IllegalAccessException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (InvocationTargetException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
}
- public void focusLost(FocusEvent arg0) {
- firePropertyChange(selected,
((JTextField) editor).getText());
- }
- });
+ selected = ((Item)
val2).getProperty().getDisplayName();
+ currentValue = ((JTextField) editor).getText();
+ }
+
+ public void focusLost(FocusEvent arg0) {
+ firePropertyChange(selected, ((JTextField)
editor).getText());
+ }
+ });
}
}
--
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.