当前位置: 首页>>代码示例>>Java>>正文


Java TableModelEvent.getSource方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:QueryBuilderGraphFrame.java

示例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);
        }
    } 
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SchemaPanel.java

示例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");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:XMBeanAttributes.java

示例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");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:XMBeanAttributes.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:52,代码来源:QueryBuilderGraphFrame.java

示例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);
  }
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:52,代码来源:BasicGraphGuiRootJSplitPane.java

示例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);
			}
			
		} 
		
	}

}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:64,代码来源:TimeSeriesTableModel.java

示例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 ---------
		}
	}

}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:75,代码来源:XyTableModel.java


注:本文中的javax.swing.event.TableModelEvent.getSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。