1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 09:25:31 +02:00

Fix for 172144, defines context for CDT-Views to enable kbd-shortcuts.

This commit is contained in:
Markus Schorn 2007-02-01 16:50:45 +00:00
parent 50c791143e
commit c22550e30e
11 changed files with 504 additions and 31 deletions

View file

@ -373,3 +373,7 @@ TextProposalCategory= &Word Proposals
SpecificContentAssist.name= C/C++ Content Assist
SpecificContentAssist.desc= A parameterizable command that invokes content assist with a single completion proposal category
SpecificContentAssist.param= type
# CView context
cViewScope.name = In C/C++ Views
cViewScope.description = In C/C++ Views

View file

@ -913,8 +913,15 @@
id="org.eclipse.cdt.ui.cEditorScope">
</context>
</extension>
<extension
point="org.eclipse.ui.bindings">
<extension point="org.eclipse.ui.contexts">
<context
name="%cViewScope.name"
description="%cViewScope.description"
id="org.eclipse.cdt.ui.cViewScope"
parentId="org.eclipse.ui.contexts.window"
/>
</extension>
<extension point="org.eclipse.ui.bindings">
<!-- win32: M1=CTRL, M2=SHIFT, M3=ALT, M4=-
carbon: M1=COMMAND, M2=SHIFT, M3=ALT, M4=CTRL -->
<key
@ -947,16 +954,27 @@
contextId="org.eclipse.cdt.ui.cEditorScope"
commandId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
sequence="M1+M3+H"
contextId="org.eclipse.cdt.ui.cViewScope"
commandId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<!--removed, see bug 167162
<key
sequence="M1+F3"
contextId="org.eclipse.cdt.ui.cEditorScope"
commandId="org.eclipse.cdt.ui.edit.opendef"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/-->
<key
sequence="F3"
contextId="org.eclipse.cdt.ui.cEditorScope"
commandId="org.eclipse.cdt.ui.edit.opendecl"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
sequence="F3"
contextId="org.eclipse.cdt.ui.cViewScope"
commandId="org.eclipse.cdt.ui.edit.opendecl"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
sequence="M1+M2+T"
contextId="org.eclipse.cdt.ui.cEditorScope"
@ -967,16 +985,31 @@
sequence="M1+M2+G"
contextId="org.eclipse.cdt.ui.cEditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
commandId="org.eclipse.cdt.ui.search.findrefs"
sequence="M1+M2+G"
contextId="org.eclipse.cdt.ui.cViewScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
commandId="org.eclipse.cdt.ui.search.finddecl"
sequence="M1+G"
contextId="org.eclipse.cdt.ui.cEditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
commandId="org.eclipse.cdt.ui.search.finddecl"
sequence="M1+G"
contextId="org.eclipse.cdt.ui.cViewScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
sequence="F4"
contextId="org.eclipse.cdt.ui.cEditorScope"
commandId="org.eclipse.cdt.ui.edit.open.type.hierarchy"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
sequence="F4"
contextId="org.eclipse.cdt.ui.cViewScope"
commandId="org.eclipse.cdt.ui.edit.open.type.hierarchy"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<!--key
sequence="M1+M2+H"
contextId="org.eclipse.cdt.ui.cEditorScope"
@ -1626,6 +1659,13 @@
<instanceof value="org.eclipse.cdt.core.model.ICElement"/>
</enablement>
</actionProvider>
<actionProvider
class="org.eclipse.cdt.internal.ui.navigator.CNavigatorOpenViewActionProvider"
id="org.eclipse.cdt.ui.navigator.actions.open.view">
<enablement>
<instanceof value="org.eclipse.cdt.core.model.ICElement"/>
</enablement>
</actionProvider>
<actionProvider
class="org.eclipse.cdt.internal.ui.navigator.CNavigatorEditActionProvider"
id="org.eclipse.cdt.ui.navigator.actions.edit"
@ -1768,5 +1808,4 @@
class="org.eclipse.cdt.internal.ui.navigator.CNavigatorDragAdapterAssistant"
viewerId="org.eclipse.ui.navigator.ProjectExplorer"/>
</extension>
</plugin>

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2007 Wind River Systems, Inc. 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
@ -53,6 +53,8 @@ import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
@ -130,6 +132,7 @@ public class CHViewPart extends ViewPart {
private OpenViewActionGroup fOpenViewActionGroup;
private SelectionSearchGroup fSelectionSearchGroup;
private CRefactoringActionGroup fRefactoringActionGroup;
private IContextActivation fContextActivation;
public void setFocus() {
@ -190,9 +193,21 @@ public class CHViewPart extends ViewPart {
setMessage(CHMessages.CHViewPart_emptyPageMessage);
initializeActionStates();
IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
if (ctxService != null) {
fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
}
}
public void dispose() {
if (fContextActivation != null) {
IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
if (ctxService != null) {
ctxService.deactivateContext(fContextActivation);
}
}
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.dispose();
fOpenViewActionGroup= null;
@ -310,6 +325,8 @@ public class CHViewPart extends ViewPart {
private void createActions() {
// action gruops
fOpenViewActionGroup= new OpenViewActionGroup(this);
fOpenViewActionGroup.setSuppressCallHierarchy(true);
fOpenViewActionGroup.setSuppressProperties(true);
fSelectionSearchGroup= new SelectionSearchGroup(getSite());
fRefactoringActionGroup= new CRefactoringActionGroup(this);

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others.
* Copyright (c) 2000, 2007 QNX Software 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
@ -68,6 +68,8 @@ import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ResourceWorkingSetFilter;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.part.ISetSelectionTarget;
import org.eclipse.ui.part.IShowInSource;
@ -239,6 +241,7 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
}
}
};
private IContextActivation fContextActivation;
/**
* Handles an open event from the viewer.
@ -576,8 +579,12 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
}
memento = null;
}
IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
if (ctxService != null) {
fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
}
}
protected ProblemTreeViewer createViewer(Composite parent) {
return new RemoteTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
}
@ -598,6 +605,13 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha
* (non-Javadoc) Method declared on IWorkbenchPart.
*/
public void dispose() {
if (fContextActivation != null) {
IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
if (ctxService != null) {
ctxService.deactivateContext(fContextActivation);
}
}
getSite().getPage().removePartListener(partListener);
CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
if (viewer != null) {

View file

@ -82,6 +82,7 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
/**
* Action definition ID of the open definition action
* (value <code>"org.eclipse.cdt.ui.edit.opendef"</code>).
* @deprecated see bug 167162
*/
public static final String OPEN_DEF= "org.eclipse.cdt.ui.edit.opendef"; //$NON-NLS-1$

View file

@ -61,6 +61,8 @@ import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ContributionItemFactory;
import org.eclipse.ui.actions.OpenFileAction;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.part.IShowInSource;
import org.eclipse.ui.part.IShowInTarget;
import org.eclipse.ui.part.IShowInTargetList;
@ -133,6 +135,8 @@ public class IBViewPart extends ViewPart
private Action fPreviousAction;
private Action fRefreshAction;
private Action fHistoryAction;
private IContextActivation fContextActivation;
private WorkingSetFilterUI fWorkingSetFilterUI;
public void setFocus() {
@ -215,8 +219,25 @@ public class IBViewPart extends ViewPart
initializeActionStates();
restoreInput();
fMemento= null;
IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
if (ctxService != null) {
fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
}
}
public void dispose() {
if (fContextActivation != null) {
IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
if (ctxService != null) {
ctxService.deactivateContext(fContextActivation);
}
}
if (fWorkingSetFilterUI != null) {
fWorkingSetFilterUI.dispose();
}
}
private void initializeActionStates() {
boolean includedBy= true;
boolean filterSystem= false;
@ -348,7 +369,7 @@ public class IBViewPart extends ViewPart
}
private void createActions() {
WorkingSetFilterUI wsFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
fWorkingSetFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
protected void onWorkingSetChange() {
updateWorkingSetFilter(this);
}
@ -506,7 +527,7 @@ public class IBViewPart extends ViewPart
// tm.add(fNext);
// tm.add(fPrevious);
// tm.add(new Separator());
wsFilterUI.fillActionBars(actionBars);
fWorkingSetFilterUI.fillActionBars(actionBars);
mm.add(fIncludedByAction);
mm.add(fIncludesToAction);
mm.add(new Separator());

View file

@ -0,0 +1,96 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.navigator;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionExtensionSite;
import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
public class CNavigatorOpenViewActionProvider extends CommonActionProvider {
private OpenViewActionGroup fOpenViewActionGroup;
/*
* @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
*/
public void init(ICommonActionExtensionSite site) {
ICommonViewerWorkbenchSite workbenchSite= null;
if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite();
}
if (workbenchSite != null) {
if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
fOpenViewActionGroup= new OpenViewActionGroup(workbenchSite.getPart());
}
}
}
/*
* @see org.eclipse.ui.actions.ActionGroup#dispose()
*/
public void dispose() {
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.dispose();
fOpenViewActionGroup = null;
}
super.dispose();
}
/*
* @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
*/
public void fillActionBars(IActionBars actionBars) {
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.fillActionBars(actionBars);
}
}
/*
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
public void fillContextMenu(IMenuManager menu) {
if (fOpenViewActionGroup != null) {
ISelection selection = getContext().getSelection();
if (SelectionSearchGroup.canActionBeAdded(selection)){
fOpenViewActionGroup.fillContextMenu(menu);
}
}
}
/*
* @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
*/
public void setContext(ActionContext context) {
super.setContext(context);
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.setContext(context);
}
}
/*
* @see org.eclipse.ui.actions.ActionGroup#updateActionBars()
*/
public void updateActionBars() {
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.updateActionBars();
}
}
}

