本文整理匯總了Java中javax.swing.event.TableModelEvent.getSource方法的典型用法代碼示例。如果您正苦於以下問題:Java TableModelEvent.getSource方法的具體用法?Java TableModelEvent.getSource怎麽用?Java TableModelEvent.getSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.event.TableModelEvent
的用法示例。
在下文中一共展示了TableModelEvent.getSource方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
public void tableChanged(TableModelEvent e) {
// if the graph is disabled, do not handle any events.
if ( _disableQBGF )
return;
// if the graph is being generated from model, do not handle events.
if (_queryBuilder._updateModel == false)
return;
Log.getLogger().finest("Entering QBGF.tableChanged, source: " + e.getSource()); // NOI18N
if (e.getSource() instanceof QueryBuilderTableModel)
tableModelChanged(e);
else if (e.getSource() instanceof QueryBuilderInputTableModel)
inputTableModelChanged(e);
}
示例2: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
public void tableChanged(TableModelEvent e) {
//System.out.println("TBALE changed");
//boolean prefixFlag = false;
int row = e.getFirstRow();
int column = e.getColumn();
AbstractTableModel tblModel = (AbstractTableModel) e.getSource();
Object data = tblModel.getValueAt(row, column);
if(column == SCHEMA_COL) {
SchemaObject rowValue = (SchemaObject)data;
if(rowValue.toString().equals(startString))
return;
String genPrefix = (String) tblModel.getValueAt(row, PREFIX_COL);
if (genPrefix == null || genPrefix.equals(" ") ) {
String prefix = generateUniquePrefix();
tableModel.setValueAt(prefix, row, PREFIX_COL);
}
if(row == tableModel.getRowCount() - 1) {
addRow(startString);
}
//if its the first row, then select it as primary
if(row == 0) {
// System.out.println("added first row");
tblModel.setValueAt(new Boolean(true), 0, 0);
}
}
}
示例3: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
public void tableChanged(final TableModelEvent e) {
// only post changes to the draggable column
if (isColumnEditable(e.getColumn())) {
final TableModel model = (TableModel)e.getSource();
Object tableValue = model.getValueAt(e.getFirstRow(),
e.getColumn());
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("tableChanged: firstRow="+e.getFirstRow()+
", lastRow="+e.getLastRow()+", column="+e.getColumn()+
", value="+tableValue);
}
// if it's a String, try construct new value
// using the defined type.
if (tableValue instanceof String) {
try {
tableValue =
Utils.createObjectFromString(getClassName(e.getFirstRow()), // type
(String)tableValue);// value
} catch (Throwable ex) {
popupAndLog(ex,"tableChanged",
Messages.PROBLEM_SETTING_ATTRIBUTE);
}
}
final String attributeName = getValueName(e.getFirstRow());
final Attribute attribute =
new Attribute(attributeName,tableValue);
setAttribute(attribute, "tableChanged");
}
}
示例4: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
public void tableChanged(final TableModelEvent e) {
// only post changes to the draggable column
if (isColumnEditable(e.getColumn())) {
final TableModel model = (TableModel)e.getSource();
Object tableValue = model.getValueAt(e.getFirstRow(),
e.getColumn());
if (LOGGER.isLoggable(Level.TRACE)) {
LOGGER.log(Level.TRACE,
"tableChanged: firstRow="+e.getFirstRow()+
", lastRow="+e.getLastRow()+", column="+e.getColumn()+
", value="+tableValue);
}
// if it's a String, try construct new value
// using the defined type.
if (tableValue instanceof String) {
try {
tableValue =
Utils.createObjectFromString(getClassName(e.getFirstRow()), // type
(String)tableValue);// value
} catch (Throwable ex) {
popupAndLog(ex,"tableChanged",
Messages.PROBLEM_SETTING_ATTRIBUTE);
}
}
final String attributeName = getValueName(e.getFirstRow());
final Attribute attribute =
new Attribute(attributeName,tableValue);
setAttribute(attribute, "tableChanged");
}
}
示例5: tableModelChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
private void tableModelChanged(TableModelEvent e) {
Log.getLogger().entering("QueryBuilderGraphFrame", "tableModelChanged");
// We have a mouse click inside a graph table node, indicating select/deselect.
// Propagate the information to the input table
// Extract some information from the event
int row = e.getFirstRow(); // the first row that changed
int column = e.getColumn(); // the column for this event
QueryBuilderTableModel model = (QueryBuilderTableModel) e.getSource();
String tableSpec = model.getTableSpec();
// DB column name
String columnName = (String) model.getValueAt(row, column+2);
// boolean - Selected/deselected
Object value = model.getValueAt(row, column);
if (value==Boolean.TRUE) { // A column has been selected
// Update the query model if appropriate
// Do this first so that it's available when adding the row
if (_queryBuilder._updateModel) {
_queryBuilder.getQueryModel().addColumn(tableSpec, columnName);
_queryBuilderInputTable.selectColumn(tableSpec, columnName, Boolean.TRUE);
}
}
else if (value==Boolean.FALSE) { // A column has been deselected
// Update the query model, if we're not being driven by it
// Do this before updating the grid, because we use the model to generate sortorder
if (_queryBuilder._updateModel) {
_queryBuilder.getQueryModel().removeColumn(tableSpec, columnName); }
// do not remove the whole row, just deselect the output column.
_queryBuilderInputTable.selectColumn(tableSpec, columnName, Boolean.FALSE);
}
// We used to update the text query after every event. That
// caused degraded performance. Now, we check whether we've
// received a real event, or we're generating the graph as a
// batch operation. Also, we trigger only on TableModel events,
// so InputTableMode must explicitly invoke
if (_queryBuilder._updateText) {
// An interactive event -- update the text query
_queryBuilder.generateText();
}
}
示例6: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent tme) {
if (this.quiteTabelModelListener==true) return;
int row = tme.getFirstRow();
int column = tme.getColumn();
DefaultTableModel model = (DefaultTableModel) tme.getSource();
if (column == 0 && row >= 0 && row < model.getRowCount()) {
String oldCompID = this.currNetworkComponent.getId();
String newCompID = (String) model.getValueAt(row, column);
if (!oldCompID.equals(newCompID)) {
String message = null;
String title = "Warning";
if (newCompID == null || newCompID.length() == 0) {
// --- Check if the component id is empty
message = "Enter a valid name";
JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
getJTableComponents().getModel().setValueAt(oldCompID, row, column);
} else if (newCompID.contains(" ")) {
// --- Check for spaces
message = "Enter the name without spaces";
JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
getJTableComponents().getModel().setValueAt(oldCompID, row, column);
} else if (getGraphController().getNetworkModelAdapter().getNetworkComponent(newCompID) != null) {
// --- Check if a network component name already exists
message = "The component name already exists!" + newLine + "Choose a different one.";
JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
getJTableComponents().getModel().setValueAt(oldCompID, row, column);
} else if (this.getGraphController().getProject().getSimulationSetups().getCurrSimSetup().isAgentNameExists(newCompID)) {
// --- Check if the agent name already exists in the simulation setup
message = "An agent with the name already exists in the simulation setup!" + newLine + " Choose a different one.";
JOptionPane.showMessageDialog(this, Language.translate(message, Language.EN), Language.translate(title, Language.EN), JOptionPane.WARNING_MESSAGE);
getJTableComponents().getModel().setValueAt(oldCompID, row, column);
} else {
// --- All validations done, rename the component and update the network model
// --- renaming NetworkComponents and GraphElements
this.getGraphController().getNetworkModelAdapter().renameNetworkComponent(oldCompID, newCompID);
}
}
}
// System.out.println(row+","+column);
}
示例7: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent tme) {
if(tme.getSource()==this && tme.getFirstRow()>=0){
if(tme.getType()==TableModelEvent.UPDATE){
// --- Update Events in the table ---------
if(tme.getColumn() > 0){
// --- A single value was edited ------------------------------------
int seriesIndex = tme.getColumn()-1; // First column contains the time stamps.
int rowIndex = tme.getFirstRow();
Number key = (Number) this.getValueAt(rowIndex, 0);
Number value = (Number) this.getValueAt(rowIndex, tme.getColumn());
Vector<Number> rowVector = this.getRow(rowIndex);
try {
if(value!=null){
// --- Update new entry in chart and ontology model ---------
this.getChartModel().addOrUpdateValuePair(seriesIndex, key, value);
this.getOntologyModel().addOrUpdateValuePair(seriesIndex, key, value);
} else {
if (this.isEmptyTableModelRow(rowVector)==false) {
// --- Rewrite the data row -----------------------------
for (int i=1; i < rowVector.size(); i++) {
Number seriesValue = (Number) rowVector.get(i);
int series = i-1;
if (seriesValue!=null) {
this.getChartModel().addOrUpdateValuePair(series, key, seriesValue);
this.getOntologyModel().addOrUpdateValuePair(series, key, seriesValue);
} else {
this.getChartModel().removeValuePair(series, key);
this.getOntologyModel().removeValuePair(series, key);
}
} // end for
} else {
// --- Empty row, delete ValuePair ----------------------
this.getChartModel().removeValuePair(seriesIndex, key);
this.getOntologyModel().removeValuePair(seriesIndex, key);
}
}
} catch (NoSuchSeriesException e) {
System.err.println("Error updating data model: Series "+seriesIndex+" does mot exist!");
e.printStackTrace();
}
} else if(tme.getColumn() == 0) {
// --- The key value (e.g. the time stamp) was edited ---------------
Number oldKey = (Number) this.getLatestChangedValue();
Number newKey = (Number) this.getValueAt(tme.getFirstRow(), 0);
this.getChartModel().updateKey(oldKey, newKey);
this.getOntologyModel().updateKey(oldKey, newKey);
}
}
}
}
示例8: tableChanged
import javax.swing.event.TableModelEvent; //導入方法依賴的package包/類
@Override
public void tableChanged(TableModelEvent tme) {
if(tme.getSource()==this && tme.getFirstRow()>=0){
if(tme.getType()==TableModelEvent.UPDATE){
// --- Update Events in the table ---------------------------------------
try {
int rowIndex = tme.getFirstRow();
int colIndex = tme.getColumn();
Vector<Number> rowVector = this.getRow(rowIndex);
Float xValue = (Float) rowVector.get(1);
Float yValue = (Float) rowVector.get(2);
// --- Do we have changes? ------------------------------------------
if (colIndex==1) {
if (((Float)this.latestChangedValue).equals(xValue)) return;
if (this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).getAvoidDuplicateXValues()==true) {
// --- Risk of duplicate x values ? -------------------------
if (this.tableModelDataVector.getRowByValue(colIndex, xValue, rowIndex)!=null) {
// --- Another row contains this value, undo ------------
String title = "Doppelte X-Werte nicht zulässig!";
String msg = "Doppelte X-Werte sind derzeit nicht zulässig!\n";
msg += "Die Aktion wird rückgängig gemacht.";
JOptionPane.showMessageDialog(this.myJTable, Language.translate(msg), Language.translate(title), JOptionPane.WARNING_MESSAGE, null);
xValue = (Float) this.latestChangedValue;
this.tableModelDataVector.get(rowIndex).set(colIndex, xValue);
return;
}
}
} else if (colIndex==2) {
if (((Float)this.latestChangedValue).equals(yValue)) return;
}
// --- A value of a series was edited -------------------------------
if(xValue!=null && yValue!=null){
// --- Update new entry in chart and ontology model --------
this.getOntologyModel().updateXyValuePair(this.getFocusedSeriesIndex(), rowIndex, xValue, yValue);
if (this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).getAutoSort()==true) {
this.tableModelDataVector.sort();
this.getOntologyModel().getSeries(this.getFocusedSeriesIndex()).sort();
// --- Find new position of the row vector -------------
rowIndex = this.tableModelDataVector.indexOf(rowVector);
}
this.getChartModel().setXYSeriesAccordingToOntologyModel(this.getFocusedSeriesIndex());
if (rowIndex!=-1) {
int rowIndexTable = this.myJTable.convertRowIndexToView(rowIndex);
this.myJTable.setRowSelectionInterval(rowIndexTable, rowIndexTable);
this.myJTable.changeSelection(rowIndexTable, 0, false, false);
}
} else {
// --- We have an empty yValue, delete ValuePair ------------
this.tableModelDataVector.remove(rowIndex);
if (this.getRowCount()==0) {
this.parentDataModel.removeSeries(this.getFocusedSeriesIndex());
} else {
this.getOntologyModel().removeXyValuePair(this.getFocusedSeriesIndex(), rowIndex);
this.getChartModel().setXYSeriesAccordingToOntologyModel(this.getFocusedSeriesIndex());
}
}
} catch (NoSuchSeriesException e) {
System.err.println("Error updating data model: Series "+this.getFocusedSeriesIndex()+" does mot exist!");
e.printStackTrace();
}
} else {
// --- Insert or Delete events in the table ---------
}
}
}