Methods Summary |
---|
private void | checkDeleteable()Checks to see if the "deletable" state (can delete/
nothing to delete) has changed and if so fire an
enablement changed notification.
boolean oldIsDeleteable = isDeleteable;
isDeleteable = isDeleteEnabled();
if (oldIsDeleteable != isDeleteable) {
fireEnablementChanged(DELETE);
}
|
private void | checkSelectable()Checks to see if the "selectable" state (can select)
has changed and if so fire an enablement changed notification.
boolean oldIsSelectable = isSelectable;
isSelectable = isSelectAllEnabled();
if (oldIsSelectable != isSelectable) {
fireEnablementChanged(SELECT_ALL);
}
|
private void | checkSelection()Checks to see if the selection state (selection /
no selection) has changed and if so fire an
enablement changed notification.
boolean oldIsSelection = isSelection;
isSelection = text.getSelectionCount() > 0;
if (oldIsSelection != isSelection) {
fireEnablementChanged(COPY);
fireEnablementChanged(CUT);
}
|
protected org.eclipse.swt.widgets.Button | createButton(org.eclipse.swt.widgets.Composite parent)
Button result = new Button(parent, SWT.DOWN | SWT.FLAT);
result.setText("..."); //$NON-NLS-1$
return result;
|
protected org.eclipse.swt.widgets.Control | createContents(org.eclipse.swt.widgets.Composite cell)
text = new Text(cell, SWT.SINGLE);
text.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
handleDefaultSelection(e);
}
});
text.addKeyListener(new KeyAdapter() {
// hook key pressed - see PR 14201
@Override
public void keyPressed(KeyEvent e) {
keyReleaseOccured(e);
// as a result of processing the above call, clients may have
// disposed this cell editor
if ((getControl() == null) || getControl().isDisposed()) {
return;
}
checkSelection(); // see explanation below
checkDeleteable();
checkSelectable();
}
});
text.addTraverseListener(new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_ESCAPE
|| e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
}
}
});
// We really want a selection listener but it is not supported so we
// use a key listener and a mouse listener to know when selection changes
// may have occurred
text.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent e) {
checkSelection();
checkDeleteable();
checkSelectable();
}
});
text.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
EditableDialogCellEditor.this.focusLost();
}
});
text.setFont(cell.getFont());
text.setBackground(cell.getBackground());
text.setText("");//$NON-NLS-1$
text.addModifyListener(getModifyListener());
return text;
|
protected java.lang.Object | doGetValue()The TextCellEditor implementation of
this CellEditor framework method returns
the text string.
return text.getText();
|
protected void | doSetFocus()
if (text != null) {
text.selectAll();
text.setFocus();
checkSelection();
checkDeleteable();
checkSelectable();
}
|
protected void | editOccured(org.eclipse.swt.events.ModifyEvent e)Processes a modify event that occurred in this text cell editor.
This framework method performs validation and sets the error message
accordingly, and then reports a change via fireEditorValueChanged .
Subclasses should call this method at appropriate times. Subclasses
may extend or reimplement.
String value = text.getText();
if (value == null) {
value = "";//$NON-NLS-1$
}
Object typedValue = value;
boolean oldValidState = isValueValid();
boolean newValidState = isCorrect(typedValue);
if (!newValidState) {
// try to insert the current value into the error message.
setErrorMessage(MessageFormat.format(getErrorMessage(),
new Object[] { value }));
}
valueChanged(oldValidState, newValidState);
|
private org.eclipse.swt.events.ModifyListener | getModifyListener()Return the modify listener.
if (modifyListener == null) {
modifyListener = new ModifyListener() {
public void modifyText(ModifyEvent e) {
editOccured(e);
}
};
}
return modifyListener;
|
protected void | handleDefaultSelection(org.eclipse.swt.events.SelectionEvent event)Handles a default selection event from the text control by applying the editor
value and deactivating this cell editor.
// same with enter-key handling code in keyReleaseOccured(e);
fireApplyEditorValue();
deactivate();
|
public boolean | isCopyEnabled()The TextCellEditor implementation of this
CellEditor method returns true if
the current selection is not empty.
if (text == null || text.isDisposed()) {
return false;
}
return text.getSelectionCount() > 0;
|
public boolean | isCutEnabled()The TextCellEditor implementation of this
CellEditor method returns true if
the current selection is not empty.
if (text == null || text.isDisposed()) {
return false;
}
return text.getSelectionCount() > 0;
|
public boolean | isDeleteEnabled()The TextCellEditor implementation of this
CellEditor method returns true
if there is a selection or if the caret is not positioned
at the end of the text.
if (text == null || text.isDisposed()) {
return false;
}
return text.getSelectionCount() > 0
|| text.getCaretPosition() < text.getCharCount();
|
public boolean | isPasteEnabled()The TextCellEditor implementation of this
CellEditor method always returns true .
if (text == null || text.isDisposed()) {
return false;
}
return true;
|
public boolean | isSaveAllEnabled()Check if save all is enabled
if (text == null || text.isDisposed()) {
return false;
}
return true;
|
public boolean | isSelectAllEnabled()Returns true if this cell editor is
able to perform the select all action.
This default implementation always returns
false .
Subclasses may override
if (text == null || text.isDisposed()) {
return false;
}
return text.getCharCount() > 0;
|
protected void | keyReleaseOccured(org.eclipse.swt.events.KeyEvent keyEvent)Processes a key release event that occurred in this cell editor.
The TextCellEditor implementation of this framework method
ignores when the RETURN key is pressed since this is handled in
handleDefaultSelection .
An exception is made for Ctrl+Enter for multi-line texts, since
a default selection event is not sent in this case.
if (keyEvent.character == '\r") { // Return key
// Enter is handled in handleDefaultSelection.
// Do not apply the editor value in response to an Enter key event
// since this can be received from the IME when the intent is -not-
// to apply the value.
// See bug 39074 [CellEditors] [DBCS] canna input mode fires bogus event from Text Control
//
// An exception is made for Ctrl+Enter for multi-line texts, since
// a default selection event is not sent in this case.
if (text != null && !text.isDisposed()
&& (text.getStyle() & SWT.MULTI) != 0) {
if ((keyEvent.stateMask & SWT.CTRL) != 0) {
super.keyReleaseOccured(keyEvent);
}
}
return;
}
super.keyReleaseOccured(keyEvent);
|
public void | performCopy()The TextCellEditor implementation of this
CellEditor method copies the
current selection to the clipboard.
text.copy();
|
public void | performCut()The TextCellEditor implementation of this
CellEditor method cuts the
current selection to the clipboard.
text.cut();
checkSelection();
checkDeleteable();
checkSelectable();
|
public void | performDelete()The TextCellEditor implementation of this
CellEditor method deletes the
current selection or, if there is no selection,
the character next character from the current position.
if (text.getSelectionCount() > 0) {
// remove the contents of the current selection
text.insert(""); //$NON-NLS-1$
} else {
// remove the next character
int pos = text.getCaretPosition();
if (pos < text.getCharCount()) {
text.setSelection(pos, pos + 1);
text.insert(""); //$NON-NLS-1$
}
}
checkSelection();
checkDeleteable();
checkSelectable();
|
public void | performPaste()The TextCellEditor implementation of this
CellEditor method pastes the
the clipboard contents over the current selection.
text.paste();
checkSelection();
checkDeleteable();
checkSelectable();
|
public void | performSelectAll()The TextCellEditor implementation of this
CellEditor method selects all of the
current text.
text.selectAll();
checkSelection();
checkDeleteable();
|
protected void | updateContents(java.lang.Object value)
Assert.isTrue(text != null && (value == null || (value instanceof String)));
if (value != null) {
text.removeModifyListener(getModifyListener());
text.setText((String) value);
text.addModifyListener(getModifyListener());
}
|