Java Code Examples for org.eclipse.ui.handlers.HandlerUtil#toggleCommandState()

The following examples show how to use org.eclipse.ui.handlers.HandlerUtil#toggleCommandState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgnoreNamedImportSpecifierHandler.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Command cmd = event.getCommand();
	boolean currentState = HandlerUtil.toggleCommandState(cmd);
	N4JSReferenceQueryExecutor.ignoreNamedImportSpecifier = !currentState;
	return null;
}
 
Example 2
Source File: ConsiderOverridenMembersHandler.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Command cmd = event.getCommand();
	boolean currentState = HandlerUtil.toggleCommandState(cmd);
	N4JSReferenceQueryExecutor.considerOverridenMethods = !currentState;
	return null;
}
 
Example 3
Source File: PCalTranslateAutomaticallyHandler.java    From tlaplus with MIT License 5 votes vote down vote up
@Execute
public void execute(final ExecutionEvent event, final IWorkbench workbench) throws ExecutionException {
	// Toggle the IHandler's state at the UI level (check mark on/off) and
	// unsubscribe/subscribe the EventHandler.
	final IEventBroker eventBroker = workbench.getService(IEventBroker.class);
	if (HandlerUtil.toggleCommandState(event.getCommand())) {
		eventBroker.unsubscribe(this);
	} else {
		eventBroker.unsubscribe(this);
		Assert.isTrue(eventBroker.subscribe(TLAEditor.PRE_SAVE_EVENT, this));
	}
}
 
Example 4
Source File: ToggleTextNodesHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	Command command = event.getCommand();
	boolean oldValue = HandlerUtil.toggleCommandState(command);
	HTMLPreferenceUtil.setShowTextNodesInOutline(!oldValue);

	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof AbstractThemeableEditor)
	{
		CommonOutlinePage page = ((AbstractThemeableEditor) editor).getOutlinePage();
		page.refresh();
	}
	return null;
}
 
Example 5
Source File: ToggleOutlineHandler.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	boolean toShow = !HandlerUtil.toggleCommandState(event.getCommand());
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	if (page != null)
	{
		if (toShow)
		{
			try
			{
				page.showView(OUTLINE_VIEW_ID);
			}
			catch (PartInitException e)
			{
				IdeLog.logError(CommonEditorPlugin.getDefault(), Messages.ToggleOutlineHandler_ERR_OpeningOutline,
						e);
			}
		}
		else
		{
			IViewPart viewPart = page.findView(OUTLINE_VIEW_ID);
			if (viewPart != null)
			{
				page.hideView(viewPart);
			}
		}
	}
	return null;
}
 
Example 6
Source File: KonsZumVerrechnenLinkCommand.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	boolean alreadyToggled = HandlerUtil.toggleCommandState(event.getCommand());
	
	IWorkbenchPage activePage =
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	KonsZumVerrechnenView kzvView =
		(KonsZumVerrechnenView) activePage.findView(KonsZumVerrechnenView.ID);
	
	final CommonViewer cv = kzvView.getLeftSide();
	final TreeViewer tvSel = kzvView.getRightSide();
	
	// goes from toggled to not toggled
	if (alreadyToggled) {
		cv.getViewerWidget().removeSelectionChangedListener(leftSideSelChangeListener);
		tvSel.removeSelectionChangedListener(rightSideSelChangeListener);
	} else {
		// toggled
		leftSideSelChangeListener = new TreeSelectionChangedListener(tvSel);
		rightSideSelChangeListener =
			new TreeSelectionChangedListener((TreeViewer) cv.getViewerWidget());
		
		cv.getViewerWidget().addSelectionChangedListener(leftSideSelChangeListener);
		tvSel.addSelectionChangedListener(rightSideSelChangeListener);
	}
	
	return null;
}
 
Example 7
Source File: StockSCSToggleArticleOutlay.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent executionEvent) throws ExecutionException{
	
	Command command = executionEvent.getCommand();
	HandlerUtil.toggleCommandState(command);
	
	ICommandService commandService =
		(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
	commandService.refreshElements(executionEvent.getCommand().getId(), null);
	
	return null;
}
 
Example 8
Source File: ApplyCustomSortingHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	boolean useDefault = HandlerUtil.toggleCommandState(event.getCommand());
	
	ViewerSortOrder sortOrder =
		ViewerSortOrder.getSortOrderPerValue(ViewerSortOrder.DEFAULT.ordinal());
	if (!useDefault) {
		sortOrder = ViewerSortOrder.getSortOrderPerValue(ViewerSortOrder.MANUAL.ordinal());
	}
	
	MedicationView medicationView = (MedicationView) PlatformUI.getWorkbench()
		.getActiveWorkbenchWindow().getActivePage().findView(MedicationView.PART_ID);
	medicationView.setMedicationTableViewerComparator(sortOrder);
	return null;
}