Stop using deprecated Action contstructors taking Shell param.
Change-Id: Ia27d41b7b9d433125a90bcc0fe29bb62bb4bc1be
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/BuildActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/BuildActionGroup.java
index 0665040..534e406 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/BuildActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/BuildActionGroup.java
@@ -17,7 +17,6 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
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.IWorkbenchSite;
@@ -26,7 +25,6 @@
import org.eclipse.ui.actions.BuildAction;
import org.eclipse.ui.ide.IDEActionFactory;
-
/**
* Contributes all build related actions to the context menu and installs
* handlers for the corresponding global menu actions.
@@ -42,25 +40,27 @@
private IWorkbenchSite fSite;
private BuildAction fBuildAction;
- private RefreshAction fRefreshAction;
+ private RefreshAction fRefreshAction;
/**
- * Creates a new <code>BuildActionGroup</code>. The group requires that
- * the selection provided by the view part's selection provider is of type
+ * Creates a new <code>BuildActionGroup</code>. The group requires that the
+ * selection provided by the view part's selection provider is of type
* <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
*
- * @param part the view part that owns this action group
+ * @param part
+ * the view part that owns this action group
*/
public BuildActionGroup(IViewPart part) {
- fSite= part.getSite();
- Shell shell= fSite.getShell();
- ISelectionProvider provider= fSite.getSelectionProvider();
+ fSite = part.getSite();
+ ISelectionProvider provider = fSite.getSelectionProvider();
- fBuildAction= new BuildAction(shell, IncrementalProjectBuilder.INCREMENTAL_BUILD);
+ fBuildAction = new BuildAction(fSite,
+ IncrementalProjectBuilder.INCREMENTAL_BUILD);
fBuildAction.setText(ActionMessages.BuildAction_label);
- fBuildAction.setActionDefinitionId("org.eclipse.ui.project.buildProject"); //$NON-NLS-1$
+ fBuildAction
+ .setActionDefinitionId("org.eclipse.ui.project.buildProject"); //$NON-NLS-1$
- fRefreshAction= new RefreshAction(fSite);
+ fRefreshAction = new RefreshAction(fSite);
fRefreshAction.setActionDefinitionId("org.eclipse.ui.file.refresh"); //$NON-NLS-1$
provider.addSelectionChangedListener(fBuildAction);
@@ -71,7 +71,7 @@
* Returns the refresh action managed by this group.
*
* @return the refresh action. If this group doesn't manage a refresh action
- * <code>null</code> is returned
+ * <code>null</code> is returned
*/
public IAction getRefreshAction() {
return fRefreshAction;
@@ -85,8 +85,9 @@
@Override
public void fillContextMenu(IMenuManager menu) {
- ISelection selection= getContext().getSelection();
- if (!ResourcesPlugin.getWorkspace().isAutoBuilding() && isBuildTarget(selection)) {
+ ISelection selection = getContext().getSelection();
+ if (!ResourcesPlugin.getWorkspace().isAutoBuilding()
+ && isBuildTarget(selection)) {
appendToGroup(menu, fBuildAction);
}
appendToGroup(menu, fRefreshAction);
@@ -95,15 +96,17 @@
@Override
public void dispose() {
- ISelectionProvider provider= fSite.getSelectionProvider();
+ ISelectionProvider provider = fSite.getSelectionProvider();
provider.removeSelectionChangedListener(fBuildAction);
provider.removeSelectionChangedListener(fRefreshAction);
super.dispose();
}
private void setGlobalActionHandlers(IActionBars actionBar) {
- actionBar.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), fBuildAction);
- actionBar.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
+ actionBar.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(),
+ fBuildAction);
+ actionBar.setGlobalActionHandler(ActionFactory.REFRESH.getId(),
+ fRefreshAction);
}
private void appendToGroup(IMenuManager menu, IAction action) {
@@ -114,7 +117,7 @@
private boolean isBuildTarget(ISelection s) {
if (!(s instanceof IStructuredSelection))
return false;
- IStructuredSelection selection= (IStructuredSelection)s;
+ IStructuredSelection selection = (IStructuredSelection) s;
if (selection.size() != 1)
return false;
return selection.getFirstElement() instanceof IScriptProject;
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ProjectActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ProjectActionGroup.java
index a930a34..fbb3f82 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ProjectActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/ProjectActionGroup.java
@@ -19,7 +19,6 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
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.IWorkbenchSite;
@@ -28,7 +27,6 @@
import org.eclipse.ui.actions.CloseUnrelatedProjectsAction;
import org.eclipse.ui.ide.IDEActionFactory;
-
/**
* Adds actions to open and close a project to the global menu bar.
*
@@ -47,29 +45,30 @@
private CloseResourceAction fCloseUnrelatedAction;
/**
- * Creates a new <code>ProjectActionGroup</code>. The group requires
- * that the selection provided by the site's selection provider is of type <code>
+ * Creates a new <code>ProjectActionGroup</code>. The group requires that
+ * the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
- * @param part the view part that owns this action group
+ * @param part
+ * the view part that owns this action group
*/
public ProjectActionGroup(IViewPart part) {
fSite = part.getSite();
- Shell shell= fSite.getShell();
- ISelectionProvider provider= fSite.getSelectionProvider();
- ISelection selection= provider.getSelection();
+ ISelectionProvider provider = fSite.getSelectionProvider();
+ ISelection selection = provider.getSelection();
- fCloseAction= new CloseResourceAction(shell);
- fCloseAction.setActionDefinitionId("org.eclipse.ui.project.closeProject"); //$NON-NLS-1$
+ fCloseAction = new CloseResourceAction(fSite);
+ fCloseAction
+ .setActionDefinitionId("org.eclipse.ui.project.closeProject"); //$NON-NLS-1$
+ fCloseUnrelatedAction = new CloseUnrelatedProjectsAction(fSite);
+ fCloseUnrelatedAction.setActionDefinitionId(
+ "org.eclipse.ui.project.closeUnrelatedProjects"); //$NON-NLS-1$
- fCloseUnrelatedAction= new CloseUnrelatedProjectsAction(shell);
- fCloseUnrelatedAction.setActionDefinitionId("org.eclipse.ui.project.closeUnrelatedProjects"); //$NON-NLS-1$
-
- fOpenAction= new OpenProjectAction(fSite);
+ fOpenAction = new OpenProjectAction(fSite);
fOpenAction.setActionDefinitionId("org.eclipse.ui.project.openProject"); //$NON-NLS-1$
if (selection instanceof IStructuredSelection) {
- IStructuredSelection s= (IStructuredSelection)selection;
+ IStructuredSelection s = (IStructuredSelection) selection;
fOpenAction.selectionChanged(s);
fCloseAction.selectionChanged(s);
fCloseUnrelatedAction.selectionChanged(s);
@@ -77,7 +76,7 @@
provider.addSelectionChangedListener(fOpenAction);
provider.addSelectionChangedListener(fCloseAction);
provider.addSelectionChangedListener(fCloseUnrelatedAction);
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(fOpenAction);
workspace.addResourceChangeListener(fCloseAction);
workspace.addResourceChangeListener(fCloseUnrelatedAction);
@@ -86,9 +85,13 @@
@Override
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), fCloseAction);
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), fCloseUnrelatedAction);
- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), fOpenAction);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.CLOSE_PROJECT.getId(), fCloseAction);
+ actionBars.setGlobalActionHandler(
+ IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(),
+ fCloseUnrelatedAction);
+ actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(),
+ fOpenAction);
}
@Override
@@ -98,19 +101,21 @@
menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fOpenAction);
if (fCloseAction.isEnabled())
menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fCloseAction);
- if (fCloseUnrelatedAction.isEnabled() && areOnlyProjectsSelected(fCloseUnrelatedAction.getStructuredSelection()))
- menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fCloseUnrelatedAction);
+ if (fCloseUnrelatedAction.isEnabled() && areOnlyProjectsSelected(
+ fCloseUnrelatedAction.getStructuredSelection()))
+ menu.appendToGroup(IContextMenuConstants.GROUP_BUILD,
+ fCloseUnrelatedAction);
}
private boolean areOnlyProjectsSelected(IStructuredSelection selection) {
if (selection.isEmpty())
return false;
- Iterator iter= selection.iterator();
+ Iterator iter = selection.iterator();
while (iter.hasNext()) {
- Object obj= iter.next();
+ Object obj = iter.next();
if (obj instanceof IAdaptable) {
- if (((IAdaptable)obj).getAdapter(IProject.class) == null)
+ if (((IAdaptable) obj).getAdapter(IProject.class) == null)
return false;
}
}
@@ -130,7 +135,7 @@
@Override
public void dispose() {
- ISelectionProvider provider= fSite.getSelectionProvider();
+ ISelectionProvider provider = fSite.getSelectionProvider();
provider.removeSelectionChangedListener(fOpenAction);
provider.removeSelectionChangedListener(fCloseAction);
provider.removeSelectionChangedListener(fCloseUnrelatedAction);