@PublicAPI public class MViewEditor extends javax.swing.AbstractCellEditor implements javax.swing.table.TableCellEditor
Using MViewPane as a cell editor provides two major advantages.
Constructor and Description |
---|
MViewEditor()
Creates the cell editor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getCellEditorValue()
Returns the edited molecule that is a
Molecule instance. |
int |
getEditable()
Returns the mode that determines if the structure is editable.
|
MViewPane |
getEditorComponent()
Returns the editor component.
|
java.awt.Component |
getTableCellEditorComponent(javax.swing.JTable table,
java.lang.Object value,
boolean isSelected,
int row,
int column)
Sets up the editor component.
|
protected void |
setBackgroundColor(javax.swing.JTable table,
MViewPane mviewPane,
boolean isSelected,
int row,
int column)
Sets the background color for the current cell based on selection.
|
protected void |
setBorder(javax.swing.JTable table,
MViewPane mviewPane,
boolean isSelected,
int row,
int column)
Sets the border for the current cell based on selection.
|
void |
setEditable(int e)
Sets the mode that determines if the structure is editable.
|
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
public MViewEditor()
table.setDefaultEditor(Molecule.class, new MViewEditor());
public MViewPane getEditorComponent()
MViewPane
editor componentpublic int getEditable()
MViewPane.VIEW_ONLY
if molecules can be viewed only,
MViewPane.EDITABLE
if they are editable with MarvinView,
MViewPane.SKETCHABLE
if they are editable with MarvinSketch.public void setEditable(int e)
MViewPane.VIEW_ONLY
: editing is disabled, MViewPane.EDITABLE
: editing is
enabled and launches MarvinView in a new window, MViewPane.SKETCHABLE
: editing is
enabled and launches MarvinSketch in a new window.
e
- identifier of the modepublic java.lang.Object getCellEditorValue()
Molecule
instance.getCellEditorValue
in interface javax.swing.CellEditor
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
getTableCellEditorComponent
in interface javax.swing.table.TableCellEditor
table
- the JTable
that is asking the editor to edit; can be
null
value
- the value of the cell to be edited; it is considered to be a Molecule
instance; null
is a valid valueisSelected
- true if the cell is to be rendered with highlightingrow
- the row of the cell being editedcolumn
- the column of the cell being editedprotected void setBackgroundColor(javax.swing.JTable table, MViewPane mviewPane, boolean isSelected, int row, int column)
getTableCellEditorComponent(javax.swing.JTable, Object, boolean, int, int)
,
overwrite to change the default behavior.table
- the JTable
that is asking the editor to edit; can be
null
mviewPane
- the editor componentisSelected
- true if the cell is to be rendered with the selection highlighted; otherwise falserow
- the row of the cell being editedcolumn
- the column of the cell being editedprotected void setBorder(javax.swing.JTable table, MViewPane mviewPane, boolean isSelected, int row, int column)
getTableCellEditorComponent(javax.swing.JTable, Object, boolean, int, int)
,
overwrite to change the default behavior.table
- the JTable
that is asking the editor to edit; can be
null
mviewPane
- the editor componentisSelected
- true if the cell is to be rendered with the selection highlighted; otherwise falserow
- the row of the cell being editedcolumn
- the column of the cell being edited