diff options
Diffstat (limited to 'core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java')
-rw-r--r-- | core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java | 93 |
1 files changed, 57 insertions, 36 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java index b7bd12c966a..257f6181443 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/actions/DeleteResConfigsAction.java @@ -55,11 +55,10 @@ import org.eclipse.cdt.internal.ui.actions.DeleteResConfigsHandler; * @deprecated as of CDT 8.0 now using {@link DeleteResConfigsHandler} */ @Deprecated -public class DeleteResConfigsAction -implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { +public class DeleteResConfigsAction implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { protected ArrayList<IResource> objects = null; - private ArrayList<ResCfgData> outData = null; + private ArrayList<ResCfgData> outData = null; @Override public void selectionChanged(IAction action, ISelection selection) { @@ -69,19 +68,20 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { if (!selection.isEmpty()) { // case for context menu if (selection instanceof IStructuredSelection) { - Object[] obs = ((IStructuredSelection)selection).toArray(); + Object[] obs = ((IStructuredSelection) selection).toArray(); if (obs.length > 0) { - for (int i=0; i<obs.length; i++) { + for (int i = 0; i < obs.length; i++) { IResource res = null; // only folders and files may be affected by this action if (obs[i] instanceof ICContainer || obs[i] instanceof ITranslationUnit) - res = ((ICElement)obs[i]).getResource(); + res = ((ICElement) obs[i]).getResource(); // project's configuration cannot be deleted else if (obs[i] instanceof IResource && !(obs[i] instanceof IProject)) - res = (IResource)obs[i]; + res = (IResource) obs[i]; if (res != null) { IProject p = res.getProject(); - if (!p.isOpen()) continue; + if (!p.isOpen()) + continue; if (!CoreModel.getDefault().isNewStyleProject(p)) continue; @@ -89,13 +89,16 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { IPath path = res.getProjectRelativePath(); // getting description in read-only mode ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); - if (prjd == null) continue; + if (prjd == null) + continue; ICConfigurationDescription[] cfgds = prjd.getConfigurations(); - if (cfgds == null || cfgds.length == 0) continue; + if (cfgds == null || cfgds.length == 0) + continue; for (ICConfigurationDescription cfgd : cfgds) { ICResourceDescription rd = cfgd.getResourceDescription(path, true); if (rd != null) { - if (objects == null) objects = new ArrayList<IResource>(); + if (objects == null) + objects = new ArrayList<IResource>(); objects.add(res); break; // stop configurations scanning } @@ -113,23 +116,21 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { openDialog(); } - private void openDialog() { - if (objects == null || objects.size() == 0) return; + if (objects == null || objects.size() == 0) + return; // create list of configurations to delete - ListSelectionDialog dialog = new ListSelectionDialog( - CUIPlugin.getActiveWorkbenchShell(), - objects, - createSelectionDialogContentProvider(), - new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0); + ListSelectionDialog dialog = new ListSelectionDialog(CUIPlugin.getActiveWorkbenchShell(), objects, + createSelectionDialogContentProvider(), new LabelProvider() { + }, ActionMessages.DeleteResConfigsAction_0); dialog.setTitle(ActionMessages.DeleteResConfigsAction_1); if (dialog.open() == Window.OK) { Object[] selected = dialog.getResult(); if (selected != null && selected.length > 0) { for (Object element : selected) { - ((ResCfgData)element).delete(); - AbstractPage.updateViews(((ResCfgData)element).res); + ((ResCfgData) element).delete(); + AbstractPage.updateViews(((ResCfgData) element).res); } } } @@ -142,9 +143,12 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { ICConfigurationDescription cfgd; ICResourceDescription rdesc; - public ResCfgData(IResource res2, ICProjectDescription prjd2, - ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) { - res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2; + public ResCfgData(IResource res2, ICProjectDescription prjd2, ICConfigurationDescription cfgd2, + ICResourceDescription rdesc2) { + res = res2; + prjd = prjd2; + cfgd = cfgd2; + rdesc = rdesc2; } // performs deletion @@ -152,24 +156,26 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { try { cfgd.removeResourceDescription(rdesc); CoreModel.getDefault().setProjectDescription(res.getProject(), prjd); - } catch (CoreException e) {} + } catch (CoreException e) { + } } + @Override public String toString() { - return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$ + return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$ } } - private IStructuredContentProvider createSelectionDialogContentProvider() { return new IStructuredContentProvider() { @Override public Object[] getElements(Object inputElement) { - if (outData != null) return outData.toArray(); + if (outData != null) + return outData.toArray(); outData = new ArrayList<ResCfgData>(); - List<?> ls = (List<?>)inputElement; + List<?> ls = (List<?>) inputElement; Iterator<?> it = ls.iterator(); IProject proj = null; ICProjectDescription prjd = null; @@ -177,7 +183,7 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { // creating list of all res descs for all objects while (it.hasNext()) { - IResource res = (IResource)it.next(); + IResource res = (IResource) it.next(); IPath path = res.getProjectRelativePath(); if (res.getProject() != proj) { proj = res.getProject(); @@ -194,24 +200,39 @@ implements IWorkbenchWindowPulldownDelegate2, IObjectActionDelegate { } return outData.toArray(); } + @Override - public void dispose() {} + public void dispose() { + } + @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } }; } @Override - public void dispose() { objects = null; } + public void dispose() { + objects = null; + } // doing nothing @Override - public void init(IWorkbenchWindow window) { } + public void init(IWorkbenchWindow window) { + } + @Override - public Menu getMenu(Menu parent) { return null; } + public Menu getMenu(Menu parent) { + return null; + } + @Override - public Menu getMenu(Control parent) { return null; } + public Menu getMenu(Control parent) { + return null; + } + @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) {} + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + } } |