Author: jgao
Date: 2009-08-03 19:05:39 -0700 (Mon, 03 Aug 2009)
New Revision: 17673
Modified:
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/AttributeBasedIDMappingServiceImpl.java
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/CyThesaurusPlugin.java
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/CyThesaurusDialog.form
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/CyThesaurusDialog.java
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/TargetAttributeSelectionTable.java
Log:
Target attribute type option of string and list was changed to "only keep one
target id" vs "keep multiple ids"
Modified:
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/AttributeBasedIDMappingServiceImpl.java
===================================================================
---
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/AttributeBasedIDMappingServiceImpl.java
2009-08-03 23:17:32 UTC (rev 17672)
+++
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/AttributeBasedIDMappingServiceImpl.java
2009-08-04 02:05:39 UTC (rev 17673)
@@ -290,7 +290,11 @@
if (attrType==CyAttributes.TYPE_SIMPLE_LIST) {
nodeAttributes.setListAttribute(nodeID, attrName, new
Vector(ids));
} else if (attrType==CyAttributes.TYPE_STRING) {
- nodeAttributes.setAttribute(nodeID, attrName,
ids.toString());
+ // only returns the first ID
+ //TODO: is that a way to get the "best" one?
+ if (!ids.isEmpty()) {
+ nodeAttributes.setAttribute(nodeID, attrName,
ids.iterator().next());
+ }
}
}
}
Modified:
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/CyThesaurusPlugin.java
===================================================================
---
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/CyThesaurusPlugin.java
2009-08-03 23:17:32 UTC (rev 17672)
+++
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/CyThesaurusPlugin.java
2009-08-04 02:05:39 UTC (rev 17673)
@@ -35,7 +35,6 @@
package csplugins.id.mapping;
-import csplugins.id.mapping.IDMappingClientManager;
import csplugins.id.mapping.ui.CyThesaurusDialog;
import csplugins.id.mapping.ui.IDMappingSourceConfigDialog;
@@ -73,30 +72,8 @@
BioDataSource.init();
Cytoscape.getDesktop().getCyMenus().getOperationsMenu().add(new
IDMappingAction());
addService();
-
-// Cytoscape.getDesktop().getCyMenus().getOperationsMenu().add(new
TestCyThesurrusServiceAction());
}
-// class TestCyThesurrusServiceAction extends CytoscapeAction {
-//
-// public static final String testPluginName =
"TestCyThesurrusServiceAction";
-// public TestCyThesurrusServiceAction() {
-// super(testPluginName); //TODO rename
-// }
-//
-// /**
-// * This method is called when the user selects the menu item.
-// */
-// @Override
-// public void actionPerformed(final ActionEvent ae) {
-// String type = "MAPPING_DIALOG";
-// String id = testPluginName + System.currentTimeMillis();
-//
-// PluginsCommunicationSupport.sendMessage(id, testPluginName,
pluginName, type);
-//
-// }
-// }
-
public static final String pluginName = "CyThesaurus";
private Map<String,Set<DataSource>> mapSrcAttrIDTypes = null;
@@ -135,7 +112,7 @@
String msgType = msg.getType();
if (msgType==null) return;
- ResponseMessage response = null;;
+ ResponseMessage response = null;
if (msgType.compareTo(Message.MSG_TYPE_TEST)==0) {
response = testService(msg);
} else if (msgType.compareTo(MSG_TYPE_REQUEST_MAPPING)==0) {
@@ -203,8 +180,6 @@
return createResponse(msg, content);
}
- content.put(RESPONSE_SUCCESS, true);
-
String[] srcTypes = new String[srcDataSources.size()];
int ids = 0;
for(DataSource ds : srcDataSources) {
@@ -215,10 +190,12 @@
String[] tgtTypes = new String[tgtDataSources.size()];
ids = 0;
for(DataSource ds : tgtDataSources) {
- srcTypes[ids++] = ds.getFullName();
+ tgtTypes[ids++] = ds.getFullName();
}
content.put(RESPONSE_TGT_ID_TYPE, tgtTypes);
+ content.put(RESPONSE_SUCCESS, true);
+
return createResponse(msg, content);
}
@@ -242,6 +219,10 @@
Map content = new HashMap();
content.put(RESPONSE_SUCCESS, !dialog.isCancelled());
+ if (!dialog.isCancelled()) {
+ mapSrcAttrIDTypes = dialog.getMapSrcAttrIDTypes();
+ }
+
return createResponse(msg, content);
}
Modified:
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/CyThesaurusDialog.form
===================================================================
---
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/CyThesaurusDialog.form
2009-08-03 23:17:32 UTC (rev 17672)
+++
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/CyThesaurusDialog.form
2009-08-04 02:05:39 UTC (rev 17673)
@@ -187,6 +187,15 @@
<Layout
class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<SubComponents>
+ <Component class="javax.swing.JButton" name="OKBtn">
+ <Properties>
+ <Property name="text" type="java.lang.String" value=" OK "/>
+ <Property name="enabled" type="boolean" value="false"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent" handler="OKBtnActionPerformed"/>
+ </Events>
+ </Component>
<Component class="javax.swing.JButton" name="cancelBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
@@ -199,15 +208,6 @@
<AuxValue name="JavaCodeGenerator_VariableModifier"
type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
- <Component class="javax.swing.JButton" name="OKBtn">
- <Properties>
- <Property name="text" type="java.lang.String" value=" OK "/>
- <Property name="enabled" type="boolean" value="false"/>
- </Properties>
- <Events>
- <EventHandler event="actionPerformed"
listener="java.awt.event.ActionListener"
parameters="java.awt.event.ActionEvent" handler="OKBtnActionPerformed"/>
- </Events>
- </Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="selectNetworkPanel">
Modified:
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/CyThesaurusDialog.java
===================================================================
---
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/CyThesaurusDialog.java
2009-08-03 23:17:32 UTC (rev 17672)
+++
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/CyThesaurusDialog.java
2009-08-04 02:05:39 UTC (rev 17673)
@@ -101,8 +101,8 @@
javax.swing.JPanel typeSourceConfPanel = new javax.swing.JPanel();
javax.swing.JButton srcConfBtn = new javax.swing.JButton();
javax.swing.JPanel OKPanel = new javax.swing.JPanel();
+ OKBtn = new javax.swing.JButton();
javax.swing.JButton cancelBtn = new javax.swing.JButton();
- OKBtn = new javax.swing.JButton();
javax.swing.JPanel selectNetworkPanel = new javax.swing.JPanel();
javax.swing.JScrollPane unselectedNetworkScrollPane = new
javax.swing.JScrollPane();
unselectedNetworkData = new SortedNetworkListModel();
@@ -210,14 +210,6 @@
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
getContentPane().add(typeSourceConfPanel, gridBagConstraints);
- cancelBtn.setText("Cancel");
- cancelBtn.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- cancelBtnActionPerformed(evt);
- }
- });
- OKPanel.add(cancelBtn);
-
OKBtn.setText(" OK ");
OKBtn.setEnabled(false);
OKBtn.addActionListener(new java.awt.event.ActionListener() {
@@ -227,6 +219,14 @@
});
OKPanel.add(OKBtn);
+ cancelBtn.setText("Cancel");
+ cancelBtn.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cancelBtnActionPerformed(evt);
+ }
+ });
+ OKPanel.add(cancelBtn);
+
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
Modified:
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/TargetAttributeSelectionTable.java
===================================================================
---
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/TargetAttributeSelectionTable.java
2009-08-03 23:17:32 UTC (rev 17672)
+++
csplugins/trunk/soc/jgao/IDMapping/src/csplugins/id/mapping/ui/TargetAttributeSelectionTable.java
2009-08-04 02:05:39 UTC (rev 17673)
@@ -81,17 +81,17 @@
private int rowCount;
private List<JComboBox> idTypeComboBoxes;
private List<String> destinationAttributes;
- private List<JComboBox> attrTypeComboBoxes;
+ private List<JComboBox> oneIDOnlyComboBoxes;
private List<JButton> rmvBtns;
private JButton addBtn;
private final String headerIDType = "Target ID Type";
private final String headerAttrName = "Target New Attribute";
- private final String headerAttrType = "Attribute Type";
+ private final String headerOneIDOnly = "Keep only one target ID?";
private final String headerBtn = " ";
- private final String stringAttrType = "String";
- private final String listAttrType = "List";
+ private final String oneIDOnly = "Keep one ID only";
+ private final String multiIDs = "Keep multiple IDs";
private java.awt.Color defBgColor = (new JScrollPane()).getBackground();
@@ -104,7 +104,7 @@
destinationAttributes = new Vector();
idTypeComboBoxes = new Vector();
- attrTypeComboBoxes = new Vector();
+ oneIDOnlyComboBoxes = new Vector();
rmvBtns = new Vector();
addBtn = new JButton("Insert");
addBtn.setBackground(defBgColor);
@@ -145,7 +145,7 @@
}
});
- setPreferredColumnWidths(new double[]{0.3,0.3,0.15,0.15});
+ setPreferredColumnWidths(new double[]{0.3,0.3,0.3,0.1});
setColumnEditorAndCellRenderer();
}
@@ -188,7 +188,8 @@
List<DataSource> ret = new Vector();
for (int i=0; i<rowCount; i++) {
- DataSourceWrapper dsw =
(DataSourceWrapper)idTypeComboBoxes.get(i).getSelectedItem();
+ DataSourceWrapper dsw = (DataSourceWrapper)idTypeComboBoxes.get(i)
+ .getSelectedItem();
DataSource ds = dsw.DataSource();
ret.add(ds);
}
@@ -197,15 +198,17 @@
public List<String> getTgtAttrNames() {
Set<String> usedName = new HashSet();
- usedName.add("ID");
-
usedName.addAll(Arrays.asList(Cytoscape.getNodeAttributes().getAttributeNames()));
+ usedName.add("ID"); //TODO: remove Cy3
+ usedName.addAll(Arrays.asList(Cytoscape.getNodeAttributes()
+ .getAttributeNames()));
usedName.addAll(destinationAttributes);
List<String> ret = new Vector();
for (int row=0; row<rowCount; row++) {
String attr = destinationAttributes.get(row);
if (attr.length()==0) {
- DataSourceWrapper dsw =
(DataSourceWrapper)idTypeComboBoxes.get(row).getSelectedItem();
+ DataSourceWrapper dsw = (DataSourceWrapper)idTypeComboBoxes
+ .get(row).getSelectedItem();
attr = dsw.toString();
if (usedName.contains(attr)) {
@@ -227,8 +230,10 @@
public List<Byte> getTgtAttrTypes() {
List<Byte> ret = new Vector();
for (int i=0; i<rowCount; i++) {
- String type = (String) attrTypeComboBoxes.get(i).getSelectedItem();
- byte attrType = type.compareTo(listAttrType)==0 ?
CyAttributes.TYPE_SIMPLE_LIST : CyAttributes.TYPE_STRING;
+ boolean oneId = oneIDOnly.compareTo((String)oneIDOnlyComboBoxes
+ .get(i).getSelectedItem())==0;
+ byte attrType = oneId ?
+ CyAttributes.TYPE_STRING : CyAttributes.TYPE_SIMPLE_LIST;
ret.add(attrType);
}
@@ -242,7 +247,8 @@
Map<DataSource, String> ret = new HashMap();
for (int i=0; i<rowCount; i++) {
- DataSourceWrapper dsw =
(DataSourceWrapper)idTypeComboBoxes.get(i).getSelectedItem();
+ DataSourceWrapper dsw = (DataSourceWrapper)idTypeComboBoxes.get(i)
+ .getSelectedItem();
DataSource ds = dsw.DataSource();
String name = getAttrName(i);
ret.put(ds, name);
@@ -254,9 +260,11 @@
Map<String,Byte> ret = new HashMap();
for (int i=0; i<rowCount; i++) {
String name = getAttrName(i);
- String type = (String) attrTypeComboBoxes.get(i).getSelectedItem();
- byte attrType = type.compareTo(listAttrType)==0 ?
CyAttributes.TYPE_SIMPLE_LIST : CyAttributes.TYPE_STRING;
-
+ boolean oneId = oneIDOnly.compareTo((String)oneIDOnlyComboBoxes
+ .get(i).getSelectedItem())==0;
+ byte attrType = oneId ?
+ CyAttributes.TYPE_STRING : CyAttributes.TYPE_SIMPLE_LIST;
+
ret.put(name, attrType);
}
return ret;
@@ -276,28 +284,34 @@
TableColumn column = colModel.getColumn(iCol);
RowTableCellEditor rowEditor = new RowTableCellEditor(this);
for (int ir=0; ir<rowCount; ir++) {
- rowEditor.setEditorAt(ir, new
DefaultCellEditor(idTypeComboBoxes.get(ir)));
+ rowEditor.setEditorAt(ir,
+ new DefaultCellEditor(idTypeComboBoxes.get(ir)));
}
column.setCellEditor(rowEditor);
if (supportedIDType.isEmpty()) {
column.setCellRenderer(new TableCellRenderer() {
- private DefaultTableCellRenderer defaultRenderer = new
DefaultTableCellRenderer();
+ private DefaultTableCellRenderer defaultRenderer
+ = new DefaultTableCellRenderer();
//@Override
- public java.awt.Component getTableCellRendererComponent(JTable
table, Object value,
- boolean isSelected, boolean hasFocus, int row, int
column) {
- JLabel label = (JLabel)
defaultRenderer.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);
+ public java.awt.Component getTableCellRendererComponent(
+ JTable table, Object value, boolean isSelected,
+ boolean hasFocus, int row, int column) {
+ JLabel label = (JLabel) defaultRenderer
+ .getTableCellRendererComponent(table, value,
+ isSelected, hasFocus, row, column);
if (row<rowCount) {
if (isSelected) {
-
label.setBackground(table.getSelectionBackground());
-
label.setForeground(table.getSelectionForeground());
+ label.setBackground(table.getSelectionBackground());
+ label.setForeground(table.getSelectionForeground());
} else {
- label.setBackground(table.getBackground());
- label.setForeground(table.getForeground());
+ label.setBackground(table.getBackground());
+ label.setForeground(table.getForeground());
}
label.setText("No supported ID type");
- label.setToolTipText("Please select a non-empty ID
mapping source first.");
+ label.setToolTipText("Please select a non-empty ID " +
+ "mapping source first.");
return label;
} else if (row==rowCount) {
label.setBackground(defBgColor);
@@ -305,43 +319,51 @@
label.setText("");
return label;
} else {
- return
defaultRenderer.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);
+ return defaultRenderer.getTableCellRendererComponent(
+ table, value, isSelected, hasFocus, row,
+ column);
}
}
});
} else {
- column.setCellRenderer(new ComboBoxTableCellRenderer());
+ column.setCellRenderer(new ComponentTableCellRenderer());
}
// headerAttrName
iCol = colModel.getColumnIndex(headerAttrName);
column = colModel.getColumn(iCol);
column.setCellRenderer(new TableCellRenderer() {
- private DefaultTableCellRenderer defaultRenderer = new
DefaultTableCellRenderer();
+ private DefaultTableCellRenderer defaultRenderer
+ = new DefaultTableCellRenderer();
//@Override
- public java.awt.Component getTableCellRendererComponent(JTable
table, Object value,
- boolean isSelected, boolean hasFocus, int row, int
column) {
+ public java.awt.Component getTableCellRendererComponent(
+ JTable table, Object value, boolean isSelected,
+ boolean hasFocus, int row, int column) {
if (row==rowCount) {
- JLabel label = (JLabel) (new
DefaultTableCellRenderer()).getTableCellRendererComponent(table, value,
isSelected, hasFocus, row, column);
+ JLabel label = (JLabel) (new DefaultTableCellRenderer()).
+ getTableCellRendererComponent(table, value,
+ isSelected, hasFocus, row, column);
label.setBackground(defBgColor);
label.setForeground(defBgColor);
return label;
} else {
- return
defaultRenderer.getTableCellRendererComponent(table, value, isSelected,
hasFocus, row, column);
+ return defaultRenderer.getTableCellRendererComponent(table,
+ value, isSelected, hasFocus, row, column);
}
}
});
- // ID type
- iCol = colModel.getColumnIndex(headerAttrType);
+ // one id only
+ iCol = colModel.getColumnIndex(headerOneIDOnly);
column = colModel.getColumn(iCol);
rowEditor = new RowTableCellEditor(this);
for (int ir=0; ir<rowCount; ir++) {
- rowEditor.setEditorAt(ir, new
DefaultCellEditor(attrTypeComboBoxes.get(ir)));
+ rowEditor.setEditorAt(ir,
+ new DefaultCellEditor(oneIDOnlyComboBoxes.get(ir)));
}
column.setCellEditor(rowEditor);
- column.setCellRenderer(new ComboBoxTableCellRenderer());
+ column.setCellRenderer(new ComponentTableCellRenderer());
// button
iCol = colModel.getColumnIndex(headerBtn);
@@ -358,8 +380,8 @@
JComboBox cc = new JComboBox(new Vector(supportedIDType));
idTypeComboBoxes.add(cc);
- cc = new JComboBox(new String[]{listAttrType,stringAttrType});
- attrTypeComboBoxes.add(cc);
+ cc = new JComboBox(new String[]{multiIDs, oneIDOnly});
+ oneIDOnlyComboBoxes.add(cc);
rowCount++;
@@ -383,7 +405,7 @@
destinationAttributes.remove(row);
idTypeComboBoxes.remove(row);
- attrTypeComboBoxes.remove(row);
+ oneIDOnlyComboBoxes.remove(row);
rmvBtns.remove(row);
}
@@ -400,7 +422,7 @@
destinationAttributes.remove(row);
idTypeComboBoxes.remove(row);
- attrTypeComboBoxes.remove(row);
+ oneIDOnlyComboBoxes.remove(row);
rmvBtns.remove(row);
rowCount--;
@@ -428,7 +450,7 @@
}
private class IDTypeSelectionTableModel extends AbstractTableModel {
- private final String[] columnNames =
{headerIDType,headerAttrName,headerAttrType,headerBtn};
+ private final String[] columnNames =
{headerIDType,headerAttrName,headerOneIDOnly,headerBtn};
//@Override
public int getColumnCount() {
@@ -458,8 +480,8 @@
return getAttrName(row);
}
- if (colName.compareTo(headerAttrType)==0) {
- return attrTypeComboBoxes.get(row);
+ if (colName.compareTo(headerOneIDOnly)==0) {
+ return oneIDOnlyComboBoxes.get(row);
}
if (colName.compareTo(headerBtn)==0) {
@@ -480,7 +502,7 @@
@Override
public Class getColumnClass(int c) {
- return String.class;
+ return String.class;
}
@Override
@@ -499,7 +521,7 @@
return true;
}
- if (colName.compareTo(headerAttrType)==0) {
+ if (colName.compareTo(headerOneIDOnly)==0) {
return true;
}
@@ -513,10 +535,12 @@
@Override
public void setValueAt(Object value, int row, int col) {
+ if (row>=rowCount) return;
+
String colName = getColumnName(col);
- if (colName.compareTo(headerAttrName)==0 && row<rowCount) {
+ if (colName.compareTo(headerAttrName)==0) {
Set<String> usedName = new HashSet();
- usedName.add("ID");
+ usedName.add("ID"); //TODO remove in Cy3
usedName.addAll(Arrays.asList(Cytoscape.getNodeAttributes().getAttributeNames()));
usedName.addAll(destinationAttributes);
String str = (String)value;
@@ -537,11 +561,11 @@
}
}
- // render checkcombobox
- class ComboBoxTableCellRenderer implements TableCellRenderer {
+ // render combobox
+ class ComponentTableCellRenderer implements TableCellRenderer {
private DefaultTableCellRenderer defaultRenderer;
- public ComboBoxTableCellRenderer() {
+ public ComponentTableCellRenderer() {
defaultRenderer = new DefaultTableCellRenderer();
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---