📄 celleditor.java
字号:
/** * Returns the input validator for this cell editor. * * @return the input validator, or <code>null</code> if none */ public ICellEditorValidator getValidator() { return validator; } /** * Returns this cell editor's value provided that it has a valid one. * * @return the value of this cell editor, or <code>null</code> * if the cell editor does not contain a valid value */ public final Object getValue() { if (!valid) { return null; } return doGetValue(); } /** * Returns whether this cell editor is activated. * * @return <code>true</code> if this cell editor's control is * currently activated, and <code>false</code> if not activated */ public boolean isActivated() { // Use the state of the visible style bit (getVisible()) rather than the // window's actual visibility (isVisible()) to get correct handling when // an ancestor control goes invisible, see bug 85331. return control != null && control.getVisible(); } /** * Returns <code>true</code> if this cell editor is * able to perform the copy action. * <p> * This default implementation always returns * <code>false</code>. * </p> * <p> * Subclasses may override * </p> * @return <code>true</code> if copy is possible, * <code>false</code> otherwise */ public boolean isCopyEnabled() { return false; } /** * Returns whether the given value is valid for this cell editor. * This cell editor's validator (if any) makes the actual determination. * * @return <code>true</code> if the value is valid, and <code>false</code> * if invalid */ protected boolean isCorrect(Object value) { errorMessage = null; if (validator == null) { return true; } errorMessage = validator.isValid(value); return (errorMessage == null || errorMessage.equals(""));//$NON-NLS-1$ } /** * Returns <code>true</code> if this cell editor is * able to perform the cut action. * <p> * This default implementation always returns * <code>false</code>. * </p> * <p> * Subclasses may override * </p> * @return <code>true</code> if cut is possible, * <code>false</code> otherwise */ public boolean isCutEnabled() { return false; } /** * Returns <code>true</code> if this cell editor is * able to perform the delete action. * <p> * This default implementation always returns * <code>false</code>. * </p> * <p> * Subclasses may override * </p> * @return <code>true</code> if delete is possible, * <code>false</code> otherwise */ public boolean isDeleteEnabled() { return false; } /** * Returns whether the value of this cell editor has changed since the * last call to <code>setValue</code>. * * @return <code>true</code> if the value has changed, and <code>false</code> * if unchanged */ public boolean isDirty() { return dirty; } /** * Marks this cell editor as dirty. * @since 2.1 */ protected void markDirty() { dirty = true; } /** * Returns <code>true</code> if this cell editor is * able to perform the find action. * <p> * This default implementation always returns * <code>false</code>. * </p> * <p> * Subclasses may override * </p> * @return <code>true</code> if find is possible, * <code>false</code> otherwise */ public boolean isFindEnabled() { return false; } /** * Returns <code>true</code> if this cell editor is * able to perform the paste action. * <p> * This default implementation always returns * <code>false</code>. * </p> * <p> * Subclasses may override * </p> * @return <code>true</code> if paste is possible, * <code>false</code> otherwise */ public boolean isPasteEnabled() { return false; } /** * Returns <code>true</code> if this cell editor is * able to perform the redo action. * <p> * This default implementation always returns * <code>false</code>. * </p> * <p> * Subclasses may override * </p> * @return <code>true</code> if redo is possible, * <code>false</code> otherwise */ public boolean isRedoEnabled() { return false; } /** * Returns <code>true</code> if this cell editor is * able to perform the select all action. * <p> * This default implementation always returns * <code>false</code>. * </p> * <p> * Subclasses may override * </p> * @return <code>true</code> if select all is possible, * <code>false</code> otherwise */ public boolean isSelectAllEnabled() { return false; } /** * Returns <code>true</code> if this cell editor is * able to perform the undo action. * <p> * This default implementation always returns * <code>false</code>. * </p> * <p> * Subclasses may override * </p> * @return <code>true</code> if undo is possible, * <code>false</code> otherwise */ public boolean isUndoEnabled() { return false; } /** * Returns whether this cell editor has a valid value. * The default value is false. * * @return <code>true</code> if the value is valid, and <code>false</code> * if invalid * * @see #setValueValid(boolean) */ public boolean isValueValid() { return valid; } /** * Processes a key release event that occurred in this cell editor. * <p> * The default implementation of this framework method cancels editing * when the ESC key is pressed. When the RETURN key is pressed the current * value is applied and the cell editor deactivates. * Subclasses should call this method at appropriate times. * Subclasses may also extend or reimplement. * </p> * * @param keyEvent the key event */ protected void keyReleaseOccured(KeyEvent keyEvent) { if (keyEvent.character == '\u001b') { // Escape character fireCancelEditor(); } else if (keyEvent.character == '\r') { // Return key fireApplyEditorValue(); deactivate(); } } /** * Processes a focus lost event that occurred in this cell editor. * <p> * The default implementation of this framework method applies the current * value and deactivates the cell editor. * Subclasses should call this method at appropriate times. * Subclasses may also extend or reimplement. * </p> */ protected void focusLost() { if (isActivated()) { fireApplyEditorValue(); deactivate(); } } /** * Performs the copy action. * This default implementation does nothing. * <p> * Subclasses may override * </p> */ public void performCopy() { } /** * Performs the cut action. * This default implementation does nothing. * <p> * Subclasses may override * </p> */ public void performCut() { } /** * Performs the delete action. * This default implementation does nothing. * <p> * Subclasses may override * </p> */ public void performDelete() { } /** * Performs the find action. * This default implementation does nothing. * <p> * Subclasses may override * </p> */ public void performFind() { } /** * Performs the paste action. * This default implementation does nothing. * <p> * Subclasses may override * </p> */ public void performPaste() { } /** * Performs the redo action. * This default implementation does nothing. * <p> * Subclasses may override * </p> */ public void performRedo() { } /** * Performs the select all action. * This default implementation does nothing. * <p> * Subclasses may override * </p> */ public void performSelectAll() { } /** * Performs the undo action. * This default implementation does nothing. * <p> * Subclasses may override * </p> */ public void performUndo() { } /** * Removes the given listener from this cell editor. * Has no affect if an identical listener is not registered. * * @param listener a cell editor listener */ public void removeListener(ICellEditorListener listener) { listeners.remove(listener); } /** * Removes the given property change listener from this cell editor. * Has no affect if an identical property change listener is not * registered. * * @param listener a property change listener */ public void removePropertyChangeListener(IPropertyChangeListener listener) { propertyChangeListeners.remove(listener); } /** * Sets or clears the current error message for this cell editor. * <p> * No formatting is done here, the message to be set is expected to be fully formatted * before being passed in. * </p> * @param message the error message, or <code>null</code> to clear */ protected void setErrorMessage(String message) { errorMessage = message; } /** * Sets the focus to the cell editor's control. */ public void setFocus() { doSetFocus(); } /** * Sets the input validator for this cell editor. * * @param validator the input validator, or <code>null</code> if none */ public void setValidator(ICellEditorValidator validator) { this.validator = validator; } /** * Sets this cell editor's value. * * @param value the value of this cell editor */ public final void setValue(Object value) { valid = isCorrect(value); dirty = false; doSetValue(value); } /** * Sets the valid state of this cell editor. * The default value is false. * Subclasses should call this method on construction. * * @param valid <code>true</code> if the current valie is valid, * and <code>false</code> if invalid * * @see #isValueValid */ protected void setValueValid(boolean valid) { this.valid = valid; } /** * The value has changed. * Updates the valid state flag, marks this cell editor as dirty, * and notifies all registered cell editor listeners of a value change. * * @param oldValidState the valid state before the end user changed the value * @param newValidState the current valid state * @see ICellEditorListener#editorValueChanged */ protected void valueChanged(boolean oldValidState, boolean newValidState) { valid = newValidState; dirty = true; fireEditorValueChanged(oldValidState, newValidState); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -