No need here for additional private inner variables that cover outer
class's versions of the same thing. No need for a pointer to the outer
class, as "me" is already the "this" of the other class.
Added necessary JTable.repaint() to fix the problem that "stopping"
editing was relying upon the invalidation to be maintained throughout
the modal dialog, but JavaScript cannot keep the thread from doing its
repaints. So in JavaScript, while the modal dialog is loading, the
validate sequence from stopping editing fires. Thus, when the editing
dialog closes, it is already validated for the previous value, and we
need to explicitly repaint the table to see the update.
+
+// @Override
+// public void repaint() {
+// System.out.println("FS repaint");
+// super.repaint();
+//
+// }
+//
+// @Override
+// public void repaint(long tm, int x, int y, int width, int height) {
+// System.out.println("FS repaint " + x + " " + y + " " + width + " " + height);
+// super.repaint(tm, x, y, width, height);
+//
+// }
+// @Override
+// public void invalidate() {
+// if (isValid())
+// System.out.println("FS invalidating ");
+// super.invalidate();
+// }
+//
+// @Override
+// public void validate() {
+// System.out.println("FS validating " + isValid());
+// super.validate();
+// }
+
@Override
public String getToolTipText(MouseEvent e)
{
@Override
public String getToolTipText(MouseEvent e)
{
table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));
ToolTipManager.sharedInstance().registerComponent(table);
table.getTableHeader().setFont(new Font("Verdana", Font.PLAIN, 12));
ToolTipManager.sharedInstance().registerComponent(table);
- table.setDefaultEditor(FeatureColour.class, new ColorEditor(this));
+ table.setDefaultEditor(FeatureColour.class, new ColorEditor());
table.setDefaultRenderer(FeatureColour.class, new ColorRenderer());
table.setDefaultRenderer(FeatureColour.class, new ColorRenderer());
- table.setDefaultEditor(FeatureMatcherSet.class, new FilterEditor(this));
+ table.setDefaultEditor(FeatureMatcherSet.class, new FilterEditor());
table.setDefaultRenderer(FeatureMatcherSet.class, new FilterRenderer());
TableColumn colourColumn = new TableColumn(COLOUR_COLUMN, 75,
table.setDefaultRenderer(FeatureMatcherSet.class, new FilterRenderer());
TableColumn colourColumn = new TableColumn(COLOUR_COLUMN, 75,
- new ColorRenderer(), new ColorEditor(this));
+ new ColorRenderer(), new ColorEditor());
table.addColumn(colourColumn);
TableColumn filterColumn = new TableColumn(FILTER_COLUMN, 75,
table.addColumn(colourColumn);
TableColumn filterColumn = new TableColumn(FILTER_COLUMN, 75,
- new FilterRenderer(), new FilterEditor(this));
+ new FilterRenderer(), new FilterEditor());
table.addColumn(filterColumn);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
table.addColumn(filterColumn);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
renderGraduatedColor(comp, gcol, w, h);
}
renderGraduatedColor(comp, gcol, w, h);
}
- class ColorEditor extends AbstractCellEditor
+ @SuppressWarnings("serial")
+class ColorEditor extends AbstractCellEditor
implements TableCellEditor, ActionListener
{
implements TableCellEditor, ActionListener
{
FeatureColourI currentColor;
FeatureColourI currentColor;
- public ColorEditor(FeatureSettings fs)
// Set up the editor (from the table's point of view),
// which is a button.
// This button brings up the color chooser dialog,
// Set up the editor (from the table's point of view),
// which is a button.
// This button brings up the color chooser dialog,
public void colourSelected(Color c)
{
currentColor = new FeatureColour(c);
public void colourSelected(Color c)
{
currentColor = new FeatureColour(c);
- me.table.setValueAt(currentColor, rowSelected, COLOUR_COLUMN);
+ table.setValueAt(currentColor, rowSelected, COLOUR_COLUMN);
fireEditingStopped();
}
@Override
fireEditingStopped();
}
@Override
/*
* variable colour and filters dialog
*/
/*
* variable colour and filters dialog
*/
- chooser = new FeatureTypeSettings(me.fr, type);
+ chooser = new FeatureTypeSettings(fr, type);
if (!Jalview.isJS())
{
chooser.setRequestFocusEnabled(true);
if (!Jalview.isJS())
{
chooser.setRequestFocusEnabled(true);
* update table data without triggering updateFeatureRenderer
*/
currentColor = fr.getFeatureColours().get(type);
* update table data without triggering updateFeatureRenderer
*/
currentColor = fr.getFeatureColours().get(type);
- FeatureMatcherSetI currentFilter = me.fr.getFeatureFilter(type);
+ FeatureMatcherSetI currentFilter = fr.getFeatureFilter(type);
if (currentFilter == null)
{
currentFilter = new FeatureMatcherSet();
if (currentFilter == null)
{
currentFilter = new FeatureMatcherSet();
.getData()[rowSelected];
data[COLOUR_COLUMN] = currentColor;
data[FILTER_COLUMN] = currentFilter;
.getData()[rowSelected];
data[COLOUR_COLUMN] = currentColor;
data[FILTER_COLUMN] = currentFilter;
+ // SwingJS needs an explicit repaint() here,
+ // rather than relying upon no validation having
+ // occurred since the stopEditing call was made.
+ // Its laying out has not been stopped by the modal frame
+ table.validate();
+ table.repaint();
{
currentColor = (FeatureColourI) value;
this.rowSelected = row;
{
currentColor = (FeatureColourI) value;
this.rowSelected = row;
- type = me.table.getValueAt(row, TYPE_COLUMN).toString();
+ type = table.getValueAt(row, TYPE_COLUMN).toString();
- button.setBackground(me.getBackground());
+ button.setBackground(getBackground());
if (!currentColor.isSimpleColour())
{
JLabel btn = new JLabel();
if (!currentColor.isSimpleColour())
{
JLabel btn = new JLabel();
* as display text). On click in the cell, opens the Feature Display Settings
* dialog at the Filters tab.
*/
* as display text). On click in the cell, opens the Feature Display Settings
* dialog at the Filters tab.
*/
- class FilterEditor extends AbstractCellEditor
+ @SuppressWarnings("serial")
+class FilterEditor extends AbstractCellEditor
implements TableCellEditor, ActionListener
{
implements TableCellEditor, ActionListener
{
FeatureMatcherSetI currentFilter;
FeatureMatcherSetI currentFilter;
- public FilterEditor(FeatureSettings me)
button = new JButton();
button.setActionCommand(EDIT);
button.addActionListener(this);
button = new JButton();
button.setActionCommand(EDIT);
button.addActionListener(this);
{
if (button == e.getSource())
{
{
if (button == e.getSource())
{
- FeatureTypeSettings chooser = new FeatureTypeSettings(me.fr, type);
+ FeatureTypeSettings chooser = new FeatureTypeSettings(fr, type);
chooser.addActionListener(this);
chooser.setRequestFocusEnabled(true);
chooser.requestFocus();
chooser.addActionListener(this);
chooser.setRequestFocusEnabled(true);
chooser.requestFocus();
* update table data without triggering updateFeatureRenderer
*/
FeatureColourI currentColor = fr.getFeatureColours().get(type);
* update table data without triggering updateFeatureRenderer
*/
FeatureColourI currentColor = fr.getFeatureColours().get(type);
- currentFilter = me.fr.getFeatureFilter(type);
+ currentFilter = fr.getFeatureFilter(type);
if (currentFilter == null)
{
currentFilter = new FeatureMatcherSet();
}
if (currentFilter == null)
{
currentFilter = new FeatureMatcherSet();
}
Object[] data = ((FeatureTableModel) table.getModel())
.getData()[rowSelected];
data[COLOUR_COLUMN] = currentColor;
data[FILTER_COLUMN] = currentFilter;
fireEditingStopped();
Object[] data = ((FeatureTableModel) table.getModel())
.getData()[rowSelected];
data[COLOUR_COLUMN] = currentColor;
data[FILTER_COLUMN] = currentFilter;
fireEditingStopped();
+ // SwingJS needs an explicit repaint() here,
+ // rather than relying upon no validation having
+ // occurred since the stopEditing call was made.
+ // Its laying out has not been stopped by the modal frame
+ table.validate();
+ table.repaint();
{
currentFilter = (FeatureMatcherSetI) value;
this.rowSelected = row;
{
currentFilter = (FeatureMatcherSetI) value;
this.rowSelected = row;
- type = me.table.getValueAt(row, TYPE_COLUMN).toString();
+ type = table.getValueAt(row, TYPE_COLUMN).toString();
- button.setBackground(me.getBackground());
+ button.setBackground(getBackground());
button.setText(currentFilter.toString());
button.setIcon(null);
return button;
button.setText(currentFilter.toString());
button.setIcon(null);
return button;