From 63c1614833ad2e2e5c27b1e6bb6c0538868478f5 Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Thu, 14 Feb 2013 16:33:33 -0800 Subject: Bug 145635 - Support for debug view pin & clone - Cleanup: removed redundant pin actions. --- org.eclipse.debug.ui/plugin.xml | 3 +- .../internal/ui/actions/ActionMessages.properties | 4 +- .../internal/ui/contexts/DebugContextManager.java | 12 -- .../internal/ui/contexts/PinToContextAction.java | 54 -------- .../ui/contexts/AbstractPinnableDebugView.java | 24 +--- .../debug/ui/contexts/AbstractPinnableView.java | 2 +- .../debug/ui/contexts/IDebugContextManager.java | 11 -- .../debug/ui/contexts/NewPinnedViewAction.java | 10 +- .../ui/contexts/NewPinnedViewDropDownAction.java | 150 --------------------- .../debug/ui/contexts/NewViewInstanceAction.java | 2 +- .../contexts/PinViewToContextDropDownAction.java | 131 ------------------ .../PinViewToContextDynamicContribution.java | 136 ------------------- .../debug/ui/contexts/PinViewToContextHandler.java | 75 ----------- 13 files changed, 9 insertions(+), 605 deletions(-) delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/contexts/PinToContextAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/NewPinnedViewDropDownAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/PinViewToContextDropDownAction.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/PinViewToContextDynamicContribution.java delete mode 100644 org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/PinViewToContextHandler.java diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml index ca2ae6ba1..f505ffe84 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml @@ -875,11 +875,12 @@ - * The following example demonstrates how this contribution can be used to - * add a drop-down pin action to a view. - *
- * <extension 
- *    point="org.eclipse.ui.menus">
- *     <menuContribution locationURI="toolbar:org.eclipse.debug.ui.VariableView?after=additions">
- *          <command
- *              commandId="org.eclipse.debug.ui.pinViewToContextDropDown"
- *              icon="icons/full/elcl16/pin.gif"
- *              label="%PinViewToContextCommand.label"
- *              style="pulldown"
- *              tooltip="%PinViewToContextCommand.label">
- *          </command>
- *     </menuContribution>
- *     <menuContribution
- *           locationURI="menu:org.eclipse.debug.ui.pinViewToContextDropDown">
- *           <dynamic
- *                 class="org.eclipse.debug.ui.contexts.PinViewToContextContribution"
- *                 id="org.eclipse.debug.ui.pinToContextFactories">
- *           </dynamic>
- *     </menuContribution>
- * </extension>  
- * 
- * <extension point="org.eclipse.ui.commands">
- *   <command 
- *      id="org.eclipse.debug.ui.pinViewToContextDropDown"
- *      defaultHandler="org.eclipse.debug.ui.contexts.PinViewToContextDropDownHandler" 
- *      name="%PinViewToContextCommand.label"
- *      description="%PinViewToContextCommand.description"/>
- * </extension>
- * 
- * - * @since 3.9 - * @noextend This class is not intended to be sub-classed by clients. - */ -public class PinViewToContextDynamicContribution extends CompoundContributionItem implements IWorkbenchContribution { - - private IServiceLocator fServiceLocator; - - private static IContributionItem[] NO_PIN_PROVIDERS_CONTRIBUTION_ITEMS = new IContributionItem[] { - new ContributionItem() { - public void fill(Menu menu, int index) { - MenuItem item = new MenuItem(menu, SWT.NONE); - item.setEnabled(false); - item.setText("No pinned context providers available"); //$NON-NLS-1$ - } - - public boolean isEnabled() { - return false; - } - } - }; - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems() - */ - protected IContributionItem[] getContributionItems() { - IWorkbenchPart part = null; - IPartService partService = (IPartService)fServiceLocator.getService(IPartService.class); - if (partService != null) { - part = partService.getActivePart(); - } - - // If no part or selection, disable all. - if (!(part instanceof IPinnablePart)) { - return NO_PIN_PROVIDERS_CONTRIBUTION_ITEMS; - } - IPinnablePart pinnable = (IPinnablePart)part; - - // Get breakpoint toggle target IDs. - IDebugContextManager manager = DebugUITools.getDebugContextManager(); - IPinnedContextFactory[] factories = manager.getEnabledContextViewerFactories(pinnable, StructuredSelection.EMPTY); - - IContributionItem[] items = new IContributionItem[factories.length + 1]; - items[0] = makeActionContributionItem(new ClearPinnedContextAction(pinnable), 1); - for (int i = 0; i < factories.length; i++) { - Action action = new PinToContextAction(pinnable, factories[i]); - items[i + 1] = makeActionContributionItem(action, i + 2); - } - - return items; - } - - private IContributionItem makeActionContributionItem(Action action, int accelerator) { - if (accelerator < 10) { - StringBuffer label= new StringBuffer(); - //add the numerical accelerator - label.append('&'); - label.append(accelerator); - label.append(' '); - label.append(action.getText()); - action.setText(label.toString()); - } - return new ActionContributionItem(action); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator) - */ - public void initialize(IServiceLocator serviceLocator) { - fServiceLocator = serviceLocator; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/PinViewToContextHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/PinViewToContextHandler.java deleted file mode 100644 index ebd95c8f4..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/contexts/PinViewToContextHandler.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Wind River Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wind River Systems - initial API and implementation - *******************************************************************************/ - -package org.eclipse.debug.ui.contexts; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.handlers.HandlerUtil; - -/** - * Command handler that pins a view to a debug context. - *

- * The handler selects the pin-able context factory based on the active - * debug context provider and on the available factories. If a view is - * already pinned to a context, this handler will un-pin the view. - *

- *

- * This handler can be used in conjunction with a dynamic contribution for - * a drop-down pin menu. See {@link PinViewToContextDynamicContribution} for - * details. - *

- * @noextend This class is not intended to be subclassed by clients. - * @since 3.9 - */ -public class PinViewToContextHandler extends AbstractHandler { - - public Object execute(ExecutionEvent event) throws ExecutionException { - IWorkbenchPart part = HandlerUtil.getActivePartChecked(event); - if (part instanceof IPinnablePart) { - IPinnablePart pinnable = (IPinnablePart)part; - if (!pinnable.isPinned()) { - pinnable.pin(getFactory(event)); - } else { - pinnable.clearPin(); - } - } - return null; - } - - private IPinnableDebugContextProvider getContextProvider(ExecutionEvent event) { - IDebugContextProvider provider = getContextService(event).getActiveProvider(); - if (provider instanceof IPinnableDebugContextProvider) { - return (IPinnableDebugContextProvider)provider; - } - return null; - } - - private IDebugContextService getContextService(ExecutionEvent event) { - IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); - if (window != null) { - return DebugUITools.getDebugContextManager().getContextService(window); - } - return null; - } - - private IPinnedContextFactory getFactory(ExecutionEvent event) { - IPinnableDebugContextProvider provider = getContextProvider(event); - if (provider != null) { - return DebugUITools.getDebugContextManager().getPinnedContextViewerFactory( provider.getFactoryId() ); - } - return null; - } -} \ No newline at end of file -- cgit v1.2.3