mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 437692 - Refactor OpenNewViewActionDelegate to permit
programmatically adding OpenNewViewAction to view toolbars/menu Change-Id: I7adc6e0e70206bd3671011632300816636dab450 Reviewed-on: https://git.eclipse.org/r/28709 Reviewed-by: Marc Dumais <marc.dumais@ericsson.com> Tested-by: Marc Dumais <marc.dumais@ericsson.com>
This commit is contained in:
parent
d911875741
commit
42f137042f
4 changed files with 113 additions and 36 deletions
|
@ -9,6 +9,7 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Ericsson - Added tracepoint support (284286)
|
* Ericsson - Added tracepoint support (284286)
|
||||||
* Marc Khouzam (Ericsson) - Added dynamic printf support (400628)
|
* Marc Khouzam (Ericsson) - Added dynamic printf support (400628)
|
||||||
|
* Marc Dumais (Ericsson) - Bug 437692
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui;
|
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_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_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_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_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$
|
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_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 = 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_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.
|
* Returns the image managed under the given key in this registry.
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
# Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
|
# Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
|
||||||
# Marc Khouzam (Ericsson) - Added dynamic printf support (400628)
|
# Marc Khouzam (Ericsson) - Added dynamic printf support (400628)
|
||||||
# Simon Marchi (Ericsson) - Modified error messages in CastToArrayActionDelegate (437182)
|
# 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.
|
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
|
CRulerToggleBreakpointAction_accelerator=Double Click
|
||||||
CAddDynamicPrintfInteractiveRulerAction_label=Add &Dynamic Printf...
|
CAddDynamicPrintfInteractiveRulerAction_label=Add &Dynamic Printf...
|
||||||
CAddDynamicPrintfInteractiveRulerAction_error_message=Unable to create dynamic printf
|
CAddDynamicPrintfInteractiveRulerAction_error_message=Unable to create dynamic printf
|
||||||
|
OpenNewViewActionText=Open New View
|
||||||
|
OpenNewViewActionTooltipText=Open New View
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,27 +7,20 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
|
* Patrick Chuong (Texas Instruments) - Pin and Clone Supports (331781)
|
||||||
|
* Marc Dumais (Ericsson) - Bug 437692
|
||||||
*****************************************************************/
|
*****************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
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.action.IAction;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.ui.IViewActionDelegate;
|
import org.eclipse.ui.IViewActionDelegate;
|
||||||
import org.eclipse.ui.IViewPart;
|
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.
|
* Opens a new view of the same type.
|
||||||
*/
|
*/
|
||||||
public class OpenNewViewActionDelegate implements IViewActionDelegate {
|
public class OpenNewViewActionDelegate implements IViewActionDelegate {
|
||||||
private IViewPart fView;
|
private OpenNewViewAction fOpenNewViewAction = new OpenNewViewAction();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
|
@ -35,32 +28,7 @@ public class OpenNewViewActionDelegate implements IViewActionDelegate {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run(IAction action) {
|
public void run(IAction action) {
|
||||||
IViewSite site = fView.getViewSite();
|
fOpenNewViewAction.run();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -77,6 +45,6 @@ public class OpenNewViewActionDelegate implements IViewActionDelegate {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void init(IViewPart view) {
|
public void init(IViewPart view) {
|
||||||
fView = view;
|
fOpenNewViewAction.init(view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue