Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 45522 Details for
Bug 140337
[CView] Common Navigator extensions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Project Explorer extensions
bug140337-20060629.patch (text/plain), 81.55 KB, created by
Anton Leherbauer
on 2006-06-29 05:18:56 EDT
(
hide
)
Description:
Project Explorer extensions
Filename:
MIME Type:
Creator:
Anton Leherbauer
Created:
2006-06-29 05:18:56 EDT
Size:
81.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.6 >diff -u -r1.6 MANIFEST.MF >--- META-INF/MANIFEST.MF 15 May 2006 19:02:44 -0000 1.6 >+++ META-INF/MANIFEST.MF 29 Jun 2006 08:51:33 -0000 >@@ -66,5 +66,8 @@ > org.eclipse.ui.console, > org.eclipse.core.filebuffers, > org.eclipse.core.runtime, >- org.eclipse.help >+ org.eclipse.help, >+ org.eclipse.ui.navigator, >+ org.eclipse.core.expressions, >+ org.eclipse.ui.navigator.resources > Eclipse-LazyStart: true >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/plugin.properties,v >retrieving revision 1.94 >diff -u -r1.94 plugin.properties >--- plugin.properties 14 Jun 2006 12:15:53 -0000 1.94 >+++ plugin.properties 29 Jun 2006 08:51:32 -0000 >@@ -328,3 +328,6 @@ > > IndexView.name=C/C++ Index > RebuildIndex.name=Rebuild Index >+ >+# Common Navigator >+navigatorContent.name = CDT Elements >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/plugin.xml,v >retrieving revision 1.188 >diff -u -r1.188 plugin.xml >--- plugin.xml 23 May 2006 03:17:52 -0000 1.188 >+++ plugin.xml 29 Jun 2006 08:51:33 -0000 >@@ -1358,4 +1358,217 @@ > </objectContribution> > </extension> > >+<!--- Common Navigator extensions --> >+ <extension >+ point="org.eclipse.ui.navigator.navigatorContent"> >+ <navigatorContent >+ activeByDefault="true" >+ contentProvider="org.eclipse.cdt.internal.ui.navigator.CNavigatorContentProvider" >+ icon="icons/view16/cview.gif" >+ id="org.eclipse.cdt.ui.navigator.content" >+ labelProvider="org.eclipse.cdt.internal.ui.navigator.CNavigatorLabelProvider" >+ name="%navigatorContent.name" >+ priority="normal"> >+ <triggerPoints> >+ <or> >+ <adapt type="org.eclipse.core.resources.IProject"> >+ <or> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.cnature"/> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.ccnature"/> >+ </or> >+ </adapt> >+ <instanceof value="org.eclipse.core.resources.IWorkspaceRoot"/> >+ <instanceof value="org.eclipse.core.resources.IFolder" /> >+ <instanceof value="org.eclipse.core.resources.IFile" /> >+ <instanceof value="org.eclipse.core.resources.IStorage" /> >+ <instanceof value="org.eclipse.cdt.core.model.ICProject"/> >+ <instanceof value="org.eclipse.cdt.core.model.ICContainer"/> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement"/> >+ <instanceof value="org.eclipse.cdt.ui.CElementGrouping"/> >+ </or> >+ </triggerPoints> >+ <possibleChildren> >+ <or> >+ <instanceof value="org.eclipse.core.resources.IWorkspaceRoot"/> >+ <instanceof value="org.eclipse.core.resources.IFolder" /> >+ <instanceof value="org.eclipse.core.resources.IFile" /> >+ <instanceof value="org.eclipse.core.resources.IStorage" /> >+ <instanceof value="org.eclipse.cdt.core.model.ICProject"/> >+ <instanceof value="org.eclipse.cdt.core.model.ICContainer"/> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement"/> >+ <instanceof value="org.eclipse.cdt.ui.CElementGrouping"/> >+ </or> >+ </possibleChildren> >+ <override >+ policy="InvokeAlwaysRegardlessOfSuppressedExt" >+ suppressedExtensionId="org.eclipse.ui.navigator.resourceContent"/> >+ <commonSorter >+ class="org.eclipse.cdt.ui.CElementSorter" >+ id="org.eclipse.cdt.ui.commonSorter"/> >+ <actionProvider >+ class="org.eclipse.cdt.internal.ui.navigator.CNavigatorOpenActionProvider" >+ id="org.eclipse.cdt.ui.navigator.actions.open" >+ overrides="org.eclipse.ui.navigator.resources.OpenActions"> >+ <enablement> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement"/> >+ </enablement> >+ </actionProvider> >+ <actionProvider >+ class="org.eclipse.cdt.internal.ui.navigator.CNavigatorBuildActionProvider" >+ id="org.eclipse.cdt.ui.navigator.actions.build"> >+ <enablement> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement"/> >+ </enablement> >+ </actionProvider> >+ <actionProvider >+ class="org.eclipse.cdt.internal.ui.navigator.CNavigatorWorkingSetActionProvider" >+ id="org.eclipse.cdt.ui.navigator.actions.workingSet"> >+ </actionProvider> >+ <actionProvider >+ class="org.eclipse.cdt.internal.ui.navigator.CNavigatorSearchActionProvider" >+ id="org.eclipse.cdt.ui.navigator.actions.search"> >+ <enablement> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement"/> >+ </enablement> >+ </actionProvider> >+ <commonWizard >+ associatedExtensionId="org.eclipse.cdt.ui.navigator.content" >+ menuGroupId="org.eclipse.cdt.ui" >+ type="new" >+ wizardId="org.eclipse.cdt.ui.wizards.NewSourceFileCreationWizard"> >+ <enablement> >+ <or> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement" /> >+ <adapt type="org.eclipse.core.resources.IProject"> >+ <or> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.cnature"/> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.ccnature"/> >+ </or> >+ </adapt> >+ </or> >+ </enablement> >+ </commonWizard> >+ <commonWizard >+ associatedExtensionId="org.eclipse.cdt.ui.navigator.content" >+ menuGroupId="org.eclipse.cdt.ui" >+ type="new" >+ wizardId="org.eclipse.cdt.ui.wizards.NewHeaderFileCreationWizard"> >+ <enablement> >+ <or> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement" /> >+ <adapt type="org.eclipse.core.resources.IProject"> >+ <or> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.cnature"/> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.ccnature"/> >+ </or> >+ </adapt> >+ </or> >+ </enablement> >+ </commonWizard> >+ <commonWizard >+ associatedExtensionId="org.eclipse.cdt.ui.navigator.content" >+ menuGroupId="org.eclipse.cdt.ui" >+ type="new" >+ wizardId="org.eclipse.cdt.ui.wizards.NewSourceFolderCreationWizard"> >+ <enablement> >+ <or> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement" /> >+ <adapt type="org.eclipse.core.resources.IProject"> >+ <or> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.cnature"/> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.ccnature"/> >+ </or> >+ </adapt> >+ </or> >+ </enablement> >+ </commonWizard> >+ <commonWizard >+ associatedExtensionId="org.eclipse.cdt.ui.navigator.content" >+ menuGroupId="org.eclipse.cdt.ui" >+ type="new" >+ wizardId="org.eclipse.cdt.ui.wizards.NewClassCreationWizard"> >+ <enablement> >+ <or> >+ <instanceof value="org.eclipse.cdt.core.model.ICElement" /> >+ <adapt type="org.eclipse.core.resources.IProject"> >+ <or> >+ <test >+ property="org.eclipse.core.resources.projectNature" >+ value="org.eclipse.cdt.core.ccnature"/> >+ </or> >+ </adapt> >+ </or> >+ </enablement> >+ </commonWizard> >+ <dropAssistant >+ class="org.eclipse.cdt.internal.ui.navigator.CNavigatorDropAdapterAssistant" >+ id="org.eclipse.cdt.ui.navigator.dropAssistant"> >+ <possibleDropTargets> >+ <or> >+ <instanceof value="org.eclipse.cdt.core.model.ISourceReference"/> >+ </or> >+ </possibleDropTargets> >+ </dropAssistant> >+ </navigatorContent> >+ <commonFilter >+ class="org.eclipse.cdt.internal.ui.filters.ExecutableFilter" >+ description="%HideExecutableFiles.description" >+ id="org.eclipse.cdt.ui.navigator.filters.ExecutableFilter" >+ name="%HideExecutableFiles.label"/> >+ <commonFilter >+ class="org.eclipse.cdt.internal.ui.filters.SharedFilter" >+ description="%HideSharedFiles.description" >+ id="org.eclipse.cdt.ui.navigator.filters.SharedFilter" >+ name="%HideSharedFiles.label"/> >+ <commonFilter >+ class="org.eclipse.cdt.internal.ui.filters.ObjectFilter" >+ description="%HideObjectFiles.description" >+ id="org.eclipse.cdt.ui.navigator.filters.ObjectFilter" >+ name="%HideObjectFiles.label"/> >+ <commonFilter >+ class="org.eclipse.cdt.internal.ui.filters.ArchiveFilter" >+ description="%HideArchiveFiles.description" >+ id="org.eclipse.cdt.ui.navigator.filters.ArchiveFilter" >+ name="%HideArchiveFiles.label"/> >+ <commonFilter >+ class="org.eclipse.cdt.internal.ui.filters.NonCProjectsFilter" >+ description="%HideNonCProjects.description" >+ id="org.eclipse.cdt.ui.navigator.filters.NonCProjectsFilter" >+ name="%HideNonCProjects.label"/> >+ <commonFilter >+ class="org.eclipse.cdt.internal.ui.filters.NonCElementFilter" >+ description="%HideNonCElements.description" >+ id="org.eclipse.cdt.ui.navigator.filters.NonCElementFilter" >+ name="%HideNonCElements.label"/> >+ </extension> >+ <extension >+ point="org.eclipse.ui.navigator.viewer"> >+ <viewerContentBinding viewerId="org.eclipse.ui.navigator.ProjectExplorer"> >+ <includes> >+ <contentExtension pattern="org.eclipse.cdt.ui.navigator.content"/> >+ <contentExtension pattern="org.eclipse.cdt.ui.navigator.filters.*"/> >+ <contentExtension pattern="org.eclipse.cdt.ui.wizards.*"/> >+ </includes> >+ </viewerContentBinding> >+ <dragAssistant >+ class="org.eclipse.cdt.internal.ui.navigator.CNavigatorDragAdapterAssistant" >+ viewerId="org.eclipse.ui.navigator.ProjectExplorer"/> >+ </extension> >+ > </plugin> >Index: src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java,v >retrieving revision 1.8 >diff -u -r1.8 DeclarationsSearchGroup.java >--- src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java 23 Jun 2006 17:26:10 -0000 1.8 >+++ src/org/eclipse/cdt/internal/ui/search/actions/DeclarationsSearchGroup.java 29 Jun 2006 08:51:33 -0000 >@@ -42,8 +42,6 @@ > private FindDeclarationsProjectAction fFindDeclarationsProjectAction; > private FindDeclarationsInWorkingSetAction fFindDeclarationsInWorkingSetAction; > >- private ArrayList actions; >- > public DeclarationsSearchGroup(IWorkbenchSite site) { > fFindDeclarationsAction= new FindDeclarationsAction(site); > fFindDeclarationsProjectAction = new FindDeclarationsProjectAction(site); >@@ -81,9 +79,9 @@ > > if (fEditor != null){ > menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu); >+ } else { >+ incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, declarationsMenu); > } >- >- incomingMenu.add(declarationsMenu); > incomingMenu = declarationsMenu; > > FindAction[] actions = getWorkingSetActions(); >Index: src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java,v >retrieving revision 1.12 >diff -u -r1.12 ReferencesSearchGroup.java >--- src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java 23 Jun 2006 17:26:10 -0000 1.12 >+++ src/org/eclipse/cdt/internal/ui/search/actions/ReferencesSearchGroup.java 29 Jun 2006 08:51:33 -0000 >@@ -73,13 +73,10 @@ > > if (fEditor != null){ > menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu); >+ } else { >+ incomingMenu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, refsMenu); > } > >- >-// /setReferenceMenuEnabled(); >- >- >- incomingMenu.add(refsMenu); > incomingMenu = refsMenu; > > FindAction[] actions = getWorkingSetActions(); >Index: src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java,v >retrieving revision 1.27 >diff -u -r1.27 MainActionGroup.java >--- src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java 14 Jun 2006 12:15:52 -0000 1.27 >+++ src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java 29 Jun 2006 08:51:33 -0000 >@@ -180,7 +180,7 @@ > //Can be added once support for manually adding external files to index is established > /*menu.add(new Separator()); > menu.add(addToIndexAction);*/ >- menu.add(new Separator()); >+ menu.add(new Separator(org.eclipse.search.ui.IContextMenuConstants.GROUP_SEARCH)); > addSearchMenu(menu, celements); > menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); > menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$ >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,147 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ * Anton Leherbauer (Wind River Systems) - adaptations for Common Navigator >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import java.util.Iterator; >+ >+import org.eclipse.cdt.internal.ui.cview.CViewMessages; >+import org.eclipse.core.resources.ICommand; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IncrementalProjectBuilder; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.jface.action.GroupMarker; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.actions.BuildAction; >+import org.eclipse.ui.navigator.ICommonMenuConstants; >+ >+/** >+ * Common Navigator compatible clone of {@link org.eclipse.cdt.internal.ui.cview.BuildGroup}. >+ * <p> >+ * Adds action "Clean Project" and group marker "buildGroup" to the context menu. >+ * </p> >+ * @see org.eclipse.cdt.internal.ui.cview.BuildGroup >+ * @see org.eclipse.ui.actions.BuildAction >+ */ >+public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup { >+ >+ private BuildAction fCleanAction; >+ >+ // Menu tags for the build >+ final String BUILD_GROUP_MARKER= "buildGroup"; //$NON-NLS-1$ >+ final String BUILD_GROUP_MARKER_END= "end-buildGroup"; //$NON-NLS-1$ >+ >+ /** >+ * Create action group associated with given view part. >+ * @param viewPart >+ */ >+ public CNavigatorBuildActionGroup(IViewPart viewPart) { >+ super(viewPart); >+ } >+ >+ public void fillActionBars(IActionBars actionBars) { >+ } >+ >+ /** >+ * Adds the build actions to the context menu. >+ * <p> >+ * The following conditions apply: build-only projects selected, auto build >+ * disabled, at least one * builder present >+ * </p> >+ * <p> >+ * No disabled action should be on the context menu. >+ * </p> >+ * >+ * @param menu >+ * context menu to add actions to >+ */ >+ public void fillContextMenu(IMenuManager menu) { >+ IStructuredSelection selection= (IStructuredSelection) getContext().getSelection(); >+ boolean isProjectSelection= true; >+ boolean hasOpenProjects= false; >+ boolean hasClosedProjects= false; >+ boolean hasBuilder= true; // false if any project is closed or does >+ // not have builder >+ >+ Iterator resources= selection.iterator(); >+ while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) { >+ Object next= resources.next(); >+ IProject project= null; >+ >+ if (next instanceof IProject) { >+ project= (IProject) next; >+ } else if (next instanceof IAdaptable) { >+ IResource res= (IResource)((IAdaptable)next).getAdapter(IResource.class); >+ if (res instanceof IProject) { >+ project= (IProject) res; >+ } >+ } >+ >+ if (project == null) { >+ isProjectSelection= false; >+ continue; >+ } >+ if (project.isOpen()) { >+ hasOpenProjects= true; >+ if (hasBuilder && !hasBuilder(project)) { >+ hasBuilder= false; >+ } >+ } else { >+ hasClosedProjects= true; >+ hasBuilder= false; >+ } >+ } >+ >+ menu.insertAfter(ICommonMenuConstants.GROUP_BUILD, new GroupMarker(BUILD_GROUP_MARKER)); >+ >+ if (!selection.isEmpty() && isProjectSelection && hasBuilder) { >+ fCleanAction.selectionChanged(selection); >+ if (fCleanAction.isEnabled()) { >+ menu.appendToGroup(BUILD_GROUP_MARKER, fCleanAction); >+ } >+ } >+ menu.appendToGroup(BUILD_GROUP_MARKER, new GroupMarker(BUILD_GROUP_MARKER_END)); >+ } >+ >+ /** >+ * Returns whether there are builders configured on the given project. >+ * >+ * @return <code>true</code> if it has builders, <code>false</code> if >+ * not, or if this could not be determined >+ */ >+ boolean hasBuilder(IProject project) { >+ try { >+ ICommand[] commands= project.getDescription().getBuildSpec(); >+ if (commands.length > 0) return true; >+ } catch (CoreException e) { >+ // Cannot determine if project has builders. Project is closed >+ // or does not exist. Fall through to return false. >+ } >+ return false; >+ } >+ >+ protected void makeActions() { >+ Shell shell= getViewPart().getSite().getShell(); >+ >+ fCleanAction= new BuildAction(shell, IncrementalProjectBuilder.CLEAN_BUILD); >+ fCleanAction.setText(CViewMessages.getString("CleanAction.label")); //$NON-NLS-1$ >+ >+ } >+ >+ public void updateActionBars() { >+ } >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import org.eclipse.jface.action.IMenuManager; >+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; >+ >+/** >+ * A Common Navigator action provider providing the contributions >+ * from the build action group. >+ * >+ * @see CNavigatorBuildActionGroup >+ */ >+public class CNavigatorBuildActionProvider extends CommonActionProvider { >+ >+ private CNavigatorBuildActionGroup fBuildGroup; >+ >+ /* >+ * @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) { >+ IViewPart viewPart= (IViewPart) workbenchSite.getPart(); >+ >+ fBuildGroup= new CNavigatorBuildActionGroup(viewPart); >+ } >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#dispose() >+ */ >+ public void dispose() { >+ if (fBuildGroup != null) { >+ fBuildGroup.dispose(); >+ fBuildGroup = null; >+ } >+ super.dispose(); >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) >+ */ >+ public void fillActionBars(IActionBars actionBars) { >+ if (fBuildGroup != null) { >+ fBuildGroup.fillActionBars(actionBars); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) >+ */ >+ public void fillContextMenu(IMenuManager menu) { >+ if (fBuildGroup != null) { >+ fBuildGroup.fillContextMenu(menu); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext) >+ */ >+ public void setContext(ActionContext context) { >+ super.setContext(context); >+ if (fBuildGroup != null) { >+ fBuildGroup.setContext(context); >+ } >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorSearchActionProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,98 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup; >+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; >+ >+/** >+ * Common Navigator action provider for the C-search sub menus. >+ * >+ * @see org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup >+ */ >+public class CNavigatorSearchActionProvider extends CommonActionProvider { >+ >+ private SelectionSearchGroup fSearchGroup; >+ >+ /* >+ * @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) { >+ fSearchGroup= new SelectionSearchGroup(workbenchSite.getSite()); >+ } >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#dispose() >+ */ >+ public void dispose() { >+ if (fSearchGroup != null) { >+ fSearchGroup.dispose(); >+ fSearchGroup = null; >+ } >+ super.dispose(); >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) >+ */ >+ public void fillActionBars(IActionBars actionBars) { >+ if (fSearchGroup != null) { >+ fSearchGroup.fillActionBars(actionBars); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) >+ */ >+ public void fillContextMenu(IMenuManager menu) { >+ if (fSearchGroup != null) { >+ ISelection selection = getContext().getSelection(); >+ if (SelectionSearchGroup.canActionBeAdded(selection)){ >+ fSearchGroup.fillContextMenu(menu); >+ } >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext) >+ */ >+ public void setContext(ActionContext context) { >+ super.setContext(context); >+ if (fSearchGroup != null) { >+ fSearchGroup.setContext(context); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#updateActionBars() >+ */ >+ public void updateActionBars() { >+ if (fSearchGroup != null) { >+ fSearchGroup.updateActionBars(); >+ } >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenActionProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,95 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import org.eclipse.jface.action.IMenuManager; >+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.ICommonActionConstants; >+import org.eclipse.ui.navigator.ICommonActionExtensionSite; >+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; >+ >+/** >+ * A Common Navigator action provider providing the contributions >+ * from the open editor action group. >+ * >+ * @see CNavigatorOpenEditorActionGroup >+ */ >+public class CNavigatorOpenActionProvider extends CommonActionProvider { >+ >+ private CNavigatorOpenEditorActionGroup fOpenGroup; >+ >+ /* >+ * @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) { >+ IViewPart viewPart = (IViewPart) workbenchSite.getPart(); >+ >+ fOpenGroup = new CNavigatorOpenEditorActionGroup(viewPart); >+ } >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#dispose() >+ */ >+ public void dispose() { >+ if (fOpenGroup != null) { >+ fOpenGroup.dispose(); >+ fOpenGroup = null; >+ } >+ super.dispose(); >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) >+ */ >+ public void fillActionBars(IActionBars actionBars) { >+ if (fOpenGroup != null) { >+ fOpenGroup.updateActionBars(); >+ if (fOpenGroup.getOpenAction().isEnabled()) { >+ actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, fOpenGroup.getOpenAction()); >+ } >+ } >+ >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) >+ */ >+ public void fillContextMenu(IMenuManager menu) { >+ if (fOpenGroup != null) { >+ if (fOpenGroup.getOpenAction().isEnabled()) { >+ fOpenGroup.fillContextMenu(menu); >+ } >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext) >+ */ >+ public void setContext(ActionContext context) { >+ super.setContext(context); >+ if (fOpenGroup != null) { >+ fOpenGroup.setContext(context); >+ } >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorWorkingSetActionProvider.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorWorkingSetActionProvider.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorWorkingSetActionProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorWorkingSetActionProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,138 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilter; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.Separator; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.jface.viewers.StructuredViewer; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.actions.ActionContext; >+import org.eclipse.ui.actions.WorkingSetFilterActionGroup; >+import org.eclipse.ui.navigator.CommonActionProvider; >+import org.eclipse.ui.navigator.ICommonActionExtensionSite; >+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite; >+ >+/** >+ * A Common Navigator action provider adding standard working set filter support. >+ * >+ * @see CNavigatorWorkingSetActionGroup >+ * @see org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilter >+ */ >+public class CNavigatorWorkingSetActionProvider extends CommonActionProvider { >+ >+ private CNavigatorWorkingSetActionGroup fWorkingSetGroup; >+ private WorkingSetFilter fWorkingSetFilter; >+ private boolean fContributed; >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) >+ */ >+ public void fillActionBars(IActionBars actionBars) { >+ if(fWorkingSetGroup != null && !fContributed) { >+ // contribute only once to action bars >+ fContributed= true; >+ // add an extra separator before the working set filter actions >+ // TLETODO [CN] add working set filter actions on top of the menu >+ actionBars.getMenuManager().add(new Separator()); >+ fWorkingSetGroup.fillActionBars(actionBars); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) >+ */ >+ public void fillContextMenu(IMenuManager menu) { >+ if (fWorkingSetGroup != null) { >+ fWorkingSetGroup.fillContextMenu(menu); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite) >+ */ >+ public void init(ICommonActionExtensionSite site) { >+ super.init(site); >+ ICommonViewerWorkbenchSite workbenchSite= null; >+ if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) { >+ workbenchSite= (ICommonViewerWorkbenchSite) site.getViewSite(); >+ } >+ if (workbenchSite != null) { >+ if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) { >+ final StructuredViewer viewer= site.getStructuredViewer(); >+ fWorkingSetFilter= new WorkingSetFilter(); >+ viewer.addFilter(fWorkingSetFilter); >+ IPropertyChangeListener workingSetUpdater= new IPropertyChangeListener() { >+ public void propertyChange(PropertyChangeEvent event) { >+ String property= event.getProperty(); >+ if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) { >+ Object newValue= event.getNewValue(); >+ if (newValue instanceof IWorkingSet) { >+ fWorkingSetFilter.setWorkingSet((IWorkingSet) newValue); >+ viewer.refresh(); >+ } else if (newValue == null) { >+ fWorkingSetFilter.setWorkingSet(null); >+ viewer.refresh(); >+ } >+ } >+ }}; >+ fWorkingSetGroup= new CNavigatorWorkingSetActionGroup(workbenchSite.getShell(), workingSetUpdater); >+ } >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext) >+ */ >+ public void setContext(ActionContext context) { >+ super.setContext(context); >+ if (fWorkingSetGroup != null) { >+ fWorkingSetGroup.setContext(context); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.CommonActionProvider#restoreState(org.eclipse.ui.IMemento) >+ */ >+ public void restoreState(IMemento memento) { >+ super.restoreState(memento); >+ if (fWorkingSetGroup != null && memento != null) { >+ fWorkingSetGroup.restoreState(memento); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.CommonActionProvider#saveState(org.eclipse.ui.IMemento) >+ */ >+ public void saveState(IMemento memento) { >+ super.saveState(memento); >+ if (fWorkingSetGroup != null && memento != null) { >+ fWorkingSetGroup.saveState(memento); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#dispose() >+ */ >+ public void dispose() { >+ if (fWorkingSetGroup != null) { >+ fWorkingSetGroup.dispose(); >+ fWorkingSetGroup= null; >+ } >+ super.dispose(); >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/AbstractCNavigatorActionGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,93 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ * Anton Leherbauer (Wind River Systems) - adaptations for Common Navigator >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import java.net.URL; >+ >+import org.eclipse.cdt.ui.CUIPlugin; >+import org.eclipse.core.runtime.FileLocator; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.util.Assert; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.actions.ActionGroup; >+ >+/** >+ * A basic abstract action group implementation similar to >+ * {@link org.eclipse.cdt.internal.ui.cview.CViewActionGroup}, avoiding >+ * the explicit dependency on {@link org.eclipse.cdt.internal.ui.cview.CView} to >+ * allow reuse in the Common Navigator. >+ * >+ * @see org.eclipse.cdt.internal.ui.cview.CViewActionGroup >+ */ >+public abstract class AbstractCNavigatorActionGroup extends ActionGroup { >+ >+ /** >+ * The view part this action group is associated with. >+ */ >+ private final IViewPart fViewPart; >+ >+ /** >+ * Create a new action group associated with given view part. >+ * >+ * @param viewPart >+ * the view part this action group is associated with, may not be >+ * <code>null</code>. >+ */ >+ public AbstractCNavigatorActionGroup(IViewPart viewPart) { >+ Assert.isNotNull(viewPart); >+ fViewPart = viewPart; >+ makeActions(); >+ } >+ >+ /** >+ * Provide access to the view part this action group has been registered with. >+ * >+ * @return the view part >+ */ >+ protected IViewPart getViewPart() { >+ return fViewPart; >+ } >+ >+ /** >+ * Returns the image descriptor with the given relative path. >+ */ >+ protected ImageDescriptor getImageDescriptor(String relativePath) { >+ String iconPath = "/icons/" + relativePath; //$NON-NLS-1$ >+ URL iconURL = FileLocator.find(CUIPlugin.getDefault().getBundle(), new Path(iconPath), null); >+ // it's safe to pass null >+ return ImageDescriptor.createFromURL(iconURL); >+ } >+ >+ /** >+ * Makes the actions contained in this action group. >+ */ >+ protected abstract void makeActions(); >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) >+ */ >+ public abstract void fillContextMenu(IMenuManager menu); >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) >+ */ >+ public abstract void fillActionBars(IActionBars actionBars); >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#updateActionBars() >+ */ >+ public abstract void updateActionBars(); >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/OpenCElementAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,72 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import org.eclipse.cdt.core.model.ICElement; >+import org.eclipse.cdt.core.model.ISourceReference; >+import org.eclipse.cdt.internal.ui.util.EditorUtility; >+import org.eclipse.cdt.ui.CUIPlugin; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.actions.OpenFileAction; >+ >+/** >+ * Open an editor and navigate to the source location of >+ * the currently selected <code>ICElement</code>. >+ * In case of multiple selections, opening is delegated to >+ * the base class {@link OpenFileAction}. >+ */ >+public class OpenCElementAction extends OpenFileAction { >+ >+ private ICElement fOpenElement; >+ /** >+ * @param page >+ */ >+ public OpenCElementAction(IWorkbenchPage page) { >+ super(page); >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.OpenSystemEditorAction#run() >+ */ >+ public void run() { >+ if (fOpenElement != null) { >+ IEditorPart part; >+ try { >+ part= EditorUtility.openInEditor(fOpenElement); >+ if (fOpenElement instanceof ISourceReference) { >+ EditorUtility.revealInEditor(part, (ICElement)fOpenElement); >+ } >+ } catch (CoreException exc) { >+ CUIPlugin.getDefault().log(exc.getStatus()); >+ } >+ } else { >+ super.run(); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.OpenSystemEditorAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) >+ */ >+ protected boolean updateSelection(IStructuredSelection selection) { >+ fOpenElement = null; >+ if (selection.size() == 1) { >+ Object element = selection.getFirstElement(); >+ if (element instanceof ICElement && element instanceof ISourceReference) { >+ fOpenElement = (ICElement)element; >+ } >+ } >+ return fOpenElement != null || super.updateSelection(selection); >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,63 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import java.util.Iterator; >+ >+import org.eclipse.cdt.core.model.ICElement; >+import org.eclipse.cdt.core.model.ISourceReference; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.dnd.DragSourceEvent; >+import org.eclipse.swt.dnd.Transfer; >+import org.eclipse.ui.navigator.CommonDragAdapterAssistant; >+import org.eclipse.ui.views.navigator.LocalSelectionTransfer; >+ >+ >+/** >+ * A Common Navigator drag assistant for <code>ICElement</code>s being also >+ * <code>ISourceReference</code>s. >+ * >+ * @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter >+ * @see org.eclipse.cdt.internal.ui.cview.CView#initDrag() >+ */ >+public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant { >+ >+ /* >+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#getSupportedTransferTypes() >+ */ >+ public Transfer[] getSupportedTransferTypes() { >+ Transfer[] transfers= new Transfer[] { >+ LocalSelectionTransfer.getInstance() >+ }; >+ return transfers; >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection) >+ */ >+ public boolean setDragData(DragSourceEvent event, >+ IStructuredSelection selection) { >+ if (selection instanceof IStructuredSelection) { >+ for (Iterator iter= ((IStructuredSelection)selection).iterator(); iter.hasNext();) { >+ Object element= iter.next(); >+ if (element instanceof ICElement) { >+ if (!(element instanceof ISourceReference)) { >+ return false; >+ } >+ } >+ } >+ event.data = selection; >+ return true; >+ } >+ return false; >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorWorkingSetActionGroup.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorWorkingSetActionGroup.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorWorkingSetActionGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorWorkingSetActionGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,66 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.IWorkingSet; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.actions.WorkingSetFilterActionGroup; >+ >+/** >+ * A Common Navigator adapted <code>WorkingSetFilterActionGroup</code> adding persistency. >+ * >+ * @see org.eclipse.ui.actions.WorkingSetFilterActionGroup >+ * @see org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup >+ */ >+public class CNavigatorWorkingSetActionGroup extends WorkingSetFilterActionGroup { >+ >+ private static final String TAG_WORKING_SET_NAME= "workingSetName"; //$NON-NLS-1$ >+ >+ /** >+ * Create a new working set filter action group. >+ * @param shell >+ * @param workingSetUpdater >+ */ >+ public CNavigatorWorkingSetActionGroup(Shell shell, IPropertyChangeListener workingSetUpdater) { >+ super(shell, workingSetUpdater); >+ } >+ >+ /** >+ * Saves the state of the filter actions in a memento. >+ * >+ * @param memento the memento >+ */ >+ public void saveState(IMemento memento) { >+ String workingSetName= ""; //$NON-NLS-1$ >+ IWorkingSet workingSet= getWorkingSet(); >+ if (workingSet != null) { >+ workingSetName= workingSet.getName(); >+ } >+ memento.putString(TAG_WORKING_SET_NAME, workingSetName); >+ } >+ >+ /** >+ * Restores the state of the filter actions from a memento. >+ * <p> >+ * Note: This method does not refresh the viewer. >+ * </p> >+ * @param memento >+ */ >+ public void restoreState(IMemento memento) { >+ String workingSetName= memento.getString(TAG_WORKING_SET_NAME); >+ IWorkingSet workingSet= PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSetName); >+ setWorkingSet(workingSet); >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorLabelProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import org.eclipse.cdt.core.model.IArchiveContainer; >+import org.eclipse.cdt.core.model.IBinary; >+import org.eclipse.cdt.core.model.IBinaryContainer; >+import org.eclipse.cdt.core.model.IBinaryModule; >+import org.eclipse.cdt.core.model.ICElement; >+import org.eclipse.cdt.core.model.ICProject; >+import org.eclipse.cdt.internal.ui.cview.CViewLabelProvider; >+import org.eclipse.cdt.internal.ui.cview.CViewMessages; >+import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider; >+import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.model.IWorkbenchAdapter; >+import org.eclipse.ui.navigator.ICommonContentExtensionSite; >+import org.eclipse.ui.navigator.ICommonLabelProvider; >+ >+/** >+ * A label provider suitable for the Common Navigator providing also >+ * status message text for the current selected item. >+ * >+ * @see org.eclipse.cdt.internal.ui.cview.CView#getStatusLineMessage() >+ */ >+public class CNavigatorLabelProvider extends CViewLabelProvider implements ICommonLabelProvider { >+ >+ /** >+ * Create a default label provider. >+ * >+ * @see org.eclipse.cdt.internal.ui.cview.CView#createLabelProvider() >+ */ >+ public CNavigatorLabelProvider() { >+ super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS, >+ AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS >+ | CElementImageProvider.SMALL_ICONS); >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.ICommonLabelProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite) >+ */ >+ public void init(ICommonContentExtensionSite extensionSite) { >+ // no-op >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento) >+ */ >+ public void restoreState(IMemento memento) { >+ // no-op >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento) >+ */ >+ public void saveState(IMemento memento) { >+ // no-op >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(java.lang.Object) >+ */ >+ public String getDescription(Object element) { >+ if (element instanceof IResource) { >+ return ((IResource) element).getFullPath().makeRelative().toString(); >+ } else if (element instanceof ICElement) { >+ ICElement celement = (ICElement) element; >+ IResource res = (IResource) celement.getAdapter(IResource.class); >+ if (res != null) { >+ return res.getFullPath().toString(); >+ } else if (celement.getElementType() == ICElement.C_VCONTAINER) { >+ if (celement instanceof IBinaryContainer) { >+ ICProject cproj = celement.getCProject(); >+ if (cproj != null) { >+ return cproj.getPath() + CViewMessages.getString("CView.binaries"); //$NON-NLS-1$ >+ } >+ } else if (celement instanceof IArchiveContainer) { >+ ICProject cproj = celement.getCProject(); >+ if (cproj != null) { >+ return cproj.getPath() + CViewMessages.getString("CView.archives"); //$NON-NLS-1$ >+ } >+ } else if (celement instanceof IBinaryModule) { >+ IBinary bin = ((IBinaryModule) celement).getBinary(); >+ return bin.getPath() + ":" + celement.getElementName(); //$NON-NLS-1$ >+ } >+ } else if (celement.getElementType() > ICElement.C_UNIT) { >+ return celement.getPath().toString() + " - [" + celement.getElementName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ return celement.getElementName(); >+ } else if (element instanceof IWorkbenchAdapter) { >+ IWorkbenchAdapter wAdapter = (IWorkbenchAdapter)element; >+ return wAdapter.getLabel(element); >+ } >+ return null; >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,258 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import java.lang.reflect.InvocationTargetException; >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.cdt.core.model.CModelException; >+import org.eclipse.cdt.core.model.CoreModel; >+import org.eclipse.cdt.core.model.ICElement; >+import org.eclipse.cdt.core.model.ISourceReference; >+import org.eclipse.cdt.core.model.ITranslationUnit; >+import org.eclipse.cdt.internal.ui.cview.CViewMessages; >+import org.eclipse.cdt.internal.ui.util.ExceptionHandler; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.dialogs.ProgressMonitorDialog; >+import org.eclipse.jface.operation.IRunnableContext; >+import org.eclipse.jface.operation.IRunnableWithProgress; >+import org.eclipse.jface.util.LocalSelectionTransfer; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.swt.dnd.DND; >+import org.eclipse.swt.dnd.DropTargetEvent; >+import org.eclipse.swt.dnd.TransferData; >+import org.eclipse.ui.navigator.CommonDropAdapter; >+import org.eclipse.ui.navigator.CommonDropAdapterAssistant; >+ >+/** >+ * A Common Navigator drop adapter assistant handling dropping of <code>ICElement</code>s. >+ * >+ * @see org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter >+ * @see org.eclipse.cdt.internal.ui.cview.CView#initDrop() >+ */ >+public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { >+ >+ /* >+ * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(org.eclipse.ui.navigator.CommonDropAdapter, org.eclipse.swt.dnd.DropTargetEvent, java.lang.Object) >+ */ >+ public IStatus handleDrop(CommonDropAdapter dropAdapter, >+ DropTargetEvent event, Object target) { >+ try { >+ switch(event.detail) { >+ case DND.DROP_MOVE: >+ return handleDropMove(target, event); >+ case DND.DROP_COPY: >+ return handleDropCopy(target, event); >+ } >+ } catch (CModelException e){ >+ ExceptionHandler.handle(e, CViewMessages.getString("SelectionTransferDropAdapter.error.title"), CViewMessages.getString("SelectionTransferDropAdapter.error.message")); //$NON-NLS-1$ //$NON-NLS-2$ >+ return e.getStatus(); >+ } catch(InvocationTargetException e) { >+ ExceptionHandler.handle(e, CViewMessages.getString("SelectionTransferDropAdapter.error.title"), CViewMessages.getString("SelectionTransferDropAdapter.error.exception")); //$NON-NLS-1$ //$NON-NLS-2$ >+ return Status.CANCEL_STATUS; >+ } catch (InterruptedException e) { >+ //ok >+ } finally { >+ // The drag source listener must not perform any operation >+ // since this drop adapter did the remove of the source even >+ // if we moved something. >+ event.detail= DND.DROP_NONE; >+ } >+ return Status.CANCEL_STATUS; >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData) >+ */ >+ public IStatus validateDrop(Object target, int operation, >+ TransferData transferType) { >+ try { >+ switch(operation) { >+ case DND.DROP_DEFAULT: >+ return handleValidateMove(target); >+ case DND.DROP_COPY: >+ return handleValidateCopy(target); >+ case DND.DROP_MOVE: >+ return handleValidateMove(target); >+ } >+ } catch (CModelException e){ >+ ExceptionHandler.handle(e, CViewMessages.getString("SelectionTransferDropAdapter.error.title"), CViewMessages.getString("SelectionTransferDropAdapter.error.message")); //$NON-NLS-1$ //$NON-NLS-2$ >+ } >+ return Status.CANCEL_STATUS; >+ } >+ >+ private IStatus handleValidateCopy(Object target) throws CModelException{ >+ if (target != null) { >+ >+ ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); >+ ICElement[] cElements= getCElements(selection); >+ >+ if (!canCopyElements(cElements)) >+ return Status.CANCEL_STATUS; >+ >+ if (target instanceof ISourceReference) { >+ return Status.OK_STATUS; >+ } >+ >+ } >+ return Status.CANCEL_STATUS; >+ } >+ >+ private IStatus handleValidateMove(Object target) throws CModelException { >+ if (target != null) { >+ >+ ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); >+ ICElement[] cElements= getCElements(selection); >+ >+ if (!canMoveElements(cElements)) >+ return Status.CANCEL_STATUS; >+ >+ if (target instanceof ISourceReference) { >+ return Status.OK_STATUS; >+ } >+ >+ } >+ return Status.CANCEL_STATUS; >+ } >+ >+ private IStatus handleDropCopy(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{ >+ ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); >+ final ICElement[] cElements= getCElements(selection); >+ >+ if (target instanceof ICElement) { >+ ICElement cTarget = (ICElement)target; >+ ICElement parent = cTarget; >+ boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit; >+ if (!isTargetTranslationUnit) { >+ parent = cTarget.getParent(); >+ } >+ final ICElement[] containers = new ICElement[cElements.length]; >+ for (int i = 0; i < containers.length; ++i) { >+ containers[i] = parent; >+ } >+ ICElement[] neighbours = null; >+ if (!isTargetTranslationUnit) { >+ neighbours = new ICElement[cElements.length]; >+ for (int i = 0; i < neighbours.length; ++i) { >+ neighbours[i] = cTarget; >+ } >+ } >+ final ICElement[] siblings = neighbours; >+ IRunnableWithProgress runnable = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ try { >+ CoreModel.getDefault().getCModel().copy(cElements, containers, siblings, null, false, monitor); >+ } catch (CModelException e) { >+ throw new InvocationTargetException(e); >+ } >+ } >+ }; >+ run(runnable); >+ return Status.OK_STATUS; >+ } >+ return Status.CANCEL_STATUS; >+ } >+ >+ private IStatus handleDropMove(final Object target, DropTargetEvent event) throws CModelException, InvocationTargetException, InterruptedException{ >+ ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); >+ final ICElement[] cElements= getCElements(selection); >+ >+ if (target instanceof ICElement) { >+ ICElement cTarget = (ICElement)target; >+ ICElement parent = cTarget; >+ boolean isTargetTranslationUnit = cTarget instanceof ITranslationUnit; >+ if (!isTargetTranslationUnit) { >+ parent = cTarget.getParent(); >+ } >+ final ICElement[] containers = new ICElement[cElements.length]; >+ for (int i = 0; i < containers.length; ++i) { >+ containers[i] = parent; >+ } >+ ICElement[] neighbours = null; >+ if (!isTargetTranslationUnit) { >+ neighbours = new ICElement[cElements.length]; >+ for (int i = 0; i < neighbours.length; ++i) { >+ neighbours[i] = cTarget; >+ } >+ } >+ final ICElement[] siblings = neighbours; >+ IRunnableWithProgress runnable = new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ try { >+ CoreModel.getDefault().getCModel().move(cElements, containers, siblings, null, false, monitor); >+ } catch (CModelException e) { >+ throw new InvocationTargetException(e); >+ } >+ } >+ }; >+ run(runnable); >+ return Status.OK_STATUS; >+ } >+ return Status.CANCEL_STATUS; >+ } >+ >+ public void run(IRunnableWithProgress runnable) throws InterruptedException, InvocationTargetException { >+ IRunnableContext context= new ProgressMonitorDialog(getShell()); >+ context.run(true, true, runnable); >+ } >+ >+ public static ICElement[] getCElements(ISelection selection) { >+ if (!(selection instanceof IStructuredSelection)) { >+ return null; >+ } >+ List elements = ((IStructuredSelection)selection).toList(); >+ List resources= new ArrayList(elements.size()); >+ for (Iterator iter= elements.iterator(); iter.hasNext();) { >+ Object element= iter.next(); >+ if (element instanceof ITranslationUnit) { >+ continue; >+ } >+ if (element instanceof ICElement) >+ resources.add(element); >+ } >+ return (ICElement[]) resources.toArray(new ICElement[resources.size()]); >+ } >+ >+ private static boolean canCopyElements(ICElement[] cElements) { >+ if (cElements != null) { >+ return hasCommonParent(cElements); >+ } >+ return false; >+ } >+ >+ private static boolean canMoveElements(ICElement[] cElements) { >+ if (cElements != null) { >+ return hasCommonParent(cElements); >+ } >+ return false; >+ } >+ >+ private static boolean hasCommonParent(ICElement[] elements) { >+ if (elements.length > 1) { >+ ICElement parent = elements[0]; >+ for (int i = 0; i < elements.length; ++i) { >+ ICElement p = elements[i].getParent(); >+ if (parent == null && p!= null) { >+ return false; >+ } else if (!parent.equals(p)){ >+ return false; >+ } >+ } >+ } >+ return true; >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorOpenEditorActionGroup.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,149 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ * Anton Leherbauer (Wind River Systems) - adaptations for Common Navigator >+ *******************************************************************************/ >+ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import org.eclipse.cdt.internal.ui.actions.SelectionConverter; >+import org.eclipse.cdt.internal.ui.cview.CViewMessages; >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.action.IMenuManager; >+import org.eclipse.jface.action.MenuManager; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.ui.IActionBars; >+import org.eclipse.ui.IViewPart; >+import org.eclipse.ui.actions.OpenFileAction; >+import org.eclipse.ui.actions.OpenInNewWindowAction; >+import org.eclipse.ui.actions.OpenWithMenu; >+import org.eclipse.ui.navigator.ICommonMenuConstants; >+ >+ >+/** >+ * This is basically a clone of {@link org.eclipse.cdt.internal.ui.OpenFileGroup}, >+ * but without explicit dependency on CView. This opens it up for use in the >+ * Common Navigator framework. >+ * <p> >+ * Contributes an "Open" action for the default editor, an "Open With" sub-menu >+ * for all applicable editors if one or more files are selected. >+ * For all container selections, an "Open In New Window" action is contributed. >+ * </p> >+ * >+ * @see org.eclipse.cdt.internal.ui.cview.OpenFileGroup >+ * @see org.eclipse.ui.actions.OpenFileAction >+ * @see org.eclipse.ui.actions.OpenWithMenu >+ * @see org.eclipse.ui.actions.OpenInNewWindowAction >+ */ >+public class CNavigatorOpenEditorActionGroup extends AbstractCNavigatorActionGroup { >+ >+ /** The open file action. */ >+ private OpenFileAction fOpenFileAction; >+ >+ /** >+ * Create an action group for the given view part. >+ * >+ * @param viewPart >+ */ >+ public CNavigatorOpenEditorActionGroup(IViewPart viewPart) { >+ super(viewPart); >+ } >+ >+ protected void makeActions() { >+ fOpenFileAction= new OpenCElementAction(getViewPart().getSite().getPage()); >+ } >+ >+ public void fillContextMenu(IMenuManager menu) { >+ IStructuredSelection celements= (IStructuredSelection) getContext().getSelection(); >+ IStructuredSelection selection= SelectionConverter.convertSelectionToResources(celements); >+ >+ fOpenFileAction.selectionChanged(celements); >+ if (fOpenFileAction.isEnabled()) { >+ menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, fOpenFileAction); >+ fillOpenWithMenu(menu, selection); >+ } >+ >+ addNewWindowAction(menu, selection); >+ } >+ >+ /** >+ * Adds the OpenWith submenu to the context menu. >+ * >+ * @param menu >+ * the context menu >+ * @param selection >+ * the current selection >+ */ >+ private void fillOpenWithMenu(IMenuManager menu, IStructuredSelection selection) { >+ // Only supported if exactly one file is selected. >+ if (selection.size() != 1) { >+ return; >+ } >+ Object element= selection.getFirstElement(); >+ if (!(element instanceof IFile)) { >+ return; >+ } >+ >+ MenuManager submenu= new MenuManager(CViewMessages.getString("OpenWithMenu.label"), ICommonMenuConstants.GROUP_OPEN_WITH); //$NON-NLS-1$ >+ submenu.add(new OpenWithMenu(getViewPart().getSite().getPage(), (IFile) element)); >+ menu.insertAfter(ICommonMenuConstants.GROUP_OPEN_WITH, submenu); >+ } >+ >+ /** >+ * Adds the Open in New Window action to the context menu. >+ * >+ * @param menu >+ * the context menu >+ * @param selection >+ * the current selection >+ */ >+ private void addNewWindowAction(IMenuManager menu, IStructuredSelection selection) { >+ >+ // Only supported if exactly one container (i.e open project or folder) is selected. >+ if (selection.size() != 1) { >+ return; >+ } >+ Object element= selection.getFirstElement(); >+ if (!(element instanceof IContainer)) { >+ return; >+ } >+ if (element instanceof IProject && !(((IProject) element).isOpen())) { >+ return; >+ } >+ >+ menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, new OpenInNewWindowAction(getViewPart().getSite().getWorkbenchWindow(), (IContainer) element)); >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars) >+ */ >+ public void fillActionBars(IActionBars actionBars) { >+ } >+ >+ /* >+ * @see org.eclipse.ui.actions.ActionGroup#updateActionBars() >+ */ >+ public void updateActionBars() { >+ IStructuredSelection celements= (IStructuredSelection) getContext().getSelection(); >+ fOpenFileAction.selectionChanged(celements); >+ } >+ >+ /** >+ * Returns the open action managed by this action group. >+ * >+ * @return the open action >+ */ >+ IAction getOpenAction() { >+ return fOpenFileAction; >+ } >+ >+} >Index: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java >=================================================================== >RCS file: src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java >diff -N src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,334 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Anton Leherbauer (Wind River Systems) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.internal.ui.navigator; >+ >+import java.util.Arrays; >+import java.util.Iterator; >+import java.util.LinkedHashSet; >+import java.util.List; >+import java.util.Set; >+ >+import org.eclipse.cdt.core.model.CoreModel; >+import org.eclipse.cdt.core.model.ICElement; >+import org.eclipse.cdt.core.model.ICModel; >+import org.eclipse.cdt.internal.ui.cview.CViewContentProvider; >+import org.eclipse.cdt.ui.CUIPlugin; >+import org.eclipse.cdt.ui.PreferenceConstants; >+import org.eclipse.core.resources.IContainer; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IWorkspaceRoot; >+import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.jface.viewers.Viewer; >+import org.eclipse.ui.IMemento; >+import org.eclipse.ui.navigator.ICommonContentExtensionSite; >+import org.eclipse.ui.navigator.IExtensionStateModel; >+import org.eclipse.ui.navigator.IPipelinedTreeContentProvider; >+import org.eclipse.ui.navigator.PipelinedShapeModification; >+import org.eclipse.ui.navigator.PipelinedViewerUpdate; >+ >+/** >+ * A content provider populating a Common Navigator view with CDT model content. >+ */ >+public class CNavigatorContentProvider extends CViewContentProvider implements IPipelinedTreeContentProvider { >+ >+ /** The CN extension state model for persisting viewer options */ >+ private IExtensionStateModel fStateModel; >+ /** The input object as supplied in the call to {@link #inputChanged()} */ >+ private Object fRealInput; >+ private IPropertyChangeListener fPropertyChangeListener; >+ >+ /* >+ * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite) >+ */ >+ public void init(ICommonContentExtensionSite commonContentExtensionSite) { >+ IExtensionStateModel stateModel= commonContentExtensionSite.getExtensionStateModel(); >+ IMemento memento= commonContentExtensionSite.getMemento(); >+ >+ fStateModel= stateModel; >+ restoreState(memento); >+ fPropertyChangeListener= new IPropertyChangeListener() { >+ public void propertyChange(PropertyChangeEvent event) { >+ boolean refreshViewer= false; >+ String property= event.getProperty(); >+ >+ if (property.equals(PreferenceConstants.PREF_SHOW_CU_CHILDREN)) { >+ boolean showCUChildren= fStateModel.getBooleanProperty(PreferenceConstants.PREF_SHOW_CU_CHILDREN); >+ setProvideMembers(showCUChildren); >+ refreshViewer= true; >+ } else if (property.equals(PreferenceConstants.CVIEW_GROUP_INCLUDES)) { >+ boolean groupIncludes= fStateModel.getBooleanProperty(PreferenceConstants.CVIEW_GROUP_INCLUDES); >+ setIncludesGrouping(groupIncludes); >+ refreshViewer= true; >+ } >+ >+ if (refreshViewer && getViewer() != null) { >+ getViewer().refresh(); >+ } >+ } >+ }; >+ CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener); >+ // TLETODO [CN] use extension state model for view options persistence >+// fStateModel.addPropertyChangeListener(listener); >+ } >+ >+ /* >+ * @see org.eclipse.cdt.ui.CElementContentProvider#dispose() >+ */ >+ public void dispose() { >+ CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener); >+ // TLETODO [CN] use extension state model for view options persistence >+// fStateModel.removePropertyChangeListener(fPropertyChangeListener); >+ super.dispose(); >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento) >+ */ >+ public void restoreState(IMemento memento) { >+ IPreferenceStore store= PreferenceConstants.getPreferenceStore(); >+ boolean showCUChildren= store.getBoolean(PreferenceConstants.PREF_SHOW_CU_CHILDREN); >+ boolean groupIncludes= store.getBoolean(PreferenceConstants.CVIEW_GROUP_INCLUDES); >+ if (memento != null) { >+ String mementoValue= memento.getString(PreferenceConstants.PREF_SHOW_CU_CHILDREN); >+ if (mementoValue != null) { >+ showCUChildren= Boolean.parseBoolean(mementoValue); >+ } >+ mementoValue= memento.getString(PreferenceConstants.CVIEW_GROUP_INCLUDES); >+ if (mementoValue != null) { >+ groupIncludes= Boolean.parseBoolean(mementoValue); >+ } >+ } >+ setProvideMembers(showCUChildren); >+ setIncludesGrouping(groupIncludes); >+ setProvideWorkingCopy(true); >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento) >+ */ >+ public void saveState(IMemento memento) { >+ if (memento != null) { >+ memento.putString(PreferenceConstants.PREF_SHOW_CU_CHILDREN, String.valueOf(getProvideMembers())); >+ memento.putString(PreferenceConstants.CVIEW_GROUP_INCLUDES, String.valueOf(areIncludesGroup())); >+ } >+ } >+ >+ /* >+ * @see org.eclipse.cdt.ui.CElementContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) >+ */ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ fRealInput= newInput; >+ super.inputChanged(viewer, oldInput, findInputElement(newInput)); >+ } >+ >+ private Object findInputElement(Object newInput) { >+ if (newInput instanceof IWorkspaceRoot) { >+ return CoreModel.create((IWorkspaceRoot) newInput); >+ } >+ return newInput; >+ } >+ >+ /* >+ * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#getParent(java.lang.Object) >+ */ >+ public Object getParent(Object element) { >+ Object parent= super.getParent(element); >+ if (parent instanceof ICModel) { >+ return getViewerInput() != null ? fRealInput : parent; >+ } >+ return parent; >+ } >+ >+ /** >+ * Access the viewer input. >+ * @return the viewer input >+ */ >+ protected Object getViewerInput() { >+ return fInput; >+ } >+ >+ /** >+ * Access the viewer. >+ * @return the viewer >+ */ >+ protected Viewer getViewer() { >+ return fViewer; >+ } >+ >+ /* >+ * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#getElements(java.lang.Object) >+ */ >+ public Object[] getElements(Object parent) { >+ if (parent instanceof IWorkspaceRoot) { >+ return super.getElements(CoreModel.create((IWorkspaceRoot)parent)); >+ } >+ return super.getElements(parent); >+ } >+ >+ /* >+ * @see org.eclipse.cdt.internal.ui.cview.CViewContentProvider#getChildren(java.lang.Object) >+ */ >+ public Object[] getChildren(Object element) { >+ Object children[]; >+ if (element instanceof IWorkspaceRoot) { >+ children = super.getChildren(CoreModel.create((IWorkspaceRoot)element)); >+ } else { >+ children = super.getChildren(element); >+ } >+ return children; >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set) >+ */ >+ public void getPipelinedChildren(Object parent, Set currentChildren) { >+ Object[] children= getChildren(parent); >+ for (Iterator iter= currentChildren.iterator(); iter.hasNext();) { >+ if (iter.next() instanceof IResource) { >+ iter.remove(); >+ } >+ } >+ currentChildren.addAll(Arrays.asList(children)); >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set) >+ */ >+ public void getPipelinedElements(Object input, Set currentElements) { >+ // only replace plain resource elements with custom elements >+ // and avoid duplicating elements already customized >+ // by upstream content providers >+ Object[] elements= getElements(input); >+ List elementList= Arrays.asList(elements); >+ for (Iterator iter= currentElements.iterator(); iter.hasNext();) { >+ Object element= iter.next(); >+ IResource resource= null; >+ if (element instanceof IResource) { >+ resource= (IResource)element; >+ } else if (element instanceof IAdaptable) { >+ resource= (IResource)((IAdaptable)element).getAdapter(IResource.class); >+ } >+ if (resource != null) { >+ int i= elementList.indexOf(resource); >+ if (i >= 0) { >+ elements[i]= null; >+ } >+ } >+ } >+ for (int i= 0; i < elements.length; i++) { >+ Object element= elements[i]; >+ if (element instanceof ICElement) { >+ ICElement cElement= (ICElement)element; >+ IResource resource= cElement.getResource(); >+ if (resource != null) { >+ currentElements.remove(resource); >+ } >+ currentElements.add(element); >+ } else if (element != null) { >+ currentElements.add(element); >+ } >+ } >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedParent(java.lang.Object, java.lang.Object) >+ */ >+ public Object getPipelinedParent(Object object, Object suggestedParent) { >+ return getParent(object); >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptAdd(org.eclipse.ui.navigator.PipelinedShapeModification) >+ */ >+ public PipelinedShapeModification interceptAdd(PipelinedShapeModification addModification) { >+ convertToCElements(addModification); >+ return addModification; >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRefresh(org.eclipse.ui.navigator.PipelinedViewerUpdate) >+ */ >+ public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) { >+ return convertToCElements(refreshSynchronization.getRefreshTargets()); >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRemove(org.eclipse.ui.navigator.PipelinedShapeModification) >+ */ >+ public PipelinedShapeModification interceptRemove(PipelinedShapeModification removeModification) { >+ convertToCElements(removeModification.getChildren()); >+ return removeModification; >+ } >+ >+ /* >+ * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptUpdate(org.eclipse.ui.navigator.PipelinedViewerUpdate) >+ */ >+ public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) { >+ return convertToCElements(updateSynchronization.getRefreshTargets()); >+ } >+ >+ /** >+ * Converts the shape modification to use ICElements. >+ * >+ * @param modification >+ * the shape modification to convert >+ * @return <code>true</code> if the shape modification set was modified >+ */ >+ private boolean convertToCElements( >+ PipelinedShapeModification modification) { >+ Object parent= modification.getParent(); >+ if (parent instanceof IContainer) { >+ ICElement element= CoreModel.getDefault().create((IContainer) parent); >+ if (element != null && element.exists()) { >+ // don't convert the root >+ if( !(element instanceof ICModel)) { >+ modification.setParent(element); >+ } >+ return convertToCElements(modification.getChildren()); >+ >+ } >+ } >+ return false; >+ } >+ >+ /** >+ * Converts the given set to ICElements. >+ * >+ * @param currentChildren >+ * The set of current children that would be contributed or >+ * refreshed in the viewer. >+ * @return <code>true</code> if the input set was modified >+ */ >+ private boolean convertToCElements(Set currentChildren) { >+ LinkedHashSet convertedChildren= new LinkedHashSet(); >+ ICElement newChild; >+ for (Iterator iter= currentChildren.iterator(); iter.hasNext();) { >+ Object child= iter.next(); >+ if (child instanceof IResource) { >+ if ((newChild= CoreModel.getDefault().create((IResource) child)) != null >+ && newChild.exists()) { >+ iter.remove(); >+ convertedChildren.add(newChild); >+ } >+ } >+ } >+ if (!convertedChildren.isEmpty()) { >+ currentChildren.addAll(convertedChildren); >+ return true; >+ } >+ return false; >+ >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 140337
: 45522 |
45567