diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index 6d8b0fc9165..ded3a2cf53e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -9,6 +9,7 @@ * QNX Software Systems - Initial API and implementation * Ericsson - Added tracepoint support (284286) * Marc Khouzam (Ericsson) - Added dynamic printf support (400628) + * Marc Dumais (Ericsson) - Bug 437692 *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui; @@ -125,6 +126,7 @@ public class CDebugImages { public static final String IMG_LCL_DETAIL_PANE_RIGHT = NAME_PREFIX + "det_pane_right.gif"; //$NON-NLS-1$ public static final String IMG_LCL_DETAIL_PANE_HIDE = NAME_PREFIX + "det_pane_hide.gif"; //$NON-NLS-1$ public static final String IMG_LCL_COLLAPSE_ALL = NAME_PREFIX + "collapseall.gif"; //$NON-NLS-1$ + public static final String IMG_LCL_OPEN_NEW_VIEW = NAME_PREFIX + "open_new.gif"; //$NON-NLS-1$ public static final String IMG_WIZBAN_ADD_SOURCE = NAME_PREFIX + "addsrcloc_wiz.gif"; //$NON-NLS-1$ public static final String IMG_WIZBAN_PATH_MAPPING = NAME_PREFIX + "mapping_wiz.gif"; //$NON-NLS-1$ @@ -212,6 +214,7 @@ public class CDebugImages { public static final ImageDescriptor DESC_LCL_DETAIL_PANE_HIDE_DISABLED = createManaged(T_DLCL, IMG_LCL_DETAIL_PANE_HIDE); public static final ImageDescriptor DESC_LCL_COLLAPSE_ALL = createManaged(T_ELCL, IMG_LCL_COLLAPSE_ALL); public static final ImageDescriptor DESC_LCL_COLLAPSE_ALL_DISABLED = createManaged(T_DLCL, IMG_LCL_COLLAPSE_ALL); + public static final ImageDescriptor DESC_LCL_OPEN_NEW_VIEW = createManaged(T_ELCL, IMG_LCL_OPEN_NEW_VIEW); /** * Returns the image managed under the given key in this registry. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties index 97b7568306b..db038c6df1d 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties @@ -10,6 +10,7 @@ # Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299 # Marc Khouzam (Ericsson) - Added dynamic printf support (400628) # Simon Marchi (Ericsson) - Modified error messages in CastToArrayActionDelegate (437182) +# Marc Dumais (Ericsson) - Bug 437692 ############################################################################### LoadSymbolsActionDelegate.Unable_to_load_symbols_of_shared_library_1=Unable to load symbols of shared library. @@ -140,3 +141,5 @@ CRulerToggleBreakpointActionDelegate_label=Toggle Brea&kpoint CRulerToggleBreakpointAction_accelerator=Double Click CAddDynamicPrintfInteractiveRulerAction_label=Add &Dynamic Printf... CAddDynamicPrintfInteractiveRulerAction_error_message=Unable to create dynamic printf +OpenNewViewActionText=Open New View +OpenNewViewActionTooltipText=Open New View diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewAction.java new file mode 100644 index 00000000000..51cc6fd8334 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewAction.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2010, 2014 Texas Instruments 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: + * Patrick Chuong (Texas Instruments) - Initial implementation of run() + * Marc Dumais (Ericsson) - Bug 437692 + *******************************************************************************/ + +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.cdt.debug.internal.ui.CDebugImages; +import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils; +import org.eclipse.cdt.debug.internal.ui.pinclone.ViewIDCounterManager; +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; + +/** + * Opens a new view of a configured type. + */ +public class OpenNewViewAction extends Action { + private IViewPart fView; + + public OpenNewViewAction() { + } + + @Override + public String getText() { + return ActionMessages.getString("OpenNewViewActionText"); //$NON-NLS-1$ + } + + @Override + public String getId() { + return "org.eclipse.cdt.debug.ui.toolbar.openNewView"; //$NON-NLS-1$ + } + + @Override + public String getToolTipText() { + return ActionMessages.getString("OpenNewViewActionTooltipText"); //$NON-NLS-1$ + } + + @Override + public ImageDescriptor getDisabledImageDescriptor() { + return CDebugImages.DESC_LCL_OPEN_NEW_VIEW; + } + + @Override + public ImageDescriptor getHoverImageDescriptor() { + return CDebugImages.DESC_LCL_OPEN_NEW_VIEW; + } + + @Override + public ImageDescriptor getImageDescriptor() { + return CDebugImages.DESC_LCL_OPEN_NEW_VIEW; + } + + @Override + public void run() { + if (fView == null) return; + + IViewSite site = fView.getViewSite(); + String viewId = site.getId(); + IWorkbenchWindow ww = fView.getViewSite().getWorkbenchWindow(); + if (ww != null) { + Integer secondaryId = null; + boolean assignSecondaryId = false; + + // if there is a view without a secondary id, than get the next available id. + IViewReference[] viewRefs = ww.getActivePage().getViewReferences(); + for (IViewReference viewRef : viewRefs) { + if (viewId.equals(viewRef.getId()) && (viewRef.getSecondaryId() == null)) { + assignSecondaryId = true; + break; + } + } + if (assignSecondaryId) + secondaryId = ViewIDCounterManager.getInstance().getNextCounter(viewId); + + try { + ww.getActivePage().showView(viewId, + secondaryId != null ? PinCloneUtils.encodeClonedPartSecondaryId(secondaryId.toString()) : null, + IWorkbenchPage.VIEW_ACTIVATE); + } catch (PartInitException e) { + CDebugUIPlugin.log(e); + } + } + } + + /** Sets the view, that this action will open a new instance of */ + public void init(IViewPart view) { + fView = view; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewActionDelegate.java index a06155ab6a6..80b62e76427 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/OpenNewViewActionDelegate.java @@ -7,27 +7,20 @@ * * Contributors: * Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781) + * Marc Dumais (Ericsson) - Bug 437692 *****************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; -import org.eclipse.cdt.debug.internal.ui.pinclone.PinCloneUtils; -import org.eclipse.cdt.debug.internal.ui.pinclone.ViewIDCounterManager; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IViewReference; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; /** * Opens a new view of the same type. */ public class OpenNewViewActionDelegate implements IViewActionDelegate { - private IViewPart fView; + private OpenNewViewAction fOpenNewViewAction = new OpenNewViewAction(); /* * (non-Javadoc) @@ -35,32 +28,7 @@ public class OpenNewViewActionDelegate implements IViewActionDelegate { */ @Override public void run(IAction action) { - IViewSite site = fView.getViewSite(); - String viewId = site.getId(); - IWorkbenchWindow ww = fView.getViewSite().getWorkbenchWindow(); - if (ww != null) { - Integer secondaryId = null; - boolean assignSecondaryId = false; - - // if there is a view without a secondary id, than get the next available id. - IViewReference[] viewRefs = ww.getActivePage().getViewReferences(); - for (IViewReference viewRef : viewRefs) { - if (viewId.equals(viewRef.getId()) && (viewRef.getSecondaryId() == null)) { - assignSecondaryId = true; - break; - } - } - if (assignSecondaryId) - secondaryId = ViewIDCounterManager.getInstance().getNextCounter(viewId); - - try { - ww.getActivePage().showView(viewId, - secondaryId != null ? PinCloneUtils.encodeClonedPartSecondaryId(secondaryId.toString()) : null, - IWorkbenchPage.VIEW_ACTIVATE); - } catch (PartInitException e) { - CDebugUIPlugin.log(e); - } - } + fOpenNewViewAction.run(); } /* @@ -77,6 +45,6 @@ public class OpenNewViewActionDelegate implements IViewActionDelegate { */ @Override public void init(IViewPart view) { - fView = view; + fOpenNewViewAction.init(view); } }