@Override public void actionPerformed(ActionEvent ae) { FeatureDescriptor fd = _getSelection(); if (fd instanceof PropertySet) { int row = SheetTable.this.getSelectedRow(); boolean b = getPropertySetModel().isExpanded(fd); if (!b) { toggleExpanded(row); } } }
private void updateSheetTableSelection(MouseEvent e) { Component comp = (Component) e.getSource(); if (comp instanceof SheetTable) { SheetTable table = (SheetTable) comp; table.changeSelection(table.rowAtPoint(e.getPoint()), 0, false, false); } }
@Override protected void finalize() { instanceCount--; if (instanceCount == 0) { renderer = null; sheetCellEditor = null; cleanup(); } }
/** Restarts inline edit mode if the the preceding custom edit failed */ @Override public void editorClosed() { if (lastFailed) { editCellAt(getSelectedRow(), 1, null); } repaint(); customEditorIsOpen = false; }
/** Initiate editing automatically - triggered by the focus event countdown */ private void autoEdit() { editCellAt(getSelectedRow(), getSelectedColumn(), null); if (editorComp != null) { editorComp.requestFocus(); } countDown = -1; }
enterEditRequest(); if (editingRow == row && isEditing() && column == 0) { removeEditor(); exitEditRequest(); return false; if (editingRow == row && isEditing()) { exitEditRequest(); return false; if (PropUtils.psCommitOnFocusLoss && isEditing()) { getEditor().stopCellEditing(); if ((e instanceof MouseEvent) && (onCenterLine ((MouseEvent)e))) { exitEditRequest(); return false; if ((e instanceof MouseEvent) && (onCustomEditorButton ( (MouseEvent) e))) { if (PropUtils.isLoggable(SheetTable.class)) { if (isEditing() && editingRow != row) { removeEditor(); int prevSel = getSelectedRow();
/** Overridden to catch a mouse pressed event over the custom editor * button and invoke the custom editor even if we do not have focus; * otherwise, for example, in the options dialog, clicking from the * tree to the table over the custom editor button will just set focus * to the table, but will not initiate the custom editor dialog */ public void processMouseEvent(MouseEvent me) { if (me.getID() == me.MOUSE_PRESSED) { if (onCustomEditorButton(me) && !hasFocus()) { if (PropUtils.psCommitOnFocusLoss && isEditing()) { getEditor().stopCellEditing(); } int row = rowAtPoint(me.getPoint()); int col = columnAtPoint(me.getPoint()); if (row != -1 && col != -1) { changeSelection(row, col, false, false); getCustomEditorAction().actionPerformed( new ActionEvent (this, ActionEvent.ACTION_PERFORMED, ACTION_CUSTOM_EDITOR)); me.consume(); return; } } } super.processMouseEvent(me); }
/** Restore the previous editing state, if the previously edited * FeatureDescriptor is still available for editing */ void restoreEditingState() { int idx = indexOfLastSelected(); boolean canResumeEditing = idx != -1; if (!canResumeEditing) idx = lastSelectedRow; if (idx == -1) { clearSavedEditingState(); return; } if (idx < getRowCount()) { changeSelection(idx, 1, false, false); if ((canResumeEditing) && wasEditing) { editCellAt (idx, 1); InplaceEditor ine = getEditor().getInplaceEditor(); if ((ine != null) && (partialValue != null)) { ine.setValue (partialValue); } } } clearSavedEditingState(); }
FeatureDescriptor fd = getSheetModel().getPropertySetModel().getFeatureDescriptor(row); if (!isCellEditable(row, 1)) { return true; if (isEditing()) { removeEditor(); changeSelection(row, 1, false, false); paintRow(row);
/** Overridden to supply different tooltips depending on mouse position (name, * value, custom editor button). Will HTML-ize long tooltips*/ @Override public String getToolTipText(MouseEvent e) { if (customEditorIsOpen) { return null; } String result; Point pt = e.getPoint(); int row = rowAtPoint(pt); int col = columnAtPoint(pt); if ((col == 1) && onCustomEditorButton(e)) { result = NbBundle.getMessage(SheetTable.class, "CTL_EDBUTTON_TIP"); // NOI18N } else { result = getSheetModel().getDescriptionFor(row, col); if ((col == 1) && (result != null) && (result.length() > 100)) { //e.g. Jesse's new file list property gives massive //tooltips; break them up result = PropUtils.createHtmlTooltip( getPropertySetModel().getFeatureDescriptor(row).getDisplayName(), result ); } } if ((result != null) && "".equals(result.trim())) { result = null; // prevents 2x2 dot as a tooltip } return result; }
table.setFont(f); psheet.setBackground(table.getBackground()); setBackground(table.getBackground()); psheet.setMarginColor(PropUtils.getSetRendererColor()); add(psheet, BorderLayout.CENTER); table.setBorder(BorderFactory.createEmptyBorder()); table.addChangeListener(listener);
int row = rowAtPoint(pt); int col = columnAtPoint(pt); FeatureDescriptor fd = getSheetModel().getPropertySetModel().getFeatureDescriptor(row); if( null == fd ) { success = e.getX() > (getWidth() - PropUtils.getCustomButtonWidth());
/** Temporarily store the currently edited feature descriptor and partial * value from the editor. This info is used to restore the editing state * after temporary losses of focus and recoverable changes like reordering * the model, or changes that derive from the underlying node */ void saveEditingState() { storedFd = _getSelection(); if (isEditing()) { InplaceEditor ine = getEditor().getInplaceEditor(); if (ine != null) { partialValue = ine.getValue(); } } }
/** Overridden to check the focus event countdown and initiate editing on * the second focus event following a failed edit (dialog was shown) */ public void processFocusEvent(FocusEvent fe) { super.processFocusEvent(fe); if (fe.getID() == fe.FOCUS_GAINED) { countDown--; if (countDown == 0) { autoEdit(); } } if (fe.getID() == fe.FOCUS_GAINED || (fe.getOppositeComponent() != null && fe.getID() == fe.FOCUS_LOST && !isAncestorOf(fe.getOppositeComponent()))) { //Ensure the description goes back to the node description if //we lose focus fireChange(); } }
/** * Select (and start editing) the given property. * @param fd * @param startEditing */ public void select( FeatureDescriptor fd, boolean startEditing ) { PropertySetModel psm = getPropertySetModel(); final int index = psm.indexOf( fd ); if( index < 0 ) { return; //not in our list } getSelectionModel().setSelectionInterval( index, index ); if( startEditing && psm.isProperty( index ) ) { editCellAt( index, 1, new MouseEvent( SheetTable.this, 0, System.currentTimeMillis(), 0, 0, 0, 1, false) ); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { SheetCellEditor cellEditor = getEditor(); if( null != cellEditor ) { InplaceEditor inplace = cellEditor.getInplaceEditor(); if( null != inplace && null != inplace.getComponent() ) { inplace.getComponent().requestFocus(); } } } }); } }
@Override public boolean isEnabled() { return _getSelection() instanceof PropertySet; } }
public boolean editCellAt(int row, int column, EventObject e) { assert SwingUtilities.isEventDispatchThread(); enterEditRequest(); if( (editingRow == row) && isEditing() ) { if( 0 == column ) { getEditor().stopCellEditing(); removeEditor(); exitEditRequest(); if (PropUtils.psCommitOnFocusLoss && isEditing()) { getEditor().stopCellEditing(); if (isGoingToBeClosed()) { return false; if ((e instanceof MouseEvent) && (onCenterLine((MouseEvent) e))) { exitEditRequest(); if ((e instanceof MouseEvent) && (onCustomEditorButton((MouseEvent) e))) { if (PropUtils.isLoggable(SheetTable.class)) { PropUtils.log(SheetTable.class, "Got a mouse click on the " + "custom editor button"); //NOI18N if (isEditing() && (editingRow != row)) { removeEditor();
/** Overridden to catch a mouse pressed event over the custom editor * button and invoke the custom editor even if we do not have focus; * otherwise, for example, in the options dialog, clicking from the * tree to the table over the custom editor button will just set focus * to the table, but will not initiate the custom editor dialog */ public void processMouseEvent(MouseEvent me) { if (me.getID() == me.MOUSE_PRESSED) { if (onCustomEditorButton(me) && !hasFocus()) { if (PropUtils.psCommitOnFocusLoss && isEditing()) { getEditor().stopCellEditing(); } int row = rowAtPoint(me.getPoint()); int col = columnAtPoint(me.getPoint()); if (row != -1 && col != -1) { changeSelection(row, col, false, false); getCustomEditorAction().actionPerformed( new ActionEvent (this, ActionEvent.ACTION_PERFORMED, ACTION_CUSTOM_EDITOR)); me.consume(); return; } } } super.processMouseEvent(me); }
/** Restore the previous editing state, if the previously edited * FeatureDescriptor is still available for editing */ void restoreEditingState() { int idx = indexOfLastSelected(); boolean canResumeEditing = idx != -1; if (!canResumeEditing) { idx = lastSelectedRow; } if (idx == -1) { clearSavedEditingState(); return; } if (idx < getRowCount()) { changeSelection(idx, 1, false, false); if ((canResumeEditing) && wasEditing) { editCellAt(idx, 1); InplaceEditor ine = getEditor().getInplaceEditor(); if ((ine != null) && (partialValue != null)) { ine.setValue(partialValue); } } } clearSavedEditingState(); }
FeatureDescriptor fd = getSheetModel().getPropertySetModel().getFeatureDescriptor(row); if (fd.getValue("stringValues") != null) return false; //NOI18N Property p = fd instanceof Property ? (Property) fd : null; if (!isCellEditable (row, 1)) return true; if (isEditing()) { removeEditor(); changeSelection (row, 1, false, false); paintRow (row);