Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-05-12 06:36:05 +0000
committerLars Vogel2019-05-12 06:52:28 +0000
commit90994ba8d30730d4d070f1dfea01a26aeff32e58 (patch)
tree2c881be36f5bd8ac3e054449e65c7ef0f28e5599
parent179c7eaefa0f07711939c279367732b8ae96276d (diff)
downloadeclipse.platform.ui-90994ba8d30730d4d070f1dfea01a26aeff32e58.tar.gz
eclipse.platform.ui-90994ba8d30730d4d070f1dfea01a26aeff32e58.tar.xz
eclipse.platform.ui-90994ba8d30730d4d070f1dfea01a26aeff32e58.zip
Reformat org.eclipse.ui.views.navigator package due to usage of spacesI20190512-1800
instead of tabs Also removes trailing whitespace Change-Id: Ifa0a6b259c34c77d56c1ccfc93c2e496bcad01bf Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CollapseAllAction.java38
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CopyAction.java276
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FilterSelectionAction.java82
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/FiltersContentProvider.java105
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoActionGroup.java137
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceAction.java60
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/GotoResourceDialog.java6
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/INavigatorHelpContextIds.java43
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/IResourceNavigator.java164
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/LocalSelectionTransfer.java15
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/MainActionGroup.java526
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDragAdapter.java318
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorDropAdapter.java670
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/NavigatorFrameSource.java77
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/OpenActionGroup.java154
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/PasteAction.java332
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/RefactorActionGroup.java213
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceComparator.java287
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigator.java2077
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorAction.java77
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorActionGroup.java89
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMessages.java52
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorMoveAction.java83
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceNavigatorRenameAction.java63
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourcePatternFilter.java180
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSelectionUtil.java116
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceSorter.java287
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ShowInNavigatorAction.java101
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortAndFilterActionGroup.java66
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/SortViewAction.java56
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/StringMatcher.java710
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ToggleLinkingAction.java23
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/WorkspaceActionGroup.java340
33 files changed, 3838 insertions, 3985 deletions
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CollapseAllAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CollapseAllAction.java
index 529b46a3315..8a547bba40d 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CollapseAllAction.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/CollapseAllAction.java
@@ -19,30 +19,30 @@ import org.eclipse.ui.handlers.CollapseAllHandler;
/**
* Collapse all project nodes.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
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);
- }
+ /**
+ * 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 <code>IAction</code>.
- */
- @Override
+ /*
+ * Implementation of method defined on <code>IAction</code>.
+ */
+ @Override
public void run() {
- getNavigator().getViewer().collapseAll();
- }
+ 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
index 73945aad29f..82e9e515ca5 100644
--- 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
@@ -35,7 +35,8 @@ 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.
+ * Standard action for copying the currently selected resources to the
+ * clipboard.
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
@@ -44,190 +45,175 @@ import org.eclipse.ui.part.ResourceTransfer;
* @since 2.0
*/
@Deprecated
-/*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 <code>null</code>
- */
- 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
+/* 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 <code>null</code>
+ */
+ 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 <code>CopyAction</code> implementation of this method defined
- * on <code>IAction</code> copies the selected resources to the
- * clipboard.
- */
+ /**
+ * The <code>CopyAction</code> implementation of this method defined on
+ * <code>IAction</code> copies the selected resources to the clipboard.
+ */
List<? extends IResource> 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) {
+ 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) {
+ 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];
+ 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());
+ }
+ 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) {
+ // 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) {
+ }
+
+ /**
+ * 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)) {
+ if (MessageDialog.openQuestion(shell, ResourceNavigatorMessages.CopyToClipboardProblemDialog_title,
+ ResourceNavigatorMessages.CopyToClipboardProblemDialog_message)) {
setClipboard(resources, fileNames, names);
}
- }
- }
-
+ }
+ }
- @Override
+ @Override
protected boolean updateSelection(IStructuredSelection selection) {
- /**
- * The <code>CopyAction</code> implementation of this
- * <code>SelectionListenerAction</code> method enables this action if
- * one or more resources of compatible types are selected.
- */
+ /**
+ * The <code>CopyAction</code> implementation of this
+ * <code>SelectionListenerAction</code> method enables this action if one or
+ * more resources of compatible types are selected.
+ */
- if (!super.updateSelection(selection)) {
+ if (!super.updateSelection(selection)) {
return false;
}
- if (getSelectedNonResources().size() > 0) {
+ if (getSelectedNonResources().size() > 0) {
return false;
}
List<? extends IResource> selectedResources = getSelectedResources();
- if (selectedResources.isEmpty()) {
+ if (selectedResources.isEmpty()) {
return false;
}
- boolean projSelected = selectionIsOfType(IResource.PROJECT);
- boolean fileFoldersSelected = selectionIsOfType(IResource.FILE
- | IResource.FOLDER);
- if (!projSelected && !fileFoldersSelected) {
+ boolean projSelected = selectionIsOfType(IResource.PROJECT);
+ boolean fileFoldersSelected = selectionIsOfType(IResource.FILE | IResource.FOLDER);
+ if (!projSelected && !fileFoldersSelected) {
return false;
}
- // selection must be homogeneous
- if (projSelected && fileFoldersSelected) {
+ // selection must be homogeneous
+ if (projSelected && fileFoldersSelected) {
return false;
}
- // must have a common parent
- IContainer firstParent = ((IResource) selectedResources.get(0))
- .getParent();
- if (firstParent == null) {
+ // must have a common parent
+ IContainer firstParent = ((IResource) selectedResources.get(0)).getParent();
+ if (firstParent == null) {
return false;
}
Iterator<? extends IResource> resourcesEnum = selectedResources.iterator();
- while (resourcesEnum.hasNext()) {
- IResource currentResource = resourcesEnum.next();
- if (!currentResource.getParent().equals(firstParent)) {
+ while (resourcesEnum.hasNext()) {
+ IResource currentResource = resourcesEnum.next();
+ if (!currentResource.getParent().equals(firstParent)) {
return false;
}
- }
+ }
- return true;
- }
+ 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
index f2c895e7185..10fd7690305 100644
--- 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
@@ -23,58 +23,56 @@ import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
/**
* The FilterSelectionAction opens the filters dialog.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public class FilterSelectionAction extends ResourceNavigatorAction {
- private static final String FILTER_TOOL_TIP = ResourceNavigatorMessages.FilterSelection_toolTip;
+ 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_SELECTION_MESSAGE = ResourceNavigatorMessages.FilterSelection_message;
- private static final String FILTER_TITLE_MESSAGE = ResourceNavigatorMessages.FilterSelection_title;
+ 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);
- }
+ /**
+ * 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 <code>IAction</code>.
- */
- @Override
+ /*
+ * Implementation of method defined on <code>IAction</code>.
+ */
+ @Override
public void run() {
- IResourceNavigator navigator = getNavigator();
- ResourcePatternFilter filter = navigator.getPatternFilter();
- FiltersContentProvider contentProvider = new FiltersContentProvider(
- filter);
+ IResourceNavigator navigator = getNavigator();
+ ResourcePatternFilter filter = navigator.getPatternFilter();
+ FiltersContentProvider contentProvider = new FiltersContentProvider(filter);
- ListSelectionDialog dialog = new ListSelectionDialog(getShell(),
- getViewer(), contentProvider, new LabelProvider(),
- FILTER_SELECTION_MESSAGE);
+ 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);
- }
- }
+ 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
index 382ddda1482..0dbd8bc2a52 100644
--- 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
@@ -27,83 +27,82 @@ import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
/**
* The FiltersContentProvider provides the elements for use by the list dialog
* for selecting the patterns to apply.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
-/* package */class FiltersContentProvider implements
- IStructuredContentProvider {
+/* package */class FiltersContentProvider implements IStructuredContentProvider {
private static List<String> definedFilters;
private static List<String> defaultFilters;
- private ResourcePatternFilter resourceFilter;
+ 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;
- }
+ /**
+ * 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
+ @Override
public void dispose() {
- }
+ }
- /**
- * Returns the filters which are enabled by default.
- *
- * @return a list of strings
- */
+ /**
+ * Returns the filters which are enabled by default.
+ *
+ * @return a list of strings
+ */
public static List<String> getDefaultFilters() {
- if (defaultFilters == null) {
- readFilters();
- }
- return defaultFilters;
- }
+ if (defaultFilters == null) {
+ readFilters();
+ }
+ return defaultFilters;
+ }
- /**
- * Returns the filters currently defined for the navigator.
- *
- * @return a list of strings
- */
+ /**
+ * Returns the filters currently defined for the navigator.
+ *
+ * @return a list of strings
+ */
public static List<String> getDefinedFilters() {
- if (definedFilters == null) {
- readFilters();
- }
- return definedFilters;
- }
+ if (definedFilters == null) {
+ readFilters();
+ }
+ return definedFilters;
+ }
- @Override
+ @Override
public Object[] getElements(Object inputElement) {
- return getDefinedFilters().toArray();
- }
+ return getDefinedFilters().toArray();
+ }
- /**
- * Return the initially selected elements.
- *
- * @return an array with the initial selections
- */
- public String[] getInitialSelections() {
- return this.resourceFilter.getPatterns();
- }
+ /**
+ * Return the initially selected elements.
+ *
+ * @return an array with the initial selections
+ */
+ public String[] getInitialSelections() {
+ return this.resourceFilter.getPatterns();
+ }
- @Override
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
+ }
- /**
- * Reads the filters currently defined for the workbench.
- */
- private static void readFilters() {
+ /**
+ * 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);
+ .getExtensionPoint(IDEWorkbenchPlugin.IDE_WORKBENCH + '.' + ResourcePatternFilter.FILTERS_TAG);
if (extension != null) {
for (IExtension currentExtension : extension.getExtensions()) {
IConfigurationElement[] configElements = currentExtension.getConfigurationElements();
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
index ee0791b6cb5..d59a05a4812 100644
--- 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
@@ -32,100 +32,91 @@ import org.eclipse.ui.views.framelist.UpAction;
/**
* This is the action group for the goto actions.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public class GotoActionGroup extends ResourceNavigatorActionGroup {
- private BackAction backAction;
+ private BackAction backAction;
- private ForwardAction forwardAction;
+ private ForwardAction forwardAction;
- private GoIntoAction goIntoAction;
+ private GoIntoAction goIntoAction;
- private UpAction upAction;
+ private UpAction upAction;
- private GotoResourceAction goToResourceAction;
+ private GotoResourceAction goToResourceAction;
- public GotoActionGroup(IResourceNavigator navigator) {
- super(navigator);
- }
+ public GotoActionGroup(IResourceNavigator navigator) {
+ super(navigator);
+ }
- @Override
+ @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()) {
+ 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
+ @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);
+ 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);
- }
+ IToolBarManager toolBar = actionBars.getToolBarManager();
+ toolBar.add(backAction);
+ toolBar.add(forwardAction);
+ toolBar.add(upAction);
+ }
- @Override
+ @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);
- }
+ 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
+ @Override
public void updateActionBars() {
- ActionContext context = getContext();
- boolean enable = false;
+ 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();
+ // 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
- }
+ 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
index b0b643b5e4a..3cbc03dadeb 100644
--- 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
@@ -19,45 +19,41 @@ 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.
+ * Implements the go to resource action. Opens a dialog and set the navigator
+ * selection with the resource selected by the user.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
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);
- }
+ /**
+ * 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
+ /**
+ * 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) {
+ 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);
- }
+ 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
index b22869db7b4..46e726ca377 100644
--- 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
@@ -31,11 +31,9 @@ import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
/**
* Creates a new instance of the class.
*/
- protected GotoResourceDialog(Shell parentShell, IContainer container,
- int typesMask) {
+ 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);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parentShell, INavigatorHelpContextIds.GOTO_RESOURCE_DIALOG);
}
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/INavigatorHelpContextIds.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/INavigatorHelpContextIds.java
index 66e1b2af87c..4020e7b9b34 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/INavigatorHelpContextIds.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/INavigatorHelpContextIds.java
@@ -22,45 +22,36 @@ import org.eclipse.ui.PlatformUI;
* This interface contains constants only; it is not intended to be implemented
* or extended.
* </p>
+ *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*
*/
-/*package*/interface INavigatorHelpContextIds {
- public static final String PREFIX = PlatformUI.PLUGIN_ID + "."; //$NON-NLS-1$
+/* package */interface INavigatorHelpContextIds {
+ public static final String PREFIX = PlatformUI.PLUGIN_ID + "."; //$NON-NLS-1$
- // Actions
- public static final String FILTER_SELECTION_ACTION = PREFIX
- + "filter_selection_action_context"; //$NON-NLS-1$
+ // Actions
+ public static final String FILTER_SELECTION_ACTION = PREFIX + "filter_selection_action_context"; //$NON-NLS-1$
- public static final String GOTO_RESOURCE_ACTION = PREFIX
- + "goto_resource_action_context"; //$NON-NLS-1$
+ public static final String GOTO_RESOURCE_ACTION = PREFIX + "goto_resource_action_context"; //$NON-NLS-1$
- public static final String RESOURCE_NAVIGATOR_MOVE_ACTION = PREFIX
- + "resource_navigator_move_action_context"; //$NON-NLS-1$
+ public static final String RESOURCE_NAVIGATOR_MOVE_ACTION = PREFIX + "resource_navigator_move_action_context"; //$NON-NLS-1$
- public static final String RESOURCE_NAVIGATOR_RENAME_ACTION = PREFIX
- + "resource_navigator_rename_action_context"; //$NON-NLS-1$
+ public static final String RESOURCE_NAVIGATOR_RENAME_ACTION = PREFIX + "resource_navigator_rename_action_context"; //$NON-NLS-1$
- public static final String SHOW_IN_NAVIGATOR_ACTION = PREFIX
- + "show_in_navigator_action_context"; //$NON-NLS-1$
+ public static final String SHOW_IN_NAVIGATOR_ACTION = PREFIX + "show_in_navigator_action_context"; //$NON-NLS-1$
- public static final String SORT_VIEW_ACTION = PREFIX
- + "sort_view_action_context"; //$NON-NLS-1$
+ public static final String SORT_VIEW_ACTION = PREFIX + "sort_view_action_context"; //$NON-NLS-1$
- public static final String COPY_ACTION = PREFIX
- + "resource_navigator_copy_action_context"; //$NON-NLS-1$
+ public static final String COPY_ACTION = PREFIX + "resource_navigator_copy_action_context"; //$NON-NLS-1$
- public static final String PASTE_ACTION = PREFIX
- + "resource_navigator_paste_action_context"; //$NON-NLS-1$
+ public static final String PASTE_ACTION = PREFIX + "resource_navigator_paste_action_context"; //$NON-NLS-1$
- public static final String COLLAPSE_ALL_ACTION = PREFIX
- + "collapse_all_action_context"; //$NON-NLS-1$
+ public static final String COLLAPSE_ALL_ACTION = PREFIX + "collapse_all_action_context"; //$NON-NLS-1$
- // Dialogs
- public static final String GOTO_RESOURCE_DIALOG = PREFIX
- + "goto_resource_dialog_context"; //$NON-NLS-1$
+ // Dialogs
+ public static final String GOTO_RESOURCE_DIALOG = PREFIX + "goto_resource_dialog_context"; //$NON-NLS-1$
- // Views
- public static final String RESOURCE_VIEW = PREFIX + "resource_view_context"; //$NON-NLS-1$
+ // Views
+ public static final String RESOURCE_VIEW = PREFIX + "resource_view_context"; //$NON-NLS-1$
}
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
index 202ed372732..7576f241172 100644
--- 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
@@ -19,12 +19,11 @@ 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 defines the API for the resource navigator. The action groups
+ * should restrict themselves to using this API.
* <p>
- * This interface is not intended to be implemented by clients.
- * Subclass <code>org.eclipse.ui.views.ResourceNavigator</code>
- * instead.
+ * This interface is not intended to be implemented by clients. Subclass
+ * <code>org.eclipse.ui.views.ResourceNavigator</code> instead.
* </p>
*
* @since 2.0
@@ -34,95 +33,104 @@ import org.eclipse.ui.views.framelist.FrameList;
@Deprecated
public interface IResourceNavigator extends IViewPart {
- /**
- * Returns the pattern filter.
- *
- * @return the pattern filter
- */
- ResourcePatternFilter getPatternFilter();
+ /**
+ * Returns the pattern filter.
+ *
+ * @return the pattern filter
+ */
+ ResourcePatternFilter getPatternFilter();
- /**
+ /**
* Returns the active working set, or <code>null</code> if none.
*
* @return the active working set, or <code>null</code> if none
* @since 2.0
*/
- IWorkingSet getWorkingSet();
+ IWorkingSet getWorkingSet();
- /**
- * Returns the current sorter.
- * @return the resource navigator's sorter
- *
- * @deprecated as of 3.3, use {@link IResourceNavigator#getComparator()} instead
- */
- @Deprecated
+ /**
+ * 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
+ /**
+ * 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();
+ /**
+ * 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 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);
+ /**
+ * 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 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 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 <code>true</code> if linking is enabled, <code>false</code> if not
- * @since 2.1
- */
- boolean isLinkingEnabled();
+ /**
+ * Returns whether this navigator's selection automatically tracks the active
+ * editor.
+ *
+ * @return <code>true</code> if linking is enabled, <code>false</code> if not
+ * @since 2.1
+ */
+ boolean isLinkingEnabled();
- /**
- * Sets the working set for this view, or <code>null</code> to clear it.
- *
- * @param workingSet the working set, or <code>null</code> to clear it
- * @since 2.0
- */
- void setWorkingSet(IWorkingSet workingSet);
+ /**
+ * Sets the working set for this view, or <code>null</code> to clear it.
+ *
+ * @param workingSet the working set, or <code>null</code> to clear it
+ * @since 2.0
+ */
+ void setWorkingSet(IWorkingSet workingSet);
- /**
- * Sets whether this navigator's selection automatically tracks the active editor.
- *
- * @param enabled <code>true</code> to enable, <code>false</code> to disable
- * @since 2.1
- */
- void setLinkingEnabled(boolean enabled);
+ /**
+ * Sets whether this navigator's selection automatically tracks the active
+ * editor.
+ *
+ * @param enabled <code>true</code> to enable, <code>false</code> 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
index ad0ca7972c6..ee63f1a1f60 100644
--- 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
@@ -26,20 +26,19 @@ import org.eclipse.swt.dnd.TransferData;
*
* @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 as of 3.5, use
+ * {@link org.eclipse.jface.util.LocalSelectionTransfer} instead
*/
@Deprecated
-public class LocalSelectionTransfer extends
- org.eclipse.jface.util.LocalSelectionTransfer {
+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.
+ * 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();
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
index d455053c0e1..7dd800706d7 100644
--- 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
@@ -52,315 +52,293 @@ 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.
+ * 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
public class MainActionGroup extends ResourceNavigatorActionGroup {
- protected AddBookmarkAction addBookmarkAction;
+ protected AddBookmarkAction addBookmarkAction;
- protected AddTaskAction addTaskAction;
+ protected AddTaskAction addTaskAction;
- protected PropertyDialogAction propertyDialogAction;
+ protected PropertyDialogAction propertyDialogAction;
- protected ImportResourcesAction importAction;
+ protected ImportResourcesAction importAction;
- protected ExportResourcesAction exportAction;
+ protected ExportResourcesAction exportAction;
- protected CollapseAllAction collapseAllAction;
+ protected CollapseAllAction collapseAllAction;
- protected ToggleLinkingAction toggleLinkingAction;
+ protected ToggleLinkingAction toggleLinkingAction;
- protected GotoActionGroup gotoGroup;
+ protected GotoActionGroup gotoGroup;
- protected OpenActionGroup openGroup;
+ protected OpenActionGroup openGroup;
- protected RefactorActionGroup refactorGroup;
+ protected RefactorActionGroup refactorGroup;
- protected WorkingSetFilterActionGroup workingSetGroup;
+ protected WorkingSetFilterActionGroup workingSetGroup;
- protected SortAndFilterActionGroup sortAndFilterGroup;
+ protected SortAndFilterActionGroup sortAndFilterGroup;
- protected UndoRedoActionGroup undoRedoGroup;
+ protected UndoRedoActionGroup undoRedoGroup;
- protected WorkspaceActionGroup workspaceGroup;
+ protected WorkspaceActionGroup workspaceGroup;
- private IResourceChangeListener resourceChangeListener;
+ private IResourceChangeListener resourceChangeListener;
- private NewWizardMenu newWizardMenu;
+ private NewWizardMenu newWizardMenu;
- /**
- * Constructs the main action group.
- *
- * @param navigator the navigator view
- */
- public MainActionGroup(IResourceNavigator navigator) {
- super(navigator);
- resourceChangeListener = event -> handleResourceChanged(event);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(
- resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
- makeSubGroups();
- }
+ /**
+ * Constructs the main action group.
+ *
+ * @param navigator the navigator view
+ */
+ public MainActionGroup(IResourceNavigator navigator) {
+ super(navigator);
+ resourceChangeListener = event -> handleResourceChanged(event);
+ 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;
- }
+ /**
+ * 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;
- }
+ 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
+ // 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
+ 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);
- }
- }
+ 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);
+ 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);
- }
+ undoRedoGroup = new UndoRedoActionGroup(getNavigator().getSite(), workspaceContext, true);
+ }
- /**
- * Extends the superclass implementation to set the context in the subgroups.
- */
- @Override
+ /**
+ * 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
+ 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
+ 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
+ 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
+ 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
+ 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
+ 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();
- }
+ 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
index 7a287e42f86..97a70452f33 100644
--- 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
@@ -41,200 +41,198 @@ import org.eclipse.ui.part.ResourceTransfer;
import org.eclipse.ui.statushandlers.StatusManager;
/**
- * Implements drag behaviour when items are dragged out of the
- * resource navigator.
+ * 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
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
+ 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);
+ LocalSelectionTransfer.getInstance().setSelection(null);
- if (event.doit == false) {
+ 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)) {
+ 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;
+ 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) {
+ 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) {
+ 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
+ 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);
+ final int typeMask = IResource.FILE | IResource.FOLDER;
+ IResource[] resources = getSelectedResources(typeMask);
- if (resources == null || resources.length == 0) {
+ 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)) {
+ 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) {
+ // 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) {
+ }
+ if (actualLength == 0) {
return;
}
- // was one or more of the locations null?
- if (actualLength < length) {
- String[] tempFileNames = fileNames;
- fileNames = new String[actualLength];
+ // 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
+ }
+ 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 (Iterator i = selection.iterator(); i.hasNext();) {
- Object next = i.next();
- 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) {
+ 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 (Iterator i = selection.iterator(); i.hasNext();) {
+ Object next = i.next();
+ 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<IResource> 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
- Iterator itr = structuredSelection.iterator();
- while (itr.hasNext()) {
- Object obj = itr.next();
- 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;
- }
+ ISelection selection = selectionProvider.getSelection();
+ if (!(selection instanceof IStructuredSelection) || selection.isEmpty()) {
+ return null;
+ }
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+
+ // loop through list and look for matching items
+ Iterator itr = structuredSelection.iterator();
+ while (itr.hasNext()) {
+ Object obj = itr.next();
+ 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
index cad9289124d..9fb66e03328 100644
--- 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
@@ -50,10 +50,9 @@ 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.
+ * 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
@@ -61,246 +60,235 @@ import org.eclipse.ui.part.ResourceTransfer;
@Deprecated
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);
- }
+ /**
+ * 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() {
+ /**
+ * 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<IResource> selectedResources = new ArrayList<>();
- ISelection selection = LocalSelectionTransfer.getInstance()
- .getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) selection;
+ ISelection selection = LocalSelectionTransfer.getInstance().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
for (Iterator<?> i = ssel.iterator(); i.hasNext();) {
- Object o = i.next();
+ Object o = i.next();
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 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
+ 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) {
+ 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();
+ }
+ 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;
- }
+ 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()));
+ * 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());
+ IContainer target = getActualTarget((IResource) getCurrentTarget());
- boolean shouldLinkAutomatically = false;
+ boolean shouldLinkAutomatically = false;
if (target.isVirtual()) {
shouldLinkAutomatically = true;
for (IResource source : sources) {
@@ -311,15 +299,14 @@ public class NavigatorDropAdapter extends PluginDropAdapter implements IOverwrit
}
}
- CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
- shell);
+ CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(shell);
- // if the target is a group and all sources are files, then automatically create links
+ // 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 {
+ } else {
boolean allSourceAreLinksOrGroups = true;
for (int i = 0; i < sources.length; i++) {
if (!sources[0].isVirtual() && !sources[0].isLinked()) {
@@ -327,10 +314,13 @@ public class NavigatorDropAdapter extends PluginDropAdapter implements IOverwrit
break;
}
}
- // if all sources are either links or groups, copy then normally, don't show the dialog
+ // 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);
+ 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);
@@ -343,32 +333,28 @@ public class NavigatorDropAdapter extends PluginDropAdapter implements IOverwrit
if (dialog.getVariable() != null)
operation.setRelativeVariable(dialog.getVariable());
operation.copyResources(sources, target);
- }
- else
+ } else
return problems;
- }
- else
+ } else
operation.copyResources(sources, target);
- }
- else
+ } else
operation.copyResources(sources, target);
}
- return problems;
- }
+ 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()));
+ /**
+ * 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());
+ IContainer target = getActualTarget((IResource) getCurrentTarget());
- boolean shouldLinkAutomatically = false;
+ boolean shouldLinkAutomatically = false;
if (target.isVirtual()) {
shouldLinkAutomatically = true;
for (IResource source : sources) {
@@ -380,132 +366,122 @@ public class NavigatorDropAdapter extends PluginDropAdapter implements IOverwrit
}
if (shouldLinkAutomatically) {
- CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
- getShell());
+ 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);
+ 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;
- }
+ return problems;
+ }
- /*
- * @see org.eclipse.ui.dialogs.IOverwriteQuery#queryOverwrite(java.lang.String)
- */
- @Override
+ /*
+ * @see org.eclipse.ui.dialogs.IOverwriteQuery#queryOverwrite(java.lang.String)
+ */
+ @Override
public String queryOverwrite(String pathString) {
- if (alwaysOverwrite) {
+ 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];
+ 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) {
+ 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) {
+ 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());
+ 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) {
+ } 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();
- }
+ }
+ }
+ } // 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
index ff5626c93ab..8bbc1080a0c 100644
--- 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
@@ -23,54 +23,53 @@ 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
public class NavigatorFrameSource extends TreeViewerFrameSource {
- private ResourceNavigator navigator;
+ 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;
- }
+ /**
+ * 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
+ /**
+ * 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;
- }
+ TreeFrame frame = super.createFrame(input);
+ frame.setName(navigator.getFrameName(input));
+ frame.setToolTipText(navigator.getFrameToolTipText(input));
+ return frame;
+ }
- /**
- * Also updates the navigator's title.
- */
- @Override
+ /**
+ * Also updates the navigator's title.
+ */
+ @Override
protected void frameChanged(TreeFrame frame) {
- IResource resource = (IResource) frame.getInput();
- IProject project = resource.getProject();
+ 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();
- }
- }
+ 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
index 74dd4169bf4..3d977a977ae 100644
--- 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
@@ -30,114 +30,108 @@ 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
public class OpenActionGroup extends ResourceNavigatorActionGroup {
- private OpenFileAction openFileAction;
+ private OpenFileAction openFileAction;
- /**
- * The id for the Open With submenu.
- */
- public static final String OPEN_WITH_ID = PlatformUI.PLUGIN_ID
- + ".OpenWithSubMenu"; //$NON-NLS-1$
+ /**
+ * 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);
- }
+ public OpenActionGroup(IResourceNavigator navigator) {
+ super(navigator);
+ }
- @Override
+ @Override
protected void makeActions() {
- openFileAction = new OpenFileAction(navigator.getSite().getPage());
- }
+ openFileAction = new OpenFileAction(navigator.getSite().getPage());
+ }
- @Override
+ @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) {
+ 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)) {
+ 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) {
+ 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)) {
+ Object element = selection.getFirstElement();
+ if (!(element instanceof IContainer)) {
return;
}
- if (element instanceof IProject && !(((IProject) element).isOpen())) {
+ if (element instanceof IProject && !(((IProject) element).isOpen())) {
return;
}
- menu.add(new OpenInNewWindowAction(navigator.getSite()
- .getWorkbenchWindow(), (IContainer) element));
- }
+ menu.add(new OpenInNewWindowAction(navigator.getSite().getWorkbenchWindow(), (IContainer) element));
+ }
- /**
- * Runs the default action (open file).
- */
- @Override
+ /**
+ * 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();
- }
- }
+ 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
index 7765963a522..ef0f9a921b3 100644
--- 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
@@ -33,237 +33,229 @@ 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.
+ * Standard action for pasting resources on the clipboard to the selected
+ * resource's location.
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
+ *
* @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
-/*package*/class PasteAction extends SelectionListenerAction {
+/* package */class PasteAction extends SelectionListenerAction {
- /**
- * The id of this action.
- */
- public static final String ID = PlatformUI.PLUGIN_ID + ".PasteAction";//$NON-NLS-1$
+ /**
+ * 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;
+ /**
+ * The shell in which to show any dialogs.
+ */
+ private Shell shell;
- /**
- * System clipboard
- */
- private Clipboard clipboard;
+ /**
+ * 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);
- }
+ /**
+ * 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() {
- List selectedResources = getSelectedResources();
+ /**
+ * 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() {
+ List selectedResources = getSelectedResources();
- for (int i = 0; i < selectedResources.size(); i++) {
- IResource resource = (IResource) selectedResources.get(i);
+ for (int i = 0; i < selectedResources.size(); i++) {
+ IResource resource = (IResource) selectedResources.get(i);
- if (resource instanceof IProject && !((IProject) resource).isOpen()) {
+ if (resource instanceof IProject && !((IProject) resource).isOpen()) {
return null;
}
- if (resource.getType() == IResource.FILE) {
+ if (resource.getType() == IResource.FILE) {
resource = resource.getParent();
}
- if (resource != null) {
+ if (resource != null) {
return resource;
}
- }
- return null;
- }
+ }
+ 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()) {
+ /**
+ * 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;
- }
+ }
+ return false;
+ }
- /**
- * Implementation of method defined on <code>IAction</code>.
- */
- @Override
+ /**
+ * Implementation of method defined on <code>IAction</code>.
+ */
+ @Override
public void run() {
- // try a resource transfer
- ResourceTransfer resTransfer = ResourceTransfer.getInstance();
- IResource[] resourceData = (IResource[]) clipboard
- .getContents(resTransfer);
+ // 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();
+ 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;
- }
+ 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);
+ // 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();
+ 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);
- }
- }
+ 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) {
+ /**
+ * 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 <code>PasteAction</code> implementation of this
- * <code>SelectionListenerAction</code> 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
+ /**
+ * The <code>PasteAction</code> implementation of this
+ * <code>SelectionListenerAction</code> 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)) {
+ 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);
+ 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;
+ 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) {
+ 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;
- }
+ }
+ return true;
+ }
- if (getSelectedNonResources().size() > 0) {
+ 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) {
+ 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 (int i = 0; i < selectedResources.size(); i++) {
- IResource resource = (IResource) selectedResources.get(i);
- if (resource.getType() != IResource.FILE) {
+ // 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 (int i = 0; i < selectedResources.size(); i++) {
+ IResource resource = (IResource) selectedResources.get(i);
+ if (resource.getType() != IResource.FILE) {
return false;
}
- if (!targetResource.equals(resource.getParent())) {
+ 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) {
+ }
+ }
+ 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)) {
+ 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;
+ }
+ TransferData[] transfers = clipboard.getAvailableTypes();
+ FileTransfer fileTransfer = FileTransfer.getInstance();
+ for (TransferData transfer : transfers) {
+ if (fileTransfer.isSupportedType(transfer)) {
return true;
}
- }
- return false;
- }
+ }
+ 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
index c1813d17481..a33acba3710 100644
--- 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
@@ -30,8 +30,8 @@ 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.
+ * 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
@@ -39,133 +39,122 @@ import org.eclipse.ui.actions.TextActionHandler;
@Deprecated
public class RefactorActionGroup extends ResourceNavigatorActionGroup {
- private Clipboard clipboard;
+ private Clipboard clipboard;
- private CopyAction copyAction;
+ private CopyAction copyAction;
- private DeleteResourceAction deleteAction;
+ private DeleteResourceAction deleteAction;
- private PasteAction pasteAction;
+ private PasteAction pasteAction;
- private ResourceNavigatorRenameAction renameAction;
+ private ResourceNavigatorRenameAction renameAction;
- private ResourceNavigatorMoveAction moveAction;
+ private ResourceNavigatorMoveAction moveAction;
- private TextActionHandler textActionHandler;
+ private TextActionHandler textActionHandler;
- public RefactorActionGroup(IResourceNavigator navigator) {
- super(navigator);
- }
+ public RefactorActionGroup(IResourceNavigator navigator) {
+ super(navigator);
+ }
- @Override
+ @Override
public void dispose() {
- if (clipboard != null) {
- clipboard.dispose();
- clipboard = null;
- }
- super.dispose();
- }
-
- @Override
+ 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
+ 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
+ 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();
- }
+ if (event.character == SWT.DEL && event.stateMask == 0) {
+ if (deleteAction.isEnabled()) {
+ deleteAction.run();
+ }
- // Swallow the event.
- event.doit = false;
+ // Swallow the event.
+ event.doit = false;
- } else if (event.keyCode == SWT.F2 && event.stateMask == 0) {
- if (renameAction.isEnabled()) {
- renameAction.run();
- }
+ } else if (event.keyCode == SWT.F2 && event.stateMask == 0) {
+ if (renameAction.isEnabled()) {
+ renameAction.run();
+ }
- // Swallow the event.
- event.doit = false;
- }
- }
+ // Swallow the event.
+ event.doit = false;
+ }
+ }
- @Override
+ @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
+ 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);
- }
+ 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/ResourceComparator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceComparator.java
index ab31cc87f66..b432740a730 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceComparator.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceComparator.java
@@ -19,16 +19,16 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
/**
- * Comparator for viewers that display items of type <code>IResource</code>.
- * The sorter supports two sort criteria:
+ * Comparator for viewers that display items of type <code>IResource</code>. The
+ * sorter supports two sort criteria:
* <p>
* <code>NAME</code>: Folders are given order precedence, followed by files.
- * Within these two groups resources are ordered by name. All name comparisons
+ * Within these two groups resources are ordered by name. All name comparisons
* are case-insensitive.
* </p>
* <p>
* <code>TYPE</code>: Folders are given order precedence, followed by files.
- * Within these two groups resources are ordered by extension. All extension
+ * Within these two groups resources are ordered by extension. All extension
* comparisons are case-insensitive.
* </p>
* <p>
@@ -39,60 +39,60 @@ import org.eclipse.jface.viewers.ViewerComparator;
*/
public class ResourceComparator extends ViewerComparator {
- /**
- * 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 <code>NAME</code> or
- * <code>TYPE</code>
- */
- public ResourceComparator(int criteria) {
- super();
- this.criteria = criteria;
- }
-
- /**
- * Returns an integer value representing the relative sort priority of the
- * given element based on its class.
- * <ul>
- * <li>resources (<code>IResource</code>) - 2</li>
- * <li>project references (<code>ProjectReference</code>) - 1</li>
- * <li>everything else - 0</li>
- * </ul>
- *
- * @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
+ /**
+ * 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 <code>NAME</code> or
+ * <code>TYPE</code>
+ */
+ public ResourceComparator(int criteria) {
+ super();
+ this.criteria = criteria;
+ }
+
+ /**
+ * Returns an integer value representing the relative sort priority of the given
+ * element based on its class.
+ * <ul>
+ * <li>resources (<code>IResource</code>) - 2</li>
+ * <li>project references (<code>ProjectReference</code>) - 1</li>
+ * <li>everything else - 0</li>
+ * </ul>
+ *
+ * @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) {
+ // 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;
@@ -105,94 +105,93 @@ public class ResourceComparator extends ViewerComparator {
} 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 <code>0</code> 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 <code>0</code> 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 getComparator().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 <code>0</code> 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 = getComparator().compare(ext1, ext2);
-
- if (result != 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 <code>0</code> 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 <code>0</code> 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 getComparator().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 <code>0</code> 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 = getComparator().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 <code>NAME</code> or <code>TYPE</code>
- */
- 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 <code>ResourceSorter.NAME</code> or
- * <code>ResourceSorter.TYPE</code>
- */
- public void setCriteria(int criteria) {
- this.criteria = criteria;
- }
+ return compareNames(resource1, resource2);
+ }
+
+ /**
+ * Returns the sort criteria of this sorter.
+ *
+ * @return the sort criterion: one of <code>NAME</code> or <code>TYPE</code>
+ */
+ 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 <code>ResourceSorter.NAME</code>
+ * or <code>ResourceSorter.TYPE</code>
+ */
+ public void setCriteria(int criteria) {
+ this.criteria = criteria;
+ }
}
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
index b7c328e60db..3c76963d52a 100644
--- 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
@@ -103,132 +103,129 @@ import org.eclipse.ui.views.framelist.TreeFrame;
/**
* Implements the Resource Navigator view.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
-public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
- IResourceNavigator {
+public class ResourceNavigator extends ViewPart implements ISetSelectionTarget, IResourceNavigator {
- private TreeViewer viewer;
+ private TreeViewer viewer;
- private IDialogSettings settings;
+ private IDialogSettings settings;
- private IMemento memento;
+ private IMemento memento;
- private FrameList frameList;
+ private FrameList frameList;
- private ResourceNavigatorActionGroup actionGroup;
+ private ResourceNavigatorActionGroup actionGroup;
- private ResourcePatternFilter patternFilter = new ResourcePatternFilter();
+ private ResourcePatternFilter patternFilter = new ResourcePatternFilter();
- private ResourceWorkingSetFilter workingSetFilter = new ResourceWorkingSetFilter();
+ private ResourceWorkingSetFilter workingSetFilter = new ResourceWorkingSetFilter();
- private boolean linkingEnabled;
+ private boolean linkingEnabled;
- private boolean dragDetected;
+ private boolean dragDetected;
- private Listener dragDetectListener;
- /**
- * Remembered working set.
- */
- private IWorkingSet workingSet;
+ 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.
+ /**
+ * 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;
+ private boolean emptyWorkingSet = false;
- /**
+ /**
* Settings constant for section name (value <code>ResourceNavigator</code>).
*/
- private static final String STORE_SECTION = "ResourceNavigator"; //$NON-NLS-1$
+ private static final String STORE_SECTION = "ResourceNavigator"; //$NON-NLS-1$
- /**
- * Settings constant for sort order (value <code>ResourceViewer.STORE_SORT_TYPE</code>).
- */
- private static final String STORE_SORT_TYPE = "ResourceViewer.STORE_SORT_TYPE"; //$NON-NLS-1$
+ /**
+ * Settings constant for sort order (value
+ * <code>ResourceViewer.STORE_SORT_TYPE</code>).
+ */
+ private static final String STORE_SORT_TYPE = "ResourceViewer.STORE_SORT_TYPE"; //$NON-NLS-1$
- /**
- * Settings constant for working set (value <code>ResourceWorkingSetFilter.STORE_WORKING_SET</code>).
- */
- private static final String STORE_WORKING_SET = "ResourceWorkingSetFilter.STORE_WORKING_SET"; //$NON-NLS-1$
+ /**
+ * Settings constant for working set (value
+ * <code>ResourceWorkingSetFilter.STORE_WORKING_SET</code>).
+ */
+ 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
+ /**
+ * @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;
+ /**
+ * 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$
+ // 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_FILTERS = "filters"; //$NON-NLS-1$
- private static final String TAG_FILTER = "filter"; //$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_SELECTION = "selection"; //$NON-NLS-1$
- private static final String TAG_EXPANDED = "expanded"; //$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_ELEMENT = "element"; //$NON-NLS-1$
- private static final String TAG_IS_ENABLED = "isEnabled"; //$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_PATH = "path"; //$NON-NLS-1$
- private static final String TAG_CURRENT_FRAME = "currentFrame"; //$NON-NLS-1$
+ private static final String TAG_CURRENT_FRAME = "currentFrame"; //$NON-NLS-1$
- private IPartListener partListener = new IPartListener() {
- @Override
+ private IPartListener partListener = new IPartListener() {
+ @Override
public void partActivated(IWorkbenchPart part) {
- if (part instanceof IEditorPart) {
+ if (part instanceof IEditorPart) {
editorActivated((IEditorPart) part);
}
- }
+ }
- @Override
+ @Override
public void partBroughtToTop(IWorkbenchPart part) {
- if (part instanceof IEditorPart) {
+ if (part instanceof IEditorPart) {
editorActivated((IEditorPart) part);
}
- }
+ }
- @Override
+ @Override
public void partClosed(IWorkbenchPart part) {
- }
+ }
- @Override
+ @Override
public void partDeactivated(IWorkbenchPart part) {
- }
+ }
- @Override
+ @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) {
+ }
+ };
+
+ 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) {
@@ -239,12 +236,12 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
// we've gone from empty to non-empty on our set.
// Restore it.
if (emptyWorkingSet) {
- emptyWorkingSet = false;
+ emptyWorkingSet = false;
workingSetFilter.setWorkingSet(workingSet);
}
}
getViewer().refresh();
- }
+ }
};
private CollapseAllHandler collapseAllHandler;
@@ -256,200 +253,195 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
*/
private OpenAndLinkWithEditorHelper openAndLinkWithEditorHelper;
+ /**
+ * Constructs a new resource navigator view.
+ */
+ public ResourceNavigator() {
+ IDialogSettings viewsSettings = getPlugin().getDialogSettings();
- /**
- * Constructs a new resource navigator view.
- */
- public ResourceNavigator() {
- IDialogSettings viewsSettings = getPlugin().getDialogSettings();
-
- settings = viewsSettings.getSection(STORE_SECTION);
- if (settings == null) {
- settings = viewsSettings.addNewSection(STORE_SECTION);
- }
+ settings = viewsSettings.getSection(STORE_SECTION);
+ if (settings == null) {
+ settings = viewsSettings.addNewSection(STORE_SECTION);
+ }
- initLinkingEnabled();
- }
+ initLinkingEnabled();
+ }
- /**
- * Converts the given selection into a form usable by the viewer,
- * where the elements are resources.
- */
- private StructuredSelection convertSelection(ISelection selection) {
+ /**
+ * Converts the given selection into a form usable by the viewer, where the
+ * elements are resources.
+ */
+ private StructuredSelection convertSelection(ISelection selection) {
ArrayList<IResource> list = new ArrayList<>();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
for (Iterator<?> i = ssel.iterator(); i.hasNext();) {
- Object o = i.next();
+ Object o = i.next();
IResource resource = Adapters.adapt(o, IResource.class);
- if (resource != null) {
- list.add(resource);
- }
- }
- }
- return new StructuredSelection(list);
- }
-
- @Override
+ 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;
+ this.viewer = viewer;
emptyWorkspaceHelper.setNonEmptyControl(viewer.getControl());
- if (memento != null) {
- restoreFilters();
- restoreLinkingEnabled();
- }
- frameList = createFrameList();
- initDragAndDrop();
- updateTitle();
+ if (memento != null) {
+ restoreFilters();
+ restoreLinkingEnabled();
+ }
+ frameList = createFrameList();
+ initDragAndDrop();
+ updateTitle();
- initContextMenu();
+ initContextMenu();
- initResourceComparator();
- initWorkingSetFilter();
+ initResourceComparator();
+ initWorkingSetFilter();
- // make sure input is set after sorters and filters,
- // to avoid unnecessary refreshes
- viewer.setInput(getInitialInput());
+ // 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();
+ // 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());
+ // 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 = getPlugin().getWorkbench()
- .getWorkingSetManager();
- workingSetManager.addPropertyChangeListener(propertyChangeListener);
+ getSite().setSelectionProvider(viewer);
+ getSite().getPage().addPartListener(partListener);
+ IWorkingSetManager workingSetManager = getPlugin().getWorkbench().getWorkingSetManager();
+ workingSetManager.addPropertyChangeListener(propertyChangeListener);
- if (memento != null) {
+ 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(manager -> ResourceNavigator.this.fillContextMenu(manager));
- 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(), getPlugin().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(event -> handleSelectionChanged(event));
- viewer.addDoubleClickListener(event -> handleDoubleClick(event));
+ 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(manager -> ResourceNavigator.this.fillContextMenu(manager));
+ 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(),
+ getPlugin().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(event -> handleSelectionChanged(event));
+ viewer.addDoubleClickListener(event -> handleDoubleClick(event));
openAndLinkWithEditorHelper = new OpenAndLinkWithEditorHelper(viewer) {
@Override
protected void activate(ISelection selection) {
Object selectedElement = getSingleElement(selection);
if (selectedElement instanceof IFile) {
- IEditorInput input = new FileEditorInput((IFile)selectedElement);
+ IEditorInput input = new FileEditorInput((IFile) selectedElement);
final IWorkbenchPage page = getSite().getPage();
IEditorPart editor = page.findEditor(input);
if (editor != null) {
@@ -461,8 +453,9 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
@Override
protected void linkToEditor(ISelection selection) {
- if (!linkScheduled) {
- // Ensure that if another selection change arrives while we're waiting for the *syncExec,
+ 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(() -> {
@@ -490,94 +483,91 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
};
-
- viewer.getControl().addKeyListener(new KeyListener() {
- @Override
+ viewer.getControl().addKeyListener(new KeyListener() {
+ @Override
public void keyPressed(KeyEvent event) {
- handleKeyPressed(event);
- }
+ handleKeyPressed(event);
+ }
- @Override
+ @Override
public void keyReleased(KeyEvent event) {
- handleKeyReleased(event);
- }
- });
+ handleKeyReleased(event);
+ }
+ });
- openAndLinkWithEditorHelper.setLinkWithEditor(linkingEnabled);
- }
+ openAndLinkWithEditorHelper.setLinkWithEditor(linkingEnabled);
+ }
- @Override
+ @Override
public void dispose() {
- getSite().getPage().removePartListener(partListener);
+ getSite().getPage().removePartListener(partListener);
- IWorkingSetManager workingSetManager = getPlugin().getWorkbench()
- .getWorkingSetManager();
- workingSetManager.removePropertyChangeListener(propertyChangeListener);
+ IWorkingSetManager workingSetManager = getPlugin().getWorkbench().getWorkingSetManager();
+ workingSetManager.removePropertyChangeListener(propertyChangeListener);
- if (collapseAllHandler != null) {
+ 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 (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) {
+ 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);
- }
+ getActionGroup().setContext(new ActionContext(selection));
+ getActionGroup().fillContextMenu(menu);
+ }
- @Override
+ @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
- */
+ 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) {
@@ -596,37 +586,38 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
return ResourcesPlugin.getWorkspace().getRoot();
}
- /**
- * Returns the pattern filter for this view.
- *
- * @return the pattern filter
- * @since 2.0
- */
- @Override
+ /**
+ * 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
+ 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 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
* <code>null</code>.
@@ -634,120 +625,121 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
* @since 2.0
* @deprecated as of 3.3, use {@link ResourceNavigator#getComparator()}
*/
- @Deprecated
+ @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
+ 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
* <code>null</code>.
- *
- * @return the <code>ResourceComparator</code>
- * @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
+ *
+ * @return the <code>ResourceComparator</code>
+ * @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
+ 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 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) {
+ 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 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();
- }
+ return path.makeRelative().toString();
+ }
- String text = ((ILabelProvider) getTreeViewer().getLabelProvider())
- .getText(element);
- if(text == null) {
+ String text = ((ILabelProvider) getTreeViewer().getLabelProvider()).getText(element);
+ if (text == null) {
return "";//$NON-NLS-1$
}
- return text;
- }
+ return text;
+ }
/**
* Handles an open event from the viewer. Opens an editor on the selected file.
@@ -756,9 +748,9 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
* @since 2.0
* @deprecated As of 3.5, replaced by {@link #handleOpen(ISelection)}
*/
- @Deprecated
+ @Deprecated
protected void handleOpen(OpenEvent event) {
- handleOpen(event.getSelection());
+ handleOpen(event.getSelection());
}
/**
@@ -769,26 +761,26 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
*/
protected void handleOpen(ISelection selection) {
if (selection instanceof IStructuredSelection) {
- getActionGroup().runDefaultAction((IStructuredSelection)selection);
+ 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));
+ }
+
+ /**
+ * 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());
@@ -798,148 +790,142 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
}
}
- }
+ }
- /**
- * 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) {
+ /**
+ * 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
+ 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
+ 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) {
+ 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) {
+ } else {
+ sortInt = settings.getInt(STORE_SORT_TYPE);
+ }
+ if (sortInt == ResourceSorter.NAME || sortInt == ResourceSorter.TYPE) {
sortType = sortInt;
}
- } catch (NumberFormatException e) {
- }
- setSorter(new ResourceSorter(sortType));
- }
+ } catch (NumberFormatException e) {
+ }
+ setSorter(new ResourceSorter(sortType));
+ }
- /**
- * Initializes the comparator.
+ /**
+ * 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) {
+ */
+ 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) {
+ } 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.equals("") == false) { //$NON-NLS-1$
- IWorkingSetManager workingSetManager = getPlugin().getWorkbench()
- .getWorkingSetManager();
+ } 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.equals("") == false) { //$NON-NLS-1$
+ IWorkingSetManager workingSetManager = getPlugin().getWorkbench().getWorkingSetManager();
workingSet = workingSetManager.getWorkingSet(workingSetName);
- } else if (PlatformUI
- .getPreferenceStore()
- .getBoolean(
- IWorkbenchPreferenceConstants.USE_WINDOW_WORKING_SET_BY_DEFAULT)) {
+ } 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();
}
@@ -951,20 +937,19 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
workingSetFilter.setWorkingSet(workingSet);
internalSetWorkingSet(workingSet);
}
- }
+ }
- /**
+ /**
* Returns whether the navigator selection automatically tracks the active
* editor.
*
- * @return <code>true</code> if linking is enabled, <code>false</code>
- * if not
+ * @return <code>true</code> if linking is enabled, <code>false</code> if not
* @since 2.0 (this was protected in 2.0, but was made public in 2.1)
*/
- @Override
+ @Override
public boolean isLinkingEnabled() {
- return linkingEnabled;
- }
+ return linkingEnabled;
+ }
/**
* Brings the corresponding editor to top if the selected resource is open.
@@ -972,9 +957,9 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
* @since 2.0
* @deprecated As of 3.5, replaced by {@link #linkToEditor(ISelection)}
*/
- @Deprecated
+ @Deprecated
protected void linkToEditor(IStructuredSelection selection) {
- linkToEditor((ISelection)selection);
+ linkToEditor((ISelection) selection);
}
/**
@@ -984,504 +969,491 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
*/
protected void linkToEditor(ISelection selection) {
- if (this != this.getSite().getPage().getActivePart())
- return;
+ if (this != this.getSite().getPage().getActivePart())
+ return;
- Object obj = getSingleElement(selection);
+ 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);
+ 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) {
+ 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<String> selectedFilters = new ArrayList<>();
- ArrayList unSelectedFilters = 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
+ // 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)) {
+ }
+
+ /*
+ * 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();
+ }
+
+ // 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();
+ 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
+ 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) {
+ 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
+ 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) {
+ 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
+ }
+ }
+ }
+ }
+
+ 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 <code>patterns</code>
- * in the preference store.
- */
- @Override
+ 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 <code>patterns</code> in the
+ * preference store.
+ */
+ @Override
public void setFiltersPreference(String[] patterns) {
- StringBuilder sb = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
- for (int i = 0; i < patterns.length; i++) {
- if (i != 0) {
+ for (int i = 0; i < patterns.length; i++) {
+ if (i != 0) {
sb.append(ResourcePatternFilter.COMMA_SEPARATOR);
}
- sb.append(patterns[i]);
- }
-
- getPlugin().getPreferenceStore().setValue(
- ResourcePatternFilter.FILTERS_TAG, sb.toString());
-
- // remove value in old workbench preference store location
- IPreferenceStore preferenceStore = IDEWorkbenchPlugin.getDefault()
- .getPreferenceStore();
- String storedPatterns = preferenceStore
- .getString(ResourcePatternFilter.FILTERS_TAG);
- if (storedPatterns.length() > 0) {
+ sb.append(patterns[i]);
+ }
+
+ getPlugin().getPreferenceStore().setValue(ResourcePatternFilter.FILTERS_TAG, sb.toString());
+
+ // 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
+ /**
+ * @see IWorkbenchPart#setFocus()
+ */
+ @Override
public void setFocus() {
- getTreeViewer().getTree().setFocus();
- }
-
- /**
- * Note: For experimental use only.
- * Sets the decorator for the navigator.
- * <p>
- * As of 2.0, this method no longer has any effect.
- * </p>
- *
- * @param decorator a label decorator or <code>null</code> for no decorations.
- * @deprecated use the decorators extension point instead; see IWorkbench.getDecoratorManager()
- */
- @Deprecated
+ getTreeViewer().getTree().setFocus();
+ }
+
+ /**
+ * Note: For experimental use only. Sets the decorator for the navigator.
+ * <p>
+ * As of 2.0, this method no longer has any effect.
+ * </p>
+ *
+ * @param decorator a label decorator or <code>null</code> 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
+ // 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
+ 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
+ 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
+ @Override
public void setWorkingSet(IWorkingSet workingSet) {
- TreeViewer treeViewer = getTreeViewer();
- Object[] expanded = treeViewer.getExpandedElements();
+ 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);
+ 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());
- }
- }
+ treeViewer.reveal(structuredSelection.getFirstElement());
+ }
+ }
/**
* Set the internal working set fields specific to the navigator.
*
- * @param workingSet
- * the new working set
+ * @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();
+ 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) {
+ /**
+ * 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
+ 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> T getAdapter(Class<T> adapter) {
- if (adapter == IShowInSource.class) {
+ if (adapter == IShowInSource.class) {
return adapter.cast(getShowInSource());
- }
- if (adapter == IShowInTarget.class) {
+ }
+ if (adapter == IShowInTarget.class) {
return adapter.cast(getShowInTarget());
- }
- return null;
- }
-
- /**
- * Returns the <code>IShowInSource</code> for this view.
- */
- protected IShowInSource getShowInSource() {
- return () -> new ShowInContext(getViewer().getInput(), getViewer()
- .getSelection());
- }
-
- /**
- * Returns the <code>IShowInTarget</code> for this view.
- */
- protected IShowInTarget getShowInTarget() {
- return context -> {
+ }
+ return null;
+ }
+
+ /**
+ * Returns the <code>IShowInSource</code> for this view.
+ */
+ protected IShowInSource getShowInSource() {
+ return () -> new ShowInContext(getViewer().getInput(), getViewer().getSelection());
+ }
+
+ /**
+ * Returns the <code>IShowInTarget</code> for this view.
+ */
+ protected IShowInTarget getShowInTarget() {
+ return context -> {
ArrayList<IResource> toSelect = new ArrayList<>();
- ISelection sel = context.getSelection();
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) sel;
+ ISelection sel = context.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) sel;
for (Iterator<?> i = ssel.iterator(); i.hasNext();) {
- Object o1 = i.next();
+ Object o1 = i.next();
IResource resource = Adapters.adapt(o1, IResource.class);
if (resource != null) {
@@ -1494,9 +1466,9 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
if (r2.getType() != IResource.ROOT) {
toSelect.add(r2);
}
- }
- }
- }
+ }
+ }
+ }
if (toSelect.isEmpty()) {
Object input = context.getInput();
IResource resource = Adapters.adapt(input, IResource.class);
@@ -1504,16 +1476,17 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
toSelect.add(resource);
}
}
- if (!toSelect.isEmpty()) {
- selectReveal(new StructuredSelection(toSelect));
- return true;
- }
- return false;
+ if (!toSelect.isEmpty()) {
+ selectReveal(new StructuredSelection(toSelect));
+ return true;
+ }
+ return false;
};
- }
+ }
/**
- * Returns the selected element if the selection consists of a single element only.
+ * Returns the selected element if the selection consists of a single element
+ * only.
*
* @param s the selection
* @return the selected first element or null
@@ -1523,7 +1496,7 @@ public class ResourceNavigator extends ViewPart implements ISetSelectionTarget,
if (!(s instanceof IStructuredSelection))
return null;
- IStructuredSelection selection = (IStructuredSelection)s;
+ IStructuredSelection selection = (IStructuredSelection) s;
if (selection.size() != 1)
return null;
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
index beb45922805..75863c731e7 100644
--- 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
@@ -22,53 +22,54 @@ import org.eclipse.ui.actions.SelectionProviderAction;
/**
* Superclass of all actions provided by the resource navigator.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public abstract class ResourceNavigatorAction extends SelectionProviderAction {
- private IResourceNavigator navigator;
+ private IResourceNavigator navigator;
- /**
- * Creates a new instance of the class.
- */
- public ResourceNavigatorAction(IResourceNavigator navigator, String label) {
- super(navigator.getViewer(), label);
- this.navigator = 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 navigator for which this action was created.
+ */
+ public IResourceNavigator getNavigator() {
+ return navigator;
+ }
- /**
- * Returns the resource viewer
- */
- protected Viewer getViewer() {
- return getNavigator().getViewer();
- }
+ /**
+ * 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 shell to use within actions.
+ */
+ protected Shell getShell() {
+ return getNavigator().getSite().getShell();
+ }
- /**
- * Returns the workbench.
- */
- protected IWorkbench getWorkbench() {
- return PlatformUI.getWorkbench();
- }
+ /**
+ * Returns the workbench.
+ */
+ protected IWorkbench getWorkbench() {
+ return PlatformUI.getWorkbench();
+ }
- /**
- * Returns the workbench window.
- */
- protected IWorkbenchWindow getWorkbenchWindow() {
- return getNavigator().getSite().getWorkbenchWindow();
- }
+ /**
+ * 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
index 1e3dbbe23eb..ccf12493431 100644
--- 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
@@ -21,8 +21,8 @@ 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.
+ * 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
@@ -36,55 +36,54 @@ import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
@Deprecated
public abstract class ResourceNavigatorActionGroup extends ActionGroup {
- /**
- * The resource navigator.
- */
- protected IResourceNavigator navigator;
+ /**
+ * 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();
- }
+ /**
+ * 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 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;
- }
+ /**
+ * 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) {
- }
+ /**
+ * 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();
+ /**
+ * 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) {
- }
+ /**
+ * 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
index dd53c243409..1c30f80be4a 100644
--- 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
@@ -13,12 +13,12 @@
*******************************************************************************/
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.
+ * @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.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
@@ -26,30 +26,28 @@ package org.eclipse.ui.views.navigator;
public class ResourceNavigatorMessages {
private ResourceNavigatorMessages() {
- // prevent instantiation of class
- }
+ // 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 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;
- }
+ /**
+ * 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
index 9ffa9cf5e4f..53bb80bd48f 100644
--- 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
@@ -30,65 +30,64 @@ 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.
+ * 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.
*
* @since 2.0
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public class ResourceNavigatorMoveAction extends MoveResourceAction {
- private StructuredViewer viewer;
+ private StructuredViewer viewer;
- private MoveProjectAction moveProjectAction;
+ 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);
- }
+ /**
+ * 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
+ @Override
public void run() {
- if (moveProjectAction.isEnabled()) {
- moveProjectAction.run();
- return;
- }
+ 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();
+ 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) {
+ while (iterator.hasNext()) {
+ IResource newResource = root.findMember((IPath) iterator.next());
+ if (newResource != null) {
resources.add(newResource);
}
- }
+ }
- this.viewer.setSelection(new StructuredSelection(resources), true);
- }
+ this.viewer.setSelection(new StructuredSelection(resources), true);
+ }
- }
+ }
- @Override
+ @Override
protected boolean updateSelection(IStructuredSelection selection) {
- moveProjectAction.selectionChanged(selection);
- return super.updateSelection(selection)
- || moveProjectAction.isEnabled();
- }
+ 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
index 39371e2dbf8..ef2c4c56d5d 100644
--- 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
@@ -27,45 +27,46 @@ 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
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public class ResourceNavigatorRenameAction extends RenameResourceAction {
- private TreeViewer viewer;
+ 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;
- }
+ /**
+ * 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
+ @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);
+ 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();
- }
- }
+ /**
+ * 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
index 02e84fd5890..49e8129b293 100644
--- 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
@@ -33,123 +33,121 @@ import org.eclipse.ui.internal.util.PrefUtil;
*/
@Deprecated
public class ResourcePatternFilter extends ViewerFilter {
- private String[] patterns;
+ private String[] patterns;
- private StringMatcher[] matchers;
+ private StringMatcher[] matchers;
- static final String COMMA_SEPARATOR = ",";//$NON-NLS-1$
+ static final String COMMA_SEPARATOR = ",";//$NON-NLS-1$
- static final String FILTERS_TAG = "resourceFilters";//$NON-NLS-1$
+ static final String FILTERS_TAG = "resourceFilters";//$NON-NLS-1$
- /**
- * Creates a new resource pattern filter.
- */
- public ResourcePatternFilter() {
- super();
- }
+ /**
+ * 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() {
+ /**
+ * Return the currently configured StringMatchers. If there aren't any look them
+ * up.
+ */
+ private StringMatcher[] getMatchers() {
- if (this.matchers == null) {
+ if (this.matchers == null) {
initializeFromPreferences();
}
- return this.matchers;
- }
+ 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() {
+ /**
+ * 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) {
+ 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.length() == 0) {
- // 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.length() == 0) {
- // revert to all filter extensions with selected == "true"
- // if there are no filters in the preference store
+ 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.length() == 0) {
+ // 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.length() == 0) {
+ // revert to all filter extensions with selected == "true"
+ // if there are no filters in the preference store
List<String> 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
+ 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<String> definedFilters = FiltersContentProvider.getDefinedFilters();
- StringTokenizer entries = new StringTokenizer(storedPatterns,
- COMMA_SEPARATOR);
+ StringTokenizer entries = new StringTokenizer(storedPatterns, COMMA_SEPARATOR);
List<String> patterns = new ArrayList<>();
- while (entries.hasMoreElements()) {
- String nextToken = entries.nextToken();
- if (definedFilters.indexOf(nextToken) > -1) {
+ 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);
+ // Convert to an array of Strings
+ String[] patternArray = new String[patterns.size()];
+ patterns.toArray(patternArray);
+ setPatterns(patternArray);
- }
+ }
- @Override
+ @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
IResource resource = Adapters.adapt(element, IResource.class);
- if (resource != null) {
- String name = resource.getName();
+ if (resource != null) {
+ String name = resource.getName();
for (StringMatcher testMatcher : getMatchers()) {
- if (testMatcher.match(name)) {
+ 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);
- }
- }
+ }
+ 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
index d741871d346..f4b6380fa46 100644
--- 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
@@ -25,62 +25,62 @@ import org.eclipse.jface.viewers.StructuredSelection;
/**
* Provides utilities for checking the validity of selections.
* <p>
- * This class provides static methods only; it is not intended to be instantiated
- * or subclassed.
+ * This class provides static methods only; it is not intended to be
+ * instantiated or subclassed.
+ *
* @since 2.0
- * </p>
+ * </p>
* @noinstantiate This class is not intended to be instantiated by clients.
* @noextend This class is not intended to be subclassed by clients.
- * @deprecated as of 3.5, use {@link org.eclipse.ui.ide.ResourceSelectionUtil} instead.
+ * @deprecated as of 3.5, use {@link org.eclipse.ui.ide.ResourceSelectionUtil}
+ * instead.
*/
@Deprecated
public class ResourceSelectionUtil {
- private 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 <code>IResource</code>)
- * @return <code>true</code> if all selected elements are resources of the right
- * type, and <code>false</code> 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) {
+ /**
+ * 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 <code>IResource</code>)
+ * @return <code>true</code> if all selected elements are resources of the right
+ * type, and <code>false</code> 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) {
Iterator<?> resources = selection.iterator();
- while (resources.hasNext()) {
- Object next = resources.next();
- if (!(next instanceof IResource)) {
+ while (resources.hasNext()) {
+ Object next = resources.next();
+ if (!(next instanceof IResource)) {
return false;
}
- if (!resourceIsType((IResource) next, resourceMask)) {
+ if (!resourceIsType((IResource) next, resourceMask)) {
return false;
}
- }
- return true;
- }
+ }
+ 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 <code>IResource</code>)
- * @return IStructuredSelection or null if any of the entries are not adaptable.
- * @see IResource#getType()
- */
- public static IStructuredSelection allResources(
- IStructuredSelection selection, int resourceMask) {
+ /**
+ * 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 <code>IResource</code>)
+ * @return IStructuredSelection or null if any of the entries are not adaptable.
+ * @see IResource#getType()
+ */
+ public static IStructuredSelection allResources(IStructuredSelection selection, int resourceMask) {
Iterator<?> adaptables = selection.iterator();
List<IResource> result = new ArrayList<>();
- while (adaptables.hasNext()) {
- Object next = adaptables.next();
+ while (adaptables.hasNext()) {
+ Object next = adaptables.next();
IResource resource = Adapters.adapt(next, IResource.class);
if (resource == null) {
@@ -89,24 +89,24 @@ public class ResourceSelectionUtil {
if (resourceIsType(resource, resourceMask)) {
result.add(resource);
}
- }
- return new StructuredSelection(result);
+ }
+ 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 <code>IResource</code>)
- * @return <code>true</code> if the resources has a matching type, and
- * <code>false</code> otherwise
- * @see IResource#getType()
- */
- public static boolean resourceIsType(IResource resource, int resourceMask) {
- return (resource.getType() & resourceMask) != 0;
- }
+ /**
+ * 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 <code>IResource</code>)
+ * @return <code>true</code> if the resources has a matching type, and
+ * <code>false</code> 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
index 73b1dafc3d6..edc7fe7d12d 100644
--- 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
@@ -19,16 +19,16 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
/**
- * Sorter for viewers that display items of type <code>IResource</code>.
- * The sorter supports two sort criteria:
+ * Sorter for viewers that display items of type <code>IResource</code>. The
+ * sorter supports two sort criteria:
* <p>
* <code>NAME</code>: Folders are given order precedence, followed by files.
- * Within these two groups resources are ordered by name. All name comparisons
+ * Within these two groups resources are ordered by name. All name comparisons
* are case-insensitive.
* </p>
* <p>
* <code>TYPE</code>: Folders are given order precedence, followed by files.
- * Within these two groups resources are ordered by extension. All extension
+ * Within these two groups resources are ordered by extension. All extension
* comparisons are case-insensitive.
* </p>
* <p>
@@ -41,60 +41,60 @@ import org.eclipse.jface.viewers.ViewerSorter;
@Deprecated
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 <code>NAME</code> or
- * <code>TYPE</code>
- */
- 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.
- * <ul>
- * <li>resources (<code>IResource</code>) - 2</li>
- * <li>project references (<code>ProjectReference</code>) - 1</li>
- * <li>everything else - 0</li>
- * </ul>
- *
- * @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
+ /**
+ * 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 <code>NAME</code> or
+ * <code>TYPE</code>
+ */
+ 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.
+ * <ul>
+ * <li>resources (<code>IResource</code>) - 2</li>
+ * <li>project references (<code>ProjectReference</code>) - 1</li>
+ * <li>everything else - 0</li>
+ * </ul>
+ *
+ * @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) {
+ // 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;
@@ -107,94 +107,93 @@ public class ResourceSorter extends ViewerSorter {
} 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 <code>0</code> 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 <code>0</code> 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 <code>0</code> 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) {
+ }
+
+ /**
+ * 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 <code>0</code> 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 <code>0</code> 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 <code>0</code> 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 <code>NAME</code> or <code>TYPE</code>
- */
- 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 <code>ResourceSorter.NAME</code> or
- * <code>ResourceSorter.TYPE</code>
- */
- public void setCriteria(int criteria) {
- this.criteria = criteria;
- }
+ return compareNames(resource1, resource2);
+ }
+
+ /**
+ * Returns the sort criteria of this sorter.
+ *
+ * @return the sort criterion: one of <code>NAME</code> or <code>TYPE</code>
+ */
+ 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 <code>ResourceSorter.NAME</code>
+ * or <code>ResourceSorter.TYPE</code>
+ */
+ 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
index c08388992d3..cebf65d864d 100644
--- 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
@@ -35,77 +35,78 @@ 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 <code>IResource</code>
- * it uses it directly, otherwise if it is an <code>IMarker</code> it uses the marker's resource,
- * otherwise if it is an <code>IAdaptable</code>, it tries to get the <code>IResource.class</code> adapter.
+ * An action which shows the current selection in the Navigator view. For each
+ * element in the selection, if it is an <code>IResource</code> it uses it
+ * directly, otherwise if it is an <code>IMarker</code> it uses the marker's
+ * resource, otherwise if it is an <code>IAdaptable</code>, it tries to get the
+ * <code>IResource.class</code> adapter.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public class ShowInNavigatorAction extends SelectionProviderAction {
- private IWorkbenchPage page;
+ 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,
+ /**
+ * 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 <code>IResource</code>
- */
+ /**
+ * Returns the resources in the given selection.
+ *
+ * @return a list of <code>IResource</code>
+ */
List<IResource> getResources(IStructuredSelection selection) {
List<IResource> v = new ArrayList<>();
for (Iterator<?> i = selection.iterator(); i.hasNext();) {
- Object o = i.next();
+ Object o = i.next();
IResource resource = Adapters.adapt(o, IResource.class);
if (resource != null) {
v.add(resource);
- } else if (o instanceof IMarker) {
+ } else if (o instanceof IMarker) {
resource = ((IMarker) o).getResource();
v.add(resource);
- }
- }
- return v;
- }
+ }
+ }
+ return v;
+ }
- /**
- * Shows the Navigator view and sets its selection to the resources
- * selected in this action's selection provider.
- */
- @Override
+ /**
+ * Shows the Navigator view and sets its selection to the resources selected in
+ * this action's selection provider.
+ */
+ @Override
public void run() {
List<IResource> v = getResources(getStructuredSelection());
- if (v.isEmpty()) {
+ 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());
- }
- }
+ 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
+ @Override
public void selectionChanged(IStructuredSelection selection) {
- setEnabled(!getResources(selection).isEmpty());
- }
+ 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
index 03961d9e578..136e896db30 100644
--- 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
@@ -22,53 +22,51 @@ import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
/**
* This is the action group for the sort and filter actions.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public class SortAndFilterActionGroup extends ResourceNavigatorActionGroup {
- private SortViewAction sortByTypeAction;
+ private SortViewAction sortByTypeAction;
- private SortViewAction sortByNameAction;
+ private SortViewAction sortByNameAction;
- private FilterSelectionAction filterAction;
+ private FilterSelectionAction filterAction;
- /**
- * Constructor.
- *
- * @param navigator
- */
- public SortAndFilterActionGroup(IResourceNavigator navigator) {
- super(navigator);
- }
+ /**
+ * Constructor.
+ *
+ * @param navigator
+ */
+ public SortAndFilterActionGroup(IResourceNavigator navigator) {
+ super(navigator);
+ }
- @Override
+ @Override
protected void makeActions() {
- sortByNameAction = new SortViewAction(navigator, false);
- sortByTypeAction = new SortViewAction(navigator, true);
+ 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$
- }
+ 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
+ @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);
- }
+ IMenuManager menu = actionBars.getMenuManager();
+ IMenuManager submenu = new MenuManager(ResourceNavigatorMessages.ResourceNavigator_sort);
+ menu.add(submenu);
+ submenu.add(sortByNameAction);
+ submenu.add(sortByTypeAction);
+ menu.add(filterAction);
+ }
- @Override
+ @Override
public void updateActionBars() {
- int criteria = navigator.getComparator().getCriteria();
- sortByNameAction.setChecked(criteria == ResourceComparator.NAME);
- sortByTypeAction.setChecked(criteria == ResourceComparator.TYPE);
- }
+ 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
index 41168cc4ec4..14e23159739 100644
--- 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
@@ -18,45 +18,45 @@ import org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages;
/**
* Implementation of the view sorting actions.
+ *
* @since 2.0
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public class SortViewAction extends ResourceNavigatorAction {
- private int sortCriteria;
+ private int sortCriteria;
- /**
- * Creates the action.
- *
- * @param navigator the resource navigator
- * @param sortByType <code>true</code> for sort by type, <code>false</code> 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);
- }
+ /**
+ * Creates the action.
+ *
+ * @param navigator the resource navigator
+ * @param sortByType <code>true</code> for sort by type, <code>false</code> 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
+ @Override
public void run() {
- IResourceNavigator navigator = getNavigator();
- ResourceComparator comparator = navigator.getComparator();
+ IResourceNavigator navigator = getNavigator();
+ ResourceComparator comparator = navigator.getComparator();
- if (comparator == null) {
+ if (comparator == null) {
navigator.setComparator(new ResourceComparator(sortCriteria));
} else {
comparator.setCriteria(sortCriteria);
- navigator.setComparator(comparator);
- }
+ navigator.setComparator(comparator);
+ }
- }
+ }
}
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/StringMatcher.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/StringMatcher.java
index 01c2c47f66d..5741fbae4dc 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/StringMatcher.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/StringMatcher.java
@@ -22,432 +22,446 @@ import java.util.ArrayList;
* @noinstantiate This class is not intended to be instantiated by clients.
*/
/* package */class StringMatcher {
- protected String fPattern;
-
- protected int fLength; // pattern length
-
- protected boolean fIgnoreWildCards;
-
- protected boolean fIgnoreCase;
-
- protected boolean fHasLeadingStar;
-
- protected boolean fHasTrailingStar;
-
- protected String fSegments[]; //the given pattern is split into * separated segments
-
- /* boundary value beyond which we don't need to search in the text */
- protected int fBound = 0;
-
- protected static final char fSingleWildCard = '\u0000';
-
- public static class Position {
- int start; //inclusive
-
- int end; //exclusive
-
- public Position(int start, int end) {
- this.start = start;
- this.end = end;
- }
-
- public int getStart() {
- return start;
- }
-
- public int getEnd() {
- return end;
- }
- }
-
- /**
- * StringMatcher constructor takes in a String object that is a simple
- * pattern which may contain '*' for 0 and many characters and
- * '?' for exactly one character.
- *
- * Literal '*' and '?' characters must be escaped in the pattern
- * e.g., "\*" means literal "*", etc.
- *
- * Escaping any other character (including the escape character itself),
- * just results in that character in the pattern.
- * e.g., "\a" means "a" and "\\" means "\"
- *
- * If invoking the StringMatcher with string literals in Java, don't forget
- * escape characters are represented by "\\".
- *
- * @param pattern the pattern to match text against
- * @param ignoreCase if true, case is ignored
- * @param ignoreWildCards if true, wild cards and their escape sequences are ignored
- * (everything is taken literally).
- */
- public StringMatcher(String pattern, boolean ignoreCase,
- boolean ignoreWildCards) {
- if (pattern == null) {
+ protected String fPattern;
+
+ protected int fLength; // pattern length
+
+ protected boolean fIgnoreWildCards;
+
+ protected boolean fIgnoreCase;
+
+ protected boolean fHasLeadingStar;
+
+ protected boolean fHasTrailingStar;
+
+ protected String fSegments[]; // the given pattern is split into * separated segments
+
+ /* boundary value beyond which we don't need to search in the text */
+ protected int fBound = 0;
+
+ protected static final char fSingleWildCard = '\u0000';
+
+ public static class Position {
+ int start; // inclusive
+
+ int end; // exclusive
+
+ public Position(int start, int end) {
+ this.start = start;
+ this.end = end;
+ }
+
+ public int getStart() {
+ return start;
+ }
+
+ public int getEnd() {
+ return end;
+ }
+ }
+
+ /**
+ * StringMatcher constructor takes in a String object that is a simple pattern
+ * which may contain '*' for 0 and many characters and '?' for exactly one
+ * character.
+ *
+ * Literal '*' and '?' characters must be escaped in the pattern e.g., "\*"
+ * means literal "*", etc.
+ *
+ * Escaping any other character (including the escape character itself), just
+ * results in that character in the pattern. e.g., "\a" means "a" and "\\" means
+ * "\"
+ *
+ * If invoking the StringMatcher with string literals in Java, don't forget
+ * escape characters are represented by "\\".
+ *
+ * @param pattern the pattern to match text against
+ * @param ignoreCase if true, case is ignored
+ * @param ignoreWildCards if true, wild cards and their escape sequences are
+ * ignored (everything is taken literally).
+ */
+ public StringMatcher(String pattern, boolean ignoreCase, boolean ignoreWildCards) {
+ if (pattern == null) {
throw new IllegalArgumentException();
}
- fIgnoreCase = ignoreCase;
- fIgnoreWildCards = ignoreWildCards;
- fPattern = pattern;
- fLength = pattern.length();
-
- if (fIgnoreWildCards) {
- parseNoWildCards();
- } else {
- parseWildCards();
- }
- }
-
- /**
- * Find the first occurrence of the pattern between <code>start</code)(inclusive)
- * and <code>end</code>(exclusive).
- * @param <code>text</code>, the String object to search in
- * @param <code>start</code>, the starting index of the search range, inclusive
- * @param <code>end</code>, the ending index of the search range, exclusive
- * @return an <code>StringMatcher.Position</code> object that keeps the starting
- * (inclusive) and ending positions (exclusive) of the first occurrence of the
- * pattern in the specified range of the text; return null if not found or subtext
- * is empty (start==end). A pair of zeros is returned if pattern is empty string
- * Note that for pattern like "*abc*" with leading and trailing stars, position of "abc"
- * is returned. For a pattern like"*??*" in text "abcdf", (1,3) is returned
- */
- public StringMatcher.Position find(String text, int start, int end) {
- if (text == null) {
+ fIgnoreCase = ignoreCase;
+ fIgnoreWildCards = ignoreWildCards;
+ fPattern = pattern;
+ fLength = pattern.length();
+
+ if (fIgnoreWildCards) {
+ parseNoWildCards();
+ } else {
+ parseWildCards();
+ }
+ }
+
+ /**
+ * Find the first occurrence of the pattern between
+ * <code>start</code)(inclusive)
+ * and <code>end</code>(exclusive).
+ *
+ * @param <code>text</code>, the String object to search in
+ * @param <code>start</code>, the starting index of the search range, inclusive
+ * @param <code>end</code>, the ending index of the search range, exclusive
+ * @return an <code>StringMatcher.Position</code> object that keeps the starting
+ * (inclusive) and ending positions (exclusive) of the first occurrence
+ * of the pattern in the specified range of the text; return null if not
+ * found or subtext is empty (start==end). A pair of zeros is returned
+ * if pattern is empty string Note that for pattern like "*abc*" with
+ * leading and trailing stars, position of "abc" is returned. For a
+ * pattern like"*??*" in text "abcdf", (1,3) is returned
+ */
+ public StringMatcher.Position find(String text, int start, int end) {
+ if (text == null) {
throw new IllegalArgumentException();
}
- int tlen = text.length();
- if (start < 0) {
+ int tlen = text.length();
+ if (start < 0) {
start = 0;
}
- if (end > tlen) {
+ if (end > tlen) {
end = tlen;
}
- if (end < 0 || start >= end) {
+ if (end < 0 || start >= end) {
return null;
}
- if (fLength == 0) {
+ if (fLength == 0) {
return new Position(start, start);
}
- if (fIgnoreWildCards) {
- int x = posIn(text, start, end);
- if (x < 0) {
+ if (fIgnoreWildCards) {
+ int x = posIn(text, start, end);
+ if (x < 0) {
return null;
}
- return new Position(x, x + fLength);
- }
+ return new Position(x, x + fLength);
+ }
- int segCount = fSegments.length;
- if (segCount == 0) {
+ int segCount = fSegments.length;
+ if (segCount == 0) {
return new Position(start, end);
}
- int curPos = start;
- int matchStart = -1;
- int i;
- for (i = 0; i < segCount && curPos < end; ++i) {
- String current = fSegments[i];
- int nextMatch = regExpPosIn(text, curPos, end, current);
- if (nextMatch < 0) {
+ int curPos = start;
+ int matchStart = -1;
+ int i;
+ for (i = 0; i < segCount && curPos < end; ++i) {
+ String current = fSegments[i];
+ int nextMatch = regExpPosIn(text, curPos, end, current);
+ if (nextMatch < 0) {
return null;
}
- if (i == 0) {
+ if (i == 0) {
matchStart = nextMatch;
}
- curPos = nextMatch + current.length();
- }
- if (i < segCount) {
+ curPos = nextMatch + current.length();
+ }
+ if (i < segCount) {
return null;
}
- return new Position(matchStart, curPos);
- }
-
- /**
- * match the given <code>text</code> with the pattern
- * @return true if matched eitherwise false
- * @param <code>text</code>, a String object
- */
- public boolean match(String text) {
- return match(text, 0, text.length());
- }
-
- /**
- * Given the starting (inclusive) and the ending (exclusive) poisitions in the
- * <code>text</code>, determine if the given substring matches with aPattern
- * @return true if the specified portion of the text matches the pattern
- * @param String <code>text</code>, a String object that contains the substring to match
- * @param int <code>start<code> marks the starting position (inclusive) of the substring
- * @param int <code>end<code> marks the ending index (exclusive) of the substring
- */
- public boolean match(String text, int start, int end) {
- if (null == text) {
+ return new Position(matchStart, curPos);
+ }
+
+ /**
+ * match the given <code>text</code> with the pattern
+ *
+ * @return true if matched eitherwise false
+ * @param <code>text</code>, a String object
+ */
+ public boolean match(String text) {
+ return match(text, 0, text.length());
+ }
+
+ /**
+ * Given the starting (inclusive) and the ending (exclusive) poisitions in the
+ * <code>text</code>, determine if the given substring matches with aPattern
+ *
+ * @return true if the specified portion of the text matches the pattern
+ * @param String <code>text</code>, a String object that contains the substring
+ * to match
+ * @param int <code>start<code> marks the starting position (inclusive) of
+ * the substring
+ * @param int <code>end<code> marks the ending index (exclusive) of the
+ * substring
+ */
+ public boolean match(String text, int start, int end) {
+ if (null == text) {
throw new IllegalArgumentException();
}
- if (start > end) {
+ if (start > end) {
return false;
}
- if (fIgnoreWildCards) {
- return (end - start == fLength)
- && fPattern.regionMatches(fIgnoreCase, 0, text, start,
- fLength);
+ if (fIgnoreWildCards) {
+ return (end - start == fLength) && fPattern.regionMatches(fIgnoreCase, 0, text, start, fLength);
}
- int segCount = fSegments.length;
- if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) {
+ int segCount = fSegments.length;
+ if (segCount == 0 && (fHasLeadingStar || fHasTrailingStar)) {
return true;
}
- if (start == end) {
+ if (start == end) {
return fLength == 0;
}
- if (fLength == 0) {
+ if (fLength == 0) {
return start == end;
}
- int tlen = text.length();
- if (start < 0) {
+ int tlen = text.length();
+ if (start < 0) {
start = 0;
}
- if (end > tlen) {
+ if (end > tlen) {
end = tlen;
}
- int tCurPos = start;
- int bound = end - fBound;
- if (bound < 0) {
+ int tCurPos = start;
+ int bound = end - fBound;
+ if (bound < 0) {
return false;
}
- int i = 0;
- String current = fSegments[i];
- int segLength = current.length();
-
- /* process first segment */
- if (!fHasLeadingStar) {
- if (!regExpRegionMatches(text, start, current, 0, segLength)) {
- return false;
- }
+ int i = 0;
+ String current = fSegments[i];
+ int segLength = current.length();
+
+ /* process first segment */
+ if (!fHasLeadingStar) {
+ if (!regExpRegionMatches(text, start, current, 0, segLength)) {
+ return false;
+ }
++i;
tCurPos = tCurPos + segLength;
- }
- if ((fSegments.length == 1) && (!fHasLeadingStar)
- && (!fHasTrailingStar)) {
- // only one segment to match, no wildcards specified
- return tCurPos == end;
- }
- /* process middle segments */
- for (; i < segCount && tCurPos <= bound; ++i) {
- current = fSegments[i];
- int currentMatch;
- int k = current.indexOf(fSingleWildCard);
- if (k < 0) {
- currentMatch = textPosIn(text, tCurPos, end, current);
- if (currentMatch < 0) {
+ }
+ if ((fSegments.length == 1) && (!fHasLeadingStar) && (!fHasTrailingStar)) {
+ // only one segment to match, no wildcards specified
+ return tCurPos == end;
+ }
+ /* process middle segments */
+ for (; i < segCount && tCurPos <= bound; ++i) {
+ current = fSegments[i];
+ int currentMatch;
+ int k = current.indexOf(fSingleWildCard);
+ if (k < 0) {
+ currentMatch = textPosIn(text, tCurPos, end, current);
+ if (currentMatch < 0) {
return false;
}
- } else {
- currentMatch = regExpPosIn(text, tCurPos, end, current);
- if (currentMatch < 0) {
+ } else {
+ currentMatch = regExpPosIn(text, tCurPos, end, current);
+ if (currentMatch < 0) {
return false;
}
- }
- tCurPos = currentMatch + current.length();
- }
-
- /* process final segment */
- if (!fHasTrailingStar && tCurPos != end) {
- int clen = current.length();
- return regExpRegionMatches(text, end - clen, current, 0, clen);
- }
- return i == segCount;
- }
-
- /**
- * This method parses the given pattern into segments seperated by wildcard '*' characters.
- * Since wildcards are not being used in this case, the pattern consists of a single segment.
- */
- private void parseNoWildCards() {
- fSegments = new String[1];
- fSegments[0] = fPattern;
- fBound = fLength;
- }
-
- /**
- * Parses the given pattern into segments seperated by wildcard '*' characters.
- * @param p, a String object that is a simple regular expression with '*' and/or '?'
- */
- private void parseWildCards() {
- if (fPattern.startsWith("*")) { //$NON-NLS-1$
+ }
+ tCurPos = currentMatch + current.length();
+ }
+
+ /* process final segment */
+ if (!fHasTrailingStar && tCurPos != end) {
+ int clen = current.length();
+ return regExpRegionMatches(text, end - clen, current, 0, clen);
+ }
+ return i == segCount;
+ }
+
+ /**
+ * This method parses the given pattern into segments seperated by wildcard '*'
+ * characters. Since wildcards are not being used in this case, the pattern
+ * consists of a single segment.
+ */
+ private void parseNoWildCards() {
+ fSegments = new String[1];
+ fSegments[0] = fPattern;
+ fBound = fLength;
+ }
+
+ /**
+ * Parses the given pattern into segments seperated by wildcard '*' characters.
+ *
+ * @param p, a String object that is a simple regular expression with '*' and/or
+ * '?'
+ */
+ private void parseWildCards() {
+ if (fPattern.startsWith("*")) { //$NON-NLS-1$
fHasLeadingStar = true;
}
- if (fPattern.endsWith("*")) {//$NON-NLS-1$
- /* make sure it's not an escaped wildcard */
- if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
- fHasTrailingStar = true;
- }
- }
+ if (fPattern.endsWith("*")) {//$NON-NLS-1$
+ /* make sure it's not an escaped wildcard */
+ if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
+ fHasTrailingStar = true;
+ }
+ }
ArrayList<String> temp = new ArrayList<>();
- int pos = 0;
- StringBuilder buf = new StringBuilder();
- while (pos < fLength) {
- char c = fPattern.charAt(pos++);
- switch (c) {
- case '\\':
- if (pos >= fLength) {
- buf.append(c);
- } else {
- char next = fPattern.charAt(pos++);
- /* if it's an escape sequence */
- if (next == '*' || next == '?' || next == '\\') {
- buf.append(next);
- } else {
- /* not an escape sequence, just insert literally */
- buf.append(c);
- buf.append(next);
- }
- }
- break;
- case '*':
- if (buf.length() > 0) {
- /* new segment */
+ int pos = 0;
+ StringBuilder buf = new StringBuilder();
+ while (pos < fLength) {
+ char c = fPattern.charAt(pos++);
+ switch (c) {
+ case '\\':
+ if (pos >= fLength) {
+ buf.append(c);
+ } else {
+ char next = fPattern.charAt(pos++);
+ /* if it's an escape sequence */
+ if (next == '*' || next == '?' || next == '\\') {
+ buf.append(next);
+ } else {
+ /* not an escape sequence, just insert literally */
+ buf.append(c);
+ buf.append(next);
+ }
+ }
+ break;
+ case '*':
+ if (buf.length() > 0) {
+ /* new segment */
temp.add(buf.toString());
- fBound += buf.length();
- buf.setLength(0);
- }
- break;
- case '?':
- /* append special character representing single match wildcard */
- buf.append(fSingleWildCard);
- break;
- default:
- buf.append(c);
- }
- }
-
- /* add last buffer to segment list */
- if (buf.length() > 0) {
+ fBound += buf.length();
+ buf.setLength(0);
+ }
+ break;
+ case '?':
+ /* append special character representing single match wildcard */
+ buf.append(fSingleWildCard);
+ break;
+ default:
+ buf.append(c);
+ }
+ }
+
+ /* add last buffer to segment list */
+ if (buf.length() > 0) {
temp.add(buf.toString());
- fBound += buf.length();
- }
+ fBound += buf.length();
+ }
fSegments = temp.toArray(new String[temp.size()]);
- }
-
- /**
- * @param <code>text</code>, a string which contains no wildcard
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int posIn(String text, int start, int end) {//no wild card in pattern
- int max = end - fLength;
-
- if (!fIgnoreCase) {
- int i = text.indexOf(fPattern, start);
- if (i == -1 || i > max) {
+ }
+
+ /**
+ * @param <code>text</code>, a string which contains no wildcard
+ * @param <code>start</code>, the starting index in the text for search,
+ * inclusive
+ * @param <code>end</code>, the stopping point of search, exclusive
+ * @return the starting index in the text of the pattern , or -1 if not found
+ */
+ protected int posIn(String text, int start, int end) {// no wild card in pattern
+ int max = end - fLength;
+
+ if (!fIgnoreCase) {
+ int i = text.indexOf(fPattern, start);
+ if (i == -1 || i > max) {
return -1;
}
- return i;
- }
+ return i;
+ }
- for (int i = start; i <= max; ++i) {
- if (text.regionMatches(true, i, fPattern, 0, fLength)) {
+ for (int i = start; i <= max; ++i) {
+ if (text.regionMatches(true, i, fPattern, 0, fLength)) {
return i;
}
- }
-
- return -1;
- }
-
- /**
- * @param <code>text</code>, a simple regular expression that may only contain '?'(s)
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @param <code>p</code>, a simple regular expression that may contains '?'
- * @param <code>caseIgnored</code>, wether the pattern is not casesensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int regExpPosIn(String text, int start, int end, String p) {
- int plen = p.length();
-
- int max = end - plen;
- for (int i = start; i <= max; ++i) {
- if (regExpRegionMatches(text, i, p, 0, plen)) {
+ }
+
+ return -1;
+ }
+
+ /**
+ * @param <code>text</code>, a simple regular expression that may only
+ * contain '?'(s)
+ * @param <code>start</code>, the starting index in the text for search,
+ * inclusive
+ * @param <code>end</code>, the stopping point of search, exclusive
+ * @param <code>p</code>, a simple regular expression that may
+ * contains '?'
+ * @param <code>caseIgnored</code>, wether the pattern is not casesensitive
+ * @return the starting index in the text of the pattern , or -1 if not found
+ */
+ protected int regExpPosIn(String text, int start, int end, String p) {
+ int plen = p.length();
+
+ int max = end - plen;
+ for (int i = start; i <= max; ++i) {
+ if (regExpRegionMatches(text, i, p, 0, plen)) {
return i;
}
- }
- return -1;
- }
-
- /**
- *
- * @return boolean
- * @param <code>text</code>, a String to match
- * @param <code>start</code>, int that indicates the starting index of match, inclusive
- * @param <code>end</code> int that indicates the ending index of match, exclusive
- * @param <code>p</code>, String, String, a simple regular expression that may contain '?'
- * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
- */
- protected boolean regExpRegionMatches(String text, int tStart, String p,
- int pStart, int plen) {
- while (plen-- > 0) {
- char tchar = text.charAt(tStart++);
- char pchar = p.charAt(pStart++);
-
- /* process wild cards */
- if (!fIgnoreWildCards) {
- /* skip single wild cards */
- if (pchar == fSingleWildCard) {
- continue;
- }
- }
- if (pchar == tchar) {
+ }
+ return -1;
+ }
+
+ /**
+ *
+ * @return boolean
+ * @param <code>text</code>, a String to match
+ * @param <code>start</code>, int that indicates the starting index of
+ * match, inclusive
+ * @param <code>end</code> int that indicates the ending index of match,
+ * exclusive
+ * @param <code>p</code>, String, String, a simple regular expression
+ * that may contain '?'
+ * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is
+ * case sensitive
+ */
+ protected boolean regExpRegionMatches(String text, int tStart, String p, int pStart, int plen) {
+ while (plen-- > 0) {
+ char tchar = text.charAt(tStart++);
+ char pchar = p.charAt(pStart++);
+
+ /* process wild cards */
+ if (!fIgnoreWildCards) {
+ /* skip single wild cards */
+ if (pchar == fSingleWildCard) {
+ continue;
+ }
+ }
+ if (pchar == tchar) {
continue;
}
- if (fIgnoreCase) {
- if (Character.toUpperCase(tchar) == Character
- .toUpperCase(pchar)) {
+ if (fIgnoreCase) {
+ if (Character.toUpperCase(tchar) == Character.toUpperCase(pchar)) {
continue;
}
- // comparing after converting to upper case doesn't handle all cases;
- // also compare after converting to lower case
- if (Character.toLowerCase(tchar) == Character
- .toLowerCase(pchar)) {
+ // comparing after converting to upper case doesn't handle all cases;
+ // also compare after converting to lower case
+ if (Character.toLowerCase(tchar) == Character.toLowerCase(pchar)) {
continue;
}
- }
- return false;
- }
- return true;
- }
-
- /**
- * @param <code>text</code>, the string to match
- * @param <code>start</code>, the starting index in the text for search, inclusive
- * @param <code>end</code>, the stopping point of search, exclusive
- * @param code>p</code>, a string that has no wildcard
- * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is case sensitive
- * @return the starting index in the text of the pattern , or -1 if not found
- */
- protected int textPosIn(String text, int start, int end, String p) {
-
- int plen = p.length();
- int max = end - plen;
-
- if (!fIgnoreCase) {
- int i = text.indexOf(p, start);
- if (i == -1 || i > max) {
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @param <code>text</code>, the string to match
+ * @param <code>start</code>, the starting index in the text for search,
+ * inclusive
+ * @param <code>end</code>, the stopping point of search, exclusive
+ * @param code>p</code>, a string that has no wildcard
+ * @param <code>ignoreCase</code>, boolean indicating wether code>p</code> is
+ * case sensitive
+ * @return the starting index in the text of the pattern , or -1 if not found
+ */
+ protected int textPosIn(String text, int start, int end, String p) {
+
+ int plen = p.length();
+ int max = end - plen;
+
+ if (!fIgnoreCase) {
+ int i = text.indexOf(p, start);
+ if (i == -1 || i > max) {
return -1;
}
- return i;
- }
+ return i;
+ }
- for (int i = 0; i <= max; ++i) {
- if (text.regionMatches(true, i, p, 0, plen)) {
+ for (int i = 0; i <= max; ++i) {
+ if (text.regionMatches(true, i, p, 0, plen)) {
return i;
}
- }
+ }
- return -1;
- }
+ return -1;
+ }
}
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
index 350d3c08b00..9036e231122 100644
--- 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
@@ -26,25 +26,24 @@ import org.eclipse.ui.IWorkbenchCommandConstants;
@Deprecated
public class ToggleLinkingAction extends ResourceNavigatorAction {
-
/**
* Constructs a new action.
*
* @param navigator the resource navigator
- * @param label the label
+ * @param label the label
*/
- public ToggleLinkingAction(IResourceNavigator navigator, String label) {
- super(navigator, label);
+ public ToggleLinkingAction(IResourceNavigator navigator, String label) {
+ super(navigator, label);
setActionDefinitionId(IWorkbenchCommandConstants.NAVIGATE_TOGGLE_LINK_WITH_EDITOR);
- setChecked(navigator.isLinkingEnabled());
- }
+ setChecked(navigator.isLinkingEnabled());
+ }
- /**
- * Runs the action.
- */
- @Override
+ /**
+ * Runs the action.
+ */
+ @Override
public void run() {
- getNavigator().setLinkingEnabled(isChecked());
- }
+ 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
index 0bee7afccf1..a08c17e9289 100644
--- 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
@@ -52,217 +52,199 @@ import org.eclipse.ui.internal.ide.StatusUtil;
/**
* This is the action group for workspace actions such as Build, Refresh Local,
* and Open/Close Project.
+ *
* @deprecated as of 3.5, use the Common Navigator Framework classes instead
*/
@Deprecated
public class WorkspaceActionGroup extends ResourceNavigatorActionGroup {
- private BuildAction buildAction;
+ private BuildAction buildAction;
- private OpenResourceAction openProjectAction;
+ private OpenResourceAction openProjectAction;
- private CloseResourceAction closeProjectAction;
+ private CloseResourceAction closeProjectAction;
- private CloseUnrelatedProjectsAction closeUnrelatedProjectsAction;
+ private CloseUnrelatedProjectsAction closeUnrelatedProjectsAction;
- private RefreshAction refreshAction;
+ private RefreshAction refreshAction;
- public WorkspaceActionGroup(IResourceNavigator navigator) {
- super(navigator);
- }
+ public WorkspaceActionGroup(IResourceNavigator navigator) {
+ super(navigator);
+ }
- @Override
+ @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.
- * <p>
- * 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
- * </p>
- * <p>
- * Both the open project and close project action may be on the menu
- * at the same time.
- * </p>
- * <p>
- * No disabled action should be on the context menu.
- * </p>
- *
- * @param menu context menu to add actions to
- */
- @Override
+ 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.
+ * <p>
+ * 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
+ * </p>
+ * <p>
+ * Both the open project and close project action may be on the menu at the same
+ * time.
+ * </p>
+ * <p>
+ * No disabled action should be on the context menu.
+ * </p>
+ *
+ * @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
+ 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();
+ 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)) {
+ 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);
- }
- }
- }
+ } 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
+ /**
+ * 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;
- }
- }
+ if (event.keyCode == SWT.F5 && event.stateMask == 0) {
+ if (refreshAction.isEnabled()) {
+ refreshAction.refreshAll();
+ }
- /**
- * Returns whether there are builders configured on the given project.
- *
- * @return <code>true</code> if it has builders,
- * <code>false</code> if not, or if this could not be determined
- */
- boolean hasBuilder(IProject project) {
- try {
- ICommand[] commands = project.getDescription().getBuildSpec();
- if (commands.length > 0) {
+ // Swallow the event
+ event.doit = false;
+ }
+ }
+
+ /**
+ * Returns whether there are builders configured on the given project.
+ *
+ * @return <code>true</code> if it has builders, <code>false</code> if not, or
+ * if this could not be determined
+ */
+ boolean hasBuilder(IProject project) {
+ try {
+ ICommand[] commands = project.getDescription().getBuildSpec();
+ if (commands.length > 0) {
return true;
}
- } catch (CoreException e) {
- // Cannot determine if project has builders. Project is closed
- // or does not exist. Fall through to return false.
- }
- return false;
- }
-
- @Override
+ } 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
+ 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();
+ 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()) {
+ 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);
- }
+ } 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
+ @Override
public void updateActionBars() {
- IStructuredSelection selection = (IStructuredSelection) getContext()
- .getSelection();
- refreshAction.selectionChanged(selection);
- buildAction.selectionChanged(selection);
- openProjectAction.selectionChanged(selection);
- closeUnrelatedProjectsAction.selectionChanged(selection);
- closeProjectAction.selectionChanged(selection);
- }
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+ refreshAction.selectionChanged(selection);
+ buildAction.selectionChanged(selection);
+ openProjectAction.selectionChanged(selection);
+ closeUnrelatedProjectsAction.selectionChanged(selection);
+ closeProjectAction.selectionChanged(selection);
+ }
}

Back to the top