Author: pwang
Date: 2011-09-12 11:42:13 -0700 (Mon, 12 Sep 2011)
New Revision: 26749
Modified:
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTable.java
Log:
Fixed bug#321
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
2011-09-12 16:33:23 UTC (rev 26748)
+++
core3/impl/trunk/table-browser-impl/src/main/java/org/cytoscape/browser/internal/BrowserTable.java
2011-09-12 18:42:13 UTC (rev 26749)
@@ -55,6 +55,10 @@
import org.cytoscape.util.swing.OpenBrowser;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyColumn;
+import java.awt.event.FocusListener;
+import java.awt.event.FocusEvent;
+import javax.swing.event.CellEditorListener;
+import javax.swing.event.ChangeEvent;
public class BrowserTable extends JTable
@@ -78,7 +82,10 @@
private final EquationCompiler compiler;
private final PopupMenuHelper popupMenuHelper;
private boolean updateColumnComparators;
+ private CellFocusListener myCellFocusListener = new CellFocusListener();
+
+
public BrowserTable(final OpenBrowser openBrowser, final
EquationCompiler compiler,
final PopupMenuHelper popupMenuHelper)
{
@@ -241,7 +248,7 @@
}
TableCellEditor editor = getCellEditor(row, column);
-
+
if ((editor != null) && editor.isCellEditable(e)) {
// Do this first so that the bounds of the JTextArea
editor
// will be correct.
@@ -257,6 +264,24 @@
return false;
}
+ //
+ FocusListener[] ls = editorComp.getFocusListeners();
+
+ boolean addMyFocusListener = true;
+ for (FocusListener l: ls){
+ if(l == this.myCellFocusListener){
+ addMyFocusListener = false;
+ break;
+ }
+ }
+
+ if (addMyFocusListener){
+
editorComp.addFocusListener(this.myCellFocusListener);
+
this.myCellFocusListener.setRow(this.editingRow);
+
this.myCellFocusListener.setColumn(this.editingColumn);
+ }
+
+
Rectangle cellRect = getCellRect(row, column, false);
if (editor instanceof MultiLineTableCellEditor) {
@@ -280,6 +305,32 @@
return false;
}
+
+ public class CellFocusListener implements FocusListener {
+
+ private int rowFocused = -1, colFocused = -1;
+ public void focusGained(FocusEvent e){
+ }
+
+ public void setRow(int rowFocused){
+ this.rowFocused = rowFocused;
+ }
+
+ public void setColumn(int colFocused){
+ this.colFocused = colFocused;
+ }
+
+ public void focusLost(FocusEvent e){
+
+ TableCellEditor editor = getCellEditor(this.rowFocused,
this.colFocused);
+
+ if ((editor != null) && editor.isCellEditable(e)) {
+ editor.stopCellEditing();
+ }
+ }
+ }
+
+
/**
* Display elements in the list objects.
*/
--
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.