Author: jm
Date: 2012-08-13 11:06:26 -0700 (Mon, 13 Aug 2012)
New Revision: 30172
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AbstractTableBrowser.java
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AttributeBrowserToolBar.java
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTable.java
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTableModel.java
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/DefaultTableBrowser.java
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/DeletionDialog.java
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/FormulaBuilderDialog.java
Log:
Fixes #1363: BrowserTableModel is now independent of its view. However, it
still has some view-related properties; e.g. show selected vs all rows mode
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AbstractTableBrowser.java
===================================================================
---
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AbstractTableBrowser.java
2012-08-13 16:06:58 UTC (rev 30171)
+++
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AbstractTableBrowser.java
2012-08-13 18:06:26 UTC (rev 30172)
@@ -7,6 +7,7 @@
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -17,6 +18,7 @@
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import org.cytoscape.application.CyApplicationManager;
@@ -70,8 +72,8 @@
// Tab title for the CytoPanel
private final String tabTitle;
- private final Map<BrowserTableModel,JScrollPane> scrollPanes;
- private final Map<CyTable,BrowserTableModel> browserTableModels;
+ private final Map<BrowserTable,JScrollPane> scrollPanes;
+ private final Map<CyTable,BrowserTable> browserTables;
private JScrollPane currentScrollPane;
protected final String appFileName;
@@ -97,8 +99,8 @@
this.eventHelper = eventHelper;
this.appFileName = tabTitle.replaceAll(" ",
"").concat(".props");
- this.scrollPanes = new HashMap<BrowserTableModel,JScrollPane>();
- this.browserTableModels = new
HashMap<CyTable,BrowserTableModel>();
+ this.scrollPanes = new HashMap<BrowserTable,JScrollPane>();
+ this.browserTables = new HashMap<CyTable,BrowserTable>();
this.setLayout(new BorderLayout());
this.setPreferredSize(PANEL_SIZE);
@@ -136,14 +138,16 @@
// Delete the given table from the JTable
public void deleteTable(CyTable cyTable){
- BrowserTableModel model = browserTableModels.remove(cyTable);
- if (model == null) {
+ BrowserTable table = browserTables.remove(cyTable);
+ if (table == null) {
return;
}
- scrollPanes.remove(model);
+ scrollPanes.remove(table);
+ TableModel model = table.getModel();
+ serviceRegistrar.unregisterAllServices(table);
serviceRegistrar.unregisterAllServices(model);
- model.getBrowserTable().setModel(new DefaultTableModel());
+ table.setModel(new DefaultTableModel());
if (currentTable == cyTable) {
currentTable = null;
@@ -154,8 +158,8 @@
if (currentScrollPane != null)
remove(currentScrollPane);
- final BrowserTableModel currentBrowserTableModel =
getCurrentBrowserTableModel();
- final JScrollPane newScrollPane =
getScrollPane(currentBrowserTableModel);
+ final BrowserTable currentBrowserTable =
getCurrentBrowserTable();
+ final JScrollPane newScrollPane =
getScrollPane(currentBrowserTable);
if (newScrollPane != null)
add(newScrollPane, BorderLayout.CENTER);
@@ -164,7 +168,7 @@
currentScrollPane = newScrollPane;
applicationManager.setCurrentTable(currentTable);
-
attributeBrowserToolBar.setBrowserTableModel(currentBrowserTableModel);
+ attributeBrowserToolBar.setBrowserTable(currentBrowserTable);
/*
@@ -174,14 +178,15 @@
*/
}
- private JScrollPane getScrollPane(final BrowserTableModel
browserTableModel) {
+ private JScrollPane getScrollPane(final BrowserTable browserTable) {
JScrollPane scrollPane = null;
- if (browserTableModel != null) {
- scrollPane = scrollPanes.get(browserTableModel);
+ if (browserTable != null) {
+ scrollPane = scrollPanes.get(browserTable);
if (scrollPane == null) {
- final BrowserTable browserTable =
browserTableModel.getBrowserTable();
+ BrowserTableModel browserTableModel =
(BrowserTableModel) browserTable.getModel();
+
serviceRegistrar.registerAllServices(browserTable, new Properties());
serviceRegistrar.registerAllServices(browserTableModel, new Properties());
browserTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
browserTable.getTableHeader().setBackground(Color.LIGHT_GRAY);
@@ -205,34 +210,35 @@
attrList.remove(CyNetwork.SUID);
attrList.remove( CyNetwork.SELECTED);
-
browserTableModel.setVisibleAttributeNames(attrList);
+ browserTable.setVisibleAttributeNames(attrList);
scrollPane = new JScrollPane(browserTable);
- scrollPanes.put(browserTableModel, scrollPane);
+ scrollPanes.put(browserTable, scrollPane);
}
}
return scrollPane;
}
- protected BrowserTableModel getCurrentBrowserTableModel() {
- BrowserTableModel btm = browserTableModels.get(currentTable);
+ protected BrowserTable getCurrentBrowserTable() {
+ BrowserTable table = browserTables.get(currentTable);
- if (btm == null && currentTable != null) {
- final BrowserTable browserTable = new
BrowserTable(compiler, popupMenuHelper,
+ if (table == null && currentTable != null) {
+ table = new BrowserTable(compiler, popupMenuHelper,
applicationManager, eventHelper,
tableManager);
BrowserTableColumnModel columnModel = new
BrowserTableColumnModel();
- browserTable.setColumnModel(columnModel);
+ table.setColumnModel(columnModel);
- btm = new BrowserTableModel(browserTable, currentTable,
compiler, tableManager);
- browserTableModels.put(currentTable, btm);
+ BrowserTableModel model = new
BrowserTableModel(currentTable, compiler, tableManager);
+ table.setModel(model);
+ browserTables.put(currentTable, table);
+ return table;
}
-
- return btm;
+ return table;
}
- protected Map<CyTable, BrowserTableModel> getAllBrowserTablesMap (){
- return browserTableModels;
+ protected Map<CyTable, BrowserTable> getAllBrowserTablesMap (){
+ return browserTables;
}
void updateColumnComparators(final TableRowSorter<BrowserTableModel>
rowSorter,
@@ -257,7 +263,7 @@
if (tscMap == null || tscMap.isEmpty())
return;
- Map<CyTable, BrowserTableModel> browserTableModels =
getAllBrowserTablesMap();
+ Map<CyTable, BrowserTable> browserTableModels =
getAllBrowserTablesMap();
for (CyTable table : browserTableModels.keySet()){
if (! tscMap.containsKey(table.getTitle()))
@@ -265,17 +271,17 @@
final TableColumnStat tcs =
tscMap.get(table.getTitle());
- final BrowserTableModel btm =
browserTableModels.get(table);
- final BrowserTableColumnModel colM =
(BrowserTableColumnModel) btm.getTable().getColumnModel();
+ final BrowserTable browserTable =
browserTables.get(table);
+ BrowserTableModel model = (BrowserTableModel)
browserTable.getModel();
+ final BrowserTableColumnModel colM =
(BrowserTableColumnModel)browserTable.getColumnModel();
colM.setAllColumnsVisible();
final List<String> orderedCols = tcs.getOrderedCol();
- final JTable jtable = btm.getTable();
for (int i =0; i< orderedCols.size(); i++){
final String colName = orderedCols.get(i);
- colM.moveColumn(
jtable.convertColumnIndexToView(btm.mapColumnNameToColumnIndex(colName)) , i);
+ colM.moveColumn(
browserTable.convertColumnIndexToView(model.mapColumnNameToColumnIndex(colName))
, i);
}
- btm.setVisibleAttributeNames(tcs.getVisibleCols());
+
browserTable.setVisibleAttributeNames(tcs.getVisibleCols());
}
@@ -284,26 +290,26 @@
@Override
public void handleEvent(SessionAboutToBeSavedEvent e) {
- Map<CyTable, BrowserTableModel> browserTableModels =
getAllBrowserTablesMap();
+ Map<CyTable, BrowserTable> browserTables =
getAllBrowserTablesMap();
List< TableColumnStat> tableColumnStatList = new
ArrayList<TableColumnStat>();
- for (CyTable table : browserTableModels.keySet()){
+ for (CyTable table : browserTables.keySet()){
TableColumnStat tcs = new
TableColumnStat(table.getTitle());
- BrowserTableModel btm = browserTableModels.get(table);
- BrowserTableColumnModel colM =
(BrowserTableColumnModel) btm.getTable().getColumnModel();
- List<String> visAttrs = btm.getVisibleAttributeNames();
+ BrowserTable browserTable = browserTables.get(table);
+ BrowserTableModel model = (BrowserTableModel)
browserTable.getModel();
+ BrowserTableColumnModel colM =
(BrowserTableColumnModel) browserTable.getColumnModel();
+ List<String> visAttrs =
browserTable.getVisibleAttributeNames();
colM.setAllColumnsVisible();
- List<String> attrs = btm.getAllAttributeNames();
- JTable jtable = btm.getTable();
+ Collection<String> attrs =
model.getAllAttributeNames();
for (String name: attrs){
- int viewIndex =
jtable.convertColumnIndexToView(btm.mapColumnNameToColumnIndex(name));
+ int viewIndex =
browserTable.convertColumnIndexToView(model.mapColumnNameToColumnIndex(name));
tcs.addColumnStat(name, viewIndex,
visAttrs.contains(name));
}
- btm.setVisibleAttributeNames(visAttrs);
+ browserTable.setVisibleAttributeNames(visAttrs);
tableColumnStatList.add(tcs);
}
TableColumnStatFileIO.write(tableColumnStatList, e,
this.appFileName );
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AttributeBrowserToolBar.java
===================================================================
---
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AttributeBrowserToolBar.java
2012-08-13 16:06:58 UTC (rev 30171)
+++
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/AttributeBrowserToolBar.java
2012-08-13 18:06:26 UTC (rev 30172)
@@ -96,6 +96,7 @@
private static final long serialVersionUID = -508393701912596399L;
+ private BrowserTable browserTable;
private BrowserTableModel browserTableModel;
private static final Dimension TOOLBAR_SIZE = new Dimension(500, 38);
@@ -180,8 +181,13 @@
}
- public void setBrowserTableModel(final BrowserTableModel
browserTableModel) {
- this.browserTableModel = browserTableModel;
+ public void setBrowserTable(final BrowserTable browserTable) {
+ this.browserTable = browserTable;
+ if (browserTable != null) {
+ browserTableModel = (BrowserTableModel)
browserTable.getModel();
+ } else {
+ browserTableModel = null;
+ }
attrListModel.setBrowserTableModel(browserTableModel);
updateEnableState();
}
@@ -201,7 +207,7 @@
for (final Object selectedValue :
selectedValues)
visibleAttributes.add((String)selectedValue);
-
browserTableModel.setVisibleAttributeNames(visibleAttributes);
+
browserTable.setVisibleAttributeNames(visibleAttributes);
}
} catch (Exception ex) {
attributeList.clearSelection();
@@ -568,7 +574,7 @@
public void mouseClicked(MouseEvent e) {
if (browserTableModel == null)
return;
-
attributeList.setSelectedItems(browserTableModel.getVisibleAttributeNames());
+
attributeList.setSelectedItems(browserTable.getVisibleAttributeNames());
attributeSelectionPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}
});
@@ -594,15 +600,13 @@
if (browserTableModel == null)
return;
- final JTable table =
browserTableModel.getTable();
-
// Do not allow opening of the formula
builder dialog
// while a cell is being edited!
- if (table.getCellEditor() != null)
+ if (browserTable.getCellEditor() !=
null)
return;
- final int cellRow =
table.getSelectedRow();
- final int cellColumn =
table.getSelectedColumn();
+ final int cellRow =
browserTable.getSelectedRow();
+ final int cellColumn =
browserTable.getSelectedColumn();
if (cellRow == -1 || cellColumn == -1
|| !browserTableModel.isCellEditable(cellRow, cellColumn)) {
JOptionPane.showMessageDialog(rootFrame, "Can't enter a formula w/o a selected
cell.",
@@ -613,7 +617,7 @@
final CyTable attrs =
browserTableModel.getAttributes();
initAttribNameToTypeMap(attrs,
attrName, attribNameToTypeMap);
final FormulaBuilderDialog
formulaBuilderDialog = new FormulaBuilderDialog(compiler,
-
browserTableModel, rootFrame, attrName);
+ browserTable,
rootFrame, attrName);
formulaBuilderDialog.setLocationRelativeTo(rootFrame);
formulaBuilderDialog.setVisible(true);
}
@@ -632,7 +636,7 @@
}
private String getAttribName(final int cellRow, final int cellColumn) {
- int colIndexModel =
browserTableModel.getTable().convertColumnIndexToModel(cellColumn);
+ int colIndexModel =
browserTable.convertColumnIndexToModel(cellColumn);
return browserTableModel.getColumnName( colIndexModel);
}
@@ -696,7 +700,7 @@
final Set<String> allAttrNames
= new HashSet<String>();
for (final CyColumn column :
table.getColumns())
allAttrNames.add(column.getName());
-
browserTableModel.setVisibleAttributeNames(allAttrNames);
+
browserTable.setVisibleAttributeNames(allAttrNames);
// ***DO NOT *** Resize column
//ColumnResizer.adjustColumnPreferredWidths(browserTableModel.getTable());
@@ -723,7 +727,7 @@
unselectAllAttributesButton.addMouseListener(new
MouseAdapter() {
public void mouseClicked(MouseEvent e) {
try {
-
browserTableModel.setVisibleAttributeNames(new HashSet<String>());
+
browserTable.setVisibleAttributeNames(new HashSet<String>());
} catch (Exception ex) {
attributeList.clearSelection();
}
@@ -738,7 +742,7 @@
final String[] attrArray = getAttributeArray();
final JFrame frame = (JFrame)SwingUtilities.getRoot(this);
- final DeletionDialog dDialog = new DeletionDialog(frame,
browserTableModel.getAttributes(), browserTableModel);
+ final DeletionDialog dDialog = new DeletionDialog(frame,
browserTableModel.getAttributes(), browserTable);
dDialog.pack();
dDialog.setLocationRelativeTo(toolBar);
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTable.java
===================================================================
---
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTable.java
2012-08-13 16:06:58 UTC (rev 30171)
+++
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTable.java
2012-08-13 18:06:26 UTC (rev 30172)
@@ -30,7 +30,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
@@ -58,15 +57,27 @@
import org.cytoscape.equations.EquationCompiler;
import org.cytoscape.event.CyEventHelper;
import org.cytoscape.model.CyColumn;
+import org.cytoscape.model.CyIdentifiable;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyRow;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.events.ColumnCreatedEvent;
+import org.cytoscape.model.events.ColumnCreatedListener;
+import org.cytoscape.model.events.ColumnDeletedEvent;
+import org.cytoscape.model.events.ColumnDeletedListener;
+import org.cytoscape.model.events.ColumnNameChangedEvent;
+import org.cytoscape.model.events.ColumnNameChangedListener;
+import org.cytoscape.model.events.RowSetRecord;
+import org.cytoscape.model.events.RowsSetEvent;
+import org.cytoscape.model.events.RowsSetListener;
import org.cytoscape.view.model.CyNetworkView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class BrowserTable extends JTable implements MouseListener,
ActionListener, MouseMotionListener {
+public class BrowserTable extends JTable implements MouseListener,
ActionListener, MouseMotionListener,
+
ColumnCreatedListener, ColumnDeletedListener,
+
ColumnNameChangedListener, RowsSetListener {
private static final long serialVersionUID = 4415856756184765301L;
@@ -153,29 +164,32 @@
@Override
public void mouseClicked(MouseEvent e) {
- final int column =
getColumnModel().getColumnIndexAtX(e.getX());
- final int row = e.getY() / getRowHeight();
+ final int viewColumn =
getColumnModel().getColumnIndexAtX(e.getX());
+ final int viewRow = e.getY() / getRowHeight();
final BrowserTableModel tableModel =
(BrowserTableModel) table.getModel();
+ int modelColumn =
convertColumnIndexToModel(viewColumn);
+ int modelRow = convertRowIndexToModel(viewRow);
+
// Bail out if we're at the ID column:
- if (tableModel.isPrimaryKey(column))
+ if (tableModel.isPrimaryKey(modelColumn))
return;
// Make sure the column and row we're clicking
on actually
// exists!
- if (column >= tableModel.getColumnCount() ||
row >= tableModel.getRowCount())
+ if (modelColumn >= tableModel.getColumnCount()
|| modelRow >= tableModel.getRowCount())
return;
// If action is right click, then show edit
pop-up menu
if ((SwingUtilities.isRightMouseButton(e)) ||
(isMacPlatform() && e.isControlDown())) {
- final CyColumn cyColumn =
tableModel.getColumn(column);
- final Object primaryKeyValue =
((ValidatedObjectAndEditString) tableModel.getValueAt(row,
+ final CyColumn cyColumn =
tableModel.getColumn(modelColumn);
+ final Object primaryKeyValue =
((ValidatedObjectAndEditString) tableModel.getValueAt(modelRow,
tableModel.getDataTable().getPrimaryKey().getName())).getValidatedObject();
popupMenuHelper.createTableCellMenu(cyColumn, primaryKeyValue, table, e.getX(),
e.getY());
} else if (SwingUtilities.isLeftMouseButton(e)
&& (getSelectedRows().length != 0)) {
// Display List menu.
- showListContents(row, column, e);
+ showListContents(modelRow, modelColumn,
e);
}
}
@@ -285,7 +299,9 @@
// user click on open space on canvas, so we have to remember
it before
// it is gone
BrowserTableModel model = (BrowserTableModel) this.getModel();
- editorRemover.setCellData(model.getCellData(row, column));
+ CyRow cyRow = model.getCyRow(convertRowIndexToModel(row));
+ String columnName =
model.getColumnName(convertColumnIndexToModel(column));
+ editorRemover.setCellData(cyRow, columnName);
if ((editor != null) && editor.isCellEditable(e)) {
// Do this first so that the bounds of the JTextArea
editor
@@ -322,13 +338,11 @@
return false;
}
- public void showListContents(int viewRowIndex, int viewColumnIndex,
MouseEvent e) {
+ public void showListContents(int modelRow, int modelColumn, MouseEvent
e) {
final BrowserTableModel model = (BrowserTableModel) getModel();
- final Class<?> columnType =
model.getColumn(viewColumnIndex).getType();
+ final Class<?> columnType =
model.getColumn(modelColumn).getType();
if (columnType == List.class) {
- int modelRow = convertRowIndexToModel(viewRowIndex);
- int modelColumn =
convertColumnIndexToModel(viewColumnIndex);
final ValidatedObjectAndEditString value =
(ValidatedObjectAndEditString) model.getValueAt(modelRow, modelColumn);
if (value != null) {
@@ -419,7 +433,7 @@
else {
final String columnName =
tableModel.getColumnName(cellColumn);
final Map<String, Class>
attribNameToTypeMap = new HashMap<String, Class>();
- FormulaBuilderDialog
formulaBuilderDialog = new FormulaBuilderDialog(compiler, tableModel,
+ FormulaBuilderDialog
formulaBuilderDialog = new FormulaBuilderDialog(compiler, BrowserTable.this,
rootFrame, columnName);
formulaBuilderDialog.setLocationRelativeTo(rootFrame);
formulaBuilderDialog.setVisible(true);
@@ -566,7 +580,8 @@
private final KeyboardFocusManager focusManager;
private BrowserTableModel model;
private int row = -1, column = -1;
- private Vector cellVect = null;
+ private CyRow cyRow;
+ private String columnName;
public CellEditorRemover(final KeyboardFocusManager fm) {
this.focusManager = fm;
@@ -607,20 +622,17 @@
// disappear if
// user click on open space on canvas, so we have to remember
it before
// it is gone
- public void setCellData(Vector cellVect) {
- this.cellVect = cellVect;
+ public void setCellData(CyRow row, String columnName) {
+ this.cyRow = row;
+ this.columnName = columnName;
}
private void updateAttributeAfterCellLostFocus() {
-
- CyRow rowObj = (CyRow) cellVect.get(0);
- String columnName = (String) cellVect.get(1);
-
- ArrayList parsedData =
TableBrowserUtil.parseCellInput(rowObj.getTable(), columnName,
+ ArrayList parsedData =
TableBrowserUtil.parseCellInput(cyRow.getTable(), columnName,
MultiLineTableCellEditor.lastValueUserEntered);
if (parsedData.get(0) != null) {
- rowObj.set(columnName,
MultiLineTableCellEditor.lastValueUserEntered);
+ cyRow.set(columnName,
MultiLineTableCellEditor.lastValueUserEntered);
} else {
// Error
// discard the change
@@ -711,6 +723,219 @@
public boolean isSortedColumnAscending() {
return sortedColumnAscending;
}
+
+ public void setVisibleAttributeNames(Collection<String>
visibleAttributes) {
+ BrowserTableModel model = (BrowserTableModel) getModel();
+
+ BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
getColumnModel();
+ for (final String name : model.getAllAttributeNames()) {
+ int col = model.mapColumnNameToColumnIndex(name);
+ int convCol = convertColumnIndexToView(col);
+ TableColumn column =
columnModel.getColumnByModelIndex(col);
+ columnModel.setColumnVisible(column,
visibleAttributes.contains(name));
+ }
+
+ //don't fire this, it will reset all the columns based on model
+ //fireTableStructureChanged();
+ }
+
+ public List<String> getVisibleAttributeNames() {
+ BrowserTableModel model = (BrowserTableModel) getModel();
+ final List<String> visibleAttrNames = new ArrayList<String>();
+ for (final String name : model.getAllAttributeNames()) {
+ if (isColumnVisible(name))
+ visibleAttrNames.add(name);
+ }
+
+ return visibleAttrNames;
+ }
+
+ public boolean isColumnVisible(String name) {
+ BrowserTableModel model = (BrowserTableModel) getModel();
+ BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
getColumnModel();
+ TableColumn column =
columnModel.getColumnByModelIndex(model.mapColumnNameToColumnIndex(name));
+ return columnModel.isColumnVisible(column);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void handleEvent(final ColumnCreatedEvent e) {
+ BrowserTableModel model = (BrowserTableModel) getModel();
+ CyTable dataTable = model.getDataTable();
+
+ if (e.getSource() != dataTable)
+ return;
+ BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
getColumnModel();
+
+ model.addColumn(e.getColumnName());
+
+ int colIndex = columnModel.getColumnCount(false);
+ TableColumn newCol = new TableColumn(colIndex);
+ newCol.setHeaderValue(e.getColumnName());
+ setUpdateComparators(false);
+ addColumn(newCol);
+ final TableRowSorter<BrowserTableModel> rowSorter = new
TableRowSorter<BrowserTableModel>(model);
+ setRowSorter(rowSorter);
+ updateColumnComparators(rowSorter, model);
+ setUpdateComparators(true);
+
+ }
+
+ void updateColumnComparators(final TableRowSorter<BrowserTableModel>
rowSorter,
+ final BrowserTableModel browserTableModel) {
+ for (int column = 0; column <
browserTableModel.getColumnCount(); ++column)
+ rowSorter.setComparator(
+ column,
+ new
ValidatedObjectAndEditStringComparator(
+
browserTableModel.getColumnByModelIndex(column).getType()));
+ }
+
+ @Override
+ public void handleEvent(final ColumnDeletedEvent e) {
+ BrowserTableModel model = (BrowserTableModel) getModel();
+ CyTable dataTable = model.getDataTable();
+
+ if (e.getSource() != dataTable)
+ return;
+ BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
getColumnModel();
+
+ final String columnName = e.getColumnName();
+ boolean columnFound = false;
+ int removedColIndex = -1;
+
+ List<String> attrNames = model.getAllAttributeNames();
+ for (int i = 0; i < attrNames.size(); ++i) {
+ if (attrNames.get(i).equals(columnName)) {
+ removedColIndex = i;
+ columnModel.removeColumn
(columnModel.getColumn(convertColumnIndexToView(i)));
+ columnFound = true;
+ }
+ else if (columnFound){ //need to push back the model
indexes for all of the columns after this
+
+ TableColumn nextCol =
columnModel.getColumnByModelIndex(i);
+ nextCol.setModelIndex(i- 1);
+ }
+ }
+
+ if (removedColIndex != -1){//remove the item after the loop is
done
+ model.removeColumn(removedColIndex);
+ }
+
+ }
+
+ @Override
+ public void handleEvent(final ColumnNameChangedEvent e) {
+ BrowserTableModel model = (BrowserTableModel) getModel();
+ CyTable dataTable = model.getDataTable();
+
+ if (e.getSource() != dataTable)
+ return;
+
+ final String newColumnName = e.getNewColumnName();
+ final int column =
model.mapColumnNameToColumnIndex(e.getOldColumnName());
+ if (isColumnVisible(e.getOldColumnName())){
+ int colIndex = convertColumnIndexToView(column);
+ if (colIndex != -1)
+
getColumnModel().getColumn(colIndex).setHeaderValue(newColumnName);
+ }
+
+ renameColumnName(e.getOldColumnName(), newColumnName);
+
+ }
+
+ private void renameColumnName(final String oldName, final String
newName) {
+ BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
getColumnModel();
+ BrowserTableModel model = (BrowserTableModel) getModel();
+
+ int index = model.mapColumnNameToColumnIndex(oldName);
+ if (index >= 0){
+ model.setColumnName(index, newName);
+
columnModel.getColumn(convertColumnIndexToView(index)).setHeaderValue(newName);
+ return;
+ }
+ throw new IllegalStateException("The specified column " +
oldName +" does not exist in the model.");
+ }
+
+ @Override
+ public void handleEvent(final RowsSetEvent e) {
+ BrowserTableModel model = (BrowserTableModel) getModel();
+ CyTable dataTable = model.getDataTable();
+
+ if (e.getSource() != dataTable)
+ return;
+
+ if (!model.isShowAll()) {
+ model.clearSelectedRows();
+ boolean foundANonSelectedColumnName = false;
+ for (final RowSetRecord rowSet :
e.getPayloadCollection()) {
+ if
(!rowSet.getColumn().equals(CyNetwork.SELECTED)) {
+ foundANonSelectedColumnName = true;
+ break;
+ }
+ }
+ if (!foundANonSelectedColumnName) {
+ model.fireTableDataChanged();
+ return;
+ }
+ }
+
+ final Collection<RowSetRecord> rows = e.getPayloadCollection();
+
+ synchronized (this) {
+ if (!model.isShowAll()) {
+ model.fireTableDataChanged();
+ } else {
+ //table.clearSelection();
+ //fireTableDataChanged();
+
if(tableManager.getGlobalTables().contains(dataTable) == false)
+ bulkUpdate(rows);
+ }
+ }
+ }
+ /**
+ * Select rows in the table when something selected in the network view.
+ * @param rows
+ */
+ private void bulkUpdate(final Collection<RowSetRecord> rows) {
+ BrowserTableModel model = (BrowserTableModel) getModel();
+ CyTable dataTable = model.getDataTable();
+
+ final Map<Long, Boolean> suidMapSelected = new HashMap<Long,
Boolean>();
+ final Map<Long, Boolean> suidMapUnselected = new HashMap<Long,
Boolean>();
+
+ for(RowSetRecord rowSetRecord : rows) {
+ if(rowSetRecord.getColumn().equals(CyNetwork.SELECTED)){
+ if(((Boolean)rowSetRecord.getValue()) == true){
+
suidMapSelected.put(rowSetRecord.getRow().get(CyIdentifiable.SUID, Long.class),
(Boolean) rowSetRecord.getValue());
+ }
+ else{
+
suidMapUnselected.put(rowSetRecord.getRow().get(CyIdentifiable.SUID,
Long.class), (Boolean) rowSetRecord.getValue());
+ }
+ }
+ }
+
+ final String pKeyName = dataTable.getPrimaryKey().getName();
+ final int rowCount = getRowCount();
+ for(int i=0; i<rowCount; i++) {
+ //getting the row from data table solves the problem
with hidden or moved SUID column. However, since the rows might be sorted we
need to convert the index to model
+ final ValidatedObjectAndEditString tableKey =
(ValidatedObjectAndEditString) model.getValueAt(i, pKeyName );
+ Long pk = null;
+ try{
+ // TODO: Temp fix: is it a requirement that all
CyTables have a Long SUID column as PK?
+ pk = Long.parseLong(tableKey.getEditString());
+ } catch (NumberFormatException nfe) {
+ System.out.println("Error parsing long from
table " + getName() + ": " + nfe.getMessage());
+ }
+ if(pk != null) {
+ if (suidMapSelected.keySet().contains(pk)){
+ addRowSelectionInterval(i, i);
+ }else if
(suidMapUnselected.keySet().contains(pk)){
+ removeRowSelectionInterval(i, i);
+ }
+
+ }
+ }
+ }
}
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTableModel.java
===================================================================
---
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTableModel.java
2012-08-13 16:06:58 UTC (rev 30171)
+++
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTableModel.java
2012-08-13 18:06:26 UTC (rev 30172)
@@ -3,49 +3,30 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
import javax.swing.JOptionPane;
-import javax.swing.JTable;
import javax.swing.event.TableModelEvent;
import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableRowSorter;
import org.cytoscape.browser.internal.util.TableBrowserUtil;
import org.cytoscape.equations.Equation;
import org.cytoscape.equations.EquationCompiler;
import org.cytoscape.model.CyColumn;
-import org.cytoscape.model.CyIdentifiable;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyRow;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableManager;
-import org.cytoscape.model.events.ColumnCreatedEvent;
-import org.cytoscape.model.events.ColumnCreatedListener;
-import org.cytoscape.model.events.ColumnDeletedEvent;
-import org.cytoscape.model.events.ColumnDeletedListener;
-import org.cytoscape.model.events.ColumnNameChangedEvent;
-import org.cytoscape.model.events.ColumnNameChangedListener;
-import org.cytoscape.model.events.RowSetRecord;
import org.cytoscape.model.events.RowsCreatedEvent;
import org.cytoscape.model.events.RowsCreatedListener;
-import org.cytoscape.model.events.RowsSetEvent;
-import org.cytoscape.model.events.RowsSetListener;
-public final class BrowserTableModel extends AbstractTableModel implements
ColumnCreatedListener,
-ColumnDeletedListener, ColumnNameChangedListener, RowsSetListener,
RowsCreatedListener {
+public final class BrowserTableModel extends AbstractTableModel implements
RowsCreatedListener {
private static final long serialVersionUID = -517521404005631245L;
- private final BrowserTable table;
private final CyTable dataTable;
private final EquationCompiler compiler;
@@ -62,18 +43,15 @@
private int maxRowIndex;
- public BrowserTableModel(final BrowserTable table, final CyTable
dataTable, final EquationCompiler compiler,
+ public BrowserTableModel(final CyTable dataTable, final
EquationCompiler compiler,
final CyTableManager tableManager) {
- this.table = table;
this.dataTable = dataTable;
this.compiler = compiler;
this.regularViewMode = false;
this.tableManager = tableManager;
- initAttrNamesAndVisibilities();
-
-
-
+ attrNames = getAttributeNames(dataTable);
+
// add each row to an array to allow fast lookup from an index
final Collection<CyRow> rows = dataTable.getAllRows();
this.rowIndexToPrimaryKey = new Object[rows.size()];
@@ -83,24 +61,18 @@
rowIndexToPrimaryKey[maxRowIndex++] =
row.getRaw(primaryKey);
}
+ private List<String> getAttributeNames(CyTable table) {
+ ArrayList<String> names = new ArrayList<String>();
+ for (CyColumn column : table.getColumns()) {
+ names.add(column.getName());
+ }
+ return names;
+ }
+
CyTable getDataTable() {
return dataTable;
}
- private void initAttrNamesAndVisibilities() {
- attrNames = new ArrayList<String>();
- int i = 0;
- for (final CyColumn column : dataTable.getColumns()) {
- attrNames.add(column.getName());
- i++;
- }
-
- }
-
- public JTable getTable() { return table; }
-
- BrowserTable getBrowserTable() { return table; }
-
public CyTable getAttributes() { return dataTable; }
@Override
@@ -109,49 +81,9 @@
}
List<String> getAllAttributeNames() {
- final List<String> AttrNames = new ArrayList<String>();
-
- for (final String name : attrNames) {
- AttrNames.add(name);
- }
-
- return AttrNames;
- //Never rerturn the list of attrNames itself, because it will
be returned by reference and anychanges to this list will affect the model
- //return attrNames;
+ return new ArrayList<String>(attrNames);
}
- List<String> getVisibleAttributeNames() {
-
- final List<String> visibleAttrNames = new ArrayList<String>();
- for (final String name : attrNames) {
- if (isColumnVisible(name))
- visibleAttrNames.add(name);
- }
-
- return visibleAttrNames;
- }
-
-
- public Boolean isColumnVisible(String colName){
- BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
table.getColumnModel();
- TableColumn column =
columnModel.getColumnByModelIndex(mapColumnNameToColumnIndex(colName));
- return columnModel.isColumnVisible(column);
- }
-
- public void setVisibleAttributeNames(final Collection<String>
visibleAttributes) {
-
- BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
table.getColumnModel();
- for (final String name : attrNames) {
- int col = mapColumnNameToColumnIndex(name);
- int convCol = table.convertColumnIndexToView(col);
- TableColumn column =
columnModel.getColumnByModelIndex(col);
- columnModel.setColumnVisible(column,
visibleAttributes.contains(name));
- }
-
- //don't fire this, it will reset all the columns based on model
- //fireTableStructureChanged();
- }
-
@Override
public int getRowCount() {
final Collection<CyColumn> columns = dataTable.getColumns();
@@ -174,20 +106,20 @@
public Object getValueAt(final int rowIndex, final String columnName) {
- final CyRow row =
mapRowIndexToRow(table.convertRowIndexToModel(rowIndex));
+ final CyRow row = getCyRow(rowIndex);
return getValidatedObjectAndEditString(row, columnName);
}
@Override
public Object getValueAt(final int rowIndex, final int columnIndex) {
final String columnName = getColumnName(columnIndex);
- final CyRow row = mapRowIndexToRow(rowIndex);
+ final CyRow row = getCyRow(rowIndex);
return getValidatedObjectAndEditString(row, columnName);
}
CyColumn getColumn(final int columnIndex) {
- final String columnName = getColumnName(
table.convertColumnIndexToModel(columnIndex));
+ final String columnName = getColumnName(columnIndex);
return dataTable.getColumn(columnName);
}
@@ -198,7 +130,7 @@
return dataTable.getColumn(columnName);
}
- private CyRow mapRowIndexToRow(final int rowIndex) {
+ public CyRow getCyRow(final int rowIndex) {
if (regularViewMode) {
if (selectedRows == null)
selectedRows =
dataTable.getMatchingRows(CyNetwork.SELECTED, true);
@@ -257,83 +189,7 @@
}
}
- @SuppressWarnings("unchecked")
@Override
- public void handleEvent(final ColumnCreatedEvent e) {
- if (e.getSource() != dataTable)
- return;
- BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
table.getColumnModel();
-
- attrNames.add(e.getColumnName());
-
- int colIndex = columnModel.getColumnCount(false);
- TableColumn newCol = new TableColumn(colIndex);
- newCol.setHeaderValue(e.getColumnName());
- table.setUpdateComparators(false);
- table.addColumn(newCol);
- final TableRowSorter<BrowserTableModel> rowSorter = new
TableRowSorter<BrowserTableModel>(this);
- table.setRowSorter(rowSorter);
- updateColumnComparators(rowSorter, this);
- table.setUpdateComparators(true);
-
- }
-
- void updateColumnComparators(final TableRowSorter<BrowserTableModel>
rowSorter,
- final BrowserTableModel browserTableModel) {
- for (int column = 0; column <
browserTableModel.getColumnCount(); ++column)
- rowSorter.setComparator(
- column,
- new
ValidatedObjectAndEditStringComparator(
-
browserTableModel.getColumnByModelIndex(column).getType()));
- }
-
- @Override
- public void handleEvent(final ColumnDeletedEvent e) {
- if (e.getSource() != dataTable)
- return;
- BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
table.getColumnModel();
-
- final String columnName = e.getColumnName();
- boolean columnFound = false;
- int removedColIndex = -1;
-
- for (int i = 0; i < attrNames.size(); ++i) {
- if (attrNames.get(i).equals(columnName)) {
- removedColIndex = i;
- columnModel.removeColumn
(columnModel.getColumn(table.convertColumnIndexToView( i)));
- columnFound = true;
- }
- else if (columnFound){ //need to push back the model
indexes for all of the columns after this
-
- TableColumn nextCol =
columnModel.getColumnByModelIndex(i);
- nextCol.setModelIndex(i- 1);
- }
- }
-
- if (removedColIndex != -1){//remove the item after the loop is
done
- attrNames.remove(removedColIndex);
- }
-
- }
-
- @Override
- public void handleEvent(final ColumnNameChangedEvent e) {
- if (e.getSource() != dataTable)
- return;
-
- final String newColumnName = e.getNewColumnName();
- final int column =
mapColumnNameToColumnIndex(e.getOldColumnName());
- if (isColumnVisible(e.getOldColumnName())){
- int colIndex = table.convertColumnIndexToView(column);
- if (colIndex != -1)
-
table.getColumnModel().getColumn(colIndex).setHeaderValue(newColumnName);
- }
-
- renameColumnName(e.getOldColumnName(), newColumnName);
-
- }
-
- @Override
public synchronized void handleEvent(RowsCreatedEvent e) {
if(!e.getSource().equals(this.dataTable))
return ;
@@ -350,41 +206,6 @@
fireTableDataChanged();
}
- @Override
- public void handleEvent(final RowsSetEvent e) {
- if (e.getSource() != dataTable)
- return;
-
- if (regularViewMode) {
- selectedRows = null;
- boolean foundANonSelectedColumnName = false;
- for (final RowSetRecord rowSet :
e.getPayloadCollection()) {
- if
(!rowSet.getColumn().equals(CyNetwork.SELECTED)) {
- foundANonSelectedColumnName = true;
- break;
- }
- }
- if (!foundANonSelectedColumnName) {
- fireTableDataChanged();
- return;
- }
- }
-
- final Collection<RowSetRecord> rows = e.getPayloadCollection();
-
- synchronized (this) {
- if (regularViewMode) {
- fireTableDataChanged();
- } else {
- //table.clearSelection();
- //fireTableDataChanged();
-
if(tableManager.getGlobalTables().contains(dataTable) == false)
- bulkUpdate(rows);
- }
- }
- }
-
-
/**
* Switch view mode.
*
@@ -412,63 +233,6 @@
}
- /**
- * Select rows in the table when something selected in the network view.
- * @param rows
- */
- private void bulkUpdate(final Collection<RowSetRecord> rows) {
- final int columnCount = table.getColumnCount();
-
- final Map<Long, Boolean> suidMapSelected = new HashMap<Long,
Boolean>();
- final Map<Long, Boolean> suidMapUnselected = new HashMap<Long,
Boolean>();
-
- for(RowSetRecord rowSetRecord : rows) {
- if(rowSetRecord.getColumn().equals(CyNetwork.SELECTED)){
- if(((Boolean)rowSetRecord.getValue()) == true){
-
suidMapSelected.put(rowSetRecord.getRow().get(CyIdentifiable.SUID, Long.class),
(Boolean) rowSetRecord.getValue());
- }
- else{
-
suidMapUnselected.put(rowSetRecord.getRow().get(CyIdentifiable.SUID,
Long.class), (Boolean) rowSetRecord.getValue());
- }
- }
- }
-
- final BrowserTableModel btmodel = ((BrowserTableModel)
table.getModel() );
- final String pKeyName = dataTable.getPrimaryKey().getName();
- final int rowCount = table.getRowCount();
- for(int i=0; i<rowCount; i++) {
- //getting the row from data table solves the problem
with hidden or moved SUID column. However, since the rows might be sorted we
need to convert the index to model
- final ValidatedObjectAndEditString tableKey =
(ValidatedObjectAndEditString) btmodel.getValueAt(i, pKeyName );
- Long pk = null;
- try{
- // TODO: Temp fix: is it a requirement that all
CyTables have a Long SUID column as PK?
- pk = Long.parseLong(tableKey.getEditString());
- } catch (NumberFormatException nfe) {
- System.out.println("Error parsing long from
table " + table.getName() + ": " + nfe.getMessage());
- }
- if(pk != null) {
- if (suidMapSelected.keySet().contains(pk)){
- table.addRowSelectionInterval(i, i);
- /*
- if (table.getColumnCount() > 0)
-
table.addColumnSelectionInterval(0, table.getColumnCount() - 1);
- */
- }else if
(suidMapUnselected.keySet().contains(pk)){
- table.removeRowSelectionInterval(i, i);
- }
-
- }
- }
- }
-
- private void handleRowValueUpdate(final CyRow row, final String
columnName, final Object newValue,
- final Object newRawValue) {
- if (regularViewMode && columnName.equals(CyNetwork.SELECTED)) {
- fireTableDataChanged();
- }
- }
-
-
public String getCyColumnName( final int column){
return (String) dataTable.getColumns().toArray()[column];
}
@@ -480,27 +244,6 @@
- private void renameColumnName(final String oldName, final String
newName) {
-
- BrowserTableColumnModel columnModel = (BrowserTableColumnModel)
table.getColumnModel();
-
- if (attrNames.contains(oldName)){
- int index = attrNames.indexOf(oldName);
- attrNames.set(index, newName);
- columnModel.getColumn(table.convertColumnIndexToView(
index)).setHeaderValue(newName);
- return;
- }
-
- throw new IllegalStateException("The specified column " +
oldName +" does not exist in the model.");
- }
-
-
-
- public boolean isPrimaryKey (int col){
- return
dataTable.getPrimaryKey().getName().equals(getColumnName(table.convertColumnIndexToModel(col)));
- }
-
-
int mapColumnNameToColumnIndex(final String columnName) {
if(attrNames.contains(columnName))
@@ -516,16 +259,6 @@
}
- // Because tableModel will disappear if user click on open space on
canvas,
- // we have to remember it before it is gone
- public Vector getCellData(final int rowIndex, final int columnIndex){
- Vector cellVect = new Vector();
- cellVect.add(mapRowIndexToRow(rowIndex));
- cellVect.add( getColumnName(columnIndex));
-
- return cellVect;
- }
-
CyRow getRow(final Object suid) {
return dataTable.getRow(suid);
}
@@ -535,7 +268,7 @@
@Override
public void setValueAt(final Object value, final int rowIndex, final
int columnIndex) {
final String text = (String)value;
- final CyRow row = mapRowIndexToRow(rowIndex);
+ final CyRow row = getCyRow(rowIndex);
final String columnName =
mapColumnIndexToColumnName(columnIndex);
final Class<?> columnType =
dataTable.getColumn(columnName).getType();
@@ -643,4 +376,24 @@
return !column.isPrimaryKey();
}
+ public boolean isPrimaryKey(int columnIndex) {
+ CyColumn column = getColumnByModelIndex(columnIndex);
+ return column.isPrimaryKey();
+ }
+
+ void clearSelectedRows() {
+ selectedRows = null;
+ }
+
+ void setColumnName(int index, String name) {
+ attrNames.set(index, name);
+ }
+
+ void removeColumn(int index) {
+ attrNames.remove(index);
+ }
+
+ void addColumn(String name) {
+ attrNames.add(name);
+ }
}
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/DefaultTableBrowser.java
===================================================================
---
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/DefaultTableBrowser.java
2012-08-13 16:06:58 UTC (rev 30171)
+++
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/DefaultTableBrowser.java
2012-08-13 18:06:26 UTC (rev 30172)
@@ -142,8 +142,9 @@
private void changeSelectionMode() {
//rowSelectionMode = selectionModeButton.isSelected();
- getCurrentBrowserTableModel().setShowAll(rowSelectionMode);
- getCurrentBrowserTableModel().updateShowAll();
+ BrowserTableModel model = (BrowserTableModel)
getCurrentBrowserTable().getModel();
+ model.setShowAll(rowSelectionMode);
+ model.updateShowAll();
}
@Override
@@ -187,10 +188,12 @@
}
});
- final BrowserTableModel currentBrowserTableModel =
getCurrentBrowserTableModel();
+ final BrowserTable currentBrowserTable =
getCurrentBrowserTable();
- if (currentBrowserTableModel != null)
- currentBrowserTableModel.setShowAll(rowSelectionMode);
+ if (currentBrowserTable != null) {
+ final BrowserTableModel model = (BrowserTableModel)
currentBrowserTable.getModel();
+ model.setShowAll(rowSelectionMode);
+ }
showSelectedTable();
}
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/DeletionDialog.java
===================================================================
---
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/DeletionDialog.java
2012-08-13 16:06:58 UTC (rev 30171)
+++
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/DeletionDialog.java
2012-08-13 18:06:26 UTC (rev 30172)
@@ -35,14 +35,14 @@
}
private CyTable attributes;
- private BrowserTableModel tableModel;
+ private BrowserTable table;
/** Creates new form DeletionDialog */
- protected DeletionDialog(final Frame parent, final CyTable attributes,
final BrowserTableModel tableModel) {
+ protected DeletionDialog(final Frame parent, final CyTable attributes,
final BrowserTable table) {
super(parent, "Delete Attributes", /* modal = */ true);
this.attributes = attributes;
- this.tableModel = tableModel;
+ this.table = table;
initComponents();
}
@@ -67,7 +67,7 @@
int mutableCount = 0;
for (final CyColumn column :
attributes.getColumns()) {
if (!column.isImmutable())
- if
(tableModel.isColumnVisible(column.getName()))
+ if
(table.isColumnVisible(column.getName()))
++mutableCount;
}
@@ -80,7 +80,7 @@
int k = 0;
for (final CyColumn column :
attributes.getColumns()) {
if (!column.isImmutable()){
- if
(tableModel.isColumnVisible(column.getName()))
+ if
(table.isColumnVisible(column.getName()))
columnNames[k++] =
column.getName();
}
}
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/FormulaBuilderDialog.java
===================================================================
---
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/FormulaBuilderDialog.java
2012-08-13 16:06:58 UTC (rev 30171)
+++
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/FormulaBuilderDialog.java
2012-08-13 18:06:26 UTC (rev 30172)
@@ -111,18 +111,20 @@
private ApplicationDomain applicationDomain;
private Stack<Integer> undoStack;
private final EquationCompiler compiler;
+ private final BrowserTable table;
private final BrowserTableModel tableModel;
private final String targetAttrName;
public FormulaBuilderDialog(final EquationCompiler compiler,
- final BrowserTableModel tableModel, final
Frame parent,
+ final BrowserTable table, final Frame
parent,
final String targetAttrName)
{
super(parent);
this.setTitle("Creating a formula for: " + targetAttrName);
this.compiler = compiler;
- this.tableModel = tableModel;
+ this.table = table;
+ this.tableModel = (BrowserTableModel) table.getModel();
this.targetAttrName = targetAttrName;
this.stringToFunctionMap = new HashMap<String, Function>();
this.leadingArgs = new ArrayList<Class>();
@@ -304,7 +306,7 @@
private void initApplyToComboBox(final Container contentPane) {
applyToComboBox = new JComboBox();
- final int selectedCellRow =
tableModel.getTable().getSelectedRow();
+ final int selectedCellRow = table.getSelectedRow();
if (selectedCellRow >= 0)
applyToComboBox.addItem(ApplicationDomain.CURRENT_CELL);
if (attributesContainBooleanSelected())
@@ -484,7 +486,6 @@
if (formula.charAt(formula.length() - 1) != ')')
formula = formula + ")";
- final JTable table = tableModel.getTable();
final int cellColum = table.convertColumnIndexToModel(
table.getSelectedColumn());
final String attribName = tableModel.getColumnName(cellColum);
--
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.