use of org.eclipse.ui.handlers.IHandlerService in project webtools.sourceediting by eclipse.
the class StructuredTextEditor method createActions.
protected void createActions() {
super.createActions();
ResourceBundle resourceBundle = SSEUIMessages.getResourceBundle();
IWorkbenchHelpSystem helpSystem = SSEUIPlugin.getDefault().getWorkbench().getHelpSystem();
// TextView Action - moving the selected text to
// the clipboard
// override the cut/paste/delete action to make
// them run on read-only
// files
// $NON-NLS-1$
Action action = new TextOperationAction(resourceBundle, "Editor_Cut_", this, ITextOperationTarget.CUT);
action.setActionDefinitionId(IWorkbenchActionDefinitionIds.CUT);
setAction(ITextEditorActionConstants.CUT, action);
helpSystem.setHelp(action, IAbstractTextEditorHelpContextIds.CUT_ACTION);
// TextView Action - inserting the clipboard
// content at the current
// position
// override the cut/paste/delete action to make
// them run on read-only
// files
// $NON-NLS-1$
action = new TextOperationAction(resourceBundle, "Editor_Paste_", this, ITextOperationTarget.PASTE);
action.setActionDefinitionId(IWorkbenchActionDefinitionIds.PASTE);
setAction(ITextEditorActionConstants.PASTE, action);
helpSystem.setHelp(action, IAbstractTextEditorHelpContextIds.PASTE_ACTION);
// TextView Action - deleting the selected text or
// if selection is
// empty the character at the right of the current
// position
// override the cut/paste/delete action to make
// them run on read-only
// files
// $NON-NLS-1$
action = new TextOperationAction(resourceBundle, "Editor_Delete_", this, ITextOperationTarget.DELETE);
action.setActionDefinitionId(IWorkbenchActionDefinitionIds.DELETE);
setAction(ITextEditorActionConstants.DELETE, action);
helpSystem.setHelp(action, IAbstractTextEditorHelpContextIds.DELETE_ACTION);
// SourceView Action - requesting content assist to
// show completetion
// proposals for the current insert position
action = new ContentAssistAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS + UNDERSCORE, this);
helpSystem.setHelp(action, IHelpContextIds.CONTMNU_CONTENTASSIST_HELPID);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
setAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, action);
markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, true);
// SourceView Action - requesting content assist to
// show the content
// information for the current insert position
action = new TextOperationAction(SSEUIMessages.getResourceBundle(), StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION + UNDERSCORE, this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
setAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION, action);
markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION, true);
// StructuredTextViewer Action - requesting format
// of the whole
// document
action = new TextOperationAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT + UNDERSCORE, this, StructuredTextViewer.FORMAT_DOCUMENT);
helpSystem.setHelp(action, IHelpContextIds.CONTMNU_FORMAT_DOC_HELPID);
action.setActionDefinitionId(ActionDefinitionIds.FORMAT_DOCUMENT);
setAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, action);
markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, true);
markAsSelectionDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, true);
// StructuredTextViewer Action - requesting format
// of the active
// elements
action = new TextOperationAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS + UNDERSCORE, this, StructuredTextViewer.FORMAT_ACTIVE_ELEMENTS);
helpSystem.setHelp(action, IHelpContextIds.CONTMNU_FORMAT_ELEMENTS_HELPID);
action.setActionDefinitionId(ActionDefinitionIds.FORMAT_ACTIVE_ELEMENTS);
setAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, action);
markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, true);
markAsSelectionDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, true);
// StructuredTextEditor Action - add breakpoints (falling back to the
// current double-click if they can't be added)
action = new ToggleBreakpointAction(this, getVerticalRuler());
setAction(ActionDefinitionIds.TOGGLE_BREAKPOINTS, action);
// StructuredTextEditor Action - manage breakpoints
action = new ManageBreakpointAction(this, getVerticalRuler());
setAction(ActionDefinitionIds.MANAGE_BREAKPOINTS, action);
// StructuredTextEditor Action - edit breakpoints
action = new EditBreakpointAction(this, getVerticalRuler());
setAction(ActionDefinitionIds.EDIT_BREAKPOINTS, action);
// StructuredTextViewer Action - open file on selection
action = new OpenHyperlinkAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE + UNDERSCORE, this, getSourceViewer());
action.setActionDefinitionId(ActionDefinitionIds.OPEN_FILE);
setAction(StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE, action);
computeAndSetDoubleClickAction();
// add handlers to handler service
IHandlerService handlerService = getSite().getService(IHandlerService.class);
if (handlerService != null) {
IHandler gotoHandler = new GotoMatchingBracketHandler();
handlerService.activateHandler(ActionDefinitionIds.GOTO_MATCHING_BRACKET, gotoHandler);
fOutlineHandler = new QuickOutlineHandler();
handlerService.activateHandler(ActionDefinitionIds.SHOW_OUTLINE, fOutlineHandler);
IHandler toggleCommentHandler = new ToggleLineCommentHandler();
handlerService.activateHandler(ActionDefinitionIds.TOGGLE_COMMENT, toggleCommentHandler);
IHandler addCommentBlockHandler = new AddBlockCommentHandler();
handlerService.activateHandler(ActionDefinitionIds.ADD_BLOCK_COMMENT, addCommentBlockHandler);
IHandler removeCommentBlockHandler = new RemoveBlockCommentHandler();
handlerService.activateHandler(ActionDefinitionIds.REMOVE_BLOCK_COMMENT, removeCommentBlockHandler);
}
fShowPropertiesAction = new ShowPropertiesAction(getEditorPart(), getSelectionProvider());
fFoldingGroup = new FoldingActionGroup(this, getSourceViewer());
}
use of org.eclipse.ui.handlers.IHandlerService in project eclipse-integration-commons by spring-projects.
the class QuickSearchDialog method close.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.window.Window#close()
*/
public boolean close() {
this.progressJob.cancel();
this.progressJob = null;
// this.refreshProgressMessageJob.cancel();
if (showViewHandler != null) {
IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
service.deactivateHandler(showViewHandler);
showViewHandler.getHandler().dispose();
showViewHandler = null;
}
if (menuManager != null)
menuManager.dispose();
if (contextMenuManager != null)
contextMenuManager.dispose();
storeDialog(getDialogSettings());
if (searcher != null) {
searcher.cancel();
}
return super.close();
}
use of org.eclipse.ui.handlers.IHandlerService in project eclipse-integration-commons by spring-projects.
the class QuickSearchDialog method createViewMenu.
private void createViewMenu(Composite parent) {
toolBar = new ToolBar(parent, SWT.FLAT);
toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
GridData data = new GridData();
data.horizontalAlignment = GridData.END;
toolBar.setLayoutData(data);
toolBar.addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent e) {
showViewMenu();
}
});
toolItem.setImage(WorkbenchImages.getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU));
toolItem.setToolTipText(WorkbenchMessages.FilteredItemsSelectionDialog_menu);
toolItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
showViewMenu();
}
});
menuManager = new MenuManager();
fillViewMenu(menuManager);
IHandlerService service = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
IHandler handler = new AbstractHandler() {
public Object execute(ExecutionEvent event) {
showViewMenu();
return null;
}
};
showViewHandler = service.activateHandler(IWorkbenchCommandConstants.WINDOW_SHOW_VIEW_MENU, handler, new ActiveShellExpression(getShell()));
}
use of org.eclipse.ui.handlers.IHandlerService in project eclipse-integration-commons by spring-projects.
the class MultiPageDashboardEditor method getConfiguredDiscoveryWizardCommand.
/**
* Copied from TasksUiInternal to avoid initialization of
* org.eclipse.mylyn.tasks.ui.
*/
private static Command getConfiguredDiscoveryWizardCommand() {
ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
final Command discoveryWizardCommand = service.getCommand(// $NON-NLS-1$
"org.eclipse.mylyn.discovery.ui.discoveryWizardCommand");
if (discoveryWizardCommand != null) {
IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
EvaluationContext evaluationContext = createDiscoveryWizardEvaluationContext(handlerService);
// update enabled state in case something has changed (ProxyHandler
// caches state)
discoveryWizardCommand.setEnabled(evaluationContext);
}
return discoveryWizardCommand;
}
use of org.eclipse.ui.handlers.IHandlerService in project org.csstudio.display.builder by kasemir.
the class SendToElogAction method makeLogEntry.
/**
* Make a logbook entry.
*/
public void makeLogEntry() {
try {
final Attachment image_attachment = createImageAttachment();
final String text = Messages.LogentryDefaultTitle + "\n" + Messages.LogentryDefaultBody;
final LogEntryBuilder entry = LogEntryBuilder.withText(text).attach(AttachmentBuilder.attachment(image_attachment));
// get the command from plugin.xml
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
List<LogEntryBuilder> logList = new ArrayList<LogEntryBuilder>();
logList.add(entry);
Event event = new Event();
event.data = logList;
// execute the command
IHandlerService handlerService = window.getService(IHandlerService.class);
handlerService.executeCommand(OPEN_LOGENTRY_BUILDER_DIALOG_ID, event);
} catch (Exception e) {
MessageDialog.openError(null, "Logbook Error", "Failed to make logbook entry: \n" + e.getMessage());
}
}
Aggregations