From 467db5a6815c36976dc7376e15bba4dd83e40960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Fri, 17 Mar 2023 17:37:34 +0200 Subject: [PATCH] Remove ResourceNavigator and friends Tracked in https://github.com/eclipse-platform/eclipse.platform.ui/issues/644 --- .../org.eclipse.ui.ide/.settings/.api_filters | 216 ++- bundles/org.eclipse.ui.ide/plugin.xml | 7 - .../ui/views/navigator/CollapseAllAction.java | 54 - .../ui/views/navigator/CopyAction.java | 225 --- .../navigator/FilterSelectionAction.java | 84 - .../navigator/FiltersContentProvider.java | 129 -- .../ui/views/navigator/GotoActionGroup.java | 128 -- .../views/navigator/GotoResourceAction.java | 65 - .../views/navigator/GotoResourceDialog.java | 45 - .../views/navigator/IResourceNavigator.java | 136 -- .../navigator/LocalSelectionTransfer.java | 90 - .../ui/views/navigator/MainActionGroup.java | 344 ---- .../views/navigator/NavigatorDragAdapter.java | 234 --- .../views/navigator/NavigatorDropAdapter.java | 485 ------ .../views/navigator/NavigatorFrameSource.java | 75 - .../ui/views/navigator/OpenActionGroup.java | 135 -- .../ui/views/navigator/PasteAction.java | 256 --- .../views/navigator/RefactorActionGroup.java | 160 -- .../ui/views/navigator/ResourceNavigator.java | 1505 ----------------- .../navigator/ResourceNavigatorAction.java | 82 - .../ResourceNavigatorActionGroup.java | 97 -- .../navigator/ResourceNavigatorMessages.java | 61 - .../ResourceNavigatorMoveAction.java | 100 -- .../ResourceNavigatorRenameAction.java | 80 - .../navigator/ResourcePatternFilter.java | 161 -- .../navigator/ResourceSelectionUtil.java | 113 -- .../ui/views/navigator/ResourceSorter.java | 205 --- .../navigator/ShowInNavigatorAction.java | 116 -- .../navigator/SortAndFilterActionGroup.java | 78 - .../ui/views/navigator/SortViewAction.java | 69 - .../views/navigator/ToggleLinkingAction.java | 56 - .../views/navigator/WorkspaceActionGroup.java | 256 --- .../.settings/.api_filters | 8 + .../org/eclipse/ui/IPageLayout.java | 9 - .../tests/navigator/NavigatorTestSuite.java | 2 - .../navigator/ResourceNavigatorTest.java | 202 --- 36 files changed, 208 insertions(+), 5860 deletions(-) delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CollapseAllAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CopyAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FilterSelectionAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FiltersContentProvider.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoActionGroup.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceDialog.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/IResourceNavigator.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/LocalSelectionTransfer.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/MainActionGroup.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDragAdapter.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDropAdapter.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorFrameSource.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/OpenActionGroup.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/PasteAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/RefactorActionGroup.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigator.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorActionGroup.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMessages.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMoveAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorRenameAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourcePatternFilter.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSelectionUtil.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSorter.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ShowInNavigatorAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortAndFilterActionGroup.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortViewAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ToggleLinkingAction.java delete mode 100644 bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/WorkspaceActionGroup.java delete mode 100644 tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/navigator/ResourceNavigatorTest.java diff --git a/bundles/org.eclipse.ui.ide/.settings/.api_filters b/bundles/org.eclipse.ui.ide/.settings/.api_filters index a8ed9407885..839f5726080 100644 --- a/bundles/org.eclipse.ui.ide/.settings/.api_filters +++ b/bundles/org.eclipse.ui.ide/.settings/.api_filters @@ -1,34 +1,218 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml index 9b95d3db34f..dc5299beb35 100644 --- a/bundles/org.eclipse.ui.ide/plugin.xml +++ b/bundles/org.eclipse.ui.ide/plugin.xml @@ -720,13 +720,6 @@ class="org.eclipse.ui.internal.progress.ProgressView" id="org.eclipse.ui.views.ProgressView"> - - - Collapse all action (25826) - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.handlers.CollapseAllHandler; - -/** - * Collapse all project nodes. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class CollapseAllAction extends ResourceNavigatorAction { - - /** - * Creates the action. - * - * @param navigator the resource navigator - * @param label the label for the action - */ - public CollapseAllAction(IResourceNavigator navigator, String label) { - super(navigator, label); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, INavigatorHelpContextIds.COLLAPSE_ALL_ACTION); - setEnabled(true); - setActionDefinitionId(CollapseAllHandler.COMMAND_ID); - } - - /* - * Implementation of method defined on IAction. - */ - @Override - public void run() { - getNavigator().getViewer().collapseAll(); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CopyAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CopyAction.java deleted file mode 100644 index be617ffa0cb..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CopyAction.java +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWTError; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.dnd.TextTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.SelectionListenerAction; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.part.ResourceTransfer; - -/** - * Standard action for copying the currently selected resources to the - * clipboard. - *

- * This class may be instantiated; it is not intended to be subclassed. - *

- * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - * @since 2.0 - */ -@Deprecated(forRemoval = true) -/* package */class CopyAction extends SelectionListenerAction { - - /** - * The id of this action. - */ - public static final String ID = PlatformUI.PLUGIN_ID + ".CopyAction"; //$NON-NLS-1$ - - /** - * The shell in which to show any dialogs. - */ - private Shell shell; - - /** - * System clipboard - */ - private Clipboard clipboard; - - /** - * Associated paste action. May be null - */ - private PasteAction pasteAction; - - /** - * Creates a new action. - * - * @param shell the shell for any dialogs - * @param clipboard a platform clipboard - */ - public CopyAction(Shell shell, Clipboard clipboard) { - super(ResourceNavigatorMessages.CopyAction_title); - Assert.isNotNull(shell); - Assert.isNotNull(clipboard); - this.shell = shell; - this.clipboard = clipboard; - setToolTipText(ResourceNavigatorMessages.CopyAction_toolTip); - setId(CopyAction.ID); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, INavigatorHelpContextIds.COPY_ACTION); - } - - /** - * Creates a new action. - * - * @param shell the shell for any dialogs - * @param clipboard a platform clipboard - * @param pasteAction a paste action - * - * @since 2.0 - */ - public CopyAction(Shell shell, Clipboard clipboard, PasteAction pasteAction) { - this(shell, clipboard); - this.pasteAction = pasteAction; - } - - @Override - public void run() { - /** - * The CopyAction implementation of this method defined on - * IAction copies the selected resources to the clipboard. - */ - List selectedResources = getSelectedResources(); - IResource[] resources = selectedResources.toArray(new IResource[selectedResources.size()]); - - // Get the file names and a string representation - final int length = resources.length; - int actualLength = 0; - String[] fileNames = new String[length]; - StringBuilder buf = new StringBuilder(); - for (int i = 0; i < length; i++) { - IPath location = resources[i].getLocation(); - // location may be null. See bug 29491. - if (location != null) { - fileNames[actualLength++] = location.toOSString(); - } - if (i > 0) { - buf.append("\n"); //$NON-NLS-1$ - } - buf.append(resources[i].getName()); - } - // was one or more of the locations null? - if (actualLength < length) { - String[] tempFileNames = fileNames; - fileNames = new String[actualLength]; - System.arraycopy(tempFileNames, 0, fileNames, 0, actualLength); - } - setClipboard(resources, fileNames, buf.toString()); - - // update the enablement of the paste action - // workaround since the clipboard does not suppot callbacks - if (pasteAction != null && pasteAction.getStructuredSelection() != null) { - pasteAction.selectionChanged(pasteAction.getStructuredSelection()); - } - } - - /** - * Set the clipboard contents. Prompt to retry if clipboard is busy. - * - * @param resources the resources to copy to the clipboard - * @param fileNames file names of the resources to copy to the clipboard - * @param names string representation of all names - */ - private void setClipboard(IResource[] resources, String[] fileNames, String names) { - try { - // set the clipboard contents - if (fileNames.length > 0) { - clipboard.setContents(new Object[] { resources, fileNames, names }, new Transfer[] { - ResourceTransfer.getInstance(), FileTransfer.getInstance(), TextTransfer.getInstance() }); - } else { - clipboard.setContents(new Object[] { resources, names }, - new Transfer[] { ResourceTransfer.getInstance(), TextTransfer.getInstance() }); - } - } catch (SWTError e) { - if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) { - throw e; - } - if (MessageDialog.openQuestion(shell, ResourceNavigatorMessages.CopyToClipboardProblemDialog_title, - ResourceNavigatorMessages.CopyToClipboardProblemDialog_message)) { - setClipboard(resources, fileNames, names); - } - } - } - - @Override - protected boolean updateSelection(IStructuredSelection selection) { - - /** - * The CopyAction implementation of this - * SelectionListenerAction method enables this action if one or - * more resources of compatible types are selected. - */ - - if (!super.updateSelection(selection)) { - return false; - } - - if (getSelectedNonResources().size() > 0) { - return false; - } - - List selectedResources = getSelectedResources(); - if (selectedResources.isEmpty()) { - return false; - } - - boolean projSelected = selectionIsOfType(IResource.PROJECT); - boolean fileFoldersSelected = selectionIsOfType(IResource.FILE | IResource.FOLDER); - if (!projSelected && !fileFoldersSelected) { - return false; - } - - // selection must be homogeneous - if (projSelected && fileFoldersSelected) { - return false; - } - - // must have a common parent - IContainer firstParent = ((IResource) selectedResources.get(0)).getParent(); - if (firstParent == null) { - return false; - } - - Iterator resourcesEnum = selectedResources.iterator(); - while (resourcesEnum.hasNext()) { - IResource currentResource = resourcesEnum.next(); - if (!currentResource.getParent().equals(firstParent)) { - return false; - } - } - - return true; - } - -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FilterSelectionAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FilterSelectionAction.java deleted file mode 100644 index c2f435de197..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FilterSelectionAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.views.navigator; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.Window; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ListSelectionDialog; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; - -/** - * The FilterSelectionAction opens the filters dialog. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class FilterSelectionAction extends ResourceNavigatorAction { - private static final String FILTER_TOOL_TIP = ResourceNavigatorMessages.FilterSelection_toolTip; - - private static final String FILTER_SELECTION_MESSAGE = ResourceNavigatorMessages.FilterSelection_message; - - private static final String FILTER_TITLE_MESSAGE = ResourceNavigatorMessages.FilterSelection_title; - - /** - * Creates the action. - * - * @param navigator the resource navigator - * @param label the label for the action - */ - public FilterSelectionAction(IResourceNavigator navigator, String label) { - super(navigator, label); - setToolTipText(FILTER_TOOL_TIP); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, INavigatorHelpContextIds.FILTER_SELECTION_ACTION); - setEnabled(true); - } - - /* - * Implementation of method defined on IAction. - */ - @Override - public void run() { - IResourceNavigator navigator = getNavigator(); - ResourcePatternFilter filter = navigator.getPatternFilter(); - FiltersContentProvider contentProvider = new FiltersContentProvider(filter); - - ListSelectionDialog dialog = new ListSelectionDialog(getShell(), getViewer(), contentProvider, - new LabelProvider(), FILTER_SELECTION_MESSAGE); - - dialog.setTitle(FILTER_TITLE_MESSAGE); - dialog.setInitialSelections((Object[]) contentProvider.getInitialSelections()); - dialog.open(); - if (dialog.getReturnCode() == Window.OK) { - Object[] results = dialog.getResult(); - String[] selectedPatterns = new String[results.length]; - System.arraycopy(results, 0, selectedPatterns, 0, results.length); - filter.setPatterns(selectedPatterns); - navigator.setFiltersPreference(selectedPatterns); - Viewer viewer = getViewer(); - viewer.getControl().setRedraw(false); - viewer.refresh(); - viewer.getControl().setRedraw(true); - } - } - -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FiltersContentProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FiltersContentProvider.java deleted file mode 100644 index 08745531453..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FiltersContentProvider.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtension; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; - -/** - * The FiltersContentProvider provides the elements for use by the list dialog - * for selecting the patterns to apply. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -/* package */class FiltersContentProvider implements IStructuredContentProvider { - - private static List definedFilters; - - private static List defaultFilters; - - private ResourcePatternFilter resourceFilter; - - /** - * Create a FiltersContentProvider using the selections from the supplied - * resource filter. - * - * @param filter the resource pattern filter - */ - public FiltersContentProvider(ResourcePatternFilter filter) { - this.resourceFilter = filter; - } - - @Override - public void dispose() { - } - - /** - * Returns the filters which are enabled by default. - * - * @return a list of strings - */ - public static List getDefaultFilters() { - if (defaultFilters == null) { - readFilters(); - } - return defaultFilters; - } - - /** - * Returns the filters currently defined for the navigator. - * - * @return a list of strings - */ - public static List getDefinedFilters() { - if (definedFilters == null) { - readFilters(); - } - return definedFilters; - } - - @Override - public Object[] getElements(Object inputElement) { - return getDefinedFilters().toArray(); - } - - /** - * Return the initially selected elements. - * - * @return an array with the initial selections - */ - public String[] getInitialSelections() { - return this.resourceFilter.getPatterns(); - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - /** - * Reads the filters currently defined for the workbench. - */ - private static void readFilters() { - definedFilters = new ArrayList<>(); - defaultFilters = new ArrayList<>(); - IExtensionPoint extension = Platform.getExtensionRegistry() - .getExtensionPoint(IDEWorkbenchPlugin.IDE_WORKBENCH + '.' + ResourcePatternFilter.FILTERS_TAG); - if (extension != null) { - for (IExtension currentExtension : extension.getExtensions()) { - IConfigurationElement[] configElements = currentExtension.getConfigurationElements(); - for (IConfigurationElement configElement : configElements) { - String pattern = configElement.getAttribute("pattern");//$NON-NLS-1$ - if (pattern != null) { - definedFilters.add(pattern); - } - String selected = configElement.getAttribute("selected");//$NON-NLS-1$ - if (selected != null && selected.equalsIgnoreCase("true")) { //$NON-NLS-1$ - defaultFilters.add(pattern); - } - } - - } - } - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoActionGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoActionGroup.java deleted file mode 100644 index 2b2a314de4b..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoActionGroup.java +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.actions.ActionContext; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.views.framelist.BackAction; -import org.eclipse.ui.views.framelist.ForwardAction; -import org.eclipse.ui.views.framelist.FrameList; -import org.eclipse.ui.views.framelist.GoIntoAction; -import org.eclipse.ui.views.framelist.UpAction; - -/** - * This is the action group for the goto actions. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class GotoActionGroup extends ResourceNavigatorActionGroup { - - private BackAction backAction; - - private ForwardAction forwardAction; - - private GoIntoAction goIntoAction; - - private UpAction upAction; - - private GotoResourceAction goToResourceAction; - - public GotoActionGroup(IResourceNavigator navigator) { - super(navigator); - } - - @Override - public void fillContextMenu(IMenuManager menu) { - IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); - if (selection.size() == 1) { - if (ResourceSelectionUtil.allResourcesAreOfType(selection, IResource.FOLDER)) { - menu.add(goIntoAction); - } else { - IStructuredSelection resourceSelection = ResourceSelectionUtil.allResources(selection, - IResource.PROJECT); - if (resourceSelection != null && !resourceSelection.isEmpty()) { - IProject project = (IProject) resourceSelection.getFirstElement(); - if (project.isOpen()) { - menu.add(goIntoAction); - } - } - } - } - } - - @Override - public void fillActionBars(IActionBars actionBars) { - actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, goIntoAction); - actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), backAction); - actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), forwardAction); - actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, upAction); - actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE, goToResourceAction); - - IToolBarManager toolBar = actionBars.getToolBarManager(); - toolBar.add(backAction); - toolBar.add(forwardAction); - toolBar.add(upAction); - } - - @Override - protected void makeActions() { - FrameList frameList = navigator.getFrameList(); - goIntoAction = new GoIntoAction(frameList); - backAction = new BackAction(frameList); - forwardAction = new ForwardAction(frameList); - upAction = new UpAction(frameList); - goToResourceAction = new GotoResourceAction(navigator, ResourceNavigatorMessages.GoToResource_label); - } - - @Override - public void updateActionBars() { - ActionContext context = getContext(); - boolean enable = false; - - // Fix for bug 26126. Resource change listener could call - // updateActionBars without a context being set. - // This should never happen because resource navigator sets - // context immediately after this group is created. - if (context != null) { - IStructuredSelection selection = (IStructuredSelection) context.getSelection(); - - if (selection.size() == 1) { - Object object = selection.getFirstElement(); - if (object instanceof IProject) { - enable = ((IProject) object).isOpen(); - } else if (object instanceof IFolder) { - enable = true; - } - } - } - goIntoAction.setEnabled(enable); - // the rest of the actions update by listening to frame list changes - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceAction.java deleted file mode 100644 index dbcc2994817..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceAction.java +++ /dev/null @@ -1,65 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.PlatformUI; - -/** - * Implements the go to resource action. Opens a dialog and set the navigator - * selection with the resource selected by the user. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class GotoResourceAction extends ResourceNavigatorAction { - /** - * Creates a new instance of the class. - * - * @param navigator the navigator - * @param label the label - * @since 2.0 - */ - public GotoResourceAction(IResourceNavigator navigator, String label) { - super(navigator, label); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, INavigatorHelpContextIds.GOTO_RESOURCE_ACTION); - } - - /** - * Collect all resources in the workbench open a dialog asking the user to - * select a resource and change the selection in the navigator. - */ - @Override - public void run() { - IContainer container = (IContainer) getViewer().getInput(); - GotoResourceDialog dialog = new GotoResourceDialog(getShell(), container, - IResource.FILE | IResource.FOLDER | IResource.PROJECT); - dialog.open(); - Object[] result = dialog.getResult(); - if (result == null || result.length == 0 || result[0] instanceof IResource == false) { - return; - } - - IResource selection = (IResource) result[0]; - getViewer().setSelection(new StructuredSelection(selection), true); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceDialog.java deleted file mode 100644 index 27987cd5888..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceDialog.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; - -/** - * Shows a list of resources to the user with a text entry field for a string - * pattern used to filter the list of resources. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -/* package */class GotoResourceDialog extends FilteredResourcesSelectionDialog { - - /** - * Creates a new instance of the class. - */ - protected GotoResourceDialog(Shell parentShell, IContainer container, int typesMask) { - super(parentShell, false, container, typesMask); - setTitle(ResourceNavigatorMessages.Goto_title); - PlatformUI.getWorkbench().getHelpSystem().setHelp(parentShell, INavigatorHelpContextIds.GOTO_RESOURCE_DIALOG); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/IResourceNavigator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/IResourceNavigator.java deleted file mode 100644 index 3089ab16ed7..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/IResourceNavigator.java +++ /dev/null @@ -1,136 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.views.framelist.FrameList; - -/** - * This interface defines the API for the resource navigator. The action groups - * should restrict themselves to using this API. - *

- * This interface is not intended to be implemented by clients. Subclass - * org.eclipse.ui.views.ResourceNavigator instead. - *

- * - * @since 2.0 - * @noimplement This interface is not intended to be implemented by clients. - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public interface IResourceNavigator extends IViewPart { - - /** - * Returns the pattern filter. - * - * @return the pattern filter - */ - ResourcePatternFilter getPatternFilter(); - - /** - * Returns the active working set, or null if none. - * - * @return the active working set, or null if none - * @since 2.0 - */ - IWorkingSet getWorkingSet(); - - /** - * Returns the current sorter. - * - * @return the resource navigator's sorter - * - * @deprecated as of 3.3, use {@link IResourceNavigator#getComparator()} instead - */ - @Deprecated - ResourceSorter getSorter(); - - /** - * Sets the current sorter. - * - * @param sorter the sorter to use - * - * @deprecated as of 3.3, use - * {@link IResourceNavigator#setComparator(ResourceComparator)} - * instead - */ - @Deprecated - void setSorter(ResourceSorter sorter); - - /** - * Returns the current comparator. - * - * @return the resource navigator's comparator - * @since 3.3 - */ - ResourceComparator getComparator(); - - /** - * Sets the current comparator. - * - * @param comparator the comparator to use - * @since 3.3 - */ - void setComparator(ResourceComparator comparator); - - /** - * Sets the values of the filter preference to be the strings in preference - * values. - * - * @param patterns filter patterns to use on contents of the resource navigator - */ - void setFiltersPreference(String[] patterns); - - /** - * Returns the viewer which shows the resource tree. - * - * @return the resource navigator's tree viewer - */ - TreeViewer getViewer(); - - /** - * Returns the frame list for this navigator. - * - * @return the list of frames maintained by the resource navigator - */ - FrameList getFrameList(); - - /** - * Returns whether this navigator's selection automatically tracks the active - * editor. - * - * @return true if linking is enabled, false if not - * @since 2.1 - */ - boolean isLinkingEnabled(); - - /** - * Sets the working set for this view, or null to clear it. - * - * @param workingSet the working set, or null to clear it - * @since 2.0 - */ - void setWorkingSet(IWorkingSet workingSet); - - /** - * Sets whether this navigator's selection automatically tracks the active - * editor. - * - * @param enabled true to enable, false to disable - * @since 2.1 - */ - void setLinkingEnabled(boolean enabled); -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/LocalSelectionTransfer.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/LocalSelectionTransfer.java deleted file mode 100644 index 56c30cfc0f0..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/LocalSelectionTransfer.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.dnd.TransferData; - -/** - * A LocalSelectionTransfer may be used for drag and drop operations within the - * same instance of Eclipse. The selection is made available directly for use in - * the DropTargetListener. dropAccept method. The DropTargetEvent passed to - * dropAccept does not contain the drop data. The selection may be used for - * validation purposes so that the drop can be aborted if appropriate. This - * class is not intended to be subclassed. - * - * @since 2.1 - * @noextend This class is not intended to be subclassed by clients. - * @deprecated as of 3.5, use - * {@link org.eclipse.jface.util.LocalSelectionTransfer} instead - */ -@Deprecated(forRemoval = true) -public class LocalSelectionTransfer extends org.eclipse.jface.util.LocalSelectionTransfer { - - private static final LocalSelectionTransfer INSTANCE = new LocalSelectionTransfer(); - - /** - * The get/set methods delegate to JFace's LocalSelectionTransfer to allow data - * to be exchanged freely whether the client uses this LocalSelectionTransfer or - * JFace's LocalSelectionTransfer. Protected methods such as getTypeIds() are - * handled via inheritance, not delegation due to visibility constraints. - */ - private org.eclipse.jface.util.LocalSelectionTransfer jfaceTransfer = org.eclipse.jface.util.LocalSelectionTransfer - .getTransfer(); - - /** - * Only the singleton instance of this class may be used. - */ - private LocalSelectionTransfer() { - } - - /** - * Returns the singleton. - * - * @return the singleton - */ - public static LocalSelectionTransfer getInstance() { - return INSTANCE; - } - - @Override - public ISelection getSelection() { - return jfaceTransfer.getSelection(); - } - - @Override - public long getSelectionSetTime() { - return jfaceTransfer.getSelectionSetTime(); - } - - @Override - public void setSelection(ISelection s) { - jfaceTransfer.setSelection(s); - } - - @Override - public void setSelectionSetTime(long time) { - jfaceTransfer.setSelectionSetTime(time); - } - - @Override - public void javaToNative(Object object, TransferData transferData) { - jfaceTransfer.javaToNative(object, transferData); - } - - @Override - public Object nativeToJava(TransferData transferData) { - return jfaceTransfer.nativeToJava(transferData); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/MainActionGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/MainActionGroup.java deleted file mode 100644 index 31944cdc079..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/MainActionGroup.java +++ /dev/null @@ -1,344 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Sebastian Davids - Collapse all action (25826) - * Sebastian Davids - Images for menu items (27481) - * Lars Vogel - Bug 430694 - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.List; - -import org.eclipse.core.commands.operations.IUndoContext; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Adapters; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.window.IShellProvider; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.actions.ActionContext; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.AddBookmarkAction; -import org.eclipse.ui.actions.AddTaskAction; -import org.eclipse.ui.actions.ExportResourcesAction; -import org.eclipse.ui.actions.ImportResourcesAction; -import org.eclipse.ui.actions.NewWizardMenu; -import org.eclipse.ui.actions.WorkingSetFilterActionGroup; -import org.eclipse.ui.dialogs.PropertyDialogAction; -import org.eclipse.ui.ide.IDEActionFactory; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.operations.UndoRedoActionGroup; - -/** - * The main action group for the navigator. This contains a few actions and - * several subgroups. - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class MainActionGroup extends ResourceNavigatorActionGroup { - - protected AddBookmarkAction addBookmarkAction; - - protected AddTaskAction addTaskAction; - - protected PropertyDialogAction propertyDialogAction; - - protected ImportResourcesAction importAction; - - protected ExportResourcesAction exportAction; - - protected CollapseAllAction collapseAllAction; - - protected ToggleLinkingAction toggleLinkingAction; - - protected GotoActionGroup gotoGroup; - - protected OpenActionGroup openGroup; - - protected RefactorActionGroup refactorGroup; - - protected WorkingSetFilterActionGroup workingSetGroup; - - protected SortAndFilterActionGroup sortAndFilterGroup; - - protected UndoRedoActionGroup undoRedoGroup; - - protected WorkspaceActionGroup workspaceGroup; - - private IResourceChangeListener resourceChangeListener; - - private NewWizardMenu newWizardMenu; - - /** - * Constructs the main action group. - * - * @param navigator the navigator view - */ - public MainActionGroup(IResourceNavigator navigator) { - super(navigator); - resourceChangeListener = this::handleResourceChanged; - ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, - IResourceChangeEvent.POST_CHANGE); - makeSubGroups(); - } - - /** - * Handles a resource changed event by updating the enablement if one of the - * selected projects is opened or closed. - */ - protected void handleResourceChanged(IResourceChangeEvent event) { - ActionContext context = getContext(); - if (context == null) { - return; - } - - final IStructuredSelection selection = (IStructuredSelection) context.getSelection(); - if (ResourceSelectionUtil.allResourcesAreOfType(selection, IResource.PROJECT) == false) { - return; - } - List sel = selection.toList(); - IResourceDelta delta = event.getDelta(); - if (delta == null) { - return; - } - for (IResourceDelta projectDelta : delta.getAffectedChildren(IResourceDelta.CHANGED)) { - // changing the project open state or description will affect open/close/build - // action enablement - if ((projectDelta.getFlags() & (IResourceDelta.OPEN | IResourceDelta.DESCRIPTION)) != 0) { - if (sel.contains(projectDelta.getResource())) { - getNavigator().getSite().getShell().getDisplay().syncExec(() -> { - addTaskAction.selectionChanged(selection); - gotoGroup.updateActionBars(); - refactorGroup.updateActionBars(); - workspaceGroup.updateActionBars(); - }); - } - } - } - } - - /** - * Makes the actions contained directly in this action group. - */ - @Override - protected void makeActions() { - IShellProvider provider = navigator.getSite(); - - newWizardMenu = new NewWizardMenu(navigator.getSite().getWorkbenchWindow()); - addBookmarkAction = new AddBookmarkAction(provider, true); - addTaskAction = new AddTaskAction(provider); - propertyDialogAction = new PropertyDialogAction(provider, navigator.getViewer()); - - importAction = new ImportResourcesAction(navigator.getSite().getWorkbenchWindow()); - importAction.setDisabledImageDescriptor(getImageDescriptor("dtool16/import_wiz.png")); //$NON-NLS-1$ - importAction.setImageDescriptor(getImageDescriptor("etool16/import_wiz.png")); //$NON-NLS-1$ - - exportAction = new ExportResourcesAction(navigator.getSite().getWorkbenchWindow()); - exportAction.setDisabledImageDescriptor(getImageDescriptor("dtool16/export_wiz.png")); //$NON-NLS-1$ - exportAction.setImageDescriptor(getImageDescriptor("etool16/export_wiz.png")); //$NON-NLS-1$ - - collapseAllAction = new CollapseAllAction(navigator, ResourceNavigatorMessages.CollapseAllAction_title); - collapseAllAction.setToolTipText(ResourceNavigatorMessages.CollapseAllAction_toolTip); - collapseAllAction.setImageDescriptor(getImageDescriptor("elcl16/collapseall.png")); //$NON-NLS-1$ - - toggleLinkingAction = new ToggleLinkingAction(navigator, ResourceNavigatorMessages.ToggleLinkingAction_text); - toggleLinkingAction.setToolTipText(ResourceNavigatorMessages.ToggleLinkingAction_toolTip); - toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.png"));//$NON-NLS-1$ - } - - /** - * Makes the sub action groups. - */ - protected void makeSubGroups() { - gotoGroup = new GotoActionGroup(navigator); - openGroup = new OpenActionGroup(navigator); - refactorGroup = new RefactorActionGroup(navigator); - IPropertyChangeListener workingSetUpdater = event -> { - String property = event.getProperty(); - - if (WorkingSetFilterActionGroup.CHANGE_WORKING_SET.equals(property)) { - IResourceNavigator navigator = getNavigator(); - Object newValue = event.getNewValue(); - - if (newValue instanceof IWorkingSet) { - navigator.setWorkingSet((IWorkingSet) newValue); - } else if (newValue == null) { - navigator.setWorkingSet(null); - } - } - }; - TreeViewer treeView = navigator.getViewer(); - Shell shell = treeView.getControl().getShell(); - workingSetGroup = new WorkingSetFilterActionGroup(shell, workingSetUpdater); - workingSetGroup.setWorkingSet(navigator.getWorkingSet()); - sortAndFilterGroup = new SortAndFilterActionGroup(navigator); - workspaceGroup = new WorkspaceActionGroup(navigator); - IUndoContext workspaceContext = Adapters.adapt(ResourcesPlugin.getWorkspace(), IUndoContext.class); - undoRedoGroup = new UndoRedoActionGroup(getNavigator().getSite(), workspaceContext, true); - } - - /** - * Extends the superclass implementation to set the context in the subgroups. - */ - @Override - public void setContext(ActionContext context) { - super.setContext(context); - gotoGroup.setContext(context); - openGroup.setContext(context); - refactorGroup.setContext(context); - sortAndFilterGroup.setContext(context); - workspaceGroup.setContext(context); - undoRedoGroup.setContext(context); - } - - /** - * Fills the context menu with the actions contained in this group and its - * subgroups. - * - * @param menu the context menu - */ - @Override - public void fillContextMenu(IMenuManager menu) { - IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); - - MenuManager newMenu = new MenuManager(ResourceNavigatorMessages.ResourceNavigator_new); - menu.add(newMenu); - newMenu.add(newWizardMenu); - - gotoGroup.fillContextMenu(menu); - openGroup.fillContextMenu(menu); - menu.add(new Separator()); - - refactorGroup.fillContextMenu(menu); - menu.add(new Separator()); - - menu.add(importAction); - menu.add(exportAction); - importAction.selectionChanged(selection); - exportAction.selectionChanged(selection); - menu.add(new Separator()); - - workspaceGroup.fillContextMenu(menu); - - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$ - menu.add(new Separator()); - - if (selection.size() == 1) { - propertyDialogAction.selectionChanged(selection); - menu.add(propertyDialogAction); - } - } - - /** - * Adds the actions in this group and its subgroups to the action bars. - */ - @Override - public void fillActionBars(IActionBars actionBars) { - actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertyDialogAction); - actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction); - actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction); - - gotoGroup.fillActionBars(actionBars); - openGroup.fillActionBars(actionBars); - refactorGroup.fillActionBars(actionBars); - workingSetGroup.fillActionBars(actionBars); - sortAndFilterGroup.fillActionBars(actionBars); - workspaceGroup.fillActionBars(actionBars); - undoRedoGroup.fillActionBars(actionBars); - - IMenuManager menu = actionBars.getMenuManager(); - menu.add(toggleLinkingAction); - - IToolBarManager toolBar = actionBars.getToolBarManager(); - toolBar.add(new Separator()); - toolBar.add(collapseAllAction); - toolBar.add(toggleLinkingAction); - } - - /** - * Updates the actions which were added to the action bars, delegating to the - * subgroups as necessary. - */ - @Override - public void updateActionBars() { - IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); - propertyDialogAction.setEnabled(selection.size() == 1); - addBookmarkAction.selectionChanged(selection); - addTaskAction.selectionChanged(selection); - - gotoGroup.updateActionBars(); - openGroup.updateActionBars(); - refactorGroup.updateActionBars(); - workingSetGroup.updateActionBars(); - sortAndFilterGroup.updateActionBars(); - workspaceGroup.updateActionBars(); - undoRedoGroup.updateActionBars(); - } - - /** - * Runs the default action (open file) by delegating the open group. - */ - @Override - public void runDefaultAction(IStructuredSelection selection) { - openGroup.runDefaultAction(selection); - } - - /** - * Handles a key pressed event by invoking the appropriate action, delegating to - * the subgroups as necessary. - */ - @Override - public void handleKeyPressed(KeyEvent event) { - refactorGroup.handleKeyPressed(event); - workspaceGroup.handleKeyPressed(event); - } - - /** - * Extends the superclass implementation to dispose the actions in this group - * and its subgroups. - */ - @Override - public void dispose() { - ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); - - newWizardMenu.dispose(); - collapseAllAction.dispose(); - importAction.dispose(); - exportAction.dispose(); - propertyDialogAction.dispose(); - toggleLinkingAction.dispose(); - - gotoGroup.dispose(); - openGroup.dispose(); - refactorGroup.dispose(); - sortAndFilterGroup.dispose(); - workingSetGroup.dispose(); - workspaceGroup.dispose(); - undoRedoGroup.dispose(); - super.dispose(); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDragAdapter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDragAdapter.java deleted file mode 100644 index 27c0b6d3d34..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDragAdapter.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DragSource; -import org.eclipse.swt.dnd.DragSourceAdapter; -import org.eclipse.swt.dnd.DragSourceEvent; -import org.eclipse.swt.dnd.DragSourceListener; -import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.actions.ReadOnlyStateChecker; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.part.ResourceTransfer; -import org.eclipse.ui.statushandlers.StatusManager; - -/** - * Implements drag behaviour when items are dragged out of the resource - * navigator. - * - * @since 2.0 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class NavigatorDragAdapter extends DragSourceAdapter { - private static final String CHECK_MOVE_TITLE = ResourceNavigatorMessages.DragAdapter_title; - - private static final String CHECK_DELETE_MESSAGE = ResourceNavigatorMessages.DragAdapter_checkDeleteMessage; - - ISelectionProvider selectionProvider; - - private TransferData lastDataType; - - /** - * Constructs a new drag adapter. - * - * @param provider The selection provider - */ - public NavigatorDragAdapter(ISelectionProvider provider) { - selectionProvider = provider; - } - - /** - * This implementation of - * {@link DragSourceListener#dragFinished(DragSourceEvent)} responds to a drag - * that has moved resources outside the Navigator by deleting the corresponding - * source resource. - */ - @Override - public void dragFinished(DragSourceEvent event) { - LocalSelectionTransfer.getInstance().setSelection(null); - - if (event.doit == false) { - return; - } - - final int typeMask = IResource.FOLDER | IResource.FILE; - if (event.detail == DND.DROP_MOVE) { - // never delete resources when dragging outside Eclipse. - // workaround for bug 30543. - if (lastDataType != null && FileTransfer.getInstance().isSupportedType(lastDataType)) { - return; - } - - IResource[] resources = getSelectedResources(typeMask); - DragSource dragSource = (DragSource) event.widget; - Control control = dragSource.getControl(); - Shell shell = control.getShell(); - ReadOnlyStateChecker checker; - - if (resources == null || resources.length == 0) { - return; - } - - checker = new ReadOnlyStateChecker(shell, CHECK_MOVE_TITLE, CHECK_DELETE_MESSAGE); - resources = checker.checkReadOnlyResources(resources); - // delete the old elements - for (IResource resource : resources) { - try { - resource.delete(IResource.KEEP_HISTORY | IResource.FORCE, null); - } catch (CoreException e) { - StatusManager.getManager().handle(e, IDEWorkbenchPlugin.IDE_WORKBENCH); - } - } - } else if (event.detail == DND.DROP_TARGET_MOVE) { - IResource[] resources = getSelectedResources(typeMask); - - // file moved for us by OS, no need to delete the resources, just - // update the view - if (resources == null) { - return; - } - for (IResource resource : resources) { - try { - resource.refreshLocal(IResource.DEPTH_INFINITE, null); - } catch (CoreException e) { - StatusManager.getManager().handle(e, IDEWorkbenchPlugin.IDE_WORKBENCH); - } - } - } - } - - /** - * This implementation of - * {@link DragSourceListener#dragSetData(DragSourceEvent)} sets the drag event - * data based on the current selection in the Navigator. - */ - @Override - public void dragSetData(DragSourceEvent event) { - final int typeMask = IResource.FILE | IResource.FOLDER; - IResource[] resources = getSelectedResources(typeMask); - - if (resources == null || resources.length == 0) { - return; - } - - lastDataType = event.dataType; - // use local selection transfer if possible - if (LocalSelectionTransfer.getInstance().isSupportedType(event.dataType)) { - event.data = LocalSelectionTransfer.getInstance().getSelection(); - return; - } - // use resource transfer if possible - if (ResourceTransfer.getInstance().isSupportedType(event.dataType)) { - event.data = resources; - return; - } - // resort to a file transfer - if (!FileTransfer.getInstance().isSupportedType(event.dataType)) { - return; - } - - // Get the path of each file and set as the drag data - final int length = resources.length; - int actualLength = 0; - String[] fileNames = new String[length]; - for (int i = 0; i < length; i++) { - IPath location = resources[i].getLocation(); - // location may be null. See bug 29491. - if (location != null) { - fileNames[actualLength++] = location.toOSString(); - } - } - if (actualLength == 0) { - return; - } - // was one or more of the locations null? - if (actualLength < length) { - String[] tempFileNames = fileNames; - fileNames = new String[actualLength]; - System.arraycopy(tempFileNames, 0, fileNames, 0, actualLength); - } - event.data = fileNames; - } - - /** - * This implementation of {@link DragSourceListener#dragStart(DragSourceEvent)} - * allows the drag to start if the current Navigator selection contains - * resources that can be dragged. - */ - @Override - public void dragStart(DragSourceEvent event) { - lastDataType = null; - // Workaround for 1GEUS9V - DragSource dragSource = (DragSource) event.widget; - Control control = dragSource.getControl(); - if (control != control.getDisplay().getFocusControl()) { - event.doit = false; - return; - } - - IStructuredSelection selection = (IStructuredSelection) selectionProvider.getSelection(); - for (Object next : selection) { - if (!(next instanceof IFile || next instanceof IFolder)) { - event.doit = false; - return; - } - } - if (selection.isEmpty()) { - event.doit = false; - return; - } - LocalSelectionTransfer.getInstance().setSelection(selection); - event.doit = true; - } - - private IResource[] getSelectedResources(int resourceTypes) { - List resources = new ArrayList<>(); - - ISelection selection = selectionProvider.getSelection(); - if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) { - return null; - } - IStructuredSelection structuredSelection = (IStructuredSelection) selection; - - // loop through list and look for matching items - for (Object obj : structuredSelection) { - if (obj instanceof IResource) { - IResource res = (IResource) obj; - if ((res.getType() & resourceTypes) == res.getType()) { - resources.add(res); - } - } - } - IResource[] result = new IResource[resources.size()]; - resources.toArray(result); - return result; - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDropAdapter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDropAdapter.java deleted file mode 100644 index 84b8f14d818..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDropAdapter.java +++ /dev/null @@ -1,485 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2016 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Patrik Suzzi - Bug 490700 - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Adapters; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.DropTargetEvent; -import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; -import org.eclipse.ui.actions.MoveFilesAndFoldersOperation; -import org.eclipse.ui.actions.ReadOnlyStateChecker; -import org.eclipse.ui.dialogs.IOverwriteQuery; -import org.eclipse.ui.ide.dialogs.ImportTypeDialog; -import org.eclipse.ui.internal.ide.IDEInternalPreferences; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.part.PluginDropAdapter; -import org.eclipse.ui.part.ResourceTransfer; - -/** - * Implements drop behaviour for drag and drop operations that land on the - * resource navigator. - * - * @since 2.0 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class NavigatorDropAdapter extends PluginDropAdapter implements IOverwriteQuery { - - /** - * A flag indicating that overwrites should always occur. - */ - private boolean alwaysOverwrite = false; - - /** - * The last valid operation. - */ - private int lastValidOperation = DND.DROP_NONE; - - /** - * Constructs a new drop adapter. - * - * @param viewer the navigator's viewer - */ - public NavigatorDropAdapter(StructuredViewer viewer) { - super(viewer); - } - - /* - * @see org.eclipse.swt.dnd.DropTargetListener#dragEnter(org.eclipse.swt.dnd. - * DropTargetEvent) - */ - @Override - public void dragEnter(DropTargetEvent event) { - if (FileTransfer.getInstance().isSupportedType(event.currentDataType) && event.detail == DND.DROP_DEFAULT) { - // default to copy when dragging from outside Eclipse. Fixes bug 16308. - event.detail = DND.DROP_COPY; - } - super.dragEnter(event); - } - - @Override - public void dragOperationChanged(DropTargetEvent event) { - super.dragOperationChanged(event); - } - - /** - * Returns an error status with the given info. - */ - private IStatus error(String message) { - return error(message, null); - } - - /** - * Returns an error status with the given info. - */ - private IStatus error(String message, Throwable exception) { - return new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, message, exception); - } - - /** - * Returns the actual target of the drop, given the resource under the mouse. If - * the mouse target is a file, then the drop actually occurs in its parent. If - * the drop location is before or after the mouse target and feedback is - * enabled, the target is also the parent. - */ - private IContainer getActualTarget(IResource mouseTarget) { - /* if cursor is before or after mouseTarget, set target to parent */ - if (getFeedbackEnabled()) { - if (getCurrentLocation() == LOCATION_BEFORE || getCurrentLocation() == LOCATION_AFTER) { - return mouseTarget.getParent(); - } - } - /* if cursor is on a file, return the parent */ - if (mouseTarget.getType() == IResource.FILE) { - return mouseTarget.getParent(); - } - /* otherwise the mouseTarget is the real target */ - return (IContainer) mouseTarget; - } - - /** - * Returns the display - */ - private Display getDisplay() { - return getViewer().getControl().getDisplay(); - } - - /** - * Returns the resource selection from the LocalSelectionTransfer. - * - * @return the resource selection from the LocalSelectionTransfer - */ - private IResource[] getSelectedResources() { - ArrayList selectedResources = new ArrayList<>(); - - ISelection selection = LocalSelectionTransfer.getInstance().getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection) selection; - for (Object o : ssel) { - - IResource r = Adapters.adapt(o, IResource.class); - if (r != null) { - selectedResources.add(r); - } - } - } - return selectedResources.toArray(new IResource[selectedResources.size()]); - } - - /** - * Returns the shell - */ - private Shell getShell() { - return getViewer().getControl().getShell(); - } - - /** - * Returns an error status with the given info. - */ - private IStatus info(String message) { - return new Status(IStatus.INFO, PlatformUI.PLUGIN_ID, 0, message, null); - } - - /** - * Adds the given status to the list of problems. Discards OK statuses. If the - * status is a multi-status, only its children are added. - */ - private void mergeStatus(MultiStatus status, IStatus toMerge) { - if (!toMerge.isOK()) { - status.merge(toMerge); - } - } - - /** - * Returns an status indicating success. - */ - private IStatus ok() { - return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, 0, ResourceNavigatorMessages.DropAdapter_ok, null); - } - - /** - * Opens an error dialog if necessary. Takes care of complex rules necessary for - * making the error dialog look nice. - */ - private void openError(IStatus status) { - if (status == null) { - return; - } - - String genericTitle = ResourceNavigatorMessages.DropAdapter_title; - int codes = IStatus.ERROR | IStatus.WARNING; - - // simple case: one error, not a multistatus - if (!status.isMultiStatus()) { - ErrorDialog.openError(getShell(), genericTitle, null, status, codes); - return; - } - - // one error, single child of multistatus - IStatus[] children = status.getChildren(); - if (children.length == 1) { - ErrorDialog.openError(getShell(), status.getMessage(), null, children[0], codes); - return; - } - // several problems - ErrorDialog.openError(getShell(), genericTitle, null, status, codes); - } - - /** - * Perform the drop. - * - * @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent) - */ - @Override - public boolean performDrop(final Object data) { - alwaysOverwrite = false; - if (getCurrentTarget() == null || data == null) { - return false; - } - boolean result = false; - IStatus status = null; - IResource[] resources = null; - TransferData currentTransfer = getCurrentTransfer(); - if (LocalSelectionTransfer.getInstance().isSupportedType(currentTransfer)) { - resources = getSelectedResources(); - } else if (ResourceTransfer.getInstance().isSupportedType(currentTransfer)) { - resources = (IResource[]) data; - } else if (FileTransfer.getInstance().isSupportedType(currentTransfer)) { - status = performFileDrop(data); - result = status.isOK(); - } else { - result = NavigatorDropAdapter.super.performDrop(data); - } - if (resources != null && resources.length > 0) { - if (getCurrentOperation() == DND.DROP_COPY) { - status = performResourceCopy(getShell(), resources); - } else { - status = performResourceMove(resources); - } - } - openError(status); - return result; - } - - /** - * Performs a drop using the FileTransfer transfer type. - */ - private IStatus performFileDrop(Object data) { - MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 0, - ResourceNavigatorMessages.DropAdapter_problemImporting, null); - mergeStatus(problems, validateTarget(getCurrentTarget(), getCurrentTransfer())); - - final int currentOperation = getCurrentOperation(); - final IContainer target = getActualTarget((IResource) getCurrentTarget()); - final String[] names = (String[]) data; - // Run the import operation asynchronously. - // Otherwise the drag source (e.g., Windows Explorer) will be blocked - // while the operation executes. Fixes bug 16478. - Display.getCurrent().asyncExec(() -> { - getShell().forceActive(); - new CopyFilesAndFoldersOperation(getShell()).copyOrLinkFiles(names, target, currentOperation); - }); - return problems; - } - - /** - * Performs a resource copy - */ - private IStatus performResourceCopy(Shell shell, IResource[] sources) { - MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1, - ResourceNavigatorMessages.DropAdapter_problemsMoving, null); - mergeStatus(problems, validateTarget(getCurrentTarget(), getCurrentTransfer())); - - IContainer target = getActualTarget((IResource) getCurrentTarget()); - - boolean shouldLinkAutomatically = false; - if (target.isVirtual()) { - shouldLinkAutomatically = true; - for (IResource source : sources) { - if (source.getType() != IResource.FILE) { - shouldLinkAutomatically = false; - break; - } - } - } - - CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell); - - // if the target is a group and all sources are files, then automatically create - // links - if (shouldLinkAutomatically) { - operation.setCreateLinks(true); - operation.copyResources(sources, target); - } else { - boolean allSourceAreLinksOrGroups = true; - for (IResource source : sources) { - if (!source.isVirtual() && !source.isLinked()) { - allSourceAreLinksOrGroups = false; - break; - } - } - // if all sources are either links or groups, copy then normally, don't show the - // dialog - if (!allSourceAreLinksOrGroups) { - IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); - String dndPreference = store.getString( - target.isVirtual() ? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE - : IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE); - - if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) { - ImportTypeDialog dialog = new ImportTypeDialog(getShell(), getCurrentOperation(), sources, target); - dialog.setResource(target); - if (dialog.open() == Window.OK) { - if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS) - operation.setVirtualFolders(true); - if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK) - operation.setCreateLinks(true); - if (dialog.getVariable() != null) - operation.setRelativeVariable(dialog.getVariable()); - operation.copyResources(sources, target); - } else - return problems; - } else - operation.copyResources(sources, target); - } else - operation.copyResources(sources, target); - } - - return problems; - } - - /** - * Performs a resource move - */ - private IStatus performResourceMove(IResource[] sources) { - MultiStatus problems = new MultiStatus(PlatformUI.PLUGIN_ID, 1, - ResourceNavigatorMessages.DropAdapter_problemsMoving, null); - mergeStatus(problems, validateTarget(getCurrentTarget(), getCurrentTransfer())); - - IContainer target = getActualTarget((IResource) getCurrentTarget()); - - boolean shouldLinkAutomatically = false; - if (target.isVirtual()) { - shouldLinkAutomatically = true; - for (IResource source : sources) { - if (source.isVirtual() || source.isLinked()) { - shouldLinkAutomatically = false; - break; - } - } - } - - if (shouldLinkAutomatically) { - CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(getShell()); - operation.setCreateLinks(true); - operation.copyResources(sources, target); - } else { - ReadOnlyStateChecker checker = new ReadOnlyStateChecker(getShell(), - ResourceNavigatorMessages.MoveResourceAction_title, - ResourceNavigatorMessages.MoveResourceAction_checkMoveMessage); - sources = checker.checkReadOnlyResources(sources); - MoveFilesAndFoldersOperation operation = new MoveFilesAndFoldersOperation(getShell()); - operation.copyResources(sources, target); - } - - return problems; - } - - /* - * @see org.eclipse.ui.dialogs.IOverwriteQuery#queryOverwrite(java.lang.String) - */ - @Override - public String queryOverwrite(String pathString) { - if (alwaysOverwrite) { - return ALL; - } - - final String returnCode[] = { CANCEL }; - final String msg = NLS.bind(ResourceNavigatorMessages.DropAdapter_overwriteQuery, pathString); - final String[] options = { IDialogConstants.YES_LABEL, IDialogConstants.YES_TO_ALL_LABEL, - IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }; - getDisplay().syncExec(() -> { - MessageDialog dialog = new MessageDialog(getShell(), ResourceNavigatorMessages.DropAdapter_question, null, - msg, MessageDialog.QUESTION, 0, options); - dialog.open(); - int returnVal = dialog.getReturnCode(); - String[] returnCodes = { YES, ALL, NO, CANCEL }; - returnCode[0] = returnVal < 0 ? CANCEL : returnCodes[returnVal]; - }); - if (returnCode[0] == ALL) { - alwaysOverwrite = true; - } - return returnCode[0]; - } - - /** - * This method is used to notify the action that some aspect of the drop - * operation has changed. - */ - @Override - public boolean validateDrop(Object target, int dragOperation, TransferData transferType) { - - if (dragOperation != DND.DROP_NONE) { - lastValidOperation = dragOperation; - } - if (FileTransfer.getInstance().isSupportedType(transferType) && (lastValidOperation != DND.DROP_COPY)) { - return false; - } - if (super.validateDrop(target, dragOperation, transferType)) { - return true; - } - return validateTarget(target, transferType).isOK(); - } - - /** - * Ensures that the drop target meets certain criteria - */ - private IStatus validateTarget(Object target, TransferData transferType) { - if (!(target instanceof IResource)) { - return info(ResourceNavigatorMessages.DropAdapter_targetMustBeResource); - } - IResource resource = (IResource) target; - if (!resource.isAccessible()) { - return error(ResourceNavigatorMessages.DropAdapter_canNotDropIntoClosedProject); - } - IContainer destination = getActualTarget(resource); - if (destination.getType() == IResource.ROOT) { - return error(ResourceNavigatorMessages.DropAdapter_resourcesCanNotBeSiblings); - } - String message = null; - // drag within Eclipse? - if (LocalSelectionTransfer.getInstance().isSupportedType(transferType)) { - IResource[] selectedResources = getSelectedResources(); - - if (selectedResources.length == 0) { - message = ResourceNavigatorMessages.DropAdapter_dropOperationErrorOther; - } else { - CopyFilesAndFoldersOperation operation; - if (lastValidOperation == DND.DROP_COPY) { - operation = new CopyFilesAndFoldersOperation(getShell()); - if (operation.validateDestination(destination, selectedResources) != null) { - operation.setVirtualFolders(true); - message = operation.validateDestination(destination, selectedResources); - } - } else { - operation = new MoveFilesAndFoldersOperation(getShell()); - if (operation.validateDestination(destination, selectedResources) != null) { - operation.setVirtualFolders(true); - message = operation.validateDestination(destination, selectedResources); - if (message == null) - lastValidOperation = DND.DROP_COPY; - } - } - } - } // file import? - else if (FileTransfer.getInstance().isSupportedType(transferType)) { - String[] sourceNames = (String[]) FileTransfer.getInstance().nativeToJava(transferType); - if (sourceNames == null) { - // source names will be null on Linux. Use empty names to do destination - // validation. - // Fixes bug 29778 - sourceNames = new String[0]; - } - CopyFilesAndFoldersOperation copyOperation = new CopyFilesAndFoldersOperation(getShell()); - message = copyOperation.validateImportDestination(destination, sourceNames); - } - if (message != null) { - return error(message); - } - return ok(); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorFrameSource.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorFrameSource.java deleted file mode 100644 index 37a3895991d..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorFrameSource.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.views.framelist.TreeFrame; -import org.eclipse.ui.views.framelist.TreeViewerFrameSource; - -/** - * Frame source for the resource navigator. - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class NavigatorFrameSource extends TreeViewerFrameSource { - - private ResourceNavigator navigator; - - /** - * Constructs a new frame source for the specified resource navigator. - * - * @param navigator the resource navigator - */ - public NavigatorFrameSource(ResourceNavigator navigator) { - super(navigator.getTreeViewer()); - this.navigator = navigator; - } - - /** - * Returns a new frame. This implementation extends the super implementation by - * setting the frame's tool tip text to show the full path for the input - * element. - */ - @Override - protected TreeFrame createFrame(Object input) { - TreeFrame frame = super.createFrame(input); - frame.setName(navigator.getFrameName(input)); - frame.setToolTipText(navigator.getFrameToolTipText(input)); - return frame; - } - - /** - * Also updates the navigator's title. - */ - @Override - protected void frameChanged(TreeFrame frame) { - IResource resource = (IResource) frame.getInput(); - IProject project = resource.getProject(); - - if (project != null && project.isOpen() == false) { - MessageDialog.openInformation(navigator.getViewSite().getShell(), - ResourceNavigatorMessages.NavigatorFrameSource_closedProject_title, - NLS.bind(ResourceNavigatorMessages.NavigatorFrameSource_closedProject_message, project.getName())); - navigator.getFrameList().back(); - } else { - super.frameChanged(frame); - navigator.updateTitle(); - } - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/OpenActionGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/OpenActionGroup.java deleted file mode 100644 index f0db464e756..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/OpenActionGroup.java +++ /dev/null @@ -1,135 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.OpenFileAction; -import org.eclipse.ui.actions.OpenInNewWindowAction; -import org.eclipse.ui.actions.OpenWithMenu; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; - -/** - * This is the action group for the open actions. - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class OpenActionGroup extends ResourceNavigatorActionGroup { - - private OpenFileAction openFileAction; - - /** - * The id for the Open With submenu. - */ - public static final String OPEN_WITH_ID = PlatformUI.PLUGIN_ID + ".OpenWithSubMenu"; //$NON-NLS-1$ - - /** - * Creates a new action group for open actions. - * - * @param navigator the resource navigator - */ - public OpenActionGroup(IResourceNavigator navigator) { - super(navigator); - } - - @Override - protected void makeActions() { - openFileAction = new OpenFileAction(navigator.getSite().getPage()); - } - - @Override - public void fillContextMenu(IMenuManager menu) { - IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); - - boolean anyResourceSelected = !selection.isEmpty() && ResourceSelectionUtil.allResourcesAreOfType(selection, - IResource.PROJECT | IResource.FOLDER | IResource.FILE); - boolean onlyFilesSelected = !selection.isEmpty() - && ResourceSelectionUtil.allResourcesAreOfType(selection, IResource.FILE); - - if (onlyFilesSelected) { - openFileAction.selectionChanged(selection); - menu.add(openFileAction); - fillOpenWithMenu(menu, selection); - } - - if (anyResourceSelected) { - 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(ResourceNavigatorMessages.ResourceNavigator_openWith, OPEN_WITH_ID); - submenu.add(new OpenWithMenu(navigator.getSite().getPage(), (IFile) element)); - menu.add(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.add(new OpenInNewWindowAction(navigator.getSite().getWorkbenchWindow(), (IContainer) element)); - } - - /** - * Runs the default action (open file). - */ - @Override - public void runDefaultAction(IStructuredSelection selection) { - Object element = selection.getFirstElement(); - if (element instanceof IFile) { - openFileAction.selectionChanged(selection); - openFileAction.run(); - } - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/PasteAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/PasteAction.java deleted file mode 100644 index 67979ebe226..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/PasteAction.java +++ /dev/null @@ -1,256 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.List; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.dnd.TransferData; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.CopyFilesAndFoldersOperation; -import org.eclipse.ui.actions.CopyProjectOperation; -import org.eclipse.ui.actions.SelectionListenerAction; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.part.ResourceTransfer; - -/** - * Standard action for pasting resources on the clipboard to the selected - * resource's location. - *

- * This class may be instantiated; it is not intended to be subclassed. - *

- * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - * @since 2.0 - */ -@Deprecated(forRemoval = true) -/* package */class PasteAction extends SelectionListenerAction { - - /** - * The id of this action. - */ - public static final String ID = PlatformUI.PLUGIN_ID + ".PasteAction";//$NON-NLS-1$ - - /** - * The shell in which to show any dialogs. - */ - private Shell shell; - - /** - * System clipboard - */ - private Clipboard clipboard; - - /** - * Creates a new action. - * - * @param shell the shell for any dialogs - * @param clipboard the clipboard - */ - public PasteAction(Shell shell, Clipboard clipboard) { - super(ResourceNavigatorMessages.PasteAction_title); - Assert.isNotNull(shell); - Assert.isNotNull(clipboard); - this.shell = shell; - this.clipboard = clipboard; - setToolTipText(ResourceNavigatorMessages.PasteAction_toolTip); - setId(PasteAction.ID); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, INavigatorHelpContextIds.PASTE_ACTION); - } - - /** - * Returns the actual target of the paste action. Returns null if no valid - * target is selected. - * - * @return the actual target of the paste action - */ - private IResource getTarget() { - for (IResource resource : getSelectedResources()) { - if (resource instanceof IProject && !((IProject) resource).isOpen()) { - return null; - } - if (resource.getType() == IResource.FILE) { - resource = resource.getParent(); - } - if (resource != null) { - return resource; - } - } - return null; - } - - /** - * Returns whether any of the given resources are linked resources. - * - * @param resources resource to check for linked type. may be null - * @return true=one or more resources are linked. false=none of the resources - * are linked - */ - private boolean isLinked(IResource[] resources) { - for (IResource resource : resources) { - if (resource.isLinked()) { - return true; - } - } - return false; - } - - /** - * Implementation of method defined on IAction. - */ - @Override - public void run() { - // try a resource transfer - ResourceTransfer resTransfer = ResourceTransfer.getInstance(); - IResource[] resourceData = (IResource[]) clipboard.getContents(resTransfer); - - if (resourceData != null && resourceData.length > 0) { - if (resourceData[0].getType() == IResource.PROJECT) { - // enablement checks for all projects - for (IResource resource : resourceData) { - CopyProjectOperation operation = new CopyProjectOperation(this.shell); - operation.copyProject((IProject) resource); - } - } else { - // enablement should ensure that we always have access to a container - IContainer container = getContainer(); - - CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(this.shell); - operation.copyResources(resourceData, container); - } - return; - } - - // try a file transfer - FileTransfer fileTransfer = FileTransfer.getInstance(); - String[] fileData = (String[]) clipboard.getContents(fileTransfer); - - if (fileData != null) { - // enablement should ensure that we always have access to a container - IContainer container = getContainer(); - - CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(this.shell); - operation.copyFiles(fileData, container); - } - } - - /** - * Returns the container to hold the pasted resources. - */ - private IContainer getContainer() { - List selection = getSelectedResources(); - if (selection.get(0) instanceof IFile) { - return ((IFile) selection.get(0)).getParent(); - } - return (IContainer) selection.get(0); - } - - /** - * The PasteAction implementation of this - * SelectionListenerAction method enables this action if a resource - * compatible with what is on the clipboard is selected. - * - * -Clipboard must have IResource or java.io.File -Projects can always be pasted - * if they are open -Workspace folder may not be copied into itself -Files and - * folders may be pasted to a single selected folder in open project or multiple - * selected files in the same folder - */ - @Override - protected boolean updateSelection(IStructuredSelection selection) { - if (!super.updateSelection(selection)) { - return false; - } - - final IResource[][] clipboardData = new IResource[1][]; - shell.getDisplay().syncExec(() -> { - // clipboard must have resources or files - ResourceTransfer resTransfer = ResourceTransfer.getInstance(); - clipboardData[0] = (IResource[]) clipboard.getContents(resTransfer); - }); - IResource[] resourceData = clipboardData[0]; - boolean isProjectRes = resourceData != null && resourceData.length > 0 - && resourceData[0].getType() == IResource.PROJECT; - - if (isProjectRes) { - for (IResource resource : resourceData) { - // make sure all resource data are open projects - // can paste open projects regardless of selection - if (resource.getType() != IResource.PROJECT || ((IProject) resource).isOpen() == false) { - return false; - } - } - return true; - } - - if (getSelectedNonResources().size() > 0) { - return false; - } - - IResource targetResource = getTarget(); - // targetResource is null if no valid target is selected (e.g., open project) - // or selection is empty - if (targetResource == null) { - return false; - } - - // can paste files and folders to a single selection (file, folder, - // open project) or multiple file selection with the same parent - List selectedResources = getSelectedResources(); - if (selectedResources.size() > 1) { - for (IResource resource : selectedResources) { - if (resource.getType() != IResource.FILE) { - return false; - } - if (!targetResource.equals(resource.getParent())) { - return false; - } - } - } - if (resourceData != null) { - // linked resources can only be pasted into projects - if (isLinked(resourceData) && targetResource.getType() != IResource.PROJECT - && targetResource.getType() != IResource.FOLDER) { - return false; - } - - if (targetResource.getType() == IResource.FOLDER) { - // don't try to copy folder to self - for (IResource resource : resourceData) { - if (targetResource.equals(resource)) { - return false; - } - } - } - return true; - } - TransferData[] transfers = clipboard.getAvailableTypes(); - FileTransfer fileTransfer = FileTransfer.getInstance(); - for (TransferData transfer : transfers) { - if (fileTransfer.isSupportedType(transfer)) { - return true; - } - } - return false; - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/RefactorActionGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/RefactorActionGroup.java deleted file mode 100644 index eee432a2d6d..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/RefactorActionGroup.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Sebastian Davids - Images for menu items (27481) - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.window.IShellProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.DeleteResourceAction; -import org.eclipse.ui.actions.TextActionHandler; - -/** - * This is the action group for refactor actions, including global action - * handlers for copy, paste and delete. - * - * @since 2.0 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class RefactorActionGroup extends ResourceNavigatorActionGroup { - - private Clipboard clipboard; - - private CopyAction copyAction; - - private DeleteResourceAction deleteAction; - - private PasteAction pasteAction; - - private ResourceNavigatorRenameAction renameAction; - - private ResourceNavigatorMoveAction moveAction; - - private TextActionHandler textActionHandler; - - public RefactorActionGroup(IResourceNavigator navigator) { - super(navigator); - } - - @Override - public void dispose() { - if (clipboard != null) { - clipboard.dispose(); - clipboard = null; - } - super.dispose(); - } - - @Override - public void fillContextMenu(IMenuManager menu) { - IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); - - boolean anyResourceSelected = !selection.isEmpty() && ResourceSelectionUtil.allResourcesAreOfType(selection, - IResource.PROJECT | IResource.FOLDER | IResource.FILE); - - copyAction.selectionChanged(selection); - menu.add(copyAction); - pasteAction.selectionChanged(selection); - menu.add(pasteAction); - - if (anyResourceSelected) { - deleteAction.selectionChanged(selection); - menu.add(deleteAction); - moveAction.selectionChanged(selection); - menu.add(moveAction); - renameAction.selectionChanged(selection); - menu.add(renameAction); - } - } - - @Override - public void fillActionBars(IActionBars actionBars) { - textActionHandler = new TextActionHandler(actionBars); // hooks handlers - textActionHandler.setCopyAction(copyAction); - textActionHandler.setPasteAction(pasteAction); - textActionHandler.setDeleteAction(deleteAction); - renameAction.setTextActionHandler(textActionHandler); - - actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction); - actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction); - } - - /** - * Handles a key pressed event by invoking the appropriate action. - */ - @Override - public void handleKeyPressed(KeyEvent event) { - if (event.character == SWT.DEL && event.stateMask == 0) { - if (deleteAction.isEnabled()) { - deleteAction.run(); - } - - // Swallow the event. - event.doit = false; - - } else if (event.keyCode == SWT.F2 && event.stateMask == 0) { - if (renameAction.isEnabled()) { - renameAction.run(); - } - - // Swallow the event. - event.doit = false; - } - } - - @Override - protected void makeActions() { - TreeViewer treeViewer = navigator.getViewer(); - IShellProvider provider = navigator.getSite(); - clipboard = new Clipboard(provider.getShell().getDisplay()); - - pasteAction = new PasteAction(provider.getShell(), clipboard); - ISharedImages images = PlatformUI.getWorkbench().getSharedImages(); - pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED)); - pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); - - copyAction = new CopyAction(provider.getShell(), clipboard, pasteAction); - copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED)); - copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); - - moveAction = new ResourceNavigatorMoveAction(provider.getShell(), treeViewer); - renameAction = new ResourceNavigatorRenameAction(provider.getShell(), treeViewer); - - deleteAction = new DeleteResourceAction(provider); - deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); - deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); - } - - @Override - public void updateActionBars() { - IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); - - copyAction.selectionChanged(selection); - pasteAction.selectionChanged(selection); - deleteAction.selectionChanged(selection); - moveAction.selectionChanged(selection); - renameAction.selectionChanged(selection); - } - -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigator.java deleted file mode 100644 index c72f21d30a4..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigator.java +++ /dev/null @@ -1,1505 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Benjamin Muskalla - bug 105041 - * Remy Chi Jian Suen - bug 144102 - * Lars Vogel - Bug 440810 - * Andrey Loskutov - generified interface, bug 461762 - * Mickael Istria (Red Hat Inc.) - Bug 486901 - *******************************************************************************/ - -package org.eclipse.ui.views.navigator; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Objects; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Adapters; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.commands.ActionHandler; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.viewers.DecoratingLabelProvider; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.ILabelDecorator; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.OpenEvent; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.jface.viewers.ViewerSorter; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.dnd.DND; -import org.eclipse.swt.dnd.FileTransfer; -import org.eclipse.swt.dnd.Transfer; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.KeyListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IMemento; -import org.eclipse.ui.IPartListener; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbenchCommandConstants; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPreferenceConstants; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; -import org.eclipse.ui.OpenAndLinkWithEditorHelper; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ResourceWorkingSetFilter; -import org.eclipse.ui.actions.ActionContext; -import org.eclipse.ui.actions.OpenResourceAction; -import org.eclipse.ui.handlers.CollapseAllHandler; -import org.eclipse.ui.handlers.IHandlerService; -import org.eclipse.ui.ide.ResourceUtil; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.ui.internal.views.helpers.EmptyWorkspaceHelper; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.ui.part.IShowInSource; -import org.eclipse.ui.part.IShowInTarget; -import org.eclipse.ui.part.PluginTransfer; -import org.eclipse.ui.part.ResourceTransfer; -import org.eclipse.ui.part.ShowInContext; -import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.eclipse.ui.views.framelist.FrameList; -import org.eclipse.ui.views.framelist.TreeFrame; -import org.osgi.framework.FrameworkUtil; - -/** - * Implements the Resource Navigator view. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class ResourceNavigator extends ViewPart implements ISetSelectionTarget, IResourceNavigator { - - private TreeViewer viewer; - - private IDialogSettings settings; - - private IMemento memento; - - private FrameList frameList; - - private ResourceNavigatorActionGroup actionGroup; - - private ResourcePatternFilter patternFilter = new ResourcePatternFilter(); - - private ResourceWorkingSetFilter workingSetFilter = new ResourceWorkingSetFilter(); - - private boolean linkingEnabled; - - private boolean dragDetected; - - private Listener dragDetectListener; - /** - * Remembered working set. - */ - private IWorkingSet workingSet; - - /** - * Marks whether the working set we're using is currently empty. In this event - * we're effectively not using a working set. - */ - private boolean emptyWorkingSet = false; - - /** - * Settings constant for section name (value ResourceNavigator). - */ - private static final String STORE_SECTION = "ResourceNavigator"; //$NON-NLS-1$ - - /** - * Settings constant for sort order (value - * ResourceViewer.STORE_SORT_TYPE). - */ - private static final String STORE_SORT_TYPE = "ResourceViewer.STORE_SORT_TYPE"; //$NON-NLS-1$ - - /** - * Settings constant for working set (value - * ResourceWorkingSetFilter.STORE_WORKING_SET). - */ - private static final String STORE_WORKING_SET = "ResourceWorkingSetFilter.STORE_WORKING_SET"; //$NON-NLS-1$ - - /** - * @deprecated No longer used but preserved to avoid an api change. - */ - @Deprecated - public static final String NAVIGATOR_VIEW_HELP_ID = INavigatorHelpContextIds.RESOURCE_VIEW; - - /** - * True iff we've already scheduled an asynchronous call to linkToEditor - */ - private boolean linkScheduled = false; - - private EmptyWorkspaceHelper emptyWorkspaceHelper; - - // Persistance tags. - private static final String TAG_SORTER = "sorter"; //$NON-NLS-1$ - - private static final String TAG_FILTERS = "filters"; //$NON-NLS-1$ - - private static final String TAG_FILTER = "filter"; //$NON-NLS-1$ - - private static final String TAG_SELECTION = "selection"; //$NON-NLS-1$ - - private static final String TAG_EXPANDED = "expanded"; //$NON-NLS-1$ - - private static final String TAG_ELEMENT = "element"; //$NON-NLS-1$ - - private static final String TAG_IS_ENABLED = "isEnabled"; //$NON-NLS-1$ - - private static final String TAG_PATH = "path"; //$NON-NLS-1$ - - private static final String TAG_CURRENT_FRAME = "currentFrame"; //$NON-NLS-1$ - - private IPartListener partListener = new IPartListener() { - @Override - public void partActivated(IWorkbenchPart part) { - if (part instanceof IEditorPart) { - editorActivated((IEditorPart) part); - } - } - - @Override - public void partBroughtToTop(IWorkbenchPart part) { - if (part instanceof IEditorPart) { - editorActivated((IEditorPart) part); - } - } - - @Override - public void partClosed(IWorkbenchPart part) { - } - - @Override - public void partDeactivated(IWorkbenchPart part) { - } - - @Override - public void partOpened(IWorkbenchPart part) { - } - }; - - private IPropertyChangeListener propertyChangeListener = event -> { - String property = event.getProperty(); - Object newValue = event.getNewValue(); - Object oldValue = event.getOldValue(); - - if (IWorkingSetManager.CHANGE_WORKING_SET_REMOVE.equals(property) && oldValue == workingSet) { - setWorkingSet(null); - } else if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property) && newValue == workingSet) { - updateTitle(); - } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property) && newValue == workingSet) { - if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) { - // act as if the working set has been made null - if (!emptyWorkingSet) { - emptyWorkingSet = true; - workingSetFilter.setWorkingSet(null); - } - } else { - // we've gone from empty to non-empty on our set. - // Restore it. - if (emptyWorkingSet) { - emptyWorkingSet = false; - workingSetFilter.setWorkingSet(workingSet); - } - } - getViewer().refresh(); - } - }; - - private CollapseAllHandler collapseAllHandler; - - /** - * Helper to open and activate editors. - * - * @since 3.5 - */ - private OpenAndLinkWithEditorHelper openAndLinkWithEditorHelper; - - /** - * Constructs a new resource navigator view. - */ - public ResourceNavigator() { - IDialogSettings viewsSettings = PlatformUI - .getDialogSettingsProvider(FrameworkUtil.getBundle(ResourceNavigator.class)).getDialogSettings(); - - settings = viewsSettings.getSection(STORE_SECTION); - if (settings == null) { - settings = viewsSettings.addNewSection(STORE_SECTION); - } - - initLinkingEnabled(); - } - - /** - * Converts the given selection into a form usable by the viewer, where the - * elements are resources. - */ - private StructuredSelection convertSelection(ISelection selection) { - ArrayList list = new ArrayList<>(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection) selection; - for (Object o : ssel) { - IResource resource = Adapters.adapt(o, IResource.class); - if (resource != null) { - list.add(resource); - } - } - } - return new StructuredSelection(list); - } - - @Override - public void createPartControl(Composite parent) { - emptyWorkspaceHelper = new EmptyWorkspaceHelper(); - Composite displayArea = emptyWorkspaceHelper.getComposite(parent); - - TreeViewer viewer = createViewer(displayArea); - this.viewer = viewer; - - emptyWorkspaceHelper.setNonEmptyControl(viewer.getControl()); - - if (memento != null) { - restoreFilters(); - restoreLinkingEnabled(); - } - frameList = createFrameList(); - initDragAndDrop(); - updateTitle(); - - initContextMenu(); - - initResourceComparator(); - initWorkingSetFilter(); - - // make sure input is set after sorters and filters, - // to avoid unnecessary refreshes - viewer.setInput(getInitialInput()); - - // make actions after setting input, because some actions - // look at the viewer for enablement (e.g. the Up action) - makeActions(); - - // Fill the action bars and update the global action handlers' - // enabled state to match the current selection. - getActionGroup().fillActionBars(getViewSite().getActionBars()); - updateActionBars(viewer.getStructuredSelection()); - - getSite().setSelectionProvider(viewer); - getSite().getPage().addPartListener(partListener); - IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); - workingSetManager.addPropertyChangeListener(propertyChangeListener); - - if (memento != null) { - restoreState(memento); - } - memento = null; - - // Set help for the view - getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(viewer.getControl(), getHelpContextId()); - } - - /** - * Returns the help context id to use for this view. - * - * @since 2.0 - */ - protected String getHelpContextId() { - return INavigatorHelpContextIds.RESOURCE_VIEW; - } - - /** - * Initializes and registers the context menu. - * - * @since 2.0 - */ - protected void initContextMenu() { - MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ - menuMgr.setRemoveAllWhenShown(true); - menuMgr.addMenuListener(ResourceNavigator.this::fillContextMenu); - TreeViewer viewer = getTreeViewer(); - Menu menu = menuMgr.createContextMenu(viewer.getTree()); - viewer.getTree().setMenu(menu); - getSite().registerContextMenu(menuMgr, viewer); - } - - /** - * Creates the viewer. - * - * @param parent the parent composite - * @since 2.0 - */ - protected TreeViewer createViewer(Composite parent) { - TreeViewer viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); - viewer.setUseHashlookup(true); - initContentProvider(viewer); - initLabelProvider(viewer); - initFilters(viewer); - initListeners(viewer); - - return viewer; - } - - /** - * Sets the content provider for the viewer. - * - * @param viewer the viewer - * @since 2.0 - */ - protected void initContentProvider(TreeViewer viewer) { - viewer.setContentProvider(new WorkbenchContentProvider()); - } - - /** - * Sets the label provider for the viewer. - * - * @param viewer the viewer - * @since 2.0 - */ - protected void initLabelProvider(TreeViewer viewer) { - viewer.setLabelProvider(new DecoratingLabelProvider(new WorkbenchLabelProvider(), - PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); - } - - /** - * Adds the filters to the viewer. - * - * @param viewer the viewer - * @since 2.0 - */ - protected void initFilters(TreeViewer viewer) { - viewer.addFilter(patternFilter); - viewer.addFilter(workingSetFilter); - } - - /** - * Initializes the linking enabled setting from the preference store. - */ - private void initLinkingEnabled() { - // Try the dialog settings first, which remember the last choice. - String setting = settings.get(IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR); - if (setting != null) { - linkingEnabled = setting.equals("true"); //$NON-NLS-1$ - return; - } - // If not in the dialog settings, check the preference store for the default - // setting. - // Use the UI plugin's preference store since this is a public preference. - linkingEnabled = PlatformUI.getPreferenceStore() - .getBoolean(IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR); - } - - /** - * Adds the listeners to the viewer. - * - * @param viewer the viewer - * @since 2.0 - */ - protected void initListeners(final TreeViewer viewer) { - viewer.addSelectionChangedListener(this::handleSelectionChanged); - viewer.addDoubleClickListener(this::handleDoubleClick); - - openAndLinkWithEditorHelper = new OpenAndLinkWithEditorHelper(viewer) { - @Override - protected void activate(ISelection selection) { - Object selectedElement = getSingleElement(selection); - if (selectedElement instanceof IFile) { - IEditorInput input = new FileEditorInput((IFile) selectedElement); - final IWorkbenchPage page = getSite().getPage(); - IEditorPart editor = page.findEditor(input); - if (editor != null) { - page.activate(editor); - } - } - - } - - @Override - protected void linkToEditor(ISelection selection) { - if (!linkScheduled) { - // Ensure that if another selection change arrives while we're waiting for the - // *syncExec, - // we only do this work once. - linkScheduled = true; - getSite().getShell().getDisplay().asyncExec(() -> { - // There's no telling what might have changed since the syncExec was scheduled. - // Check to make sure that the widgets haven't been disposed. - linkScheduled = false; - - if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed()) { - return; - } - - if (dragDetected == false) { - // only synchronize with editor when the selection is not the result - // of a drag. Fixes bug 22274. - ResourceNavigator.this.linkToEditor(viewer.getSelection()); - } - }); - } - } - - @Override - protected void open(ISelection selection, boolean activate) { - handleOpen(selection); - } - - }; - - viewer.getControl().addKeyListener(new KeyListener() { - @Override - public void keyPressed(KeyEvent event) { - handleKeyPressed(event); - } - - @Override - public void keyReleased(KeyEvent event) { - handleKeyReleased(event); - } - }); - - openAndLinkWithEditorHelper.setLinkWithEditor(linkingEnabled); - } - - @Override - public void dispose() { - getSite().getPage().removePartListener(partListener); - - IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); - workingSetManager.removePropertyChangeListener(propertyChangeListener); - - if (collapseAllHandler != null) { - collapseAllHandler.dispose(); - } - - if (getActionGroup() != null) { - getActionGroup().dispose(); - } - Control control = viewer.getControl(); - if (dragDetectListener != null && control != null && control.isDisposed() == false) { - control.removeListener(SWT.DragDetect, dragDetectListener); - } - - super.dispose(); - } - - /** - * An editor has been activated. Sets the selection in this navigator to be the - * editor's input, if linking is enabled. - * - * @param editor the active editor - * @since 2.0 - */ - protected void editorActivated(IEditorPart editor) { - if (!isLinkingEnabled()) { - return; - } - - IFile file = ResourceUtil.getFile(editor.getEditorInput()); - if (file != null) { - ISelection newSelection = new StructuredSelection(file); - if (getTreeViewer().getStructuredSelection().equals(newSelection)) { - getTreeViewer().getTree().showSelection(); - } else { - getTreeViewer().setSelection(newSelection, true); - } - } - } - - /** - * Called when the context menu is about to open. Delegates to the action group - * using the viewer's selection as the action context. - * - * @since 2.0 - */ - protected void fillContextMenu(IMenuManager menu) { - IStructuredSelection selection = getViewer().getStructuredSelection(); - getActionGroup().setContext(new ActionContext(selection)); - getActionGroup().fillContextMenu(menu); - } - - @Override - public FrameList getFrameList() { - return frameList; - } - - /** - * Returns the initial input for the viewer. Tries to convert the page input to - * a resource, either directly or via IAdaptable. If the resource is a - * container, it uses that. If the resource is a file, it uses its parent - * folder. If a resource could not be obtained, it uses the workspace root. - * - * @since 2.0 - */ - protected IAdaptable getInitialInput() { - IResource resource = Adapters.adapt(getSite().getPage().getInput(), IResource.class); - if (resource != null) { - switch (resource.getType()) { - case IResource.FILE: - return resource.getParent(); - case IResource.FOLDER: - case IResource.PROJECT: - case IResource.ROOT: - return resource; - default: - // Unknown resource type. Fall through. - break; - } - } - return ResourcesPlugin.getWorkspace().getRoot(); - } - - /** - * Returns the pattern filter for this view. - * - * @return the pattern filter - * @since 2.0 - */ - @Override - public ResourcePatternFilter getPatternFilter() { - return this.patternFilter; - } - - /** - * Returns the working set for this view. - * - * @return the working set - * @since 2.0 - */ - @Override - public IWorkingSet getWorkingSet() { - return workingSetFilter.getWorkingSet(); - } - - /** - * Returns the navigator's plugin. - * - * @return the UI plugin for this bundle - */ - public AbstractUIPlugin getPlugin() { - return IDEWorkbenchPlugin.getDefault(); - } - - /** - * Return the sorter. If a comparator was set using - * {@link #setComparator(ResourceComparator)}, this method will return - * null. - * - * @since 2.0 - * @deprecated as of 3.3, use {@link ResourceNavigator#getComparator()} - */ - @Deprecated - @Override - public ResourceSorter getSorter() { - ViewerSorter sorter = getTreeViewer().getSorter(); - if (sorter instanceof ResourceSorter) { - return (ResourceSorter) sorter; - } - return null; - } - - /** - * Returns the comparator. If a sorter was set using - * {@link #setSorter(ResourceSorter)}, this method will return - * null. - * - * @return the ResourceComparator - * @since 3.3 - */ - - @Override - public ResourceComparator getComparator() { - ViewerComparator comparator = getTreeViewer().getComparator(); - if (comparator instanceof ResourceComparator) { - return (ResourceComparator) comparator; - } - return null; - } - - /** - * Returns the resource viewer which shows the resource hierarchy. - * - * @since 2.0 - */ - @Override - public TreeViewer getViewer() { - return viewer; - } - - /** - * Returns the tree viewer which shows the resource hierarchy. - * - * @return the tree viewer - * @since 2.0 - */ - public TreeViewer getTreeViewer() { - return viewer; - } - - /** - * Returns the shell to use for opening dialogs. Used in this class, and in the - * actions. - * - * @return the shell - * @deprecated use getViewSite().getShell() - */ - @Deprecated - public Shell getShell() { - return getViewSite().getShell(); - } - - /** - * Returns the message to show in the status line. - * - * @param selection the current selection - * @return the status line message - * @since 2.0 - */ - protected String getStatusLineMessage(IStructuredSelection selection) { - if (selection.size() == 1) { - Object o = selection.getFirstElement(); - if (o instanceof IResource) { - return ((IResource) o).getFullPath().makeRelative().toString(); - } - return ResourceNavigatorMessages.ResourceNavigator_oneItemSelected; - } - if (selection.size() > 1) { - return NLS.bind(ResourceNavigatorMessages.ResourceNavigator_statusLine, String.valueOf(selection.size())); - } - return ""; //$NON-NLS-1$ - } - - /** - * Returns the name for the given element. Used as the name for the current - * frame. - */ - String getFrameName(Object element) { - if (element instanceof IResource) { - return ((IResource) element).getName(); - } - String text = ((ILabelProvider) getTreeViewer().getLabelProvider()).getText(element); - if (text == null) { - return "";//$NON-NLS-1$ - } - return text; - } - - /** - * Returns the tool tip text for the given element. Used as the tool tip text - * for the current frame, and for the view title tooltip. - */ - String getFrameToolTipText(Object element) { - if (element instanceof IResource) { - IPath path = ((IResource) element).getFullPath(); - if (path.isRoot()) { - return ResourceNavigatorMessages.ResourceManager_toolTip; - } - return path.makeRelative().toString(); - } - - String text = ((ILabelProvider) getTreeViewer().getLabelProvider()).getText(element); - if (text == null) { - return "";//$NON-NLS-1$ - } - return text; - } - - /** - * Handles an open event from the viewer. Opens an editor on the selected file. - * - * @param event the open event - * @since 2.0 - * @deprecated As of 3.5, replaced by {@link #handleOpen(ISelection)} - */ - @Deprecated - protected void handleOpen(OpenEvent event) { - handleOpen(event.getSelection()); - } - - /** - * Handles an open event from the viewer. Opens an editor on the selected file. - * - * @param selection the selection - * @since 3.5 - */ - protected void handleOpen(ISelection selection) { - if (selection instanceof IStructuredSelection) { - getActionGroup().runDefaultAction((IStructuredSelection) selection); - } - } - - /** - * Handles a double-click event from the viewer. Expands or collapses a folder - * when double-clicked. - * - * @param event the double-click event - * @since 2.0 - */ - protected void handleDoubleClick(DoubleClickEvent event) { - IStructuredSelection selection = (IStructuredSelection) event.getSelection(); - Object element = selection.getFirstElement(); - - // 1GBZIA0: ITPUI:WIN2000 - Double-clicking in navigator should expand/collapse - // containers - TreeViewer viewer = getTreeViewer(); - if (viewer.isExpandable(element)) { - viewer.setExpandedState(element, !viewer.getExpandedState(element)); - } else if (selection.size() == 1 && (element instanceof IResource) - && ((IResource) element).getType() == IResource.PROJECT) { - OpenResourceAction ora = new OpenResourceAction(getSite()); - ora.selectionChanged((IStructuredSelection) viewer.getSelection()); - if (ora.isEnabled()) { - ora.run(); - } - } - - } - - /** - * Handles a selection changed event from the viewer. Updates the status line - * and the action bars, and links to editor (if option enabled). - * - * @param event the selection event - * @since 2.0 - */ - protected void handleSelectionChanged(SelectionChangedEvent event) { - final IStructuredSelection sel = event.getStructuredSelection(); - updateStatusLine(sel); - updateActionBars(sel); - dragDetected = false; - } - - /** - * Handles a key press event from the viewer. Delegates to the action group. - * - * @param event the key event - * @since 2.0 - */ - protected void handleKeyPressed(KeyEvent event) { - getActionGroup().handleKeyPressed(event); - } - - /** - * Handles a key release in the viewer. Does nothing by default. - * - * @param event the key event - * @since 2.0 - */ - protected void handleKeyReleased(KeyEvent event) { - } - - @Override - public void init(IViewSite site, IMemento memento) throws PartInitException { - super.init(site, memento); - this.memento = memento; - } - - /** - * Adds drag and drop support to the navigator. - * - * @since 2.0 - */ - protected void initDragAndDrop() { - int ops = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; - Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getInstance(), ResourceTransfer.getInstance(), - FileTransfer.getInstance(), PluginTransfer.getInstance() }; - TreeViewer viewer = getTreeViewer(); - viewer.addDragSupport(ops, transfers, new NavigatorDragAdapter(viewer)); - NavigatorDropAdapter adapter = new NavigatorDropAdapter(viewer); - adapter.setFeedbackEnabled(false); - viewer.addDropSupport(ops | DND.DROP_DEFAULT, transfers, adapter); - dragDetectListener = event -> dragDetected = true; - viewer.getControl().addListener(SWT.DragDetect, dragDetectListener); - } - - /** - * Creates the frame source and frame list, and connects them. - * - * @since 2.0 - */ - protected FrameList createFrameList() { - NavigatorFrameSource frameSource = new NavigatorFrameSource(this); - FrameList frameList = new FrameList(frameSource); - frameSource.connectTo(frameList); - return frameList; - } - - /** - * Initializes the sorter. - * - * @deprecated as of 3.3, use {@link ResourceNavigator#initResourceComparator()} - * instead - */ - @Deprecated - protected void initResourceSorter() { - int sortType = ResourceSorter.NAME; - try { - int sortInt = 0; - if (memento != null) { - String sortStr = memento.getString(TAG_SORTER); - if (sortStr != null) { - sortInt = Integer.parseInt(sortStr); - } - } else { - sortInt = settings.getInt(STORE_SORT_TYPE); - } - if (sortInt == ResourceSorter.NAME || sortInt == ResourceSorter.TYPE) { - sortType = sortInt; - } - } catch (NumberFormatException e) { - } - setSorter(new ResourceSorter(sortType)); - } - - /** - * Initializes the comparator. - * - * @since 3.3 - */ - protected void initResourceComparator() { - int sortType = ResourceComparator.NAME; - try { - int sortInt = 0; - if (memento != null) { - String sortStr = memento.getString(TAG_SORTER); - if (sortStr != null) { - sortInt = Integer.parseInt(sortStr); - } - } else { - sortInt = settings.getInt(STORE_SORT_TYPE); - } - if (sortInt == ResourceComparator.NAME || sortInt == ResourceComparator.TYPE) { - sortType = sortInt; - } - } catch (NumberFormatException e) { - } - setComparator(new ResourceComparator(sortType)); - } - - /** - * Restores the working set filter from the persistence store. - */ - protected void initWorkingSetFilter() { - String workingSetName = settings.get(STORE_WORKING_SET); - - IWorkingSet workingSet = null; - - if (workingSetName != null && workingSetName.isEmpty() == false) { - IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); - workingSet = workingSetManager.getWorkingSet(workingSetName); - } else if (PlatformUI.getPreferenceStore() - .getBoolean(IWorkbenchPreferenceConstants.USE_WINDOW_WORKING_SET_BY_DEFAULT)) { - // use the window set by default if the global preference is set - workingSet = getSite().getPage().getAggregateWorkingSet(); - } - - if (workingSet != null) { - // Only initialize filter. Don't set working set into viewer. - // Working set is set via WorkingSetFilterActionGroup - // during action creation. - workingSetFilter.setWorkingSet(workingSet); - internalSetWorkingSet(workingSet); - } - } - - /** - * Returns whether the navigator selection automatically tracks the active - * editor. - * - * @return true if linking is enabled, false if not - * @since 2.0 (this was protected in 2.0, but was made public in 2.1) - */ - @Override - public boolean isLinkingEnabled() { - return linkingEnabled; - } - - /** - * Brings the corresponding editor to top if the selected resource is open. - * - * @since 2.0 - * @deprecated As of 3.5, replaced by {@link #linkToEditor(ISelection)} - */ - @Deprecated - protected void linkToEditor(IStructuredSelection selection) { - linkToEditor((ISelection) selection); - } - - /** - * Brings the corresponding editor to top if the selected resource is open. - * - * @since 3.5 - */ - protected void linkToEditor(ISelection selection) { - - if (this != this.getSite().getPage().getActivePart()) - return; - - Object obj = getSingleElement(selection); - if (obj instanceof IFile) { - IFile file = (IFile) obj; - IWorkbenchPage page = getSite().getPage(); - IEditorPart editor = ResourceUtil.findEditor(page, file); - if (editor != null) { - page.bringToTop(editor); - return; - } - } - } - - /** - * Creates the action group, which encapsulates all actions for the view. - */ - protected void makeActions() { - MainActionGroup group = new MainActionGroup(this); - setActionGroup(group); - - IHandlerService service = getSite().getService(IHandlerService.class); - service.activateHandler(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR, - new ActionHandler(group.toggleLinkingAction)); - collapseAllHandler = new CollapseAllHandler(viewer); - service.activateHandler(CollapseAllHandler.COMMAND_ID, collapseAllHandler); - } - - /** - * Restores the saved filter settings. - */ - private void restoreFilters() { - IMemento filtersMem = memento.getChild(TAG_FILTERS); - - if (filtersMem != null) { // filters have been defined - IMemento children[] = filtersMem.getChildren(TAG_FILTER); - - // check if first element has new tag defined, indicates new version - if (children.length > 0 && children[0].getString(TAG_IS_ENABLED) != null) { - ArrayList selectedFilters = new ArrayList<>(); - ArrayList unSelectedFilters = new ArrayList(); - for (IMemento memento : children) { - if (memento.getString(TAG_IS_ENABLED).equals(String.valueOf(true))) { - selectedFilters.add(memento.getString(TAG_ELEMENT)); - } else { - // enabled == false - unSelectedFilters.add(memento.getString(TAG_ELEMENT)); - } - } - - /* - * merge filters from Memento with selected = true filters from plugins ensure - * there are no duplicates & don't override user preferences - */ - List pluginFilters = FiltersContentProvider.getDefaultFilters(); - for (Iterator iter = pluginFilters.iterator(); iter.hasNext();) { - String element = (String) iter.next(); - if (!selectedFilters.contains(element) && !unSelectedFilters.contains(element)) { - selectedFilters.add(element); - } - } - - // Convert to an array of Strings - String[] patternArray = new String[selectedFilters.size()]; - selectedFilters.toArray(patternArray); - getPatternFilter().setPatterns(patternArray); - - } else { // filters defined, old version: ignore filters from plugins - String filters[] = new String[children.length]; - for (int i = 0; i < children.length; i++) { - filters[i] = children[i].getString(TAG_ELEMENT); - } - getPatternFilter().setPatterns(filters); - } - } else { // no filters defined, old version: ignore filters from plugins - getPatternFilter().setPatterns(new String[0]); - } - } - - /** - * Restores the state of the receiver to the state described in the specified - * memento. - * - * @param memento the memento - * @since 2.0 - */ - protected void restoreState(IMemento memento) { - TreeViewer viewer = getTreeViewer(); - IMemento frameMemento = memento.getChild(TAG_CURRENT_FRAME); - - if (frameMemento != null) { - TreeFrame frame = new TreeFrame(viewer); - frame.restoreState(frameMemento); - frame.setName(getFrameName(frame.getInput())); - frame.setToolTipText(getFrameToolTipText(frame.getInput())); - viewer.setSelection(new StructuredSelection(frame.getInput())); - frameList.gotoFrame(frame); - } else { - IContainer container = ResourcesPlugin.getWorkspace().getRoot(); - IMemento childMem = memento.getChild(TAG_EXPANDED); - if (childMem != null) { - ArrayList elements = new ArrayList(); - for (IMemento mem : childMem.getChildren(TAG_ELEMENT)) { - Object element = container.findMember(mem.getString(TAG_PATH)); - if (element != null) { - elements.add(element); - } - } - viewer.setExpandedElements(elements.toArray()); - } - childMem = memento.getChild(TAG_SELECTION); - if (childMem != null) { - ArrayList list = new ArrayList(); - for (IMemento mem : childMem.getChildren(TAG_ELEMENT)) { - Object element = container.findMember(mem.getString(TAG_PATH)); - if (element != null) { - list.add(element); - } - } - viewer.setSelection(new StructuredSelection(list)); - } - } - } - - /** - * Restores the linking enabled state. - */ - private void restoreLinkingEnabled() { - Integer val = memento.getInteger(IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR); - if (val != null) { - linkingEnabled = val.intValue() != 0; - } - } - - /** - * @see ViewPart#saveState - */ - @Override - public void saveState(IMemento memento) { - TreeViewer viewer = getTreeViewer(); - if (viewer == null) { - if (this.memento != null) { - memento.putMemento(this.memento); - } - return; - } - - // save sorter - if (getComparator() != null) { - memento.putInteger(TAG_SORTER, getComparator().getCriteria()); - } else if (getSorter() != null) { - memento.putInteger(TAG_SORTER, getSorter().getCriteria()); - } - - // save filters - String filters[] = getPatternFilter().getPatterns(); - List selectedFilters = Arrays.asList(filters); - List allFilters = FiltersContentProvider.getDefinedFilters(); - IMemento filtersMem = memento.createChild(TAG_FILTERS); - for (Iterator iter = allFilters.iterator(); iter.hasNext();) { - String element = (String) iter.next(); - IMemento child = filtersMem.createChild(TAG_FILTER); - child.putString(TAG_ELEMENT, element); - child.putString(TAG_IS_ENABLED, String.valueOf(selectedFilters.contains(element))); - } - - if (frameList.getCurrentIndex() > 0) { - // save frame, it's not the "home"/workspace frame - TreeFrame currentFrame = (TreeFrame) frameList.getCurrentFrame(); - IMemento frameMemento = memento.createChild(TAG_CURRENT_FRAME); - currentFrame.saveState(frameMemento); - } else { - // save visible expanded elements - Object expandedElements[] = viewer.getVisibleExpandedElements(); - if (expandedElements.length > 0) { - IMemento expandedMem = memento.createChild(TAG_EXPANDED); - for (Object expandedElement : expandedElements) { - if (expandedElement instanceof IResource) { - IMemento elementMem = expandedMem.createChild(TAG_ELEMENT); - elementMem.putString(TAG_PATH, ((IResource) expandedElement).getFullPath().toString()); - } - } - } - // save selection - Object elements[] = viewer.getStructuredSelection().toArray(); - if (elements.length > 0) { - IMemento selectionMem = memento.createChild(TAG_SELECTION); - for (Object selectionElement : elements) { - if (selectionElement instanceof IResource) { - IMemento elementMem = selectionMem.createChild(TAG_ELEMENT); - elementMem.putString(TAG_PATH, ((IResource) selectionElement).getFullPath().toString()); - } - } - } - } - - saveLinkingEnabled(memento); - } - - /** - * Saves the linking enabled state. - */ - private void saveLinkingEnabled(IMemento memento) { - memento.putInteger(IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR, linkingEnabled ? 1 : 0); - } - - /** - * Selects and reveals the specified elements. - */ - @Override - public void selectReveal(ISelection selection) { - StructuredSelection ssel = convertSelection(selection); - if (!ssel.isEmpty()) { - getViewer().getControl().setRedraw(false); - getViewer().setSelection(ssel, true); - getViewer().getControl().setRedraw(true); - } - } - - /** - * Saves the filters defined as strings in patterns in the - * preference store. - */ - @Override - public void setFiltersPreference(String[] patterns) { - - getPlugin().getPreferenceStore().setValue(ResourcePatternFilter.FILTERS_TAG, - String.join(ResourcePatternFilter.COMMA_SEPARATOR, patterns)); - - // remove value in old workbench preference store location - IPreferenceStore preferenceStore = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); - String storedPatterns = preferenceStore.getString(ResourcePatternFilter.FILTERS_TAG); - if (storedPatterns.length() > 0) { - preferenceStore.setValue(ResourcePatternFilter.FILTERS_TAG, ""); //$NON-NLS-1$ - } - } - - /** - * @see IWorkbenchPart#setFocus() - */ - @Override - public void setFocus() { - getTreeViewer().getTree().setFocus(); - } - - /** - * Note: For experimental use only. Sets the decorator for the navigator. - *

- * As of 2.0, this method no longer has any effect. - *

- * - * @param decorator a label decorator or null for no decorations. - * @deprecated use the decorators extension point instead; see - * IWorkbench.getDecoratorManager() - */ - @Deprecated - public void setLabelDecorator(ILabelDecorator decorator) { - // do nothing - } - - /** - * @see IResourceNavigator#setLinkingEnabled(boolean) - * @since 2.1 - */ - @Override - public void setLinkingEnabled(boolean enabled) { - this.linkingEnabled = enabled; - - // remember the last setting in the dialog settings - settings.put(IWorkbenchPreferenceConstants.LINK_NAVIGATOR_TO_EDITOR, enabled); - - // if turning linking on, update the selection to correspond to the active - // editor - if (enabled) { - IEditorPart editor = getSite().getPage().getActiveEditor(); - if (editor != null) { - editorActivated(editor); - } - } - openAndLinkWithEditorHelper.setLinkWithEditor(enabled); - } - - /** - * Sets the resource sorter. - * - * @param sorter the resource sorter - * @since 2.0 - * @deprecated as of 3.3, use - * {@link ResourceNavigator#setComparator(ResourceComparator)} - */ - @Deprecated - @Override - public void setSorter(ResourceSorter sorter) { - TreeViewer viewer = getTreeViewer(); - ViewerSorter viewerSorter = viewer.getSorter(); - - viewer.getControl().setRedraw(false); - if (viewerSorter == sorter) { - viewer.refresh(); - } else { - viewer.setSorter(sorter); - } - viewer.getControl().setRedraw(true); - settings.put(STORE_SORT_TYPE, sorter.getCriteria()); - - // update the sort actions' checked state - updateActionBars((IStructuredSelection) viewer.getSelection()); - } - - /** - * Sets the resource comparator - * - * @param comparator the resource comparator - * @since 3.3 - */ - @Override - public void setComparator(ResourceComparator comparator) { - TreeViewer viewer = getTreeViewer(); - ViewerComparator viewerComparator = viewer.getComparator(); - - viewer.getControl().setRedraw(false); - if (viewerComparator == comparator) { - viewer.refresh(); - } else { - viewer.setComparator(comparator); - } - viewer.getControl().setRedraw(true); - settings.put(STORE_SORT_TYPE, comparator.getCriteria()); - - // update the sort actions' checked state - updateActionBars(viewer.getStructuredSelection()); - } - - @Override - public void setWorkingSet(IWorkingSet workingSet) { - TreeViewer treeViewer = getTreeViewer(); - Object[] expanded = treeViewer.getExpandedElements(); - IStructuredSelection structuredSelection = treeViewer.getStructuredSelection(); - - boolean refreshNeeded = internalSetWorkingSet(workingSet); - - workingSetFilter.setWorkingSet(emptyWorkingSet ? null : workingSet); - if (workingSet != null) { - settings.put(STORE_WORKING_SET, workingSet.getName()); - } else { - settings.put(STORE_WORKING_SET, ""); //$NON-NLS-1$ - } - updateTitle(); - if (refreshNeeded) { - treeViewer.refresh(); - } - treeViewer.setExpandedElements(expanded); - if (structuredSelection.isEmpty() == false) { - treeViewer.reveal(structuredSelection.getFirstElement()); - } - } - - /** - * Set the internal working set fields specific to the navigator. - * - * @param workingSet the new working set - * @since 3.2 - */ - private boolean internalSetWorkingSet(IWorkingSet workingSet) { - boolean refreshNeeded = !Objects.equals(this.workingSet, workingSet); - this.workingSet = workingSet; - emptyWorkingSet = workingSet != null && workingSet.isAggregateWorkingSet() && workingSet.isEmpty(); - return refreshNeeded; - } - - /** - * Updates the action bar actions. - * - * @param selection the current selection - * @since 2.0 - */ - protected void updateActionBars(IStructuredSelection selection) { - ResourceNavigatorActionGroup group = getActionGroup(); - if (group != null) { - group.setContext(new ActionContext(selection)); - group.updateActionBars(); - } - } - - /** - * Updates the message shown in the status line. - * - * @param selection the current selection - */ - protected void updateStatusLine(IStructuredSelection selection) { - String msg = getStatusLineMessage(selection); - getViewSite().getActionBars().getStatusLineManager().setMessage(msg); - } - - /** - * Updates the title text and title tool tip. Called whenever the input of the - * viewer changes. Called whenever the input of the viewer changes. - * - * @since 2.0 - */ - public void updateTitle() { - Object input = getViewer().getInput(); - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkingSet workingSet = workingSetFilter.getWorkingSet(); - - if (input == null || input.equals(workspace) || input.equals(workspace.getRoot())) { - setContentDescription(""); //$NON-NLS-1$ - if (workingSet != null) { - setTitleToolTip( - NLS.bind(ResourceNavigatorMessages.ResourceNavigator_workingSetToolTip, workingSet.getLabel())); - } else { - setTitleToolTip(""); //$NON-NLS-1$ - } - } else { - ILabelProvider labelProvider = (ILabelProvider) getTreeViewer().getLabelProvider(); - String inputToolTip = getFrameToolTipText(input); - String text = labelProvider.getText(input); - if (text != null) { - setContentDescription(text); - } - if (workingSet != null) { - setTitleToolTip(NLS.bind(ResourceNavigatorMessages.ResourceNavigator_workingSetInputToolTip, - inputToolTip, workingSet.getLabel())); - } else { - setTitleToolTip(inputToolTip); - } - } - } - - /** - * Returns the action group. - * - * @return the action group - */ - protected ResourceNavigatorActionGroup getActionGroup() { - return actionGroup; - } - - /** - * Sets the action group. - * - * @param actionGroup the action group - */ - protected void setActionGroup(ResourceNavigatorActionGroup actionGroup) { - this.actionGroup = actionGroup; - } - - @Override - public T getAdapter(Class adapter) { - if (adapter == IShowInSource.class) { - return adapter.cast(getShowInSource()); - } - if (adapter == IShowInTarget.class) { - return adapter.cast(getShowInTarget()); - } - return null; - } - - /** - * Returns the IShowInSource for this view. - */ - protected IShowInSource getShowInSource() { - return () -> new ShowInContext(getViewer().getInput(), getViewer().getSelection()); - } - - /** - * Returns the IShowInTarget for this view. - */ - protected IShowInTarget getShowInTarget() { - return context -> { - ArrayList toSelect = new ArrayList<>(); - ISelection sel = context.getSelection(); - if (sel instanceof IStructuredSelection) { - IStructuredSelection ssel = (IStructuredSelection) sel; - for (Object o1 : ssel) { - - IResource resource = Adapters.adapt(o1, IResource.class); - if (resource != null) { - toSelect.add(resource); - } - - IMarker marker = Adapters.adapt(o1, IMarker.class); - if (marker != null) { - IResource r2 = marker.getResource(); - if (r2.getType() != IResource.ROOT) { - toSelect.add(r2); - } - } - } - } - if (toSelect.isEmpty()) { - Object input = context.getInput(); - IResource resource = Adapters.adapt(input, IResource.class); - if (resource != null) { - toSelect.add(resource); - } - } - if (!toSelect.isEmpty()) { - selectReveal(new StructuredSelection(toSelect)); - return true; - } - return false; - }; - } - - /** - * Returns the selected element if the selection consists of a single element - * only. - * - * @param s the selection - * @return the selected first element or null - * @since 3.5 - */ - protected static final Object getSingleElement(ISelection s) { - if (!(s instanceof IStructuredSelection)) - return null; - - IStructuredSelection selection = (IStructuredSelection) s; - if (selection.size() != 1) - return null; - - return selection.getFirstElement(); - } - -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorAction.java deleted file mode 100644 index b6b913b4ac1..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorAction.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.SelectionProviderAction; - -/** - * Superclass of all actions provided by the resource navigator. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public abstract class ResourceNavigatorAction extends SelectionProviderAction { - - private IResourceNavigator navigator; - - /** - * Creates a new instance of the class. - */ - public ResourceNavigatorAction(IResourceNavigator navigator, String label) { - super(navigator.getViewer(), label); - this.navigator = navigator; - } - - /** - * Returns the resource navigator for which this action was created. - */ - public IResourceNavigator getNavigator() { - return navigator; - } - - /** - * Returns the resource viewer - */ - protected Viewer getViewer() { - return getNavigator().getViewer(); - } - - /** - * Returns the shell to use within actions. - */ - protected Shell getShell() { - return getNavigator().getSite().getShell(); - } - - /** - * Returns the workbench. - */ - protected IWorkbench getWorkbench() { - return PlatformUI.getWorkbench(); - } - - /** - * Returns the workbench window. - */ - protected IWorkbenchWindow getWorkbenchWindow() { - return getNavigator().getSite().getWorkbenchWindow(); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorActionGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorActionGroup.java deleted file mode 100644 index 1740dcc0f9f..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorActionGroup.java +++ /dev/null @@ -1,97 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Sebastian Davids - Images for menu items (27481) - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.ui.actions.ActionGroup; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; - -/** - * This is the action group for all the resource navigator actions. It delegates - * to several subgroups for most of the actions. - * - * @see GotoActionGroup - * @see OpenActionGroup - * @see RefactorActionGroup - * @see SortAndFilterActionGroup - * @see WorkspaceActionGroup - * - * @since 2.0 - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public abstract class ResourceNavigatorActionGroup extends ActionGroup { - - /** - * The resource navigator. - */ - protected IResourceNavigator navigator; - - /** - * Constructs a new navigator action group and creates its actions. - * - * @param navigator the resource navigator - */ - public ResourceNavigatorActionGroup(IResourceNavigator navigator) { - this.navigator = navigator; - makeActions(); - } - - /** - * Returns the image descriptor with the given relative path. - */ - protected ImageDescriptor getImageDescriptor(String relativePath) { - return IDEWorkbenchPlugin.getIDEImageDescriptor(relativePath); - - } - - /** - * Returns the resource navigator. - */ - public IResourceNavigator getNavigator() { - return navigator; - } - - /** - * Handles a key pressed event by invoking the appropriate action. Does nothing - * by default. - */ - public void handleKeyPressed(KeyEvent event) { - } - - /** - * Makes the actions contained in this action group. - */ - protected abstract void makeActions(); - - /** - * Runs the default action in the group. Does nothing by default. - * - * @param selection the current selection - */ - public void runDefaultAction(IStructuredSelection selection) { - } - -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMessages.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMessages.java deleted file mode 100644 index 9b3efc07b15..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMessages.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -/** - * Utility class which helps managing messages - * - * @since 2.0 - * @deprecated These messages are not API and should not be referenced outside - * of this plug-in. - * @noextend This class is not intended to be subclassed by clients. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @noinstantiate This class is not intended to be instantiated by clients. - */ -@Deprecated(forRemoval = true) -public class ResourceNavigatorMessages { - - private ResourceNavigatorMessages() { - // prevent instantiation of class - } - - /** - * Returns the formatted message for the given key in the resource bundle. - * - * @param key the resource name - * @param args the message arguments - * @return the string - */ - public static String format(String key, Object[] args) { - return key; - } - - /** - * Returns the resource object with the given key in the resource bundle. If - * there isn't any value under the given key, the key is returned. - * - * @param key the resource name - * @return the string - */ - public static String getString(String key) { - return key; - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMoveAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMoveAction.java deleted file mode 100644 index e61b40fa73e..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMoveAction.java +++ /dev/null @@ -1,100 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.StructuredViewer; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.MoveProjectAction; -import org.eclipse.ui.actions.MoveResourceAction; - -/** - * The ResourceNavigatorMoveAction is a resource move that aso updates the - * navigator to show the result of the move. It also delegates to - * MoveProjectAction as needed. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @since 2.0 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class ResourceNavigatorMoveAction extends MoveResourceAction { - private StructuredViewer viewer; - - private MoveProjectAction moveProjectAction; - - /** - * Create a ResourceNavigatorMoveAction and use the supplied viewer to update - * the UI. - * - * @param shell Shell - * @param structureViewer StructuredViewer - */ - public ResourceNavigatorMoveAction(Shell shell, StructuredViewer structureViewer) { - super(shell); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, - INavigatorHelpContextIds.RESOURCE_NAVIGATOR_MOVE_ACTION); - this.viewer = structureViewer; - this.moveProjectAction = new MoveProjectAction(shell); - } - - @Override - public void run() { - if (moveProjectAction.isEnabled()) { - moveProjectAction.run(); - return; - } - - super.run(); - List destinations = getDestinations(); - if (destinations != null && destinations.isEmpty() == false) { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - List resources = new ArrayList(); - Iterator iterator = destinations.iterator(); - - while (iterator.hasNext()) { - IResource newResource = root.findMember((IPath) iterator.next()); - if (newResource != null) { - resources.add(newResource); - } - } - - this.viewer.setSelection(new StructuredSelection(resources), true); - } - - } - - @Override - protected boolean updateSelection(IStructuredSelection selection) { - moveProjectAction.selectionChanged(selection); - return super.updateSelection(selection) || moveProjectAction.isEnabled(); - } - -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorRenameAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorRenameAction.java deleted file mode 100644 index caffe4f1360..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorRenameAction.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.RenameResourceAction; - -/** - * The ResourceNavigatorRenameAction is the rename action used by the - * ResourceNavigator that also allows updating after rename. - * - * @since 2.0 - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class ResourceNavigatorRenameAction extends RenameResourceAction { - private TreeViewer viewer; - - /** - * Create a ResourceNavigatorRenameAction and use the tree of the supplied - * viewer for editing. - * - * @param shell Shell - * @param treeViewer TreeViewer - */ - public ResourceNavigatorRenameAction(Shell shell, TreeViewer treeViewer) { - super(shell, treeViewer.getTree()); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, - INavigatorHelpContextIds.RESOURCE_NAVIGATOR_RENAME_ACTION); - this.viewer = treeViewer; - } - - @Override - protected void runWithNewPath(IPath path, IResource resource) { - IWorkspaceRoot root = resource.getProject().getWorkspace().getRoot(); - super.runWithNewPath(path, resource); - if (this.viewer != null) { - IResource newResource = root.findMember(path); - if (newResource != null) { - this.viewer.setSelection(new StructuredSelection(newResource), true); - } - } - } - - /** - * Handle the key release - */ - public void handleKeyReleased(KeyEvent event) { - if (event.keyCode == SWT.F2 && event.stateMask == 0 && isEnabled()) { - run(); - } - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourcePatternFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourcePatternFilter.java deleted file mode 100644 index 3101f40c457..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourcePatternFilter.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.ArrayList; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Adapters; -import org.eclipse.core.text.StringMatcher; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; -import org.eclipse.ui.internal.util.PrefUtil; - -/** - * Filter used to determine whether resources are to be shown or not. - * - * @since 2.0 - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class ResourcePatternFilter extends ViewerFilter { - private String[] patterns; - - private StringMatcher[] matchers; - - static final String COMMA_SEPARATOR = ",";//$NON-NLS-1$ - - static final String FILTERS_TAG = "resourceFilters";//$NON-NLS-1$ - - /** - * Creates a new resource pattern filter. - */ - public ResourcePatternFilter() { - super(); - } - - /** - * Return the currently configured StringMatchers. If there aren't any look them - * up. - */ - private StringMatcher[] getMatchers() { - - if (this.matchers == null) { - initializeFromPreferences(); - } - - return this.matchers; - } - - /** - * Gets the patterns for the receiver. Returns the cached values if there are - * any - if not look it up. - */ - public String[] getPatterns() { - - if (this.patterns == null) { - initializeFromPreferences(); - } - - return this.patterns; - - } - - /** - * Initializes the filters from the preference store. - */ - private void initializeFromPreferences() { - // get the filters that were saved by ResourceNavigator.setFiltersPreference - IPreferenceStore viewsPrefs = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); - String storedPatterns = viewsPrefs.getString(FILTERS_TAG); - - if (storedPatterns.isEmpty()) { - // try to migrate patterns from old workbench preference store location - IPreferenceStore workbenchPrefs = PrefUtil.getInternalPreferenceStore(); - storedPatterns = workbenchPrefs.getString(FILTERS_TAG); - if (storedPatterns.length() > 0) { - viewsPrefs.setValue(FILTERS_TAG, storedPatterns); - workbenchPrefs.setValue(FILTERS_TAG, ""); //$NON-NLS-1$ - } - } - - if (storedPatterns.isEmpty()) { - // revert to all filter extensions with selected == "true" - // if there are no filters in the preference store - List defaultFilters = FiltersContentProvider.getDefaultFilters(); - String[] patterns = new String[defaultFilters.size()]; - defaultFilters.toArray(patterns); - setPatterns(patterns); - return; - } - - // Get the strings separated by a comma and filter them from the currently - // defined ones - List definedFilters = FiltersContentProvider.getDefinedFilters(); - StringTokenizer entries = new StringTokenizer(storedPatterns, COMMA_SEPARATOR); - List patterns = new ArrayList<>(); - - while (entries.hasMoreElements()) { - String nextToken = entries.nextToken(); - if (definedFilters.indexOf(nextToken) > -1) { - patterns.add(nextToken); - } - } - - // Convert to an array of Strings - String[] patternArray = new String[patterns.size()]; - patterns.toArray(patternArray); - setPatterns(patternArray); - - } - - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - IResource resource = Adapters.adapt(element, IResource.class); - if (resource != null) { - String name = resource.getName(); - for (StringMatcher testMatcher : getMatchers()) { - if (testMatcher.match(name)) { - return false; - } - } - return true; - } - return true; - } - - /** - * Sets the patterns to filter out for the receiver. - */ - public void setPatterns(String[] newPatterns) { - - this.patterns = newPatterns; - this.matchers = new StringMatcher[newPatterns.length]; - for (int i = 0; i < newPatterns.length; i++) { - // Reset the matchers to prevent constructor overhead - matchers[i] = new StringMatcher(newPatterns[i], true, false); - } - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSelectionUtil.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSelectionUtil.java deleted file mode 100644 index fdca7a7f542..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSelectionUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Adapters; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; - -/** - * Provides utilities for checking the validity of selections. - *

- * This class provides static methods only; it is not intended to be - * instantiated or subclassed. - *

- * - * @since 2.0 - * - * @noinstantiate This class is not intended to be instantiated by clients. - * @noextend This class is not intended to be subclassed by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @deprecated as of 3.5, use {@link org.eclipse.ui.ide.ResourceSelectionUtil} - * instead. - */ -@Deprecated(forRemoval = true) -public class ResourceSelectionUtil { - private ResourceSelectionUtil() { - } - - /** - * Returns whether the types of the resources in the given selection are among - * the specified resource types. - * - * @param selection the selection - * @param resourceMask resource mask formed by bitwise OR of resource type - * constants (defined on IResource) - * @return true if all selected elements are resources of the right - * type, and false if at least one element is either a - * resource of some other type or a non-resource - * @see IResource#getType() - */ - public static boolean allResourcesAreOfType(IStructuredSelection selection, int resourceMask) { - for (Object next : selection) { - if (!(next instanceof IResource)) { - return false; - } - if (!resourceIsType((IResource) next, resourceMask)) { - return false; - } - } - return true; - } - - /** - * Returns the selection adapted to IResource. Returns null if any of the - * entries are not adaptable. - * - * @param selection the selection - * @param resourceMask resource mask formed by bitwise OR of resource type - * constants (defined on IResource) - * @return IStructuredSelection or null if any of the entries are not adaptable. - * @see IResource#getType() - */ - public static IStructuredSelection allResources(IStructuredSelection selection, int resourceMask) { - List result = new ArrayList<>(); - for (Object next : selection) { - - IResource resource = Adapters.adapt(next, IResource.class); - if (resource == null) { - return null; - } - if (resourceIsType(resource, resourceMask)) { - result.add(resource); - } - } - return new StructuredSelection(result); - - } - - /** - * Returns whether the type of the given resource is among the specified - * resource types. - * - * @param resource the resource - * @param resourceMask resource mask formed by bitwise OR of resource type - * constants (defined on IResource) - * @return true if the resources has a matching type, and - * false otherwise - * @see IResource#getType() - */ - public static boolean resourceIsType(IResource resource, int resourceMask) { - return (resource.getType() & resourceMask) != 0; - } - -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSorter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSorter.java deleted file mode 100644 index 2d3165ace3f..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSorter.java +++ /dev/null @@ -1,205 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerSorter; - -/** - * Sorter for viewers that display items of type IResource. The - * sorter supports two sort criteria: - *

- * NAME: Folders are given order precedence, followed by files. - * Within these two groups resources are ordered by name. All name comparisons - * are case-insensitive. - *

- *

- * TYPE: Folders are given order precedence, followed by files. - * Within these two groups resources are ordered by extension. All extension - * comparisons are case-insensitive. - *

- *

- * This class may be instantiated; it is not intended to be subclassed. - *

- * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.3, use {@link ResourceComparator} instead - * @noextend This class is not intended to be subclassed by clients. - */ -@Deprecated(forRemoval = true) -public class ResourceSorter extends ViewerSorter { - - /** - * Constructor argument value that indicates to sort items by name. - */ - public static final int NAME = 1; - - /** - * Constructor argument value that indicates to sort items by extension. - */ - public static final int TYPE = 2; - - private int criteria; - - /** - * Creates a resource sorter that will use the given sort criteria. - * - * @param criteria the sort criterion to use: one of NAME or - * TYPE - */ - public ResourceSorter(int criteria) { - super(); - this.criteria = criteria; - } - - /** - * Returns an integer value representing the relative sort priority of the given - * element based on its class. - *
    - *
  • resources (IResource) - 2
  • - *
  • project references (ProjectReference) - 1
  • - *
  • everything else - 0
  • - *
- * - * @param element the element - * @return the sort priority (larger numbers means more important) - */ - protected int classComparison(Object element) { - if (element instanceof IResource) { - return 2; - } - return 0; - } - - @Override - public int compare(Viewer viewer, Object o1, Object o2) { - // have to deal with non-resources in navigator - // if one or both objects are not resources, returned a comparison - // based on class. - if (!(o1 instanceof IResource && o2 instanceof IResource)) { - return compareClass(o1, o2); - } - IResource r1 = (IResource) o1; - IResource r2 = (IResource) o2; - - if (r1 instanceof IContainer && r2 instanceof IContainer) { - return compareNames(r1, r2); - } else if (r1 instanceof IContainer) { - return -1; - } else if (r2 instanceof IContainer) { - return 1; - } else if (criteria == NAME) { - return compareNames(r1, r2); - } else if (criteria == TYPE) { - return compareTypes(r1, r2); - } else { - return 0; - } - } - - /** - * Returns a number reflecting the collation order of the given elements based - * on their class. - * - * @param element1 the first element to be ordered - * @param element2 the second element to be ordered - * @return a negative number if the first element is less than the second - * element; the value 0 if the first element is equal to - * the second element; and a positive number if the first element is - * greater than the second element - */ - protected int compareClass(Object element1, Object element2) { - return classComparison(element1) - classComparison(element2); - } - - /** - * Returns a number reflecting the collation order of the given resources based - * on their resource names. - * - * @param resource1 the first resource element to be ordered - * @param resource2 the second resource element to be ordered - * @return a negative number if the first element is less than the second - * element; the value 0 if the first element is equal to - * the second element; and a positive number if the first element is - * greater than the second element - */ - protected int compareNames(IResource resource1, IResource resource2) { - return collator.compare(resource1.getName(), resource2.getName()); - } - - /** - * Returns a number reflecting the collation order of the given resources based - * on their respective file extensions. Resources with the same file extension - * will be collated based on their names. - * - * @param resource1 the first resource element to be ordered - * @param resource2 the second resource element to be ordered - * @return a negative number if the first element is less than the second - * element; the value 0 if the first element is equal to - * the second element; and a positive number if the first element is - * greater than the second element - */ - protected int compareTypes(IResource resource1, IResource resource2) { - String ext1 = getExtensionFor(resource1); - String ext2 = getExtensionFor(resource2); - - // Compare extensions. If they're different then return a value that - // indicates correct extension ordering. If they're the same then - // return a value that indicates the correct NAME ordering. - int result = collator.compare(ext1, ext2); - - if (result != 0) { - return result; - } - - return compareNames(resource1, resource2); - } - - /** - * Returns the sort criteria of this sorter. - * - * @return the sort criterion: one of NAME or TYPE - */ - public int getCriteria() { - return criteria; - } - - /** - * Returns the extension portion of the given resource. - * - * @param resource the resource - * @return the file extension, possibily the empty string - */ - private String getExtensionFor(IResource resource) { - String ext = resource.getFileExtension(); - return ext == null ? "" : ext; //$NON-NLS-1$ - } - - /** - * Sets the sort criteria of this sorter. - * - * @param criteria the sort criterion: one of ResourceSorter.NAME - * or ResourceSorter.TYPE - */ - public void setCriteria(int criteria) { - this.criteria = criteria; - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ShowInNavigatorAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ShowInNavigatorAction.java deleted file mode 100644 index 888af1339cc..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ShowInNavigatorAction.java +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.Adapters; -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.actions.SelectionProviderAction; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; -import org.eclipse.ui.part.ISetSelectionTarget; - -/** - * An action which shows the current selection in the Navigator view. For each - * element in the selection, if it is an IResource it uses it - * directly, otherwise if it is an IMarker it uses the marker's - * resource, otherwise if it is an IAdaptable, it tries to get the - * IResource.class adapter. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class ShowInNavigatorAction extends SelectionProviderAction { - private IWorkbenchPage page; - - /** - * Create a new instance of this class. - * - * @param page the page - * @param viewer the viewer - */ - public ShowInNavigatorAction(IWorkbenchPage page, ISelectionProvider viewer) { - super(viewer, ResourceNavigatorMessages.ShowInNavigator_text); - Assert.isNotNull(page); - this.page = page; - setDescription(ResourceNavigatorMessages.ShowInNavigator_toolTip); - page.getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(this, - INavigatorHelpContextIds.SHOW_IN_NAVIGATOR_ACTION); - } - - /** - * Returns the resources in the given selection. - * - * @return a list of IResource - */ - List getResources(IStructuredSelection selection) { - List v = new ArrayList<>(); - for (Object o : selection) { - - IResource resource = Adapters.adapt(o, IResource.class); - if (resource != null) { - v.add(resource); - } else if (o instanceof IMarker) { - resource = ((IMarker) o).getResource(); - v.add(resource); - } - } - return v; - } - - /** - * Shows the Navigator view and sets its selection to the resources selected in - * this action's selection provider. - */ - @Override - public void run() { - List v = getResources(getStructuredSelection()); - if (v.isEmpty()) { - return; - } - try { - IViewPart view = page.showView(IPageLayout.ID_RES_NAV); - if (view instanceof ISetSelectionTarget) { - ISelection selection = new StructuredSelection(v); - ((ISetSelectionTarget) view).selectReveal(selection); - } - } catch (PartInitException e) { - ErrorDialog.openError(page.getWorkbenchWindow().getShell(), - ResourceNavigatorMessages.ShowInNavigator_errorMessage, e.getMessage(), e.getStatus()); - } - } - - @Override - public void selectionChanged(IStructuredSelection selection) { - setEnabled(!getResources(selection).isEmpty()); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortAndFilterActionGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortAndFilterActionGroup.java deleted file mode 100644 index 7a0bcfade37..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortAndFilterActionGroup.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Sebastian Davids - Images for menu items (27481) - * Lars Vogel - Bug 430694 - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; - -/** - * This is the action group for the sort and filter actions. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class SortAndFilterActionGroup extends ResourceNavigatorActionGroup { - - private SortViewAction sortByTypeAction; - - private SortViewAction sortByNameAction; - - private FilterSelectionAction filterAction; - - /** - * Constructor. - * - * @param navigator the resource navigator - */ - public SortAndFilterActionGroup(IResourceNavigator navigator) { - super(navigator); - } - - @Override - protected void makeActions() { - sortByNameAction = new SortViewAction(navigator, false); - sortByTypeAction = new SortViewAction(navigator, true); - - filterAction = new FilterSelectionAction(navigator, ResourceNavigatorMessages.ResourceNavigator_filterText); - filterAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/filter_ps.png"));//$NON-NLS-1$ - filterAction.setImageDescriptor(getImageDescriptor("elcl16/filter_ps.png"));//$NON-NLS-1$ - } - - @Override - public void fillActionBars(IActionBars actionBars) { - IMenuManager menu = actionBars.getMenuManager(); - IMenuManager submenu = new MenuManager(ResourceNavigatorMessages.ResourceNavigator_sort); - menu.add(submenu); - submenu.add(sortByNameAction); - submenu.add(sortByTypeAction); - menu.add(filterAction); - } - - @Override - public void updateActionBars() { - int criteria = navigator.getComparator().getCriteria(); - sortByNameAction.setChecked(criteria == ResourceComparator.NAME); - sortByTypeAction.setChecked(criteria == ResourceComparator.TYPE); - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortViewAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortViewAction.java deleted file mode 100644 index c1abd37eaea..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortViewAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2014 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages; - -/** - * Implementation of the view sorting actions. - * - * @since 2.0 - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class SortViewAction extends ResourceNavigatorAction { - private int sortCriteria; - - /** - * Creates the action. - * - * @param navigator the resource navigator - * @param sortByType true for sort by type, false for - * sort by name - */ - public SortViewAction(IResourceNavigator navigator, boolean sortByType) { - super(navigator, - sortByType ? ResourceNavigatorMessages.SortView_byType : ResourceNavigatorMessages.SortView_byName); - if (sortByType) { - setToolTipText(ResourceNavigatorMessages.SortView_toolTipByType); - } else { - setToolTipText(ResourceNavigatorMessages.SortView_toolTipByName); - } - setEnabled(true); - sortCriteria = sortByType ? ResourceComparator.TYPE : ResourceComparator.NAME; - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, INavigatorHelpContextIds.SORT_VIEW_ACTION); - } - - @Override - public void run() { - IResourceNavigator navigator = getNavigator(); - ResourceComparator comparator = navigator.getComparator(); - - if (comparator == null) { - navigator.setComparator(new ResourceComparator(sortCriteria)); - } else { - comparator.setCriteria(sortCriteria); - navigator.setComparator(comparator); - } - - } -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ToggleLinkingAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ToggleLinkingAction.java deleted file mode 100644 index 1c51179d8b2..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ToggleLinkingAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.views.navigator; - -import org.eclipse.ui.IWorkbenchCommandConstants; - -/** - * This action toggles whether this navigator links its selection to the active - * editor. - * - * @since 2.1 - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class ToggleLinkingAction extends ResourceNavigatorAction { - - /** - * Constructs a new action. - * - * @param navigator the resource navigator - * @param label the label - */ - public ToggleLinkingAction(IResourceNavigator navigator, String label) { - super(navigator, label); - setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR); - setChecked(navigator.isLinkingEnabled()); - } - - /** - * Runs the action. - */ - @Override - public void run() { - getNavigator().setLinkingEnabled(isChecked()); - } - -} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/WorkspaceActionGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/WorkspaceActionGroup.java deleted file mode 100644 index 31c9954db6b..00000000000 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/WorkspaceActionGroup.java +++ /dev/null @@ -1,256 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - * Sebastian Davids - Images for menu items (27481) - * Lars Vogel - Bug 430694 - *******************************************************************************/ -package org.eclipse.ui.views.navigator; - -import java.lang.reflect.InvocationTargetException; -import java.util.Iterator; - -import org.eclipse.core.resources.ICommand; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.resources.WorkspaceJob; -import org.eclipse.core.runtime.Adapters; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.window.IShellProvider; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.actions.BuildAction; -import org.eclipse.ui.actions.CloseResourceAction; -import org.eclipse.ui.actions.CloseUnrelatedProjectsAction; -import org.eclipse.ui.actions.OpenResourceAction; -import org.eclipse.ui.actions.RefreshAction; -import org.eclipse.ui.actions.WorkspaceModifyOperation; -import org.eclipse.ui.ide.IDEActionFactory; -import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; -import org.eclipse.ui.internal.ide.StatusUtil; - -/** - * This is the action group for workspace actions such as Build, Refresh Local, - * and Open/Close Project. - * - * @noextend This class is not intended to be subclassed by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @noreference This class is not intended to be referenced by clients. - * - * Planned to be deleted, please see Bug - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=549953 - * @deprecated as of 3.5, use the Common Navigator Framework classes instead - */ -@Deprecated(forRemoval = true) -public class WorkspaceActionGroup extends ResourceNavigatorActionGroup { - - private BuildAction buildAction; - - private OpenResourceAction openProjectAction; - - private CloseResourceAction closeProjectAction; - - private CloseUnrelatedProjectsAction closeUnrelatedProjectsAction; - - private RefreshAction refreshAction; - - public WorkspaceActionGroup(IResourceNavigator navigator) { - super(navigator); - } - - @Override - public void fillActionBars(IActionBars actionBars) { - actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); - actionBars.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), buildAction); - actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), openProjectAction); - actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), closeProjectAction); - actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(), - closeUnrelatedProjectsAction); - } - - /** - * Adds the build, open project, close project and refresh resource actions to - * the context menu. - *

- * The following conditions apply: build-only projects selected, auto build - * disabled, at least one builder present open project-only projects selected, - * at least one closed project close project-only projects selected, at least - * one open project refresh-no closed project selected - *

- *

- * Both the open project and close project action may be on the menu at the same - * time. - *

- *

- * No disabled action should be on the context menu. - *

- * - * @param menu context menu to add actions to - */ - @Override - 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 = Adapters.adapt(next, IProject.class); - - if (project == null) { - isProjectSelection = false; - continue; - } - if (project.isOpen()) { - hasOpenProjects = true; - if (hasBuilder && !hasBuilder(project)) { - hasBuilder = false; - } - } else { - hasClosedProjects = true; - hasBuilder = false; - } - } - if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding() - && hasBuilder) { - // Allow manual incremental build only if auto build is off. - buildAction.selectionChanged(selection); - menu.add(buildAction); - } - if (!hasClosedProjects) { - refreshAction.selectionChanged(selection); - menu.add(refreshAction); - } - if (isProjectSelection) { - if (hasClosedProjects) { - openProjectAction.selectionChanged(selection); - menu.add(openProjectAction); - } - if (hasOpenProjects) { - closeProjectAction.selectionChanged(selection); - menu.add(closeProjectAction); - closeUnrelatedProjectsAction.selectionChanged(selection); - menu.add(closeUnrelatedProjectsAction); - } - } - } - - /** - * Handles a key pressed event by invoking the appropriate action. - */ - @Override - public void handleKeyPressed(KeyEvent event) { - if (event.keyCode == SWT.F5 && event.stateMask == 0) { - if (refreshAction.isEnabled()) { - refreshAction.refreshAll(); - } - - // Swallow the event - event.doit = false; - } - } - - /** - * Returns whether there are builders configured on the given project. - * - * @return true if it has builders, false 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; - } - - @Override - protected void makeActions() { - final IShellProvider provider = navigator.getSite(); - openProjectAction = new OpenResourceAction(provider); - closeProjectAction = new CloseResourceAction(provider); - closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(provider); - refreshAction = new RefreshAction(provider) { - @Override - public void run() { - final IStatus[] errorStatus = new IStatus[1]; - errorStatus[0] = Status.OK_STATUS; - final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus); - WorkspaceJob job = new WorkspaceJob("refresh") { //$NON-NLS-1$ - - @Override - public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { - try { - op.run(monitor); - Shell shell = provider.getShell(); - if (shell != null && !shell.isDisposed()) { - shell.getDisplay().asyncExec(() -> { - TreeViewer viewer = navigator.getViewer(); - if (viewer != null && viewer.getControl() != null - && !viewer.getControl().isDisposed()) { - viewer.refresh(); - } - }); - } - } catch (InvocationTargetException e) { - String msg = NLS.bind(IDEWorkbenchMessages.WorkspaceAction_logTitle, getClass().getName(), - e.getTargetException()); - throw new CoreException(StatusUtil.newStatus(IStatus.ERROR, msg, e.getTargetException())); - } catch (InterruptedException e) { - return Status.CANCEL_STATUS; - } - return errorStatus[0]; - } - - }; - ISchedulingRule rule = op.getRule(); - if (rule != null) { - job.setRule(rule); - } - job.setUser(true); - job.schedule(); - } - }; - refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.png"));//$NON-NLS-1$ - refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.png"));//$NON-NLS-1$ - buildAction = new BuildAction(provider, IncrementalProjectBuilder.INCREMENTAL_BUILD); - } - - @Override - public void updateActionBars() { - IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); - refreshAction.selectionChanged(selection); - buildAction.selectionChanged(selection); - openProjectAction.selectionChanged(selection); - closeUnrelatedProjectsAction.selectionChanged(selection); - closeProjectAction.selectionChanged(selection); - } -} diff --git a/bundles/org.eclipse.ui.workbench/.settings/.api_filters b/bundles/org.eclipse.ui.workbench/.settings/.api_filters index 0a27d0310a0..25997b82053 100644 --- a/bundles/org.eclipse.ui.workbench/.settings/.api_filters +++ b/bundles/org.eclipse.ui.workbench/.settings/.api_filters @@ -1,5 +1,13 @@ + + + + + + + + diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IPageLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IPageLayout.java index e345114058c..1f98d3bab51 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IPageLayout.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/IPageLayout.java @@ -84,15 +84,6 @@ public interface IPageLayout { */ String ID_EDITOR_AREA = "org.eclipse.ui.editorss"; //$NON-NLS-1$ - /** - * The view id for the workbench's Resource Navigator standard component. - * - * @deprecated this has been replaced by the Common Navigator Framework as of - * release 3.5. - */ - @Deprecated(forRemoval = true) - String ID_RES_NAV = "org.eclipse.ui.views.ResourceNavigator"; //$NON-NLS-1$ - /** * The view id for the Project Explorer. * diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/navigator/NavigatorTestSuite.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/navigator/NavigatorTestSuite.java index 12fa009b17d..99e517ac49b 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/navigator/NavigatorTestSuite.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/navigator/NavigatorTestSuite.java @@ -17,10 +17,8 @@ import org.junit.runner.RunWith; import org.junit.runners.Suite; -@SuppressWarnings("removal") @RunWith(Suite.class) @Suite.SuiteClasses({ - ResourceNavigatorTest.class, NavigatorTest.class }) public class NavigatorTestSuite { diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/navigator/ResourceNavigatorTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/navigator/ResourceNavigatorTest.java deleted file mode 100644 index c44532cf796..00000000000 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/navigator/ResourceNavigatorTest.java +++ /dev/null @@ -1,202 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.tests.navigator; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.IPageLayout; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; -import org.eclipse.ui.part.ISetSelectionTarget; -import org.eclipse.ui.tests.harness.util.ActionUtil; -import org.eclipse.ui.tests.harness.util.FileUtil; -import org.eclipse.ui.tests.harness.util.UITestCase; -import org.eclipse.ui.views.navigator.ResourceNavigator; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -@Deprecated(forRemoval = true) -public class ResourceNavigatorTest extends UITestCase { - private IWorkbenchPage activePage; - - private IWorkbenchWindow workbenchWindow; - - private IViewPart view; - - private IProject p1; - - private IProject p2; - - private IFile f1; - - private IFile f2; - - /** - * Constructor for ResourceNavigatorTest. - */ - public ResourceNavigatorTest() { - super(ResourceNavigatorTest.class.getSimpleName()); - } - - @Override - protected void doSetUp() throws Exception { - super.doSetUp(); - workbenchWindow = openTestWindow(); - activePage = workbenchWindow.getActivePage(); - } - - private void setupView() throws Throwable { - view = activePage.showView(IPageLayout.ID_RES_NAV); - } - - private void setupResources() throws Throwable { - if (p1 == null) { - p1 = FileUtil.createProject("TP1"); - f1 = null; - } - if (p2 == null) { - p2 = FileUtil.createProject("TP2"); - f2 = null; - } - if (f1 == null) { - f1 = FileUtil.createFile("f1.txt", p1); - } - if (f2 == null) { - f2 = FileUtil.createFile("f2.txt", p2); - } - } - - public void fixTestGlobalBookmarkAction() throws Throwable { - setupView(); - setupResources(); - - // Select a file - IStructuredSelection sel = new StructuredSelection(f1); - ((ResourceNavigator) view).selectReveal(sel); - - // Remember the previous marker count on the file - int oldCount = (f1.findMarkers(IMarker.BOOKMARK, true, - IResource.DEPTH_INFINITE)).length; - - // Now try the bookmark action - ActionUtil.runActionUsingPath(this, workbenchWindow, - IWorkbenchActionConstants.M_EDIT + '/' - + IWorkbenchActionConstants.BOOKMARK); - - // Make sure the resource was bookmarked - int newCount = (f1.findMarkers(IMarker.BOOKMARK, true, - IResource.DEPTH_INFINITE)).length; - assertTrue( - "Selected file was not bookmarked via Edit->Bookmark action.", - oldCount + 1 == newCount); - } - - /* - * This test should be moved to an interactive test suite as this test causes a - * dialog to popup when the resource is deleted by the delete action - */ - @Test - @Ignore - public void testGlobalDeleteAction() throws Throwable { - setupView(); - setupResources(); - - // Select a file - IStructuredSelection sel = new StructuredSelection(f1); - ((ResourceNavigator) view).selectReveal(sel); - - // Now try the delete action - ActionUtil.runActionUsingPath(this, workbenchWindow, - IWorkbenchActionConstants.M_EDIT + '/' + IWorkbenchActionConstants.DELETE); - - // Make sure the resource was deleted - assertTrue("Selected file was not deleted via Edit->Delete action.", p1.findMember(f1.getName()) == null); - f1 = null; - } - - @Test - public void testSelectReveal() throws Throwable { - setupView(); - setupResources(); - - ISetSelectionTarget part = (ISetSelectionTarget) view; - TreeViewer tree = ((ResourceNavigator) view).getViewer(); - - // Set the selection in the navigator - IStructuredSelection sel1 = new StructuredSelection(f1); - part.selectReveal(sel1); - // Get the selection the tree has - IStructuredSelection treeSel1 = tree.getStructuredSelection(); - assertTrue("First selection wrong size, should be only one.", treeSel1 - .size() == 1); - IResource resource1 = (IResource) treeSel1.getFirstElement(); - assertTrue("First selection contains wrong file resource.", resource1 - .equals(f1)); - - // Set the selection in the navigator - IStructuredSelection sel2 = new StructuredSelection(p2); - part.selectReveal(sel2); - // Get the selection the tree has - IStructuredSelection treeSel2 = tree.getStructuredSelection(); - assertTrue("Second selection wrong size, should be only one.", treeSel2 - .size() == 1); - IResource resource2 = (IResource) treeSel2.getFirstElement(); - assertTrue("Second selection contains wrong project resource.", - resource2.equals(p2)); - } - - @Test - public void testWorkingSet() throws Throwable { - setupView(); - setupResources(); - - ResourceNavigator navigator = ((ResourceNavigator) view); - IWorkingSetManager workingSetManager = fWorkbench - .getWorkingSetManager(); - IWorkingSet workingSet = workingSetManager.createWorkingSet("ws1", - new IAdaptable[] { f1 }); - - assertNull(navigator.getWorkingSet()); - - navigator.setWorkingSet(workingSet); - assertEquals(workingSet, navigator.getWorkingSet()); - - navigator.setWorkingSet(null); - assertNull(navigator.getWorkingSet()); - - FileUtil.createFile("f11.txt", p1); - navigator.setWorkingSet(workingSet); - TreeViewer viewer = navigator.getTreeViewer(); - viewer.expandAll(); - TreeItem[] items = viewer.getTree().getItems(); - assertEquals(p1, items[0].getData()); - items = items[0].getItems(); - assertEquals(f1, items[0].getData()); - } -} -