Java Code Examples for javax.swing.table.TableCellEditor#stopCellEditing()

The following examples show how to use javax.swing.table.TableCellEditor#stopCellEditing() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableEditorStopper.java    From beast-mcmc with GNU Lesser General Public License v2.1 6 votes vote down vote up
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();
            }
        }
    }
}
 
Example 2
Source File: AddRowAction.java    From jmeter-plugins with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: RemoveBulkAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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() );
}
 
Example 4
Source File: PDeclensionGridPanel.java    From PolyGlot with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Source File: EditGroupsDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 );
  }
}
 
Example 6
Source File: XMBeanAttributes.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void stopCellEditing() {
    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("Stop Editing Row: "+getEditingRow());
    }
    final TableCellEditor tableCellEditor = getCellEditor();
    if (tableCellEditor != null) {
        tableCellEditor.stopCellEditing();
    }
}
 
Example 7
Source File: XMBeanAttributes.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example 8
Source File: SortBulkUpAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 );
}
 
Example 9
Source File: NoSqlConfigurable.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
private void stopEditing() {
    if (table.isEditing()) {
        TableCellEditor editor = table.getCellEditor();
        if (editor != null) {
            editor.stopCellEditing();
        }
    }
}
 
Example 10
Source File: XMBeanAttributes.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void stopCellEditing() {
    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("Stop Editing Row: "+getEditingRow());
    }
    final TableCellEditor tableCellEditor = getCellEditor();
    if (tableCellEditor != null) {
        tableCellEditor.stopCellEditing();
    }
}
 
Example 11
Source File: EditGroupsDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
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() ) );
  }
}
 
Example 12
Source File: PropertySheetTable.java    From orbit-image-analysis with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Commits on-going cell editing 
 */
public void commitEditing() {
  TableCellEditor editor = getCellEditor();
  if (editor != null) {
    editor.stopCellEditing();
  }    
}
 
Example 13
Source File: StyleEditorPanel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void setData( final Element[] elements ) {
  final TableCellEditor tableCellEditor = table.getCellEditor();
  if ( tableCellEditor != null ) {
    tableCellEditor.stopCellEditing();
  }

  dataModel.setData( elements );
}
 
Example 14
Source File: SchemaPropertiesController.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
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());

}
 
Example 15
Source File: ParameterEditorDialog.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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();
}
 
Example 16
Source File: SortBulkDownAction.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 );
}
 
Example 17
Source File: XMBeanAttributes.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void stopCellEditing() {
    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("Stop Editing Row: "+getEditingRow());
    }
    final TableCellEditor tableCellEditor = getCellEditor();
    if (tableCellEditor != null) {
        tableCellEditor.stopCellEditing();
    }
}
 
Example 18
Source File: XMBeanAttributes.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void stopCellEditing() {
    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("Stop Editing Row: "+getEditingRow());
    }
    final TableCellEditor tableCellEditor = getCellEditor();
    if (tableCellEditor != null) {
        tableCellEditor.stopCellEditing();
    }
}
 
Example 19
Source File: XMBeanAttributes.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void stopCellEditing() {
    if (LOGGER.isLoggable(Level.FINER)) {
        LOGGER.finer("Stop Editing Row: "+getEditingRow());
    }
    final TableCellEditor tableCellEditor = getCellEditor();
    if (tableCellEditor != null) {
        tableCellEditor.stopCellEditing();
    }
}
 
Example 20
Source File: AccountsManager.java    From neembuu-uploader with GNU General Public License v3.0 4 votes vote down vote up
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();
    }
}