View file

@ -65,6 +65,8 @@ import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.progress.IWorkbenchSiteProgressService;
@ -177,6 +179,7 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
private OpenViewActionGroup fOpenViewActionGroup;
private SelectionSearchGroup fSelectionSearchGroup;
private CRefactoringActionGroup fRefactoringActionGroup;
private IContextActivation fContextActivation;
public void setFocus() {
fPagebook.setFocus();
@ -222,16 +225,21 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
setMessage(Messages.THViewPart_instruction);
initializeActionStates();
IContextService ctxService = (IContextService) getSite().getService(IContextService.class);
if (ctxService != null) {
fContextActivation= ctxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
}
}
private void initSelectionProvider() {
SelectionProviderMediator mediator= new SelectionProviderMediator();
mediator.addViewer(fHierarchyTreeViewer);
mediator.addViewer(fMemberViewer);
getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, mediator));
}
public void dispose() {
if (fContextActivation != null) {
IContextService ctxService = (IContextService)getSite().getService(IContextService.class);
if (ctxService != null) {
ctxService.deactivateContext(fContextActivation);
}
}
if (fOpenViewActionGroup != null) {
fOpenViewActionGroup.dispose();
fOpenViewActionGroup= null;
@ -251,6 +259,13 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
super.dispose();
}
private void initSelectionProvider() {
SelectionProviderMediator mediator= new SelectionProviderMediator();
mediator.addViewer(fHierarchyTreeViewer);
mediator.addViewer(fMemberViewer);
getSite().setSelectionProvider(new AdaptingSelectionProvider(ICElement.class, mediator));
}
private void initializeActionStates() {
int mode= THHierarchyModel.TYPE_HIERARCHY;
int orientation= ORIENTATION_AUTOMATIC;
@ -518,6 +533,8 @@ public class THViewPart extends ViewPart implements ITHModelPresenter {
private void createActions() {
// action gruops
fOpenViewActionGroup= new OpenViewActionGroup(this);
fOpenViewActionGroup.setSuppressTypeHierarchy(true);
fOpenViewActionGroup.setSuppressProperties(true);
fSelectionSearchGroup= new SelectionSearchGroup(getSite());
fRefactoringActionGroup= new CRefactoringActionGroup(this);

View file

@ -0,0 +1,245 @@
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. 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:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.viewsupport;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWindowListener;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartReference;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.navigator.CommonNavigator;
import org.eclipse.ui.part.IPage;
import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.editor.CContentOutlinePage;
/**
* Once registered as windows listener, observes all part activations. Whenever the
* CDT outline view is brought to the front, the CDT context is set.
*/
public class CDTContextActivator implements IWindowListener, IPartListener2 {
private static CDTContextActivator sInstance= new CDTContextActivator();
private Map fActivationPerOutline = new HashMap();
private Map fActivationPerNavigator= new HashMap();
private Collection fWindows= new HashSet();
private CDTContextActivator() {
}
public static CDTContextActivator getInstance() {
return sInstance;
}
public void install() {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null) {
// listen for new windows
workbench.addWindowListener(this);
IWorkbenchWindow[] wnds= workbench.getWorkbenchWindows();
for (int i = 0; i < wnds.length; i++) {
IWorkbenchWindow window = wnds[i];
register(window);
}
// register open windows
IWorkbenchWindow ww= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (ww != null) {
IWorkbenchPage activePage = ww.getActivePage();
if (activePage != null) {
IWorkbenchPartReference part= activePage.getActivePartReference();
if (part != null) {
partActivated(part);
}
}
}
}
}
public void uninstall() {
for (Iterator iterator = fWindows.iterator(); iterator.hasNext();) {
IWorkbenchWindow window = (IWorkbenchWindow) iterator.next();
unregister(window);
}
for (Iterator iterator = fActivationPerNavigator.values().iterator(); iterator.hasNext();) {
SelectionListener l= (SelectionListener) iterator.next();
l.uninstall();
}
}
private void register(IWorkbenchWindow wnd) {
wnd.getPartService().addPartListener(this);
fWindows.add(wnd);
}
private void unregister(IWorkbenchWindow wnd) {
wnd.getPartService().removePartListener(this);
fWindows.remove(wnd);
}
public void windowOpened(IWorkbenchWindow window) {
register(window);
}
public void windowClosed(IWorkbenchWindow window) {
unregister(window);
}
public void windowActivated(IWorkbenchWindow window) {
}
public void windowDeactivated(IWorkbenchWindow window) {
}
private void onContentOutlineClosed(ContentOutline outline) {
fActivationPerOutline.remove(outline);
}
private void onContentOutlineActivated(ContentOutline outline) {
IPage page = outline.getCurrentPage();
if (page instanceof CContentOutlinePage) {
if (!fActivationPerOutline.containsKey(outline)){
// cdt outline activated for the first time
IContextService ctxtService = (IContextService)outline.getViewSite().getService(IContextService.class);
IContextActivation activateContext = ctxtService.activateContext(CUIPlugin.CVIEWS_SCOPE);
fActivationPerOutline.put(outline,activateContext);
}
}
else {
IContextActivation activation = (IContextActivation) fActivationPerOutline.remove(outline);
if (activation != null) {
// other outline page brought to front
IContextService ctxtService = (IContextService)outline.getViewSite().getService(IContextService.class);
ctxtService.deactivateContext(activation);
}
}
}
private static class SelectionListener implements ISelectionChangedListener {
private IWorkbenchPartSite fSite;
private IContextService fCtxService;
private IContextActivation fActivation;
public SelectionListener(IWorkbenchPartSite site) {
fSite= site;
fCtxService= (IContextService)fSite.getService(IContextService.class);
ISelectionProvider sp= site.getSelectionProvider();
if (sp != null && fCtxService != null) {
sp.addSelectionChangedListener(this);
onNewSelection(sp.getSelection());
}
}
public void uninstall() {
ISelectionProvider sp= fSite.getSelectionProvider();
if (sp != null && fCtxService != null) {
onNewSelection(null);
sp.removeSelectionChangedListener(this);
}
}
public void selectionChanged(SelectionChangedEvent event) {
onNewSelection(event.getSelection());
}
private void onNewSelection(ISelection selection) {
boolean isRelevant= false;
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
if (((IStructuredSelection) selection).getFirstElement() instanceof ICElement) {
isRelevant = true;
}
}
if (isRelevant) {
if (fActivation == null) {
fActivation= fCtxService.activateContext(CUIPlugin.CVIEWS_SCOPE);
}
}
else {
if (fActivation != null) {
fCtxService.deactivateContext(fActivation);
fActivation= null;
}
}
}
}
private void onCommonNavigatorActivated(CommonNavigator part) {
SelectionListener l= (SelectionListener) fActivationPerNavigator.get(part);
if (l == null) {
l= new SelectionListener(part.getSite());
fActivationPerNavigator.put(part, l);
}
}
private void onCommonNavigatorClosed(CommonNavigator part) {
fActivationPerNavigator.remove(part);
}
public void partActivated(IWorkbenchPartReference partRef) {
IWorkbenchPart part= partRef.getPart(false);
if (part instanceof ContentOutline) {
onContentOutlineActivated((ContentOutline) part);
}
else if (part instanceof CommonNavigator) {
onCommonNavigatorActivated((CommonNavigator) part);
}
}
public void partClosed(IWorkbenchPartReference partRef) {
IWorkbenchPart part= partRef.getPart(false);
if (part instanceof ContentOutline) {
onContentOutlineClosed((ContentOutline)part);
}
else if (part instanceof CommonNavigator) {
onCommonNavigatorClosed((CommonNavigator) part);
}
}
public void partBroughtToTop(IWorkbenchPartReference partRef) {
}
public void partDeactivated(IWorkbenchPartReference partRef) {
}
public void partOpened(IWorkbenchPartReference partRef) {
}
public void partHidden(IWorkbenchPartReference partRef) {
}
public void partVisible(IWorkbenchPartReference partRef) {
}
public void partInputChanged(IWorkbenchPartReference partRef) {
}
}

View file

@ -87,6 +87,7 @@ import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistr
import org.eclipse.cdt.internal.ui.util.ImageDescriptorRegistry;
import org.eclipse.cdt.internal.ui.util.ProblemMarkerManager;
import org.eclipse.cdt.internal.ui.util.Util;
import org.eclipse.cdt.internal.ui.viewsupport.CDTContextActivator;
public class CUIPlugin extends AbstractUIPlugin {
@ -198,6 +199,13 @@ public class CUIPlugin extends AbstractUIPlugin {
* @since 2.0
*/
public static final String ID_CELEMENT_CREATION_ACTION_SET= "org.eclipse.cdt.ui.CElementCreationActionSet"; //$NON-NLS-1$
/**
* The id of the scope used by all the CDT views
* (value <code>"org.eclipse.cdt.ui.scope"</code>).
* @since 4.0
*/
public static final String CVIEWS_SCOPE = "org.eclipse.cdt.ui.cViewScope"; //$NON-NLS-1$
// -------- static methods --------
@ -455,12 +463,14 @@ public class CUIPlugin extends AbstractUIPlugin {
// init ast provider
getASTProvider();
CDTContextActivator.getInstance().install();
}
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
CDTContextActivator.getInstance().uninstall();
if (fASTProvider != null) {
fASTProvider.dispose();
fASTProvider= null;

View file

@ -19,22 +19,20 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.dialogs.PropertyDialogAction;
import org.eclipse.ui.part.Page;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
import org.eclipse.cdt.internal.ui.callhierarchy.OpenCallHierarchyAction;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
import org.eclipse.cdt.internal.ui.typehierarchy.OpenTypeHierarchyAction;
import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;
/**
* Action group that adds actions to open a new CDT view part or an external
@ -49,8 +47,9 @@ import org.eclipse.cdt.internal.ui.typehierarchy.THViewPart;
public class OpenViewActionGroup extends ActionGroup {
private boolean fEditorIsOwner;
private boolean fIsTypeHiararchyViewerOwner;
private boolean fIsCallHiararchyViewerOwner;
private boolean fSuppressTypeHierarchy;
private boolean fSuppressCallHierarchy;
private boolean fSuppressProperties;
private IWorkbenchSite fSite;
private String fGroupName= IContextMenuConstants.GROUP_OPEN;
@ -78,16 +77,14 @@ public class OpenViewActionGroup extends ActionGroup {
*
* @param part the view part that owns this action group
*/
public OpenViewActionGroup(IViewPart part) {
public OpenViewActionGroup(IWorkbenchPart part) {
createSiteActions(part.getSite());
fIsCallHiararchyViewerOwner= part instanceof CHViewPart;
fIsTypeHiararchyViewerOwner= part instanceof THViewPart;
}
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*/
public OpenViewActionGroup(CEditor part) {
public OpenViewActionGroup(ITextEditor part) {
fEditorIsOwner= true;
// fOpenSuperImplementation= new OpenSuperImplementationAction(part);
@ -165,16 +162,16 @@ public class OpenViewActionGroup extends ActionGroup {
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu);
if (!fEditorIsOwner) {
if (!fIsTypeHiararchyViewerOwner && fOpenTypeHierarchy.isEnabled()) {
if (!fSuppressTypeHierarchy && fOpenTypeHierarchy.isEnabled()) {
menu.appendToGroup(fGroupName, fOpenTypeHierarchy);
}
if (!fIsCallHiararchyViewerOwner && fOpenCallHierarchy.isEnabled()) {
if (!fSuppressCallHierarchy && fOpenCallHierarchy.isEnabled()) {
menu.appendToGroup(fGroupName, fOpenCallHierarchy);
}
}
// appendToGroup(menu, fOpenSuperImplementation);
IStructuredSelection selection= getStructuredSelection();
if (!fIsCallHiararchyViewerOwner && !fIsTypeHiararchyViewerOwner) {
if (!fSuppressProperties) {
if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null &&fOpenPropertiesDialog.isApplicableForSelection(selection)) {
menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog);
}
@ -240,4 +237,16 @@ public class OpenViewActionGroup extends ActionGroup {
public void setAppendToGroup(String groupName) {
fGroupName= groupName;
}
public void setSuppressTypeHierarchy(boolean suppressTypeHierarchy) {
fSuppressTypeHierarchy = suppressTypeHierarchy;
}
public void setSuppressCallHierarchy(boolean suppressCallHierarchy) {
fSuppressCallHierarchy = suppressCallHierarchy;
}
public void setSuppressProperties(boolean suppressProperties) {
fSuppressProperties = suppressProperties;
}
}