/** * tests if there should be an empty row appended * * @param inserting is set: the selected cell will be filled but is not yet */ public void addRow(boolean inserting) { int row = replaceTable.getSelectedRow(); int col = replaceTable.getSelectedColumn(); if (row + 1 == replaceTable.getRowCount() && col >= 0) { boolean[] colSet = new boolean[2]; colSet[0] = !data.lastElement().firstElement().equals(""); colSet[1] = !data.lastElement().lastElement().equals(""); colSet[col] = colSet[col] || inserting; if (colSet[0] && colSet[1]) { TableCellEditor editor = replaceTable.getCellEditor(); if (editor != null) { row = replaceTable.getEditingRow(); col = replaceTable.getEditingColumn(); data.get(row).set(col, editor.getCellEditorValue().toString()); } data.add(new Vector<String>(Arrays.asList(new String[] {"", ""}))); replaceTable.revalidate(); CASSubDialog.this.pack(); Rectangle r = replaceTable.getCellRect(replaceTable.getRowCount() - 1, col, false); scrollPane.getViewport().scrollRectToVisible(r); if (editor != null) { replaceTable.editCellAt(row, col); } } } }
/** * if editing insert inStr at current caret position * * @param inStr */ public void insertText(String inStr) { if (inStr == null) return; TableCellEditor editor = replaceTable.getCellEditor(); if (editor != null && editor instanceof MathTextCellEditor) { ((MathTextCellEditor) editor).insertString(inStr); } }
private void stopCellEditting() { if (tblPackages.getSelectedRow() < 0 || tblPackages.getSelectedColumn() < 0) return; if (pkgTblModel.isCellEditable(tblPackages.getSelectedRow(), tblPackages.getSelectedColumn())) { tblPackages .getCellEditor(tblPackages.getSelectedRow(), tblPackages.getSelectedColumn()) .stopCellEditing(); } }
// region Private Methods private static void stopCellEditing(JTable table) { if (table.getRowCount() > 0) { TableCellEditor editor = table.getCellEditor(); if (editor != null) { editor.stopCellEditing(); } } }
public void actionPerformed(ActionEvent arg0) { if (tabla.isEditing()) { tabla.getCellEditor().stopCellEditing(); } Obj_Revision_Lista_Raya lista_raya = new Obj_Revision_Lista_Raya(); lista_raya.borrar(); Imprimir_lista_raya(); new Cat_Imprimir_LR().setVisible(true); }
public void actionPerformed(ActionEvent e) { int column = table.getSelectedColumn(); int row = table.getSelectedRow(); if (table.isEditing()) table.getCellEditor().stopCellEditing(); if (column < 4) { table.changeSelection(row, column + 1, false, false); table.editCellAt(row, column + 1); } }
private static void changeTableFont(JTable table, Font f) { UIDefaults nimbusOverrides = new UIDefaults(); nimbusOverrides.put("Table.font", new FontUIResource(f)); table.putClientProperty("Nimbus.Overrides", nimbusOverrides); TableCellEditor editor = table.getCellEditor(); if (editor != null) { editor.cancelCellEditing(); } FontMetrics fm = table.getFontMetrics(f); int h = fm.getHeight() + 8; table.setRowHeight(h); SwingUtilities.updateComponentTreeUI(table); }
public void release() { if (propertiesTable.isEditing()) { propertiesTable.getCellEditor().stopCellEditing(); } propertiesModel.release(); if (holder instanceof WsdlProject) { WsdlProject project = (WsdlProject) holder; project.removeEnvironmentListener(environmentListener); project.removeProjectListener(projectListener); } projectListener = null; }
public void actionPerformed(ActionEvent ae) { Object src = ae.getSource(); replaceTable.clearSelection(); if (replaceTable.isEditing()) replaceTable.getCellEditor().stopCellEditing(); if (src instanceof JComponent) { ((JComponent) src).requestFocusInWindow(); } if (src == btEval) { if (apply(btEval.getActionCommand())) setVisible(false); } else if (src == btSub) { if (apply(btSub.getActionCommand())) setVisible(false); } else if (src == btNumeric) { if (apply(btNumeric.getActionCommand())) setVisible(false); } }
@Override public void mouseDragged(MouseEvent e) { int ctrlMask = InputEvent.CTRL_DOWN_MASK; int action = ((e.getModifiersEx() & ctrlMask) == ctrlMask) ? TransferHandler.COPY : TransferHandler.MOVE; JTable setTable = (JTable) e.getSource(); // 非選択状態からいきなりドラッグを開始すると cellEditor が残ってしまう問題の workaround if (setTable.isEditing()) { setTable.getCellEditor().stopCellEditing(); } TransferHandler handler = setTable.getTransferHandler(); handler.exportAsDrag(setTable, e, action); }
public void actionPerformed(ActionEvent arg0) { if (validaCampos() != "") { JOptionPane.showMessageDialog( null, "El Siguiente campo es requerído:\n" + validaCampos(), "Error al guardar registro", JOptionPane.WARNING_MESSAGE, new ImageIcon("Iconos//critica.png")); return; } else { if (tabla.isEditing()) { tabla.getCellEditor().stopCellEditing(); } new Progress_Bar_Guardar().setVisible(true); } }
/** Event handler for this dialog. */ public void actionPerformed(ActionEvent e) { // Force table to accept any partial edits. if (metadataTable.isEditing()) { metadataTable.getCellEditor().stopCellEditing(); } // Apply new/modified attributes to the object. Map currentObjectMetadata = currentObject.getModifiableMetadata(); Set obsoleteMetadataItems = currentObjectMetadata.keySet(); for (int row = 0; row < metadataTable.getRowCount(); row++) { String name = (String) objectMetadataTableModel.getValueAt(row, 0); String value = (String) objectMetadataTableModel.getValueAt(row, 1); currentObject.addMetadata(name, value); obsoleteMetadataItems.remove(name); } // Remove obsolete attributes. Iterator obsoleteNamesIter = obsoleteMetadataItems.iterator(); while (obsoleteNamesIter.hasNext()) { currentObject.removeMetadata((String) obsoleteNamesIter.next()); } if (e.getSource().equals(nextObjectButton)) { currentObjectIndex++; displayObjectProperties(); } else if (e.getSource().equals(previousObjectButton)) { currentObjectIndex--; displayObjectProperties(); } else if ("OK".equals(e.getActionCommand())) { modifyActionApproved = isModifyMode(); this.setVisible(false); } else if ("Cancel".equals(e.getActionCommand())) { modifyActionApproved = false; this.setVisible(false); } else if ("addMetadataItem".equals(e.getActionCommand())) { int newRowNumber = metadataTable.getRowCount() + 1; objectMetadataTableModel.addRow( new String[] {"name-" + newRowNumber, "value-" + newRowNumber}); } else if ("removeMetadataItem".equals(e.getActionCommand())) { int[] rows = metadataTable.getSelectedRows(); for (int i = rows.length - 1; i >= 0; i--) { int modelIndex = metadataTableSorter.modelIndex(rows[i]); objectMetadataTableModel.removeRow(modelIndex); } } }
/** * Saves the translation in two steps. First, the all the paragraph objects are serialized and * stored in the .slon file. Second, the target text is saved in a plain text (.translated.txt) * file. */ public void saveTranslation(JTable table) { /* If there is an unclosed segment, close it. */ try { table.getCellEditor().stopCellEditing(); } catch (Exception e1) { // do nothing // it is normal that if nothing is edited, editing can't be stopped } /* get the new translations */ ListIterator<Paragraph> iteratorP = this.paragraphs.listIterator(); Paragraph par = iteratorP.next(); ListIterator<Segment> iteratorS = par.getSegments().listIterator(); Segment seg = iteratorS.next(); DefaultTableModel tbModel = (DefaultTableModel) table.getModel(); for (int i = 0; i < paragraphs.size(); i++) { seg.getTarget().setText(tbModel.getValueAt(i, 1).toString()); seg.setComment(tbModel.getValueAt(i, 2).toString()); if (!iteratorS.hasNext()) { if (!iteratorP.hasNext()) { break; } else { par = iteratorP.next(); iteratorS = par.getSegments().listIterator(); } } seg = iteratorS.next(); } /* serialization */ try { serializeAll(project.translationFile.getAbsolutePath()); // all paragraphs // TODO check if the name of the file or the file itself is better } catch (IOException e) { e.printStackTrace(); } /* writing to a monolingual target file */ try { writeTarget(project.targetFile.getAbsolutePath()); // write to the .txt target file // TODO check if the name of the file or the file itself is better } catch (IOException e) { e.printStackTrace(); } /* resetting variables */ unsavedChanges = false; }
public void actionPerformed(ActionEvent e) { JTable table = (JTable) e.getSource(); if (!table.hasFocus()) { CellEditor cellEditor = table.getCellEditor(); if (cellEditor != null && !cellEditor.stopCellEditing()) { return; } table.requestFocus(); return; } ListSelectionModel rsm = table.getSelectionModel(); int anchorRow = rsm.getAnchorSelectionIndex(); table.editCellAt(anchorRow, PropertySheetTableModel.VALUE_COLUMN); Component editorComp = table.getEditorComponent(); if (editorComp != null) { editorComp.requestFocus(); } }
// add, find or save button public void buttonActionPerformed(java.awt.event.ActionEvent ae) { // log.debug("car button activated"); if (ae.getSource() == findButton) { int rowindex = carsTableModel.findCarByRoadNumber(findCarTextBox.getText()); if (rowindex < 0) { JOptionPane.showMessageDialog( this, MessageFormat.format( Bundle.getMessage("carWithRoadNumNotFound"), new Object[] {findCarTextBox.getText()}), Bundle.getMessage("carCouldNotFind"), JOptionPane.INFORMATION_MESSAGE); return; } // clear any sorts by column clearTableSort(carsTable); carsTable.changeSelection(rowindex, 0, false, false); return; } if (ae.getSource() == addButton) { if (f != null) { f.dispose(); } f = new CarEditFrame(); f.initComponents(); f.setTitle(Bundle.getMessage("TitleCarAdd")); } if (ae.getSource() == saveButton) { if (carsTable.isEditing()) { log.debug("cars table edit true"); carsTable.getCellEditor().stopCellEditing(); } OperationsXml.save(); saveTableDetails(carsTable); if (Setup.isCloseWindowOnSaveEnabled()) { dispose(); } } }
public EditResult performEdit( final ParameterMapping[] parameterMappings, final String[] reportFields, final String[] declaredParameter) { innerTableCellEditor.setTags(reportFields); outerTableCellEditor.setTags(declaredParameter); final ParameterMappingTableModel parameterMappingTableModel = (ParameterMappingTableModel) parameterMappingTable.getModel(); parameterMappingTableModel.setMappings(parameterMappings); if (super.performEdit() == false) { return null; } final TableCellEditor cellEditor = parameterMappingTable.getCellEditor(); if (cellEditor != null) { cellEditor.stopCellEditing(); } return new EditResult(parameterMappingTableModel.getMappings()); }
public void _commit(boolean finishChosen) throws CommitStepException { // Stop editing if any final TableCellEditor cellEditor = myTable.getCellEditor(); if (cellEditor != null) { cellEditor.stopCellEditing(); } // Check that all included fields are bound to valid bean properties final PsiNameHelper nameHelper = JavaPsiFacade.getInstance(myData.myProject).getNameHelper(); for (int i = 0; i < myData.myBindings.length; i++) { final FormProperty2BeanProperty binding = myData.myBindings[i]; if (binding.myBeanProperty == null) { continue; } if (!nameHelper.isIdentifier(binding.myBeanProperty.myName)) { throw new CommitStepException( UIDesignerBundle.message( "error.X.is.not.a.valid.property.name", binding.myBeanProperty.myName)); } } myData.myGenerateIsModified = myChkIsModified.isSelected(); }
/** * * Crea una instancia de linea de factura, por cada fila que contenga la tabla. * * @param factura */ private void rellenarLineas(IFactura factura) { TableModel modelo = jTable1.getModel(); int numFilas = modelo.getRowCount(); for (int i = 0; i < numFilas; i++) { ILineaFactura linea = FacturaHelperFactory.createLineaFactura(); String km = (String) modelo.getValueAt(i, 1); String precioKm = (String) modelo.getValueAt(i, 2); String horas = (String) modelo.getValueAt(i, 3); String total = (String) modelo.getValueAt(i, 4); // obtenemos el valor del textArea CellEditor edit = jTable1.getCellEditor(i, 0); linea.setDescripcion(edit.getCellEditorValue().toString()); linea.setKilometros(toCeroF(km)); linea.setPrecioKilometro(toCeroF(precioKm)); linea.setHorasEspera(toCero(horas)); linea.setTotal(toCeroF(total)); if (!total.equals("")) factura.addLineaFactura(linea); } }
public void setCellEditor() { for (int i = 0; i < tablafac.getRowCount(); i++) { tablafac.getCellEditor(i, 1).addCellEditorListener(this); tablafac.getCellEditor(i, 3).addCellEditorListener(this); } }
protected void comboBoxActionPerformed(ActionEvent ae) { log.debug("combobox action"); if (table.isEditing()) { table.getCellEditor().stopCellEditing(); // Allows the table contents to update } }
private void optionsComboBoxActionPerformed(ActionEvent e) { try { final int rowNumber = relationNodesetTable.getSelectedRow(); TableCellEditor cell = relationNodesetTable.getCellEditor(rowNumber, 2); if (cell.getCellEditorValue().equals("Base Node")) { String nodeName = (String) JOptionPane.showInputDialog( getRootPane(), "Enter the name of the node:", "Create a Node", JOptionPane.PLAIN_MESSAGE); if (nodeName != null) { String currentNodesetValue = relationNodesetTableModel.getValueAt(rowNumber, 1).toString(); if (currentNodesetValue.isEmpty()) { relationNodesetTableModel.setValueAt(nodeName, rowNumber, 1); } else { relationNodesetTableModel.setValueAt( currentNodesetValue + ", " + nodeName, rowNumber, 1); } } } else if (cell.getCellEditorValue().equals("Variable Node")) { Node varNode = network.buildVariableNode(); String currentNodesetValue = relationNodesetTableModel.getValueAt(rowNumber, 1).toString(); if (currentNodesetValue.isEmpty()) { relationNodesetTableModel.setValueAt(varNode.getIdentifier(), rowNumber, 1); } else { relationNodesetTableModel.setValueAt( currentNodesetValue + ", " + varNode.getIdentifier(), rowNumber, 1); } } else if (cell.getCellEditorValue().equals("build")) { JFrame popupFrame = new JFrame("build"); popupFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final cmdBuild buildPanel = new cmdBuild(network, frame, popupFrame); popupFrame.getContentPane().add(buildPanel); popupFrame.pack(); popupFrame.setVisible(true); Point point = frame.getsNePSULPanel1().getMenuDrivenCommands().cascadePosition(); popupFrame.setLocation(point); doneButton.setEnabled(false); popupFrame.addWindowListener( new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { LinkedList<Node> nodes = buildPanel.getNodes(); if (nodes.size() != 0) { for (Node item : nodes) { String currentNodesetValue = relationNodesetTableModel.getValueAt(rowNumber, 1).toString(); if (currentNodesetValue.isEmpty()) { relationNodesetTableModel.setValueAt(item.getIdentifier(), rowNumber, 1); } else { relationNodesetTableModel.setValueAt( currentNodesetValue + ", " + item.getIdentifier(), rowNumber, 1); } } } frame.getsNePSULPanel1().getMenuDrivenCommands().cascadeBack(); doneButton.setEnabled(true); } }); } else if (cell.getCellEditorValue().equals("assert")) { JFrame popupFrame = new JFrame("assert"); popupFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final cmdAssert assertPanel = new cmdAssert(network, frame, popupFrame); popupFrame.getContentPane().add(assertPanel); popupFrame.pack(); popupFrame.setVisible(true); Point point = frame.getsNePSULPanel1().getMenuDrivenCommands().cascadePosition(); popupFrame.setLocation(point); doneButton.setEnabled(false); popupFrame.addWindowListener( new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { LinkedList<Node> nodes = assertPanel.getNodes(); if (nodes.size() != 0) { for (Node item : nodes) { String currentNodesetValue = relationNodesetTableModel.getValueAt(rowNumber, 1).toString(); if (currentNodesetValue.isEmpty()) { relationNodesetTableModel.setValueAt(item.getIdentifier(), rowNumber, 1); } else { relationNodesetTableModel.setValueAt( currentNodesetValue + ", " + item.getIdentifier(), rowNumber, 1); } } } frame.getsNePSULPanel1().getMenuDrivenCommands().cascadeBack(); doneButton.setEnabled(true); } }); } else if (cell.getCellEditorValue().equals("find")) { JFrame popupFrame = new JFrame("find"); popupFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final cmdFind findPanel = new cmdFind(network, frame, popupFrame); popupFrame.getContentPane().add(findPanel); popupFrame.pack(); popupFrame.setVisible(true); Point point = frame.getsNePSULPanel1().getMenuDrivenCommands().cascadePosition(); popupFrame.setLocation(point); doneButton.setEnabled(false); popupFrame.addWindowListener( new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { LinkedList<Node> nodes = findPanel.getNodes(); if (nodes.size() != 0) { for (Node item : nodes) { String currentNodesetValue = relationNodesetTableModel.getValueAt(rowNumber, 1).toString(); if (currentNodesetValue.isEmpty()) { relationNodesetTableModel.setValueAt(item.getIdentifier(), rowNumber, 1); } else { relationNodesetTableModel.setValueAt( currentNodesetValue + ", " + item.getIdentifier(), rowNumber, 1); } } } frame.getsNePSULPanel1().getMenuDrivenCommands().cascadeBack(); doneButton.setEnabled(true); } }); } else if (cell.getCellEditorValue().equals("Existing Node")) { Node node = frame.getsNePSULPanel1().getMenuDrivenCommands().existingNodes(); if (node != null) { String currentNodesetValue = relationNodesetTableModel.getValueAt(rowNumber, 1).toString(); if (currentNodesetValue.isEmpty()) { relationNodesetTableModel.setValueAt(node.getIdentifier(), rowNumber, 1); } else { relationNodesetTableModel.setValueAt( currentNodesetValue + ", " + node.getIdentifier(), rowNumber, 1); } } } else if (cell.getCellEditorValue().equals("Act Node")) { frame .getsNePSULPanel1() .getMenuDrivenCommands() .actNodes(this, relationNodesetTable, doneButton, relationNodesetTableModel); } relationNodesetTable.setValueAt(options.getItemAt(0), rowNumber, 2); validate(); } catch (Exception e1) { } }
public void actionPerformed(ActionEvent arg0) { if (tabla.isEditing()) { tabla.getCellEditor().stopCellEditing(); } guardar_lista_raya(); }
/** Store changes to table preferences. This method is called when the user clicks Ok. */ public void storeSettings() { _prefs.putBoolean("fileColumn", fileColumn.isSelected()); _prefs.putBoolean("pdfColumn", pdfColumn.isSelected()); _prefs.putBoolean("urlColumn", urlColumn.isSelected()); _prefs.putBoolean("preferUrlDoi", preferDoi.isSelected()); _prefs.putBoolean("arxivColumn", arxivColumn.isSelected()); _prefs.putBoolean( JabRefPreferences.SHOWONELETTERHEADINGFORICONCOLUMNS, showOneLetterHeadingForIconColumns.isSelected()); /** * begin: special fields ** */ boolean newSpecialFieldsEnabled = specialFieldsEnabled.isSelected(), newRankingColumn = rankingColumn.isSelected(), newCompactRankingColumn = compactRankingColumn.isSelected(), newQualityColumn = qualityColumn.isSelected(), newPriorityColumn = priorityColumn.isSelected(), newRelevanceColumn = relevanceColumn.isSelected(), newSyncKeyWords = syncKeywords.isSelected(), newWriteSpecialFields = writeSpecialFields.isSelected(); boolean restartRequired = false; restartRequired = (oldSpecialFieldsEnabled != newSpecialFieldsEnabled) || (oldRankingColumn != newRankingColumn) || (oldCompcatRankingColumn != newCompactRankingColumn) || (oldQualityColumn != newQualityColumn) || (oldPriorityColumn != newPriorityColumn) || (oldRelevanceColumn != newRelevanceColumn) || (oldSyncKeyWords != newSyncKeyWords) || (oldWriteSpecialFields != newWriteSpecialFields); if (restartRequired) { JOptionPane.showMessageDialog( null, Globals.lang("You have changed settings for special fields.") .concat(" ") .concat(Globals.lang("You must restart JabRef for this to come into effect.")), Globals.lang("Changed special field settings"), JOptionPane.WARNING_MESSAGE); } // restart required implies that the settings have been changed // the seetings need to be stored if (restartRequired) { _prefs.putBoolean(SpecialFieldsUtils.PREF_SPECIALFIELDSENABLED, newSpecialFieldsEnabled); _prefs.putBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RANKING, newRankingColumn); _prefs.putBoolean(SpecialFieldsUtils.PREF_RANKING_COMPACT, newCompactRankingColumn); _prefs.putBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_PRIORITY, newPriorityColumn); _prefs.putBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_QUALITY, newQualityColumn); _prefs.putBoolean(SpecialFieldsUtils.PREF_SHOWCOLUMN_RELEVANCE, newRelevanceColumn); _prefs.putBoolean(SpecialFieldsUtils.PREF_AUTOSYNCSPECIALFIELDSTOKEYWORDS, newSyncKeyWords); _prefs.putBoolean(SpecialFieldsUtils.PREF_SERIALIZESPECIALFIELDS, newWriteSpecialFields); } /** * end: special fields ** */ if (colSetup.isEditing()) { int col = colSetup.getEditingColumn(), row = colSetup.getEditingRow(); colSetup.getCellEditor(row, col).stopCellEditing(); } // _prefs.putStringArray("columnNames", getChoices()); /*String[] cols = tableFields.getText().replaceAll("\\s+","") .replaceAll("\\n+","").toLowerCase().split(";"); if (cols.length > 0) for (int i=0; i<cols.length; i++) cols[i] = cols[i].trim(); else cols = null;*/ // Now we need to make sense of the contents the user has made to the // table setup table. if (tableChanged) { // First we remove all rows with empty names. int i = 0; while (i < tableRows.size()) { if (tableRows.elementAt(i).name.equals("")) tableRows.removeElementAt(i); else i++; } // Then we make arrays String[] names = new String[tableRows.size()], widths = new String[tableRows.size()]; int[] nWidths = new int[tableRows.size()]; _prefs.putInt("numberColWidth", ncWidth); for (i = 0; i < tableRows.size(); i++) { TableRow tr = tableRows.elementAt(i); names[i] = tr.name.toLowerCase(); nWidths[i] = tr.length; widths[i] = "" + tr.length; // Util.pr(names[i]+" "+widths[i]); } // Finally, we store the new preferences. _prefs.putStringArray("columnNames", names); _prefs.putStringArray("columnWidths", widths); } }