use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.
the class CloseQueryConnAction method run.
/**
* Close the query connection
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0) {
setEnabled(false);
return;
}
ISelectionProvider provider = this.getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
for (int i = 0; objArr != null && i < objArr.length; i++) {
if (!isSupported(objArr[i])) {
setEnabled(false);
return;
}
}
for (int i = 0; i < objArr.length; i++) {
CubridDatabase database = (CubridDatabase) objArr[i];
boolean isContinue = CQBConnectionUtils.processConnectionLogout(database);
if (isContinue) {
TreeViewer viewer = (TreeViewer) provider;
viewer.refresh(database, true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
}
}
LayoutManager.getInstance().fireSelectionChanged(getSelection());
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
use of org.eclipse.jface.viewers.ISelectionProvider in project KaiZen-OpenAPI-Editor by RepreZen.
the class Mocks method mockTextViewer.
public static ITextViewer mockTextViewer(OpenApi3Document document, int offset) {
ITextViewer viewer = mock(ITextViewer.class);
ISelectionProvider selectionProvider = mockSelectionProvider();
ITextSelection selection = mockSelection();
when(viewer.getDocument()).thenReturn(document);
when(viewer.getSelectedRange()).thenReturn(new Point(0, 0));
when(viewer.getSelectionProvider()).thenReturn(selectionProvider);
when(selectionProvider.getSelection()).thenReturn(selection);
when(selection.getOffset()).thenReturn(offset);
return viewer;
}
use of org.eclipse.jface.viewers.ISelectionProvider in project KaiZen-OpenAPI-Editor by RepreZen.
the class Mocks method mockTextViewer.
public static ITextViewer mockTextViewer(SwaggerDocument document, int offset) {
ITextViewer viewer = mock(ITextViewer.class);
ISelectionProvider selectionProvider = mockSelectionProvider();
ITextSelection selection = mockSelection();
when(viewer.getDocument()).thenReturn(document);
when(viewer.getSelectedRange()).thenReturn(new Point(0, 0));
when(viewer.getSelectionProvider()).thenReturn(selectionProvider);
when(selectionProvider.getSelection()).thenReturn(selection);
when(selection.getOffset()).thenReturn(offset);
return viewer;
}
use of org.eclipse.jface.viewers.ISelectionProvider in project xtext-xtend by eclipse.
the class OpenEditorTest method assertActiveEditor.
protected void assertActiveEditor(String expectedEditorID, String expectedEditorTitle, final String expectedSelection) {
IEditorPart editorPart = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
assertEquals(expectedEditorTitle, editorPart.getTitle());
IEditorSite editorSite = editorPart.getEditorSite();
assertEquals(expectedEditorID, editorSite.getId());
final ISelectionProvider selectionProvider = editorSite.getSelectionProvider();
assertTrue(selectionProvider.getSelection() instanceof ITextSelection);
// The selection may be updated asynchronously, so we may have to wait until the selection changes
workbenchTestHelper.awaitUIUpdate(new Functions.Function0<Boolean>() {
@Override
public Boolean apply() {
return expectedSelection.equals(((ITextSelection) selectionProvider.getSelection()).getText());
}
}, SELECTION_TIMEOUT);
assertEquals(expectedSelection, ((ITextSelection) selectionProvider.getSelection()).getText());
}
use of org.eclipse.jface.viewers.ISelectionProvider 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);
}
Aggregations