下面列出了javax.swing.table.TableCellEditor#stopCellEditing ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void actionPerformed( final ActionEvent e ) {
final TableCellEditor cellEditor = table.getCellEditor();
if ( cellEditor != null ) {
cellEditor.stopCellEditing();
}
final int maxIdx = selectionModel.getMaxSelectionIndex();
final ArrayList<GroupDataEntry> list = new ArrayList<GroupDataEntry>();
for ( int i = selectionModel.getMinSelectionIndex(); i <= maxIdx; i++ ) {
if ( selectionModel.isSelectedIndex( i ) ) {
list.add( tableModel.get( i ) );
}
}
for ( int i = 0; i < list.size(); i++ ) {
final GroupDataEntry dataEntry = list.get( i );
tableModel.remove( dataEntry );
}
}
/**
* Gets map of all declined word forms. Key = combined ID, value = word form
* @return
*/
@Override
public Map<String, String> getAllDecValues() {
Map<String, String> ret = new HashMap<>();
TableCellEditor editor = table.getCellEditor();
if (editor != null) {
editor.stopCellEditing();
}
decIdsToGridLocation.entrySet().forEach((entry) -> {
Object val = table.getModel().getValueAt(entry.getValue().height, entry.getValue().width);
ret.put(entry.getKey(), val == null ? "" : (String)val);
});
return ret;
}
/**
* Invoked when an action occurs.
*/
public void actionPerformed( final ActionEvent e ) {
if ( listSelectionModel.isSelectionEmpty() ) {
return;
}
if ( editorTable != null ) {
final TableCellEditor cellEditor = editorTable.getCellEditor();
if ( cellEditor != null ) {
cellEditor.stopCellEditing();
}
}
final Object[] data = tableModel.getBulkData();
final ArrayList<Object> result = new ArrayList<Object>( data.length );
for ( int i = 0; i < data.length; i++ ) {
if ( listSelectionModel.isSelectedIndex( i ) == false ) {
result.add( data[ i ] );
}
}
tableModel.setBulkData( result.toArray() );
}
public void actionPerformed(ActionEvent e) {
if (grid.isEditing()) {
TableCellEditor cellEditor = grid.getCellEditor(grid.getEditingRow(), grid.getEditingColumn());
cellEditor.stopCellEditing();
}
tableModel.addRow(defaultValues);
tableModel.fireTableDataChanged();
// Enable DELETE (which may already be enabled, but it won't hurt)
deleteRowButton.setEnabled(true);
// Highlight (select) the appropriate row.
int rowToSelect = tableModel.getRowCount() - 1;
if (rowToSelect < grid.getRowCount()) {
grid.setRowSelectionInterval(rowToSelect, rowToSelect);
}
sender.updateUI();
}
public void focusLost(FocusEvent e)
{
if (focused!=null)
{
focused.removeFocusListener(this);
focused = e.getOppositeComponent();
if (table==focused || table.isAncestorOf(focused))
{
focused.addFocusListener(this);
}
else
{
focused=null;
TableCellEditor editor = table.getCellEditor();
if (editor!=null)
{
editor.stopCellEditing();
}
}
}
}
public void stopCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Stop Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
}
public void stopCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Stop Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
}
public void stopCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Stop Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
}
/**
* Invoked when an action occurs.
*/
public void actionPerformed( final ActionEvent e ) {
if ( listSelectionModel.isSelectionEmpty() ) {
return;
}
final Object[] data = tableModel.getBulkData();
if ( listSelectionModel.getMaxSelectionIndex() == ( data.length - 1 ) ) {
// already the first entry ...
return;
}
if ( editorTable != null ) {
final TableCellEditor cellEditor = editorTable.getCellEditor();
if ( cellEditor != null ) {
cellEditor.stopCellEditing();
}
}
final Object[] result = (Object[]) data.clone();
final boolean[] selections = new boolean[ result.length ];
for ( int i = listSelectionModel.getMinSelectionIndex(); i <= listSelectionModel.getMaxSelectionIndex(); i++ ) {
selections[ i ] = listSelectionModel.isSelectedIndex( i );
}
BulkDataUtility.pushDown( result, selections );
tableModel.setBulkData( result );
listSelectionModel.setValueIsAdjusting( true );
listSelectionModel.removeSelectionInterval( 0, selections.length );
for ( int i = 0; i < selections.length; i++ ) {
final boolean selection = selections[ i ];
if ( selection ) {
listSelectionModel.addSelectionInterval( i, i );
}
}
listSelectionModel.setValueIsAdjusting( false );
}
/**
* Invoked when an action occurs.
*/
public void actionPerformed(final ActionEvent e)
{
final TableCellEditor tableCellEditor = parameterMappingTable.getCellEditor();
if (tableCellEditor != null)
{
tableCellEditor.stopCellEditing();
}
final ParameterMappingTableModel tableModel = (ParameterMappingTableModel) parameterMappingTable.getModel();
tableModel.addRow();
}
public void applyChanges()
{
TableCellEditor cellEditor = _pnl.tblSchemas.getCellEditor();
if(null != cellEditor)
{
cellEditor.stopCellEditing();
}
if(_pnl.radLoadAllAndCacheNone.isSelected())
{
_alias.getSchemaProperties().setGlobalState(SQLAliasSchemaProperties.GLOBAL_STATE_LOAD_ALL_CACHE_NONE);
}
else if(_pnl.radLoadAndCacheAll.isSelected())
{
_alias.getSchemaProperties().setGlobalState(SQLAliasSchemaProperties.GLOBAL_STATE_LOAD_AND_CACHE_ALL);
}
else if(_pnl.radSpecifySchemas.isSelected())
{
_alias.getSchemaProperties().setGlobalState(SQLAliasSchemaProperties.GLOBAL_STATE_SPECIFY_SCHEMAS);
}
_alias.getSchemaProperties().setSchemaDetails(_schemaTableModel.getData());
_alias.getSchemaProperties().setCacheSchemaIndependentMetaData(_pnl.chkCacheSchemaIndepndentMetaData.isSelected());
}
public void setData( final Element[] elements ) {
final TableCellEditor tableCellEditor = table.getCellEditor();
if ( tableCellEditor != null ) {
tableCellEditor.stopCellEditing();
}
dataModel.setData( elements );
}
/**
* Commits on-going cell editing
*/
public void commitEditing() {
TableCellEditor editor = getCellEditor();
if (editor != null) {
editor.stopCellEditing();
}
}
public void actionPerformed( final ActionEvent e ) {
final TableCellEditor cellEditor = table.getCellEditor();
if ( cellEditor != null ) {
cellEditor.stopCellEditing();
}
final EditGroupDetailsDialog dialog = new EditGroupDetailsDialog( EditGroupsDialog.this );
final RelationalGroup group = new RelationalGroup();
final EditGroupUndoEntry groupUndoEntry = dialog.editGroup( group, getReportRenderContext(), true );
if ( groupUndoEntry != null ) {
tableModel.add( new GroupDataEntry( null, groupUndoEntry.getNewName(), groupUndoEntry.getNewFields() ) );
}
}
public void stopCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Stop Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
}
public void stopCellEditing() {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.finer("Stop Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
}
private void stopEditing() {
if (table.isEditing()) {
TableCellEditor editor = table.getCellEditor();
if (editor != null) {
editor.stopCellEditing();
}
}
}
/**
* Invoked when an action occurs.
*/
public void actionPerformed( final ActionEvent e ) {
if ( listSelectionModel.isSelectionEmpty() ) {
return;
}
if ( listSelectionModel.getMinSelectionIndex() == 0 ) {
// already the first entry ...
return;
}
if ( editorTable != null ) {
final TableCellEditor cellEditor = editorTable.getCellEditor();
if ( cellEditor != null ) {
cellEditor.stopCellEditing();
}
}
final Object[] data = tableModel.getBulkData();
final Object[] result = (Object[]) data.clone();
final boolean[] selections = new boolean[ result.length ];
for ( int i = listSelectionModel.getMinSelectionIndex(); i <= listSelectionModel.getMaxSelectionIndex(); i++ ) {
selections[ i ] = listSelectionModel.isSelectedIndex( i );
}
BulkDataUtility.pushUp( result, selections );
tableModel.setBulkData( result );
listSelectionModel.setValueIsAdjusting( true );
listSelectionModel.removeSelectionInterval( 0, selections.length );
for ( int i = 0; i < selections.length; i++ ) {
final boolean selection = selections[ i ];
if ( selection ) {
listSelectionModel.addSelectionInterval( i, i );
}
}
listSelectionModel.setValueIsAdjusting( false );
}
public void stopCellEditing() {
if (LOGGER.isLoggable(Level.TRACE)) {
LOGGER.log(Level.TRACE, "Stop Editing Row: "+getEditingRow());
}
final TableCellEditor tableCellEditor = getCellEditor();
if (tableCellEditor != null) {
tableCellEditor.stopCellEditing();
}
}
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
//The user may type into the field and while the cursor is still inside,
//he may click save button.
//It will not set the value into that field and will cause error.
//So when the user clicks save button, we have to stop that cellediting process
//and set the value to the field.
//Get the currently edited cell's celleditor
TableCellEditor cellEditor = accountsTable.getCellEditor();
//Call stopCellEditing() to stop the editing process
//But if the selected cell is in first column which is non editable, then
//calling stopCellEditing will throw nullpointer exception because there's
//no editor there.. So check for null, before calling stopCellEditing().
if (cellEditor != null) {
cellEditor.stopCellEditing();
}
//Iterate through each row..
//int row = 0;
for (Account account : amw.getAccounts().values()) {
//Declare local variables to store the username and password
//If none present, empty "" is stored.
String username = "", password = "";
for (int i = 0; i < accountsTable.getModel().getRowCount(); i++) {
if(accountsTable.getValueAt(i, HOSTNAME).toString().equals(account.getHOSTNAME())){
username = accountsTable.getValueAt(i, USERNAME).toString();
password = accountsTable.getValueAt(i, PASSWORD).toString();
}
}
//The username and password field must be both filled or both empty
//Only one field should not be filled.
if (username.isEmpty() ^ password.isEmpty()) {
NULogger.getLogger().info("The username and password field must be both filled or both empty");
ThemeCheck.apply(null);
JOptionPane.showMessageDialog(this,
account.getHOSTNAME() + " " + Translation.T().dialogerror(),
account.getHOSTNAME(),
JOptionPane.WARNING_MESSAGE);
return;
}
//Username and Password (encrypted) must be stored in the .nuproperties file in the user's home folder.
NULogger.getLogger().info("Setting username and password(encrypted) to the .nuproperties file in user home folder.");
NeembuuUploaderProperties.setProperty(account.getKeyUsername(), username);
NeembuuUploaderProperties.setEncryptedProperty(account.getKeyPassword(), password);
// row++;
}
//Separate thread to start the login process
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
loginEnabledAccounts();
} catch (Exception ex) {
System.err.println("Exception while logging in.." + ex);
NULogger.getLogger().severe(ex.toString());
}
}
});
//Disposing the window
NULogger.getLogger().info("Closing Accounts Manager..");
try{
if(isVisible())
dispose();
}catch(Exception a){
System.err.println("Following error may be ignored");
a.printStackTrace();
}
}