1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 23:05:47 +02:00

fixed global actions

This commit is contained in:
David Inglis 2002-10-28 14:44:27 +00:00
parent 66b60c7ba4
commit 5c67633999
2 changed files with 72 additions and 30 deletions

View file

@ -1,3 +1,8 @@
2002-10-28 David Inglis
* /src/.../ui/cview/CView.java
Hookup actions to global actions in Projects menu, (build actions and close project).
2002-10-25 Judy N. Green 2002-10-25 Judy N. Green
Removed a redundant "Eclipse Platform" from the plugin.properties file. Removed a redundant "Eclipse Platform" from the plugin.properties file.
It was resulting in weird looking titles. It was resulting in weird looking titles.

View file

@ -8,11 +8,35 @@ package org.eclipse.cdt.internal.ui.cview;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IArchive;
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.ICElement;
import org.eclipse.cdt.core.model.ICFile;
import org.eclipse.cdt.core.model.ICRoot;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.resources.MakeUtil;
import org.eclipse.cdt.internal.ui.CContentProvider;
import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
import org.eclipse.cdt.internal.ui.makeview.MakeAction;
import org.eclipse.cdt.internal.ui.makeview.MakeTarget;
import org.eclipse.cdt.internal.ui.makeview.MakeTargetAction;
import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -63,6 +87,7 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.AddBookmarkAction; import org.eclipse.ui.actions.AddBookmarkAction;
import org.eclipse.ui.actions.BuildAction;
import org.eclipse.ui.actions.CloseResourceAction; import org.eclipse.ui.actions.CloseResourceAction;
import org.eclipse.ui.actions.CopyResourceAction; import org.eclipse.ui.actions.CopyResourceAction;
import org.eclipse.ui.actions.CreateFileAction; import org.eclipse.ui.actions.CreateFileAction;
@ -73,6 +98,7 @@ import org.eclipse.ui.actions.NewWizardAction;
import org.eclipse.ui.actions.NewWizardMenu; import org.eclipse.ui.actions.NewWizardMenu;
import org.eclipse.ui.actions.OpenFileAction; import org.eclipse.ui.actions.OpenFileAction;
import org.eclipse.ui.actions.OpenPerspectiveMenu; import org.eclipse.ui.actions.OpenPerspectiveMenu;
import org.eclipse.ui.actions.OpenResourceAction;
import org.eclipse.ui.actions.OpenSystemEditorAction; import org.eclipse.ui.actions.OpenSystemEditorAction;
import org.eclipse.ui.actions.OpenWithMenu; import org.eclipse.ui.actions.OpenWithMenu;
import org.eclipse.ui.actions.RefreshAction; import org.eclipse.ui.actions.RefreshAction;
@ -88,28 +114,6 @@ import org.eclipse.ui.views.framelist.FrameList;
import org.eclipse.ui.views.framelist.GoIntoAction; import org.eclipse.ui.views.framelist.GoIntoAction;
import org.eclipse.ui.views.framelist.UpAction; import org.eclipse.ui.views.framelist.UpAction;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IArchive;
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.ICElement;
import org.eclipse.cdt.core.model.ICFile;
import org.eclipse.cdt.core.model.ICRoot;
import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.resources.MakeUtil;
import org.eclipse.cdt.internal.ui.CContentProvider;
import org.eclipse.cdt.internal.ui.CPlugin;
import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
import org.eclipse.cdt.internal.ui.makeview.MakeAction;
import org.eclipse.cdt.internal.ui.makeview.MakeTarget;
import org.eclipse.cdt.internal.ui.makeview.MakeTargetAction;
import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
@ -135,7 +139,11 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
CreateFileAction createFileAction; CreateFileAction createFileAction;
CreateFolderAction createFolderAction; CreateFolderAction createFolderAction;
NewWizardAction newWizardAction; NewWizardAction newWizardAction;
CloseResourceAction closeResourceAction;
CloseResourceAction closeProjectAction;
OpenResourceAction openProjectAction;
BuildAction buildAction;
BuildAction rebuildAction;
// CElement action // CElement action
OpenIncludeAction openIncludeAction; OpenIncludeAction openIncludeAction;
@ -350,6 +358,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
void handleSelectionChanged(SelectionChangedEvent event) { void handleSelectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection(); IStructuredSelection sel = (IStructuredSelection) event.getSelection();
updateStatusLine(sel); updateStatusLine(sel);
updateActions(sel);
updateGlobalActions(sel); updateGlobalActions(sel);
goIntoAction.update(); goIntoAction.update();
linkToEditor(sel); linkToEditor(sel);
@ -438,6 +447,9 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
viewer.removeTreeListener(expansionListener); viewer.removeTreeListener(expansionListener);
CPlugin.getDefault().getProblemMarkerManager().removeListener(viewer); CPlugin.getDefault().getProblemMarkerManager().removeListener(viewer);
} }
IWorkspace workspace = CPlugin.getWorkspace();
workspace.removeResourceChangeListener(closeProjectAction);
workspace.removeResourceChangeListener(openProjectAction);
super.dispose(); super.dispose();
} }
@ -492,8 +504,9 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
openFileAction = new OpenFileAction(getSite().getPage()); openFileAction = new OpenFileAction(getSite().getPage());
openSystemEditorAction = new OpenSystemEditorAction(getSite().getPage()); openSystemEditorAction = new OpenSystemEditorAction(getSite().getPage());
refreshAction = new RefreshAction(shell); refreshAction = new RefreshAction(shell);
//buildAction = new BuildAction(shell, IncrementalProjectBuilder.INCREMENTAL_BUILD); buildAction =
//rebuildAction = new BuildAction(shell, IncrementalProjectBuilder.FULL_BUILD); new BuildAction(shell, IncrementalProjectBuilder.INCREMENTAL_BUILD);
rebuildAction = new BuildAction(shell, IncrementalProjectBuilder.FULL_BUILD);
makeTargetAction = new MakeTargetAction(shell); makeTargetAction = new MakeTargetAction(shell);
moveResourceAction = new MoveResourceAction (shell); moveResourceAction = new MoveResourceAction (shell);
copyResourceAction = new CopyResourceAction(shell); copyResourceAction = new CopyResourceAction(shell);
@ -512,7 +525,12 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
newWizardAction = new NewWizardAction(); newWizardAction = new NewWizardAction();
closeResourceAction = new CloseResourceAction(shell); IWorkspace workspace = CPlugin.getWorkspace();
openProjectAction = new OpenResourceAction(shell);
workspace.addResourceChangeListener(openProjectAction, IResourceChangeEvent.POST_CHANGE);
closeProjectAction = new CloseResourceAction(shell);
workspace.addResourceChangeListener(closeProjectAction, IResourceChangeEvent.POST_CHANGE);
//sortByNameAction = new SortViewAction(this, false); //sortByNameAction = new SortViewAction(this, false);
//sortByTypeAction = new SortViewAction(this, true); //sortByTypeAction = new SortViewAction(this, true);
@ -546,6 +564,21 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
IActionBars actionBars = getViewSite().getActionBars(); IActionBars actionBars = getViewSite().getActionBars();
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.DELETE, deleteResourceAction); actionBars.setGlobalActionHandler(IWorkbenchActionConstants.DELETE, deleteResourceAction);
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, addBookmarkAction); actionBars.setGlobalActionHandler(IWorkbenchActionConstants.BOOKMARK, addBookmarkAction);
actionBars.setGlobalActionHandler(
IWorkbenchActionConstants.REFRESH,
refreshAction);
actionBars.setGlobalActionHandler(
IWorkbenchActionConstants.BUILD_PROJECT,
buildAction);
actionBars.setGlobalActionHandler(
IWorkbenchActionConstants.REBUILD_PROJECT,
rebuildAction);
actionBars.setGlobalActionHandler(
IWorkbenchActionConstants.OPEN_PROJECT,
openProjectAction);
actionBars.setGlobalActionHandler(
IWorkbenchActionConstants.CLOSE_PROJECT,
closeProjectAction);
} }
@ -556,8 +589,6 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
* E.g. A project was opened or closed. * E.g. A project was opened or closed.
*/ */
void updateActions(IStructuredSelection selection) { void updateActions(IStructuredSelection selection) {
//buildAction.selectionChanged(selection);
//rebuildAction.selectionChanged(selection);
makeTargetAction.selectionChanged(selection); makeTargetAction.selectionChanged(selection);
copyResourceAction.selectionChanged(selection); copyResourceAction.selectionChanged(selection);
refreshAction.selectionChanged(selection); refreshAction.selectionChanged(selection);
@ -566,7 +597,6 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
openSystemEditorAction.selectionChanged(selection); openSystemEditorAction.selectionChanged(selection);
propertyDialogAction.selectionChanged(selection); propertyDialogAction.selectionChanged(selection);
renameResourceAction.selectionChanged(selection); renameResourceAction.selectionChanged(selection);
closeResourceAction.selectionChanged(selection);
//sortByTypeAction.selectionChanged(selection); //sortByTypeAction.selectionChanged(selection);
//sortByNameAction.selectionChanged(selection); //sortByNameAction.selectionChanged(selection);
updateGlobalActions(selection); updateGlobalActions(selection);
@ -590,6 +620,13 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
actionBars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copyResourceAction); actionBars.setGlobalActionHandler(IWorkbenchActionConstants.COPY, copyResourceAction);
actionBars.updateActionBars(); actionBars.updateActionBars();
renameResourceAction.selectionChanged(selection); renameResourceAction.selectionChanged(selection);
refreshAction.selectionChanged(selection);
buildAction.selectionChanged(selection);
rebuildAction.selectionChanged(selection);
openProjectAction.selectionChanged(selection);
closeProjectAction.selectionChanged(selection);
} }
@ -770,7 +807,7 @@ public class CView extends ViewPart implements IMenuListener, ISetSelectionTarge
menu.add(new Separator ()); menu.add(new Separator ());
if (resource instanceof IProject) { if (resource instanceof IProject) {
menu.add(closeResourceAction); menu.add(closeProjectAction);
} }
if (resource instanceof IFile || resource instanceof IFolder) { if (resource instanceof IFile || resource instanceof IFolder) {