use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method createActions.
/**
* Creates this editor's standard actions and connects them with the global
* workbench actions.
* <p>
* Subclasses may extend.</p>
*/
protected void createActions() {
ResourceAction action;
setAction(IWorkbenchCommandConstants.EDIT_CUT, null);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Cut.", this, ITextOperationTarget.CUT);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
setAction(ITextEditorActionConstants.CUT, action);
setAction(IWorkbenchCommandConstants.EDIT_COPY, null);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Copy.", this, ITextOperationTarget.COPY, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
setAction(ITextEditorActionConstants.COPY, action);
setAction(IWorkbenchCommandConstants.EDIT_PASTE, null);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Paste.", this, ITextOperationTarget.PASTE);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
setAction(ITextEditorActionConstants.PASTE, action);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Delete.", this, ITextOperationTarget.DELETE);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_ACTION);
action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
setAction(ITextEditorActionConstants.DELETE, action);
// $NON-NLS-1$
action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLine.", this, DeleteLineAction.WHOLE, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE);
setAction(ITextEditorActionConstants.DELETE_LINE, action);
// $NON-NLS-1$
action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CutLine.", this, DeleteLineAction.WHOLE, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE);
setAction(ITextEditorActionConstants.CUT_LINE, action);
// $NON-NLS-1$
action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLineToBeginning.", this, DeleteLineAction.TO_BEGINNING, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_BEGINNING_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_BEGINNING);
setAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, action);
// $NON-NLS-1$
action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CutLineToBeginning.", this, DeleteLineAction.TO_BEGINNING, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_BEGINNING_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_BEGINNING);
setAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, action);
// $NON-NLS-1$
action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLineToEnd.", this, DeleteLineAction.TO_END, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_END_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_END);
setAction(ITextEditorActionConstants.DELETE_LINE_TO_END, action);
// $NON-NLS-1$
action = new DeleteLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CutLineToEnd.", this, DeleteLineAction.TO_END, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_END_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_END);
setAction(ITextEditorActionConstants.CUT_LINE_TO_END, action);
// $NON-NLS-1$ //$NON-NLS-2$
action = new JoinLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.JoinLines.", this, " ");
action.setHelpContextId(IAbstractTextEditorHelpContextIds.JOIN_LINES_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.JOIN_LINES);
setAction(ITextEditorActionConstants.JOIN_LINES, action);
// $NON-NLS-1$
action = new MarkAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SetMark.", this, MarkAction.SET_MARK);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SET_MARK_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SET_MARK);
setAction(ITextEditorActionConstants.SET_MARK, action);
// $NON-NLS-1$
action = new MarkAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ClearMark.", this, MarkAction.CLEAR_MARK);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.CLEAR_MARK_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CLEAR_MARK);
setAction(ITextEditorActionConstants.CLEAR_MARK, action);
// $NON-NLS-1$
action = new MarkAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SwapMark.", this, MarkAction.SWAP_MARK);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SWAP_MARK_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SWAP_MARK);
setAction(ITextEditorActionConstants.SWAP_MARK, action);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SelectAll.", this, ITextOperationTarget.SELECT_ALL, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SELECT_ALL_ACTION);
action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL);
setAction(ITextEditorActionConstants.SELECT_ALL, action);
// $NON-NLS-1$
action = new ShiftAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShiftRight.", this, ITextOperationTarget.SHIFT_RIGHT);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_RIGHT_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_RIGHT);
setAction(ITextEditorActionConstants.SHIFT_RIGHT, action);
action = new // $NON-NLS-1$
ShiftAction(// $NON-NLS-1$
EditorMessages.getBundleForConstructedKeys(), // $NON-NLS-1$
"Editor.ShiftRight.", // $NON-NLS-1$
this, // $NON-NLS-1$
ITextOperationTarget.SHIFT_RIGHT) {
@Override
public void update() {
updateForTab();
}
};
setAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, action);
// $NON-NLS-1$
action = new ShiftAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShiftLeft.", this, ITextOperationTarget.SHIFT_LEFT);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_LEFT_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_LEFT);
setAction(ITextEditorActionConstants.SHIFT_LEFT, action);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Print.", this, ITextOperationTarget.PRINT, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION);
action.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PRINT);
setAction(ITextEditorActionConstants.PRINT, action);
// $NON-NLS-1$
action = new FindReplaceAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindReplace.", this);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_ACTION);
action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE);
setAction(ITextEditorActionConstants.FIND, action);
// $NON-NLS-1$
action = new FindNextAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindNext.", this, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_NEXT_ACTION);
action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_NEXT);
setAction(ITextEditorActionConstants.FIND_NEXT, action);
// $NON-NLS-1$
action = new FindNextAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindPrevious.", this, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_PREVIOUS_ACTION);
action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_PREVIOUS);
setAction(ITextEditorActionConstants.FIND_PREVIOUS, action);
// $NON-NLS-1$
action = new IncrementalFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindIncremental.", this, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION);
action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL);
setAction(ITextEditorActionConstants.FIND_INCREMENTAL, action);
// $NON-NLS-1$
action = new IncrementalFindAction(EditorMessages.getBundleForConstructedKeys(), "Editor.FindIncrementalReverse.", this, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_REVERSE_ACTION);
action.setActionDefinitionId(IWorkbenchActionDefinitionIds.FIND_INCREMENTAL_REVERSE);
setAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, action);
fSaveAction = ActionFactory.SAVE.create(getSite().getWorkbenchWindow());
setAction(ITextEditorActionConstants.SAVE, fSaveAction);
// $NON-NLS-1$
action = new RevertToSavedAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Revert.", this);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.REVERT_TO_SAVED_ACTION);
action.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REVERT);
setAction(ITextEditorActionConstants.REVERT_TO_SAVED, action);
// $NON-NLS-1$
action = new GotoLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.GotoLine.", this);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.GOTO_LINE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO);
setAction(ITextEditorActionConstants.GOTO_LINE, action);
// $NON-NLS-1$
action = new MoveLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.MoveLinesUp.", this, getSourceViewer(), true, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_UP);
setAction(ITextEditorActionConstants.MOVE_LINE_UP, action);
// $NON-NLS-1$
action = new MoveLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.MoveLinesDown.", this, getSourceViewer(), false, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN);
setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, action);
// $NON-NLS-1$
action = new MoveLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CopyLineUp.", this, getSourceViewer(), true, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_UP);
setAction(ITextEditorActionConstants.COPY_LINE_UP, action);
// $NON-NLS-1$
action = new MoveLinesAction(EditorMessages.getBundleForConstructedKeys(), "Editor.CopyLineDown.", this, getSourceViewer(), false, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_DOWN);
setAction(ITextEditorActionConstants.COPY_LINE_DOWN, action);
// $NON-NLS-1$
action = new CaseAction(EditorMessages.getBundleForConstructedKeys(), "Editor.UpperCase.", this, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.UPPER_CASE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.UPPER_CASE);
setAction(ITextEditorActionConstants.UPPER_CASE, action);
// $NON-NLS-1$
action = new CaseAction(EditorMessages.getBundleForConstructedKeys(), "Editor.LowerCase.", this, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.LOWER_CASE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.LOWER_CASE);
setAction(ITextEditorActionConstants.LOWER_CASE, action);
// $NON-NLS-1$
action = new InsertLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SmartEnter.", this, false);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER);
setAction(ITextEditorActionConstants.SMART_ENTER, action);
// $NON-NLS-1$
action = new InsertLineAction(EditorMessages.getBundleForConstructedKeys(), "Editor.SmartEnterInverse.", this, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER_INVERSE);
setAction(ITextEditorActionConstants.SMART_ENTER_INVERSE, action);
// $NON-NLS-1$
action = new ToggleInsertModeAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleInsertMode.");
action.setHelpContextId(IAbstractTextEditorHelpContextIds.TOGGLE_INSERT_MODE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
setAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE, action);
// $NON-NLS-1$
action = new HippieCompleteAction(EditorMessages.getBundleForConstructedKeys(), "Editor.HippieCompletion.", this);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.HIPPIE_COMPLETION_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.HIPPIE_COMPLETION);
setAction(ITextEditorActionConstants.HIPPIE_COMPLETION, action);
// $NON-NLS-1$
action = new ContentAssistAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ContentAssistProposal.", this);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.CONTENT_ASSIST_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
setAction(ITextEditorActionConstants.CONTENT_ASSIST, action);
markAsStateDependentAction(ITextEditorActionConstants.CONTENT_ASSIST, true);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ContentAssistContextInformation.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.CONTENT_ASSIST_CONTEXT_INFORMATION_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
setAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION, action);
markAsStateDependentAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION, true);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.QuickAssist.", this, ISourceViewer.QUICK_ASSIST);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.QUICK_ASSIST_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
setAction(ITextEditorActionConstants.QUICK_ASSIST, action);
markAsStateDependentAction(ITextEditorActionConstants.QUICK_ASSIST, true);
action = new GotoAnnotationAction(this, true);
setAction(ITextEditorActionConstants.NEXT, action);
action = new GotoAnnotationAction(this, false);
setAction(ITextEditorActionConstants.PREVIOUS, action);
// $NON-NLS-1$
action = new RecenterAction(EditorMessages.getBundleForConstructedKeys(), "Editor.Recenter.", this);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.RECENTER_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.RECENTER);
setAction(ITextEditorActionConstants.RECENTER, action);
// $NON-NLS-1$
action = new ShowWhitespaceCharactersAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShowWhitespaceCharacters.", this, getPreferenceStore());
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHOW_WHITESPACE_CHARACTERS_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS);
setAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS, action);
// $NON-NLS-1$
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShowInformation.", this, ISourceViewer.INFORMATION, true);
// $NON-NLS-1$
action = new InformationDispatchAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShowInformation.", (TextOperationAction) action);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHOW_INFORMATION_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_INFORMATION);
setAction(ITextEditorActionConstants.SHOW_INFORMATION, action);
// $NON-NLS-1$
final BlockSelectionModeToggleAction blockAction = new BlockSelectionModeToggleAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleBlockSelectionMode.", this);
action = blockAction;
action.setHelpContextId(IAbstractTextEditorHelpContextIds.BLOCK_SELECTION_MODE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.BLOCK_SELECTION_MODE);
setAction(ITextEditorActionConstants.BLOCK_SELECTION_MODE, action);
if (isWordWrapSupported()) {
// $NON-NLS-1$
final WordWrapToggleAction wrapAction = new WordWrapToggleAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ToggleWordWrap.", this, getInitialWordWrapStatus());
action = wrapAction;
action.setHelpContextId(IAbstractTextEditorHelpContextIds.WORD_WRAP_TOGGLE_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_WRAP);
setAction(ITextEditorActionConstants.WORD_WRAP, action);
blockAction.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (IAction.CHECKED == event.getProperty() && Boolean.TRUE.equals(event.getNewValue())) {
wrapAction.setChecked(false);
}
}
});
wrapAction.addPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (IAction.CHECKED == event.getProperty() && Boolean.TRUE.equals(event.getNewValue())) {
blockAction.setChecked(false);
}
}
});
}
// $NON-NLS-1$;
action = new TextOperationAction(EditorMessages.getBundleForConstructedKeys(), "Editor.OpenHyperlink.", this, HyperlinkManager.OPEN_HYPERLINK, true);
action.setHelpContextId(IAbstractTextEditorHelpContextIds.OPEN_HYPERLINK_ACTION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.OPEN_HYPERLINK);
setAction(ITextEditorActionConstants.OPEN_HYPERLINK, action);
PropertyDialogAction openProperties = new PropertyDialogAction(new IShellProvider() {
@Override
public Shell getShell() {
return getSite().getShell();
}
}, new ISelectionProvider() {
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
}
@Override
public ISelection getSelection() {
return new StructuredSelection(getEditorInput());
}
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
}
@Override
public void setSelection(ISelection selection) {
}
});
openProperties.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);
setAction(ITextEditorActionConstants.PROPERTIES, openProperties);
markAsContentDependentAction(ITextEditorActionConstants.UNDO, true);
markAsContentDependentAction(ITextEditorActionConstants.REDO, true);
markAsContentDependentAction(ITextEditorActionConstants.FIND, true);
markAsContentDependentAction(ITextEditorActionConstants.FIND_NEXT, true);
markAsContentDependentAction(ITextEditorActionConstants.FIND_PREVIOUS, true);
markAsContentDependentAction(ITextEditorActionConstants.FIND_INCREMENTAL, true);
markAsContentDependentAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, true);
markAsSelectionDependentAction(ITextEditorActionConstants.CUT, true);
markAsSelectionDependentAction(ITextEditorActionConstants.COPY, true);
markAsSelectionDependentAction(ITextEditorActionConstants.PASTE, true);
markAsSelectionDependentAction(ITextEditorActionConstants.DELETE, true);
markAsSelectionDependentAction(ITextEditorActionConstants.SHIFT_RIGHT, true);
markAsSelectionDependentAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, true);
markAsSelectionDependentAction(ITextEditorActionConstants.UPPER_CASE, true);
markAsSelectionDependentAction(ITextEditorActionConstants.LOWER_CASE, true);
markAsPropertyDependentAction(ITextEditorActionConstants.UNDO, true);
markAsPropertyDependentAction(ITextEditorActionConstants.REDO, true);
markAsPropertyDependentAction(ITextEditorActionConstants.REVERT_TO_SAVED, true);
markAsPropertyDependentAction(ITextEditorActionConstants.SAVE, true);
markAsStateDependentAction(ITextEditorActionConstants.UNDO, true);
markAsStateDependentAction(ITextEditorActionConstants.REDO, true);
markAsStateDependentAction(ITextEditorActionConstants.CUT, true);
markAsStateDependentAction(ITextEditorActionConstants.PASTE, true);
markAsStateDependentAction(ITextEditorActionConstants.DELETE, true);
markAsStateDependentAction(ITextEditorActionConstants.SHIFT_RIGHT, true);
markAsStateDependentAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, true);
markAsStateDependentAction(ITextEditorActionConstants.SHIFT_LEFT, true);
markAsStateDependentAction(ITextEditorActionConstants.FIND, true);
markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE, true);
markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, true);
markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE_TO_END, true);
markAsStateDependentAction(ITextEditorActionConstants.MOVE_LINE_UP, true);
markAsStateDependentAction(ITextEditorActionConstants.MOVE_LINE_DOWN, true);
markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE, true);
markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, true);
markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE_TO_END, true);
setActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT_TAB, '\t', -1, SWT.NONE);
setActionActivationCode(ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT);
}
use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.
the class AbstractTemplatesPage method createControl.
@Override
public void createControl(Composite ancestor) {
setupActions();
fControl = new SashForm(ancestor, SWT.VERTICAL);
createTemplateTree(fControl);
createPatternForm(fControl);
hookContextMenu();
initializeDND();
updateButtons();
int sashSize = fPreferenceStore.getInt(SASH_SIZE_PREF_ID);
fControl.setWeights(new int[] { sashSize, 100 - sashSize });
fTemplateChangeListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
getShell().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
refresh();
}
});
}
};
getTemplatePreferenceStore().addPropertyChangeListener(fTemplateChangeListener);
updateContextTypes(getEditorContextTypeIds());
}
use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.
the class AnnotationColumn method initialize.
/**
* Initializes the given line number ruler column from the preference store.
*/
private void initialize() {
if (fDelegate == null)
fDelegate = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, new DefaultMarkerAnnotationAccess());
IPreferenceStore store = getPreferenceStore();
if (store != null && fDelegate instanceof AnnotationRulerColumn) {
final AnnotationRulerColumn column = (AnnotationRulerColumn) fDelegate;
// initial set up
for (Iterator<AnnotationPreference> iter2 = fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext(); ) {
AnnotationPreference preference = iter2.next();
String key = preference.getVerticalRulerPreferenceKey();
boolean showAnnotation = true;
if (key != null && store.contains(key))
showAnnotation = store.getBoolean(key);
if (showAnnotation)
column.addAnnotationType(preference.getAnnotationType());
}
column.addAnnotationType(Annotation.TYPE_UNKNOWN);
// link to preference store
fPropertyListener = new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
AnnotationPreference annotationPreference = getVerticalRulerAnnotationPreference(property);
if (annotationPreference != null && property.equals(annotationPreference.getVerticalRulerPreferenceKey())) {
Object type = annotationPreference.getAnnotationType();
if (getPreferenceStore().getBoolean(property))
column.addAnnotationType(type);
else
column.removeAnnotationType(type);
column.redraw();
}
}
};
store.addPropertyChangeListener(fPropertyListener);
}
}
use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.
the class ChainedPreferenceStoreTest method testChainedStore3.
/**
* Case where the initial implementation used to throw an IAE
*/
@Test
public void testChainedStore3() {
IPreferenceStore store1 = new PreferenceStore();
IPreferenceStore store2 = new PreferenceStore();
IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 });
store2.setDefault(PROPERTY, DEFAULT_VALUE);
chainedStore.addPropertyChangeListener(fPropertyChangeListener);
// simulated removal with oldValue == null
store1.firePropertyChangeEvent(PROPERTY, null, null);
chainedStore.removePropertyChangeListener(fPropertyChangeListener);
assertEquals(1, fEvents.size());
PropertyChangeEvent event = fEvents.get(0);
assertEquals(chainedStore, event.getSource());
assertEquals(PROPERTY, event.getProperty());
assertEquals(null, event.getOldValue());
assertEquals(DEFAULT_VALUE, event.getNewValue());
}
use of org.eclipse.jface.util.PropertyChangeEvent in project eclipse.platform.text by eclipse.
the class ChainedPreferenceStoreTest method testChainedStore2.
/**
* Third case where the initial implementation used to have an assertion which would fail in this case
*/
@Test
public void testChainedStore2() {
IPreferenceStore store1 = new PreferenceStore();
IPreferenceStore store2 = new PreferenceStore();
IPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { store1, store2 });
store1.setValue(PROPERTY, VALUE);
chainedStore.addPropertyChangeListener(fPropertyChangeListener);
// simulated change with newValue == null
store1.firePropertyChangeEvent(PROPERTY, DEFAULT_VALUE, null);
chainedStore.removePropertyChangeListener(fPropertyChangeListener);
assertEquals(1, fEvents.size());
PropertyChangeEvent event = fEvents.get(0);
assertEquals(store1, event.getSource());
assertEquals(PROPERTY, event.getProperty());
assertEquals(DEFAULT_VALUE, event.getOldValue());
assertEquals(null, event.getNewValue());
}
Aggregations