當前位置: 首頁>>代碼示例>>Java>>正文


Java AbstractHandler類代碼示例

本文整理匯總了Java中org.eclipse.core.commands.AbstractHandler的典型用法代碼示例。如果您正苦於以下問題:Java AbstractHandler類的具體用法?Java AbstractHandler怎麽用?Java AbstractHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AbstractHandler類屬於org.eclipse.core.commands包,在下文中一共展示了AbstractHandler類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setFindBarContextActive

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
private void setFindBarContextActive(boolean activate)
{
	fActivated = activate;
	IWorkbenchPartSite site = textEditor.getSite();
	IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
	IBindingService service = (IBindingService) site.getService(IBindingService.class);

	if (activate)
	{

		// These will be the only active commands (note that they may have multiple keybindings
		// defined in plugin.xml)
		for (Map.Entry<String, AbstractHandler> entry : fCommandToHandler.entrySet())
		{
			AbstractHandler handler = entry.getValue();
			if (handler != null)
			{
				fHandlerActivations.add(handlerService.activateHandler(entry.getKey(), handler));
			}
		}

		// Yes, no longer execute anything from the binding service (we'll do our own handling so that the commands
		// we need still get executed).
		service.setKeyFilterEnabled(false);

		service.addBindingManagerListener(fClearCommandToBindingOnChangesListener);
	}
	else
	{
		fCommandToBinding = null;
		service.setKeyFilterEnabled(true);

		service.removeBindingManagerListener(fClearCommandToBindingOnChangesListener);
		handlerService.deactivateHandlers(fHandlerActivations);
		fHandlerActivations.clear();
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:38,代碼來源:FindBarActions.java

示例2: createHandler

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
/**
 * Returns a handler that can create and open the quick menu.
 * 
 * @return a handler that can create and open the quick menu
 */
public IHandler createHandler() {
	return new AbstractHandler() {
		public Object execute(ExecutionEvent event) throws ExecutionException {
			createMenu();
			return null;
		}
	};
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:14,代碼來源:JDTQuickMenuCreator.java

示例3: getHandler_OpenDefinition

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
protected AbstractHandler getHandler_OpenDefinition() {
	return getEditorHandler((editor) -> {
		OpenNewEditorMode newEditorMode = OpenNewEditorMode.TRY_REUSING_EXISTING;
		SourceRange selection = EditorUtils.getSelectionSR(editor);
		return createOpenDefinitionOperation(editor, selection, newEditorMode);
	});
}
 
開發者ID:GoClipse,項目名稱:goclipse,代碼行數:8,代碼來源:LangEditorActionContributor.java

示例4: execute

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
/**
 * execute {@link OpenUrlHandler} or {@link OpenDefaultEditorHandler}
 * dependent on the type of the selected node's attachment.
 * 
 * @param event ExecutionEvent An event
 * @return result of the execution
 * @throws ExecutionException if an exception occurred during execution OpenUrlHandler or OpenDefaultEditorHandler.
 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    
    GraphicalEditPart editPart = getSelectedElement(event);
    String attachment = null;
    
    if (editPart == null) {
    	DcaseLinkEditPart linkEditPart = DcaseEditorUtil.getFirstCurrentSelectedLink();
    	if (linkEditPart != null) {
    		BasicLink basicLink = (BasicLink)DcaseEditorUtil.getElement(linkEditPart);
    		attachment = basicLink.getAttachment();
    	}
    } else {
        BasicNode basicNode = getBasicNode(editPart);
        attachment = basicNode.getAttachment();
    }
    
    if (attachment != null && attachment.length() > 0) {
        
        if (isUrl(attachment)) {
            // in the case of uri type, execute OpenUrlHandler.
            AbstractHandler openUrlHandler = new OpenUrlHandler();
            return openUrlHandler.execute(event);
        } else if (ModuleUtil.isWorkspaceReference(attachment)) {
            // in the case of Workspace type, execute OpenDefaultEditorHandler.
            AbstractHandler openDefaultEditorHandler = new OpenDefaultEditorHandler();
            return openDefaultEditorHandler.execute(event);
        } else {
            AbstractHandler openModuleHandler = new OpenModuleHandler();
            return openModuleHandler.execute(event);
        }
    } else {
        MessageWriter.showErrorMessageBox(NLS.bind(Messages.OpenUrlHandler_5, "Attachment")); //$NON-NLS-1$
        return null;
    }
}
 
開發者ID:d-case,項目名稱:d-case_editor,代碼行數:45,代碼來源:OpenAttachmentHandler.java

示例5: internalExecute

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
@Override
protected Object internalExecute(ExecutionEvent event) throws Exception {
	Shell shell = HandlerUtil.getActiveShell(event);
	
	AbstractHandler original;
	String id = event.getCommand().getId();
	if ("org.eclipse.egit.ui.PushHeadToGerrit".equals(id)) { //$NON-NLS-1$
		original = new PushHeadToGerritCommand();
	} else if ("org.eclipse.egit.ui.FetchGerritChange".equals(id)) { //$NON-NLS-1$
		original = new FetchChangeFromGerritCommand();
	} else {
		return null;
	}

	IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(GerritToolsPlugin.PLUGIN_ID);
	if (!prefs.getBoolean(PREF_SHOW_USE_GERRIT_TOOLS_INFO, true)) {
		return original.execute(event);
	}
	
	MessageDialogWithToggle dialog = new MessageDialogWithToggle(
			shell, "Use Gerrit Tools", null, null, MessageDialog.INFORMATION, 
			new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 
			0, "Do not show again", false) {

		protected Control createMessageArea(Composite theParent) {
			super.createMessageArea(theParent);
			Link link = new Link(theParent, SWT.WRAP);

			GridDataFactory
					.fillDefaults()
					.align(SWT.FILL, SWT.BEGINNING)
					.grab(true, false)
					.hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
							SWT.DEFAULT).applyTo(link);
	        
			link.setText("Gerrit Tools provides an improved experience when pushing and fetching from Gerrit. <a>Learn more about using Gerrit Tools.</a>\n\nContinue to the standard EGit action?");
			
			link.addSelectionListener(new SelectionAdapter() {
				@Override
				public void widgetSelected(SelectionEvent e) {
					try {
						PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(
								new URL("https://github.com/Genuitec/gerrit-tools/wiki")); //$NON-NLS-1$
					} catch (Exception e1) {
						throw new RuntimeException(e1);
					}
				}});
			return theParent;
		}
		
	};
	
	try {
		if (dialog.open() == IDialogConstants.YES_ID) {
			return original.execute(event);
		}
	} finally {
		prefs.putBoolean(PREF_SHOW_USE_GERRIT_TOOLS_INFO, !dialog.getToggleState());
	}
	return null;
}
 
開發者ID:Genuitec,項目名稱:gerrit-tools,代碼行數:62,代碼來源:UseGerritToolsWarningCommand.java

示例6: activateHandler

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
protected void activateHandler(String string, AbstractHandler handler) {
	IHandlerActivation handlerActivation = getHandlerService_2().activateHandler(string, handler);
	handlerActivations.add(handlerActivation);
}
 
開發者ID:GoClipse,項目名稱:goclipse,代碼行數:5,代碼來源:LangEditorActionContributor.java

示例7: getHandler_GoToMatchingBracket

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
protected AbstractHandler getHandler_GoToMatchingBracket() {
	return new GoToMatchingBracketHandler(getPage());
}
 
開發者ID:GoClipse,項目名稱:goclipse,代碼行數:4,代碼來源:LangEditorActionContributor.java

示例8: getHandler_ToggleComment

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
protected AbstractHandler getHandler_ToggleComment() {
	return new ToggleCommentHandler(getPage());
}
 
開發者ID:GoClipse,項目名稱:goclipse,代碼行數:4,代碼來源:LangEditorActionContributor.java

示例9: getHandler_QuickOutline

import org.eclipse.core.commands.AbstractHandler; //導入依賴的package包/類
protected AbstractHandler getHandler_QuickOutline() {
	return new OpenQuickOutlineHandler(getPage());
}
 
開發者ID:GoClipse,項目名稱:goclipse,代碼行數:4,代碼來源:LangEditorActionContributor.java


注:本文中的org.eclipse.core.commands.AbstractHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。