Remove internal and deprecated classes/methods in dltk.ui.
No need to keep them around to pollute the workspaces.
Non-javadoc see comment removed wherever seen too.
Change-Id: Ib27a1630c0fd02fa8dad9a1a94f5d4be2758d574
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java
index 96f3009..7bd489a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/StandardModelElementContentProvider.java
@@ -88,8 +88,8 @@
* </p>
*
*/
-public class StandardModelElementContentProvider implements
- ITreeContentProvider, IWorkingCopyProvider {
+public class StandardModelElementContentProvider
+ implements ITreeContentProvider, IWorkingCopyProvider {
protected static final Object[] NO_CHILDREN = new Object[0];
protected boolean fProvideMembers;
@@ -139,34 +139,9 @@
fProvideMembers = b;
}
- /**
- * @deprecated Since 3.0 compilation unit children are always provided as
- * working copies. The Java model does not support the
- * 'original' mode anymore.
- */
- @Deprecated
- public boolean getProvideWorkingCopy() {
- return fProvideWorkingCopy;
- }
-
- /**
- * @deprecated Since 3.0 compilation unit children are always provided from
- * the working copy. The Java model offers a unified world and
- * does not support the 'original' mode anymore.
- */
- @Deprecated
- public void setProvideWorkingCopy(boolean b) {
- fProvideWorkingCopy = b;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see IWorkingCopyProvider#providesWorkingCopies()
- */
@Override
public boolean providesWorkingCopies() {
- return getProvideWorkingCopy();
+ return fProvideWorkingCopy;
}
@Override
@@ -409,7 +384,8 @@
* Note: This method is for internal use only. Clients should not call this
* method.
*/
- protected Object[] getScriptProjects(IScriptModel jm) throws ModelException {
+ protected Object[] getScriptProjects(IScriptModel jm)
+ throws ModelException {
return jm.getScriptProjects();
}
@@ -462,7 +438,8 @@
// We therefore exclude Java elements from the list
// of non-Java resources.
if (isFolderOnClasspath) {
- if (javaProject.findProjectFragment(member.getFullPath()) == null) {
+ if (javaProject
+ .findProjectFragment(member.getFullPath()) == null) {
nonJavaResources.add(member);
}
} else if (!javaProject.isOnBuildpath(member)) {
@@ -479,13 +456,15 @@
protected boolean isBuildPathChange(IModelElementDelta delta) {
// need to test the flags only for package fragment roots
- if (delta.getElement().getElementType() != IModelElement.PROJECT_FRAGMENT)
+ if (delta.getElement()
+ .getElementType() != IModelElement.PROJECT_FRAGMENT)
return false;
int flags = delta.getFlags();
return (delta.getKind() == IModelElementDelta.CHANGED
&& ((flags & IModelElementDelta.F_ADDED_TO_BUILDPATH) != 0)
- || ((flags & IModelElementDelta.F_REMOVED_FROM_BUILDPATH) != 0) || ((flags & IModelElementDelta.F_REORDER) != 0));
+ || ((flags & IModelElementDelta.F_REMOVED_FROM_BUILDPATH) != 0)
+ || ((flags & IModelElementDelta.F_REORDER) != 0));
}
/**
@@ -507,8 +486,8 @@
if (element instanceof IScriptFolder) {
IScriptFolder fragment = (IScriptFolder) element;
if (fragment.exists()
- && !(fragment.hasChildren() || fragment
- .getForeignResources().length > 0)
+ && !(fragment.hasChildren()
+ || fragment.getForeignResources().length > 0)
&& fragment.hasSubfolders())
return true;
}
@@ -569,15 +548,15 @@
if (parent instanceof IScriptFolder
&& parent.getPath().equals(parent.getParent().getPath())
// unless source path is root of project path
- && !parent.getPath().equals(
- parent.getScriptProject().getPath())) {
+ && !parent.getPath()
+ .equals(parent.getScriptProject().getPath())) {
return parent.getParent();
}
return parent;
} /*
- * else if (element instanceof IJarEntryResource) { return
- * ((IJarEntryResource) element).getParent(); }
- */
+ * else if (element instanceof IJarEntryResource) { return
+ * ((IJarEntryResource) element).getParent(); }
+ */
return null;
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RefactorActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RefactorActionGroup.java
index 1627398..4c2ec4c 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RefactorActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/actions/refactoring/RefactorActionGroup.java
@@ -198,11 +198,6 @@
installQuickAccessAction();
}
- @Deprecated
- public RefactorActionGroup(IViewPart part) {
- this(part, null);
- }
-
/**
* Creates a new <code>RefactorActionGroup</code>. The action requires that
* the selection provided by the page's selection provider is of type <code>
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
index c42e5be..875c12a 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/CallHierarchyViewPart.java
@@ -958,7 +958,7 @@
new ActionGroup[] { new OpenEditorActionGroup(this),
new OpenViewActionGroup(this), new CCPActionGroup(this),
// new GenerateActionGroup(this),
- new RefactorActionGroup(this),
+ new RefactorActionGroup(this, null),
// new DLTKSearchActionGroup(this),
fSearchScopeActions, fFiltersActionGroup });
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/OpenCallHierarchyAction.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/OpenCallHierarchyAction.java
index 763afdf..f67bd3e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/OpenCallHierarchyAction.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/callhierarchy/OpenCallHierarchyAction.java
@@ -30,11 +30,9 @@
import org.eclipse.dltk.ui.util.ExceptionHandler;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchSite;
-
/**
* This action opens a call hierarchy on the selected method.
* <p>
@@ -43,81 +41,66 @@
*/
public class OpenCallHierarchyAction extends SelectionDispatchAction {
- private ScriptEditor fEditor;
+ private ScriptEditor fEditor;
- /**
- * Creates a new <code>OpenCallHierarchyAction</code>. The action requires
- * that the selection provided by the site's selection provider is of type <code>
- * org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param site the site providing context information for this action
- */
- public OpenCallHierarchyAction(IWorkbenchSite site) {
- super(site);
- setText(CallHierarchyMessages.OpenCallHierarchyAction_label);
- setToolTipText(CallHierarchyMessages.OpenCallHierarchyAction_tooltip);
- setDescription(CallHierarchyMessages.OpenCallHierarchyAction_description);
-// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_OPEN_ACTION);
- if (DLTKCore.DEBUG) {
+ /**
+ * Creates a new <code>OpenCallHierarchyAction</code>. The action requires
+ * that the selection provided by the site's selection provider is of type
+ * <code>
+ * org.eclipse.jface.viewers.IStructuredSelection</code>.
+ *
+ * @param site
+ * the site providing context information for this action
+ */
+ public OpenCallHierarchyAction(IWorkbenchSite site) {
+ super(site);
+ setText(CallHierarchyMessages.OpenCallHierarchyAction_label);
+ setToolTipText(CallHierarchyMessages.OpenCallHierarchyAction_tooltip);
+ setDescription(
+ CallHierarchyMessages.OpenCallHierarchyAction_description);
+ // PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+ // IJavaHelpContextIds.CALL_HIERARCHY_OPEN_ACTION);
+ if (DLTKCore.DEBUG) {
System.err.println("Add help support here..."); //$NON-NLS-1$
}
- }
+ }
- /**
- * Creates a new <code>OpenCallHierarchyAction</code>. The action requires
- * that the selection provided by the given selection provider is of type <code>
- * org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param site the site providing context information for this action
- * @param provider a special selection provider which is used instead
- * of the site's selection provider or <code>null</code> to use the site's
- * selection provider
- *
- *
- * @deprecated Use {@link #setSpecialSelectionProvider(ISelectionProvider)} instead. This API will be
- * removed after 3.2 M5.
- */
- @Deprecated
- public OpenCallHierarchyAction(IWorkbenchSite site, ISelectionProvider provider) {
- this(site);
- setSpecialSelectionProvider(provider);
- }
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- */
- public OpenCallHierarchyAction(ScriptEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
+ /**
+ * Note: This constructor is for internal use only. Clients should not call
+ * this constructor.
+ */
+ public OpenCallHierarchyAction(ScriptEditor editor) {
+ this(editor.getEditorSite());
+ fEditor = editor;
+ setEnabled(SelectionConverter.canOperateOn(fEditor));
+ }
@Override
public void selectionChanged(ITextSelection selection) {
- // Do nothing
- }
+ // Do nothing
+ }
@Override
public void selectionChanged(IStructuredSelection selection) {
- setEnabled(isEnabled(selection));
- }
+ setEnabled(isEnabled(selection));
+ }
- private boolean isEnabled(IStructuredSelection selection) {
- if (selection.size() != 1)
- return false;
- Object input= selection.getFirstElement();
- if (!(input instanceof IModelElement) && (input instanceof IAdaptable))
- input = ((IAdaptable)input).getAdapter(IModelElement.class);
- if (!(input instanceof IModelElement))
- return false;
- switch (((IModelElement)input).getElementType()) {
- case IModelElement.METHOD:
- return true;
- default:
- return false;
- }
- }
+ private boolean isEnabled(IStructuredSelection selection) {
+ if (selection.size() != 1)
+ return false;
+ Object input = selection.getFirstElement();
+ if (!(input instanceof IModelElement) && (input instanceof IAdaptable))
+ input = ((IAdaptable) input).getAdapter(IModelElement.class);
+ if (!(input instanceof IModelElement))
+ return false;
+ switch (((IModelElement) input).getElementType()) {
+ case IModelElement.METHOD:
+ return true;
+ default:
+ return false;
+ }
+ }
/**
* This allows alternative editor implementations to override resolution
@@ -133,119 +116,132 @@
@Override
public void run(ITextSelection selection) {
- IModelElement input= SelectionConverter.getInput(fEditor);
- if (!ActionUtil.isProcessable(getShell(), input))
- return;
+ IModelElement input = SelectionConverter.getInput(fEditor);
+ if (!ActionUtil.isProcessable(getShell(), input))
+ return;
- try {
+ try {
IModelElement[] elements = resolveModelElements();
if (elements == null)
- return;
+ return;
List<IModelElement> candidates = new ArrayList<IModelElement>(
elements.length);
- for (int i= 0; i < elements.length; i++) {
- IModelElement[] resolvedElements= CallHierarchyUI.getCandidates(elements[i]);
- if (resolvedElements != null)
- candidates.addAll(Arrays.asList(resolvedElements));
+ for (int i = 0; i < elements.length; i++) {
+ IModelElement[] resolvedElements = CallHierarchyUI
+ .getCandidates(elements[i]);
+ if (resolvedElements != null)
+ candidates.addAll(Arrays.asList(resolvedElements));
}
if (candidates.isEmpty()) {
- IModelElement enclosingMethod= getEnclosingMethod(input, selection);
- if (enclosingMethod != null) {
- candidates.add(enclosingMethod);
- }
+ IModelElement enclosingMethod = getEnclosingMethod(input,
+ selection);
+ if (enclosingMethod != null) {
+ candidates.add(enclosingMethod);
+ }
}
run(candidates.toArray(new IModelElement[candidates.size()]));
} catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(), getErrorDialogTitle(), ActionMessages.SelectionConverter_codeResolve_failed);
+ ExceptionHandler.handle(e, getShell(), getErrorDialogTitle(),
+ ActionMessages.SelectionConverter_codeResolve_failed);
} catch (InterruptedException e) {
// cancelled
}
- }
+ }
- private IModelElement getEnclosingMethod(IModelElement input, ITextSelection selection) {
- IModelElement enclosingElement= null;
- try {
- switch (input.getElementType()) {
-// case IModelElement.CLASS_FILE :
-// IClassFile classFile= (IClassFile) input.getAncestor(IModelElement.CLASS_FILE);
-// if (classFile != null) {
-// enclosingElement= classFile.getElementAt(selection.getOffset());
-// }
-// break;
- case IModelElement.SOURCE_MODULE :
- ISourceModule cu= (ISourceModule) input.getAncestor(IModelElement.SOURCE_MODULE);
- if (cu != null) {
- enclosingElement= cu.getElementAt(selection.getOffset());
- }
- break;
- }
- if (enclosingElement != null && enclosingElement.getElementType() == IModelElement.METHOD) {
- return enclosingElement;
- }
- } catch (ModelException e) {
- DLTKUIPlugin.log(e);
- }
+ private IModelElement getEnclosingMethod(IModelElement input,
+ ITextSelection selection) {
+ IModelElement enclosingElement = null;
+ try {
+ switch (input.getElementType()) {
+ // case IModelElement.CLASS_FILE :
+ // IClassFile classFile= (IClassFile)
+ // input.getAncestor(IModelElement.CLASS_FILE);
+ // if (classFile != null) {
+ // enclosingElement= classFile.getElementAt(selection.getOffset());
+ // }
+ // break;
+ case IModelElement.SOURCE_MODULE:
+ ISourceModule cu = (ISourceModule) input
+ .getAncestor(IModelElement.SOURCE_MODULE);
+ if (cu != null) {
+ enclosingElement = cu.getElementAt(selection.getOffset());
+ }
+ break;
+ }
+ if (enclosingElement != null && enclosingElement
+ .getElementType() == IModelElement.METHOD) {
+ return enclosingElement;
+ }
+ } catch (ModelException e) {
+ DLTKUIPlugin.log(e);
+ }
- return null;
- }
+ return null;
+ }
@Override
public void run(IStructuredSelection selection) {
- if (selection.size() != 1)
- return;
- Object input= selection.getFirstElement();
- if (!(input instanceof IModelElement))
+ if (selection.size() != 1)
+ return;
+ Object input = selection.getFirstElement();
+ if (!(input instanceof IModelElement))
input = ((IAdaptable) input).getAdapter(IModelElement.class);
- if (!(input instanceof IModelElement)) {
- IStatus status= createStatus(CallHierarchyMessages.OpenCallHierarchyAction_messages_no_java_element);
- openErrorDialog(status);
- return;
- }
- IModelElement element= (IModelElement) input;
- if (!ActionUtil.isProcessable(getShell(), element))
- return;
+ if (!(input instanceof IModelElement)) {
+ IStatus status = createStatus(
+ CallHierarchyMessages.OpenCallHierarchyAction_messages_no_java_element);
+ openErrorDialog(status);
+ return;
+ }
+ IModelElement element = (IModelElement) input;
+ if (!ActionUtil.isProcessable(getShell(), element))
+ return;
List<IModelElement> result = new ArrayList<IModelElement>(1);
- IStatus status= compileCandidates(result, element);
- if (status.isOK()) {
+ IStatus status = compileCandidates(result, element);
+ if (status.isOK()) {
run(result.toArray(new IModelElement[result.size()]));
- } else {
- openErrorDialog(status);
- }
- }
-
- private int openErrorDialog(IStatus status) {
- String message= CallHierarchyMessages.OpenCallHierarchyAction_messages_title;
- String dialogTitle= getErrorDialogTitle();
- return ErrorDialog.openError(getShell(), dialogTitle, message, status);
+ } else {
+ openErrorDialog(status);
+ }
}
- private static String getErrorDialogTitle() {
- return CallHierarchyMessages.OpenCallHierarchyAction_dialog_title;
- }
+ private int openErrorDialog(IStatus status) {
+ String message = CallHierarchyMessages.OpenCallHierarchyAction_messages_title;
+ String dialogTitle = getErrorDialogTitle();
+ return ErrorDialog.openError(getShell(), dialogTitle, message, status);
+ }
+
+ private static String getErrorDialogTitle() {
+ return CallHierarchyMessages.OpenCallHierarchyAction_dialog_title;
+ }
public void run(IModelElement[] elements) {
- if (elements.length == 0) {
- getShell().getDisplay().beep();
- return;
- }
- CallHierarchyUI.open(elements, getSite().getWorkbenchWindow(), getCallHierarchyID());
- }
+ if (elements.length == 0) {
+ getShell().getDisplay().beep();
+ return;
+ }
+ CallHierarchyUI.open(elements, getSite().getWorkbenchWindow(),
+ getCallHierarchyID());
+ }
- private static IStatus compileCandidates(List result, IModelElement elem) {
- IStatus ok= new Status(IStatus.OK, DLTKUIPlugin.getPluginId(), 0, "", null); //$NON-NLS-1$
- switch (elem.getElementType()) {
- case IModelElement.METHOD:
- result.add(elem);
- return ok;
- }
- return createStatus(CallHierarchyMessages.OpenCallHierarchyAction_messages_no_valid_java_element);
- }
+ private static IStatus compileCandidates(List result, IModelElement elem) {
+ IStatus ok = new Status(IStatus.OK, DLTKUIPlugin.getPluginId(), 0, "", //$NON-NLS-1$
+ null);
+ switch (elem.getElementType()) {
+ case IModelElement.METHOD:
+ result.add(elem);
+ return ok;
+ }
+ return createStatus(
+ CallHierarchyMessages.OpenCallHierarchyAction_messages_no_valid_java_element);
+ }
- private static IStatus createStatus(String message) {
- return new Status(IStatus.INFO, DLTKUIPlugin.getPluginId(), IDLTKStatusConstants.INTERNAL_ERROR, message, null);
- }
- public String getCallHierarchyID() {
- return "org.eclipse.dltk.callhierarchy.view"; //$NON-NLS-1$
- }
+ private static IStatus createStatus(String message) {
+ return new Status(IStatus.INFO, DLTKUIPlugin.getPluginId(),
+ IDLTKStatusConstants.INTERNAL_ERROR, message, null);
+ }
+
+ public String getCallHierarchyID() {
+ return "org.eclipse.dltk.callhierarchy.view"; //$NON-NLS-1$
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusInfo.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusInfo.java
deleted file mode 100644
index 76e2c29..0000000
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dialogs/StatusInfo.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- *******************************************************************************/
-package org.eclipse.dltk.internal.ui.dialogs;
-
-/**
- * A settable IStatus. Can be an error, warning, info or ok. For error, info and
- * warning states, a message describes the problem.
- *
- * @deprecated
- */
-@Deprecated
-public class StatusInfo extends org.eclipse.dltk.ui.dialogs.StatusInfo {
-
- /**
- * Creates a status set to OK (no message)
- */
- public StatusInfo() {
- super();
- }
-
- /**
- * Creates a status .
- *
- * @param severity
- * The status severity: ERROR, WARNING, INFO and OK.
- * @param message
- * The message of the status. Applies only for ERROR, WARNING and
- * INFO.
- */
- public StatusInfo(int severity, String message) {
- super(severity, message);
- }
-
-}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DLTKViewerDropAdapter.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DLTKViewerDropAdapter.java
index 9761a9a..ec0a2e1 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DLTKViewerDropAdapter.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/dnd/DLTKViewerDropAdapter.java
@@ -28,379 +28,362 @@
* <p>
* Subclasses must implement the following methods:
* <ul>
- * <li><code>validateDrop</code> - identifies valid drop targets in viewer</li>
- * <li><code>performDrop</code> - carries out a drop into a viewer</li>
+ * <li><code>validateDrop</code> - identifies valid drop targets in viewer</li>
+ * <li><code>performDrop</code> - carries out a drop into a viewer</li>
* </ul>
* The <code>setFeedbackEnabled</code> method can be called to turn on and off
* visual insertion feedback (on by default).
* </p>
* <p>
- * THIS IS (ALMOST) A ONE-TO-ONE COPY OF PLATFORMS ViewerDropAdapter
- * REFERE THERE FIRST IF YOU NEED TO FIX SOMETHING.
+ * THIS IS (ALMOST) A ONE-TO-ONE COPY OF PLATFORMS ViewerDropAdapter REFERE
+ * THERE FIRST IF YOU NEED TO FIX SOMETHING.
* </p>
*/
public abstract class DLTKViewerDropAdapter extends DropTargetAdapter {
- /**
- * Constant describing the position of the cursor relative
- * to the target object. This means the mouse is positioned
- * slightly before the target.
- * @see #getCurrentLocation()
- */
- public static final int LOCATION_BEFORE = 1;
+ /**
+ * Constant describing the position of the cursor relative to the target
+ * object. This means the mouse is positioned slightly before the target.
+ *
+ * @see #getCurrentLocation()
+ */
+ public static final int LOCATION_BEFORE = 1;
- /**
- * Constant describing the position of the cursor relative
- * to the target object. This means the mouse is positioned
- * slightly after the target.
- * @see #getCurrentLocation()
- */
- public static final int LOCATION_AFTER = 2;
+ /**
+ * Constant describing the position of the cursor relative to the target
+ * object. This means the mouse is positioned slightly after the target.
+ *
+ * @see #getCurrentLocation()
+ */
+ public static final int LOCATION_AFTER = 2;
- /**
- * Constant describing the position of the cursor relative
- * to the target object. This means the mouse is positioned
- * directly on the target.
- * @see #getCurrentLocation()
- */
- public static final int LOCATION_ON = 3;
+ /**
+ * Constant describing the position of the cursor relative to the target
+ * object. This means the mouse is positioned directly on the target.
+ *
+ * @see #getCurrentLocation()
+ */
+ public static final int LOCATION_ON = 3;
- /**
- * Constant describing the position of the cursor relative
- * to the target object. This means the mouse is not positioned
- * over or near any valid target.
- * @see #getCurrentLocation()
- */
- public static final int LOCATION_NONE = 4;
+ /**
+ * Constant describing the position of the cursor relative to the target
+ * object. This means the mouse is not positioned over or near any valid
+ * target.
+ *
+ * @see #getCurrentLocation()
+ */
+ public static final int LOCATION_NONE = 4;
- /**
- * The viewer to which this drop support has been added.
- */
- private Viewer viewer;
+ /**
+ * The viewer to which this drop support has been added.
+ */
+ private Viewer viewer;
- /**
- * The current operation.
- */
- private int currentOperation = DND.DROP_NONE;
+ /**
+ * The current operation.
+ */
+ private int currentOperation = DND.DROP_NONE;
- /**
- * The last valid operation.
- */
- private int lastValidOperation = DND.DROP_NONE;
+ /**
+ * The last valid operation.
+ */
+ private int lastValidOperation = DND.DROP_NONE;
- /**
- * The data item currently under the mouse.
- */
- private Object currentTarget;
+ /**
+ * The data item currently under the mouse.
+ */
+ private Object currentTarget;
- /**
- * Information about the position of the mouse relative to the
- * target (before, on, or after the target. Location is one of
- * the <code>LOCATION_* </code> constants defined in this type.
- */
- private int currentLocation;
+ /**
+ * Information about the position of the mouse relative to the target
+ * (before, on, or after the target. Location is one of the
+ * <code>LOCATION_* </code> constants defined in this type.
+ */
+ private int currentLocation;
- /**
- * A flag that allows adapter users to turn the insertion
- * feedback on or off. Default is <code>true</code>.
- */
- private boolean feedbackEnabled = true;
+ /**
+ * A flag that allows adapter users to turn the insertion feedback on or
+ * off. Default is <code>true</code>.
+ */
+ private boolean feedbackEnabled = true;
- /**
- * A flag that allows adapter users to turn auto scrolling
- * on or off. Default is <code>true</code>.
- */
- private boolean scrollEnabled = true;
+ /**
+ * A flag that allows adapter users to turn auto scrolling on or off.
+ * Default is <code>true</code>.
+ */
+ private boolean scrollEnabled = true;
- /**
- * A flag that allows adapter users to turn auto
- * expanding on or off. Default is <code>true</code>.
- */
- private boolean expandEnabled = true;
+ /**
+ * A flag that allows adapter users to turn auto expanding on or off.
+ * Default is <code>true</code>.
+ */
+ private boolean expandEnabled = true;
- /**
- * A flag that allows adapter users to turn selection feedback
- * on or off. Default is <code>true</code>.
- */
- private boolean selectFeedbackEnabled = true;
+ /**
+ * A flag that allows adapter users to turn selection feedback on or off.
+ * Default is <code>true</code>.
+ */
+ private boolean selectFeedbackEnabled = true;
- /**
- * Creates a new drop adapter for the given viewer.
- *
- * @param viewer the viewer
- */
- protected DLTKViewerDropAdapter(Viewer viewer) {
- this.viewer = viewer;
- }
+ /**
+ * Creates a new drop adapter for the given viewer.
+ *
+ * @param viewer
+ * the viewer
+ */
+ protected DLTKViewerDropAdapter(Viewer viewer) {
+ this.viewer = viewer;
+ }
- /**
- * Returns the position of the given event's coordinates relative to its target.
- * The position is determined to be before, after, or on the item, based on
- * some threshold value.
- *
- * @param event the event
- * @return one of the <code>LOCATION_* </code>constants defined in this class
- */
- protected int determineLocation(DropTargetEvent event) {
- if (!(event.item instanceof Item)) {
- return DLTKViewerDropAdapter.LOCATION_NONE;
- }
- Item item = (Item) event.item;
- Point coordinates = new Point(event.x, event.y);
- coordinates = viewer.getControl().toControl(coordinates);
- if (item != null) {
- Rectangle bounds = getBounds(item);
- if (bounds == null) {
- return DLTKViewerDropAdapter.LOCATION_NONE;
- }
- if ((coordinates.y - bounds.y) < 5) {
- return DLTKViewerDropAdapter.LOCATION_BEFORE;
- }
- if ((bounds.y + bounds.height - coordinates.y) < 5) {
- return DLTKViewerDropAdapter.LOCATION_AFTER;
- }
- }
- return DLTKViewerDropAdapter.LOCATION_ON;
- }
+ /**
+ * Returns the position of the given event's coordinates relative to its
+ * target. The position is determined to be before, after, or on the item,
+ * based on some threshold value.
+ *
+ * @param event
+ * the event
+ * @return one of the <code>LOCATION_* </code>constants defined in this
+ * class
+ */
+ protected int determineLocation(DropTargetEvent event) {
+ if (!(event.item instanceof Item)) {
+ return DLTKViewerDropAdapter.LOCATION_NONE;
+ }
+ Item item = (Item) event.item;
+ Point coordinates = new Point(event.x, event.y);
+ coordinates = viewer.getControl().toControl(coordinates);
+ if (item != null) {
+ Rectangle bounds = getBounds(item);
+ if (bounds == null) {
+ return DLTKViewerDropAdapter.LOCATION_NONE;
+ }
+ if ((coordinates.y - bounds.y) < 5) {
+ return DLTKViewerDropAdapter.LOCATION_BEFORE;
+ }
+ if ((bounds.y + bounds.height - coordinates.y) < 5) {
+ return DLTKViewerDropAdapter.LOCATION_AFTER;
+ }
+ }
+ return DLTKViewerDropAdapter.LOCATION_ON;
+ }
- /**
- * Returns the target item of the given drop event.
- *
- * @param event the event
- * @return The target of the drop, may be <code>null</code>.
- */
- protected Object determineTarget(DropTargetEvent event) {
- return event.item == null ? null : event.item.getData();
- }
+ /**
+ * Returns the target item of the given drop event.
+ *
+ * @param event
+ * the event
+ * @return The target of the drop, may be <code>null</code>.
+ */
+ protected Object determineTarget(DropTargetEvent event) {
+ return event.item == null ? null : event.item.getData();
+ }
- /* (non-Javadoc)
- * Method declared on DropTargetAdapter.
- * The mouse has moved over the drop target. If the
- * target item has changed, notify the action and check
- * that it is still enabled.
- */
- private void doDropValidation(DropTargetEvent event) {
- currentOperation= determineOperation(currentTarget, lastValidOperation, event.currentDataType, event.operations);
- event.detail = currentOperation;
- setFeedback(event, currentLocation);
- }
+ /*
+ * (non-Javadoc) Method declared on DropTargetAdapter. The mouse has moved
+ * over the drop target. If the target item has changed, notify the action
+ * and check that it is still enabled.
+ */
+ private void doDropValidation(DropTargetEvent event) {
+ currentOperation = determineOperation(currentTarget, lastValidOperation,
+ event.currentDataType, event.operations);
+ event.detail = currentOperation;
+ setFeedback(event, currentLocation);
+ }
- /* (non-Javadoc)
- * Method declared on DropTargetAdapter.
- * The drag has entered this widget's region. See
- * if the drop should be allowed.
- */
- @Override
+ /*
+ * (non-Javadoc) Method declared on DropTargetAdapter. The drag has entered
+ * this widget's region. See if the drop should be allowed.
+ */
+ @Override
public void dragEnter(DropTargetEvent event) {
- currentTarget = determineTarget(event);
- currentLocation = determineLocation(event);
- lastValidOperation = event.detail;
- doDropValidation(event);
- }
+ currentTarget = determineTarget(event);
+ currentLocation = determineLocation(event);
+ lastValidOperation = event.detail;
+ doDropValidation(event);
+ }
- /* (non-Javadoc)
- * Method declared on DropTargetAdapter.
- * The drop operation has changed, see if the action
- * should still be enabled.
- */
- @Override
+ /*
+ * (non-Javadoc) Method declared on DropTargetAdapter. The drop operation
+ * has changed, see if the action should still be enabled.
+ */
+ @Override
public void dragOperationChanged(DropTargetEvent event) {
- currentTarget = determineTarget(event);
- lastValidOperation = event.detail;
- doDropValidation(event);
- }
+ currentTarget = determineTarget(event);
+ lastValidOperation = event.detail;
+ doDropValidation(event);
+ }
- /* (non-Javadoc)
- * Method declared on DropTargetAdapter.
- * The mouse has moved over the drop target. If the
- * target item has changed, notify the action and check
- * that it is still enabled.
- */
- @Override
+ /*
+ * (non-Javadoc) Method declared on DropTargetAdapter. The mouse has moved
+ * over the drop target. If the target item has changed, notify the action
+ * and check that it is still enabled.
+ */
+ @Override
public void dragOver(DropTargetEvent event) {
- //use newly revealed item as target if scrolling occurs
- Object target = determineTarget(event);
+ // use newly revealed item as target if scrolling occurs
+ Object target = determineTarget(event);
- //set the location feedback
- int oldLocation = currentLocation;
- currentLocation = determineLocation(event);
- setFeedback(event, currentLocation);
+ // set the location feedback
+ int oldLocation = currentLocation;
+ currentLocation = determineLocation(event);
+ setFeedback(event, currentLocation);
- //see if anything has really changed before doing validation.
- if (target != currentTarget || currentLocation != oldLocation) {
- currentTarget = target;
- doDropValidation(event);
- }
- }
+ // see if anything has really changed before doing validation.
+ if (target != currentTarget || currentLocation != oldLocation) {
+ currentTarget = target;
+ doDropValidation(event);
+ }
+ }
- /* (non-Javadoc)
- * Method declared on DropTargetAdapter.
- * The user has dropped something on the desktop viewer.
- */
- @Override
+ /*
+ * (non-Javadoc) Method declared on DropTargetAdapter. The user has dropped
+ * something on the desktop viewer.
+ */
+ @Override
public void drop(DropTargetEvent event) {
- currentLocation = determineLocation(event);
+ currentLocation = determineLocation(event);
- //perform the drop behavior
- if (!performDrop(event.data)) {
- event.detail = DND.DROP_NONE;
- }
- currentOperation = event.detail;
- }
+ // perform the drop behavior
+ if (!performDrop(event.data)) {
+ event.detail = DND.DROP_NONE;
+ }
+ currentOperation = event.detail;
+ }
- /* (non-Javadoc)
- * Method declared on DropTargetAdapter.
- * Last chance for the action to disable itself
- */
- @Override
+ /*
+ * (non-Javadoc) Method declared on DropTargetAdapter. Last chance for the
+ * action to disable itself
+ */
+ @Override
public void dropAccept(DropTargetEvent event) {
- event.detail= determineOperation(currentTarget, event.detail, event.currentDataType, event.operations);
- }
+ event.detail = determineOperation(currentTarget, event.detail,
+ event.currentDataType, event.operations);
+ }
- /**
- * Returns the bounds of the given SWT tree or table item.
- *
- * @param item the SWT Item
- * @return the bounds, or <code>null</code> if it is not a known type of item
- */
- protected Rectangle getBounds(Item item) {
- if (item instanceof TreeItem) {
- return ((TreeItem) item).getBounds();
- }
- if (item instanceof TableItem) {
- return ((TableItem) item).getBounds(0);
- }
- return null;
- }
+ /**
+ * Returns the bounds of the given SWT tree or table item.
+ *
+ * @param item
+ * the SWT Item
+ * @return the bounds, or <code>null</code> if it is not a known type of
+ * item
+ */
+ protected Rectangle getBounds(Item item) {
+ if (item instanceof TreeItem) {
+ return ((TreeItem) item).getBounds();
+ }
+ if (item instanceof TableItem) {
+ return ((TableItem) item).getBounds(0);
+ }
+ return null;
+ }
- /**
- * Returns a constant describing the position of the mouse relative to the
- * target (before, on, or after the target.
- *
- * @return one of the <code>LOCATION_* </code> constants defined in this type
- */
- protected int getCurrentLocation() {
- return currentLocation;
- }
+ /**
+ * Returns a constant describing the position of the mouse relative to the
+ * target (before, on, or after the target.
+ *
+ * @return one of the <code>LOCATION_* </code> constants defined in this
+ * type
+ */
+ protected int getCurrentLocation() {
+ return currentLocation;
+ }
- /**
- * Returns the current operation.
- *
- * @return a <code>DROP_*</code> constant from class <code>DND</code>
- *
- * @see DND#DROP_COPY
- * @see DND#DROP_MOVE
- * @see DND#DROP_LINK
- * @see DND#DROP_NONE
- */
- protected int getCurrentOperation() {
- return currentOperation;
- }
+ /**
+ * Returns the current operation.
+ *
+ * @return a <code>DROP_*</code> constant from class <code>DND</code>
+ *
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ * @see DND#DROP_NONE
+ */
+ protected int getCurrentOperation() {
+ return currentOperation;
+ }
- /**
- * Returns the target object currently under the mouse.
- *
- * @return the current target object
- */
- protected Object getCurrentTarget() {
- return currentTarget;
- }
+ /**
+ * Returns the target object currently under the mouse.
+ *
+ * @return the current target object
+ */
+ protected Object getCurrentTarget() {
+ return currentTarget;
+ }
- /**
- * Returns whether visible insertion feedback should be presented to the user.
- * <p>
- * Typical insertion feedback is the horizontal insertion bars that appear
- * between adjacent items while dragging.
- * </p>
- *
- * @return <code>true</code> if visual feedback is desired, and <code>false</code> if not
- */
- public boolean getFeedbackEnabled() {
- return feedbackEnabled;
- }
+ /**
+ * Returns whether visible insertion feedback should be presented to the
+ * user.
+ * <p>
+ * Typical insertion feedback is the horizontal insertion bars that appear
+ * between adjacent items while dragging.
+ * </p>
+ *
+ * @return <code>true</code> if visual feedback is desired, and
+ * <code>false</code> if not
+ */
+ public boolean getFeedbackEnabled() {
+ return feedbackEnabled;
+ }
- /**
- * Returns the object currently selected by the viewer.
- *
- * @return the selected object, or <code>null</code> if either no object or
- * multiple objects are selected
- */
- protected Object getSelectedObject() {
- ISelection selection = viewer.getSelection();
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- IStructuredSelection structured = (IStructuredSelection) selection;
- return structured.getFirstElement();
- }
- return null;
- }
+ /**
+ * Returns the object currently selected by the viewer.
+ *
+ * @return the selected object, or <code>null</code> if either no object or
+ * multiple objects are selected
+ */
+ protected Object getSelectedObject() {
+ ISelection selection = viewer.getSelection();
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ IStructuredSelection structured = (IStructuredSelection) selection;
+ return structured.getFirstElement();
+ }
+ return null;
+ }
- /**
- * @return the viewer to which this drop support has been added.
- */
- protected Viewer getViewer() {
- return viewer;
- }
+ /**
+ * @return the viewer to which this drop support has been added.
+ */
+ protected Viewer getViewer() {
+ return viewer;
+ }
- /**
- * @deprecated this method should not be used. Exception handling has been
- * removed from DropTargetAdapter methods overridden by this class.
- * Handles any exception that occurs during callback, including
- * rethrowing behavior.
- * <p>
- * [Issue: Implementation prints stack trace and eats exception to avoid
- * crashing VA/J.
- * Consider conditionalizing the implementation to do one thing in VAJ
- * and something more reasonable in other operating environments.
- * ]
- * </p>
- *
- * @param exception the exception
- * @param event the event
- */
- @Deprecated
- protected void handleException(Throwable exception, DropTargetEvent event) {
- // Currently we never rethrow because VA/Java crashes if an SWT
- // callback throws anything. Generally catching Throwable is bad, but in
- // this cases it's better than hanging the image.
- exception.printStackTrace();
- event.detail = DND.DROP_NONE;
- }
+ /**
+ * Performs any work associated with the drop.
+ * <p>
+ * Subclasses must implement this method to provide drop behavior.
+ * </p>
+ *
+ * @param data
+ * the drop data
+ * @return <code>true</code> if the drop was successful, and
+ * <code>false</code> otherwise
+ */
+ public abstract boolean performDrop(Object data);
- /**
- * Performs any work associated with the drop.
- * <p>
- * Subclasses must implement this method to provide drop behavior.
- * </p>
- *
- * @param data the drop data
- * @return <code>true</code> if the drop was successful, and
- * <code>false</code> otherwise
- */
- public abstract boolean performDrop(Object data);
+ /*
+ * (non-Javadoc) Method declared on DropTargetAdapter. The mouse has moved
+ * over the drop target. If the target item has changed, notify the action
+ * and check that it is still enabled.
+ */
+ private void setFeedback(DropTargetEvent event, int location) {
+ if (feedbackEnabled) {
+ switch (location) {
+ case LOCATION_BEFORE:
+ event.feedback = DND.FEEDBACK_INSERT_BEFORE;
+ break;
+ case LOCATION_AFTER:
+ event.feedback = DND.FEEDBACK_INSERT_AFTER;
+ break;
+ case LOCATION_ON:
+ default:
+ event.feedback = DND.FEEDBACK_SELECT;
+ break;
+ }
+ }
- /* (non-Javadoc)
- * Method declared on DropTargetAdapter.
- * The mouse has moved over the drop target. If the
- * target item has changed, notify the action and check
- * that it is still enabled.
- */
- private void setFeedback(DropTargetEvent event, int location) {
- if (feedbackEnabled) {
- switch (location) {
- case LOCATION_BEFORE:
- event.feedback = DND.FEEDBACK_INSERT_BEFORE;
- break;
- case LOCATION_AFTER:
- event.feedback = DND.FEEDBACK_INSERT_AFTER;
- break;
- case LOCATION_ON:
- default:
- event.feedback = DND.FEEDBACK_SELECT;
- break;
- }
- }
-
- // Explicitly inhibit SELECT feedback if desired
+ // Explicitly inhibit SELECT feedback if desired
if (!selectFeedbackEnabled) {
event.feedback &= ~DND.FEEDBACK_SELECT;
}
@@ -411,9 +394,9 @@
if (scrollEnabled) {
event.feedback |= DND.FEEDBACK_SCROLL;
}
- }
+ }
- /**
+ /**
* Sets whether visible insertion feedback should be presented to the user.
* <p>
* Typical insertion feedback is the horizontal insertion bars that appear
@@ -424,104 +407,120 @@
* <code>true</code> if visual feedback is desired, and
* <code>false</code> if not
*/
- public void setFeedbackEnabled(boolean value) {
- feedbackEnabled = value;
- }
+ public void setFeedbackEnabled(boolean value) {
+ feedbackEnabled = value;
+ }
- /**
- * Sets whether selection feedback should be provided during dragging.
- *
- * @param value <code>true</code> if selection feedback is desired, and
- * <code>false</code> if not
- *
- * @since 3.2
- */
- public void setSelectionFeedbackEnabled(boolean value) {
- selectFeedbackEnabled = value;
- }
+ /**
+ * Sets whether selection feedback should be provided during dragging.
+ *
+ * @param value
+ * <code>true</code> if selection feedback is desired, and
+ * <code>false</code> if not
+ *
+ * @since 3.2
+ */
+ public void setSelectionFeedbackEnabled(boolean value) {
+ selectFeedbackEnabled = value;
+ }
- /**
- * Sets whether auto scrolling and expanding should be provided during dragging.
- *
- * @param value <code>true</code> if scrolling and expanding is desired, and
- * <code>false</code> if not
- * @since 2.0
- */
- public void setScrollExpandEnabled(boolean value) {
- expandEnabled = value;
- scrollEnabled = value;
- }
+ /**
+ * Sets whether auto scrolling and expanding should be provided during
+ * dragging.
+ *
+ * @param value
+ * <code>true</code> if scrolling and expanding is desired, and
+ * <code>false</code> if not
+ * @since 2.0
+ */
+ public void setScrollExpandEnabled(boolean value) {
+ expandEnabled = value;
+ scrollEnabled = value;
+ }
- /**
- * Sets whether auto expanding should be provided during dragging.
- *
- * @param value <code>true</code> if expanding is desired, and
- * <code>false</code> if not
- * @since 3.4
- */
- public void setExpandEnabled(boolean value) {
- expandEnabled = value;
- }
+ /**
+ * Sets whether auto expanding should be provided during dragging.
+ *
+ * @param value
+ * <code>true</code> if expanding is desired, and
+ * <code>false</code> if not
+ * @since 3.4
+ */
+ public void setExpandEnabled(boolean value) {
+ expandEnabled = value;
+ }
- /**
- * Sets whether auto scrolling should be provided during dragging.
- *
- * @param value <code>true</code> if scrolling is desired, and
- * <code>false</code> if not
- * @since 3.4
- */
- public void setScrollEnabled(boolean value) {
- scrollEnabled = value;
- }
+ /**
+ * Sets whether auto scrolling should be provided during dragging.
+ *
+ * @param value
+ * <code>true</code> if scrolling is desired, and
+ * <code>false</code> if not
+ * @since 3.4
+ */
+ public void setScrollEnabled(boolean value) {
+ scrollEnabled = value;
+ }
- /**
- * Validates dropping on the given object. This method is called whenever some
- * aspect of the drop operation changes.
- * <p>
- * Subclasses must implement this method to define which drops make sense.
- * </p>
- *
- * @param target the object that the mouse is currently hovering over, or
- * <code>null</code> if the mouse is hovering over empty space
- * @param operation the current drag operation (copy, move, etc.)
- * @param transferType the current transfer type
- * @return <code>true</code> if the drop is valid, and <code>false</code>
- * otherwise
- */
- public abstract boolean validateDrop(Object target, int operation,
- TransferData transferType);
+ /**
+ * Validates dropping on the given object. This method is called whenever
+ * some aspect of the drop operation changes.
+ * <p>
+ * Subclasses must implement this method to define which drops make sense.
+ * </p>
+ *
+ * @param target
+ * the object that the mouse is currently hovering over, or
+ * <code>null</code> if the mouse is hovering over empty space
+ * @param operation
+ * the current drag operation (copy, move, etc.)
+ * @param transferType
+ * the current transfer type
+ * @return <code>true</code> if the drop is valid, and <code>false</code>
+ * otherwise
+ */
+ public abstract boolean validateDrop(Object target, int operation,
+ TransferData transferType);
- /**
- * Determine the operation which should be executed given the target and the operation
- * requested by the user. This method is called whenever some aspect of the drop operation
- * changes. The operation is one of DND#DROP_DEFAULT, DND#DROP_COPY, DND#DROP_MOVE, DND#DROP_LINK.
- * <p>
- * The method returns the operation valid in the given context. The result is one of
- * DND#DROP_NONE, DND#DROP_COPY, DND#DROP_MOVE, DND#DROP_LINK, DND#DROP_DEFAULT.
- * </p>
- * <p>
- * Subclasses can overwrite this method to define which operation does make
- * sense in the given context.
- * </p>
- *
- * @param target the object that the mouse is currently hovering over, or
- * <code>null</code> if the mouse is hovering over empty space
- * @param operation the current drag operation (copy, move, etc.)
- * @param transferType the current transfer type
- * @param operations a bitwise OR'ing of the operations that the DragSource can support
- * @return the operation which will be executed if no modifier key is pressed
- * by the user
- *
- * @see DND#DROP_NONE
+ /**
+ * Determine the operation which should be executed given the target and the
+ * operation requested by the user. This method is called whenever some
+ * aspect of the drop operation changes. The operation is one of
+ * DND#DROP_DEFAULT, DND#DROP_COPY, DND#DROP_MOVE, DND#DROP_LINK.
+ * <p>
+ * The method returns the operation valid in the given context. The result
+ * is one of DND#DROP_NONE, DND#DROP_COPY, DND#DROP_MOVE, DND#DROP_LINK,
+ * DND#DROP_DEFAULT.
+ * </p>
+ * <p>
+ * Subclasses can overwrite this method to define which operation does make
+ * sense in the given context.
+ * </p>
+ *
+ * @param target
+ * the object that the mouse is currently hovering over, or
+ * <code>null</code> if the mouse is hovering over empty space
+ * @param operation
+ * the current drag operation (copy, move, etc.)
+ * @param transferType
+ * the current transfer type
+ * @param operations
+ * a bitwise OR'ing of the operations that the DragSource can
+ * support
+ * @return the operation which will be executed if no modifier key is
+ * pressed by the user
+ *
+ * @see DND#DROP_NONE
* @see DND#DROP_MOVE
* @see DND#DROP_COPY
* @see DND#DROP_LINK
- */
- protected int determineOperation(Object target, int operation, TransferData transferType, int operations) {
- if (!validateDrop(target, operation, transferType)) {
- return DND.DROP_NONE;
- }
+ */
+ protected int determineOperation(Object target, int operation,
+ TransferData transferType, int operations) {
+ if (!validateDrop(target, operation, transferType)) {
+ return DND.DROP_NONE;
+ }
- return operation;
- }
+ return operation;
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptAnnotationIterator.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptAnnotationIterator.java
index 99503fb..e7a530e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptAnnotationIterator.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/ScriptAnnotationIterator.java
@@ -32,22 +32,6 @@
*
* @param model
* the annotation model
- * @param skipIrrelevants
- * whether to skip irrelevant annotations
- * @param returnAllAnnotations
- * Whether to return non IJavaAnnotations as well
- */
- @Deprecated
- public ScriptAnnotationIterator(IAnnotationModel model,
- boolean skipIrrelevants, boolean returnAllAnnotations) {
- this(model, returnAllAnnotations);
- }
-
- /**
- * Returns a new JavaAnnotationIterator.
- *
- * @param model
- * the annotation model
* @param returnAllAnnotations
* Whether to return non IJavaAnnotations as well
*/
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingManager.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingManager.java
index 840aa77..c9035c6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingManager.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/editor/semantic/highlighting/SemanticHighlightingManager.java
@@ -148,8 +148,8 @@
fPreferenceStore = preferenceStore;
final ScriptTextTools textTools = getTextTools();
if (textTools != null) {
- fConfiguration = textTools.createSourceViewerConfiguraton(
- preferenceStore, editor);
+ fConfiguration = textTools
+ .createSourceViewerConfiguraton(preferenceStore, editor);
}
if (fEditor != null) {
Assert.isNotNull(fConfiguration);
@@ -188,27 +188,6 @@
}
/**
- * Install the semantic highlighting on the given source viewer
- * infrastructure. No reconciliation will be performed.
- *
- * @param sourceViewer
- * the source viewer
- * @param colorManager
- * the color manager
- * @param preferenceStore
- * the preference store
- * @param hardcodedRanges
- * the hard-coded ranges to be highlighted
- * @deprecated
- */
- @Deprecated
- public void install(ScriptSourceViewer sourceViewer,
- IColorManager colorManager, IPreferenceStore preferenceStore,
- HighlightedRange[][] hardcodedRanges) {
- install(null, sourceViewer, colorManager, preferenceStore);
- }
-
- /**
* Enable semantic highlighting.
*/
private void enable() {
@@ -223,8 +202,8 @@
fPresenter, fSemanticHighlightings, fHighlightings);
} else {
fHighlightingUpdater.initialize(fPresenter, fHighlightings);
- final ModuleSource code = new ModuleSource(fSourceViewer
- .getDocument().get());
+ final ModuleSource code = new ModuleSource(
+ fSourceViewer.getDocument().get());
UpdateResult result = fHighlightingUpdater.reconcile(code,
Collections.<HighlightedPosition> emptyList());
fPresenter.updatePresentation(null, result.addedPositions,
@@ -324,11 +303,11 @@
private TextAttribute createTextAttribute(IColorManager manager,
IPreferenceStore ps, String colorKey, String bgKey) {
- return createTextAttribute(manager, ps, colorKey, colorKey
- + PreferenceConstants.EDITOR_BOLD_SUFFIX, colorKey
- + PreferenceConstants.EDITOR_ITALIC_SUFFIX, colorKey
- + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX, colorKey
- + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX, bgKey);
+ return createTextAttribute(manager, ps, colorKey,
+ colorKey + PreferenceConstants.EDITOR_BOLD_SUFFIX,
+ colorKey + PreferenceConstants.EDITOR_ITALIC_SUFFIX,
+ colorKey + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX,
+ colorKey + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX, bgKey);
}
/**
@@ -342,9 +321,8 @@
final TextAttribute ta = createTextAttribute(fColorManager,
fPreferenceStore, sh.getPreferenceKey(),
sh.getBackgroundPreferenceKey());
- final boolean isEnabled = !sh.isSemanticOnly()
- || fPreferenceStore
- .getBoolean(sh.getEnabledPreferenceKey());
+ final boolean isEnabled = !sh.isSemanticOnly() || fPreferenceStore
+ .getBoolean(sh.getEnabledPreferenceKey());
fHighlightings[a] = new HighlightingStyle(ta, isEnabled, sh);
}
}
@@ -453,8 +431,8 @@
}
if (semanticHighlighting.isSemanticOnly()) {
- if (semanticHighlighting.getEnabledPreferenceKey().equals(
- event.getProperty())) {
+ if (semanticHighlighting.getEnabledPreferenceKey()
+ .equals(event.getProperty())) {
adaptToEnablementChange(fHighlightings[i], event);
fPresenter.highlightingStyleChanged(fHighlightings[i]);
refreshNeeded = true;
@@ -522,8 +500,8 @@
}
TextAttribute oldAttr = highlighting.getTextAttribute();
- highlighting.setTextAttribute(new TextAttribute(oldAttr
- .getForeground(), color, oldAttr.getStyle()));
+ highlighting.setTextAttribute(new TextAttribute(
+ oldAttr.getForeground(), color, oldAttr.getStyle()));
}
}
@@ -557,8 +535,8 @@
}
TextAttribute oldAttr = highlighting.getTextAttribute();
- highlighting.setTextAttribute(new TextAttribute(color, oldAttr
- .getBackground(), oldAttr.getStyle()));
+ highlighting.setTextAttribute(new TextAttribute(color,
+ oldAttr.getBackground(), oldAttr.getStyle()));
}
}
@@ -572,13 +550,14 @@
eventValue = true;
TextAttribute oldAttr = highlighting.getTextAttribute();
- boolean activeValue = (oldAttr.getStyle() & styleAttribute) == styleAttribute;
+ boolean activeValue = (oldAttr.getStyle()
+ & styleAttribute) == styleAttribute;
if (activeValue != eventValue)
- highlighting.setTextAttribute(new TextAttribute(oldAttr
- .getForeground(), oldAttr.getBackground(),
- eventValue ? oldAttr.getStyle() | styleAttribute : oldAttr
- .getStyle() & ~styleAttribute));
+ highlighting.setTextAttribute(new TextAttribute(
+ oldAttr.getForeground(), oldAttr.getBackground(),
+ eventValue ? oldAttr.getStyle() | styleAttribute
+ : oldAttr.getStyle() & ~styleAttribute));
}
private void addColor(String colorKey) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/preferences/OptionsConfigurationBlock.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/preferences/OptionsConfigurationBlock.java
index 59ae64a..8bfd6b2 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/preferences/OptionsConfigurationBlock.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/preferences/OptionsConfigurationBlock.java
@@ -137,22 +137,23 @@
protected void validateValuePresenceFor(PreferenceKey key) {
if (key.getStoredValue(fLookupOrder, false, fManager) == null) {
- DLTKUIPlugin
- .logErrorMessage("preference option missing: " + key + " (" + this.getClass().getName() + ')'); //$NON-NLS-1$//$NON-NLS-2$
+ DLTKUIPlugin.logErrorMessage("preference option missing: " + key //$NON-NLS-1$
+ + " (" + this.getClass().getName() + ')'); //$NON-NLS-1$
}
}
private int getRebuildCount() {
- return fManager.getWorkingCopy(
- DefaultScope.INSTANCE.getNode(DLTKUIPlugin.PLUGIN_ID)).getInt(
- REBUILD_COUNT_KEY, 0);
+ return fManager
+ .getWorkingCopy(
+ DefaultScope.INSTANCE.getNode(DLTKUIPlugin.PLUGIN_ID))
+ .getInt(REBUILD_COUNT_KEY, 0);
}
private void incrementRebuildCount() {
fRebuildCount++;
fManager.getWorkingCopy(
- DefaultScope.INSTANCE.getNode(DLTKUIPlugin.PLUGIN_ID)).putInt(
- REBUILD_COUNT_KEY, fRebuildCount);
+ DefaultScope.INSTANCE.getNode(DLTKUIPlugin.PLUGIN_ID))
+ .putInt(REBUILD_COUNT_KEY, fRebuildCount);
}
protected PreferenceKey[] getPreferenceKeys() {
@@ -164,7 +165,8 @@
IScopeContext projectContext = new ProjectScope(project);
PreferenceKey[] allKeys = getPreferenceKeys();
for (int i = 0; i < allKeys.length; i++) {
- if (allKeys[i].getStoredValue(projectContext, fManager) != null) {
+ if (allKeys[i].getStoredValue(projectContext,
+ fManager) != null) {
return true;
}
}
@@ -233,8 +235,8 @@
if (val == null) {
if (oldVal != null) {
changedSettings.add(key);
- needsBuild |= !oldVal.equals(key.getStoredValue(
- fLookupOrder, true, fManager));
+ needsBuild |= !oldVal.equals(
+ key.getStoredValue(fLookupOrder, true, fManager));
} else if (completeSettings) {
key.setStoredValue(currContext,
key.getStoredValue(fLookupOrder, true, fManager),
@@ -244,9 +246,8 @@
}
} else if (!val.equals(oldVal)) {
changedSettings.add(key);
- needsBuild |= oldVal != null
- || !val.equals(key.getStoredValue(fLookupOrder, true,
- fManager));
+ needsBuild |= oldVal != null || !val.equals(
+ key.getStoredValue(fLookupOrder, true, fManager));
}
}
return needsBuild;
@@ -267,8 +268,8 @@
fDisabledProjectSettings = new HashMap<PreferenceKey, String>();
for (int i = 0; i < allKeys.length; i++) {
PreferenceKey curr = allKeys[i];
- String oldSetting = curr.getStoredValue(fLookupOrder,
- false, fManager);
+ String oldSetting = curr.getStoredValue(fLookupOrder, false,
+ fManager);
fDisabledProjectSettings.put(curr, oldSetting);
// clear project settings
curr.setStoredValue(fLookupOrder[0], null, fManager);
@@ -313,10 +314,11 @@
if (prompt != null) {
MessageDialog dialog = new MessageDialog(getShell(),
prompt.getTitle(), null, prompt.getMessage(),
- MessageDialog.QUESTION, new String[] {
- IDialogConstants.YES_LABEL,
+ MessageDialog.QUESTION,
+ new String[] { IDialogConstants.YES_LABEL,
IDialogConstants.NO_LABEL,
- IDialogConstants.CANCEL_LABEL }, 2);
+ IDialogConstants.CANCEL_LABEL },
+ 2);
int res = dialog.open();
if (res == 0) {
doBuild = true;
@@ -360,8 +362,8 @@
PreferenceKey[] allKeys = getPreferenceKeys();
for (int i = 0; i < allKeys.length; i++) {
PreferenceKey curr = allKeys[i];
- String origValue = curr
- .getStoredValue(fLookupOrder, true, fManager);
+ String origValue = curr.getStoredValue(fLookupOrder, true,
+ fManager);
setValue(curr, origValue);
}
}
@@ -384,16 +386,8 @@
* @return
*/
protected IPreferenceChangeRebuildPrompt getPreferenceChangeRebuildPrompt(
- boolean workspaceSettings, Collection<PreferenceKey> changedOptions) {
- return null;
- }
-
- /**
- * @deprecated
- * @see #getPreferenceChangeRebuildPrompt(boolean, Collection)
- */
- @Deprecated
- protected final String[] getFullBuildDialogStrings(boolean workspaceSettings) {
+ boolean workspaceSettings,
+ Collection<PreferenceKey> changedOptions) {
return null;
}
@@ -411,8 +405,8 @@
| ExpandableComposite.CLIENT_INDENT);
excomposite.setText(label);
excomposite.setExpanded(false);
- excomposite.setFont(JFaceResources.getFontRegistry().getBold(
- JFaceResources.DIALOG_FONT));
+ excomposite.setFont(JFaceResources.getFontRegistry()
+ .getBold(JFaceResources.DIALOG_FONT));
excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL,
true, false, nColumns, 1));
excomposite.addExpansionListener(new ExpansionAdapter() {
@@ -437,8 +431,8 @@
excomposite.setExpanded(i == 0); // only expand the first node
// by default
} else {
- excomposite.setExpanded(settings.getBoolean(SETTINGS_EXPANDED
- + String.valueOf(i)));
+ excomposite.setExpanded(settings
+ .getBoolean(SETTINGS_EXPANDED + String.valueOf(i)));
}
}
}
@@ -452,7 +446,8 @@
}
private void makeScrollableCompositeAware(Control control) {
- ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(control);
+ ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(
+ control);
if (parentScrolledComposite != null) {
parentScrolledComposite.adaptChild(control);
}
@@ -470,7 +465,8 @@
}
protected final void expandedStateChanged(ExpandableComposite expandable) {
- ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(expandable);
+ ScrolledPageContent parentScrolledComposite = getParentScrolledComposite(
+ expandable);
if (parentScrolledComposite != null) {
parentScrolledComposite.reflow(true);
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerActionGroup.java
index 5913de2..e44bfda 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerActionGroup.java
@@ -71,15 +71,14 @@
private FrameList fFrameList;
private GoIntoAction fZoomInAction;
- private BackAction fBackAction;
+ private BackAction fBackAction;
private ForwardAction fForwardAction;
private UpAction fUpAction;
- //private GotoTypeAction fGotoTypeAction;
- //private GotoPackageAction fGotoPackageAction;
- //private GotoResourceAction fGotoResourceAction;
+ // private GotoTypeAction fGotoTypeAction;
+ // private GotoPackageAction fGotoPackageAction;
+ // private GotoResourceAction fGotoResourceAction;
private CollapseAllAction fCollapseAllAction;
-
private ToggleLinkingAction fToggleLinkingAction;
private RefactorActionGroup fRefactorActionGroup;
@@ -93,45 +92,47 @@
public ScriptExplorerActionGroup(ScriptExplorerPart part) {
super();
- fPart= part;
- TreeViewer viewer= part.getTreeViewer();
+ fPart = part;
+ TreeViewer viewer = part.getTreeViewer();
- IPropertyChangeListener workingSetListener= event -> doWorkingSetChanged(event);
+ IPropertyChangeListener workingSetListener = event -> doWorkingSetChanged(
+ event);
IWorkbenchPartSite site = fPart.getSite();
- setGroups(new ActionGroup[] {
- new NewWizardsActionGroup(site),
- fNavigateActionGroup= new NavigateActionGroup(fPart),
- new CCPActionGroup(fPart),
- new GenerateBuildPathActionGroup(fPart),
- new GenerateActionGroup(fPart, IContextMenuConstants.GROUP_SHOW),
- fRefactorActionGroup= new RefactorActionGroup(fPart),
- new ImportActionGroup(fPart),
- new BuildActionGroup(fPart),
- //new ScriptSearchActionGroup(fPart),
- fProjectActionGroup = new ProjectActionGroup(fPart),
- fViewActionGroup= new ViewActionGroup(fPart.getRootMode(), workingSetListener, site),
- fCustomFiltersActionGroup= new CustomFiltersActionGroup(fPart, viewer),
- new LayoutActionGroup(fPart),
- // the working set action group must be created after the project action group
- new WorkingSetActionGroup(fPart)});
-
+ setGroups(new ActionGroup[] { new NewWizardsActionGroup(site),
+ fNavigateActionGroup = new NavigateActionGroup(fPart),
+ new CCPActionGroup(fPart),
+ new GenerateBuildPathActionGroup(fPart),
+ new GenerateActionGroup(fPart,
+ IContextMenuConstants.GROUP_SHOW),
+ fRefactorActionGroup = new RefactorActionGroup(fPart, null),
+ new ImportActionGroup(fPart), new BuildActionGroup(fPart),
+ // new ScriptSearchActionGroup(fPart),
+ fProjectActionGroup = new ProjectActionGroup(fPart),
+ fViewActionGroup = new ViewActionGroup(fPart.getRootMode(),
+ workingSetListener, site),
+ fCustomFiltersActionGroup = new CustomFiltersActionGroup(fPart,
+ viewer),
+ new LayoutActionGroup(fPart),
+ // the working set action group must be created after the
+ // project action group
+ new WorkingSetActionGroup(fPart) });
fViewActionGroup.fillFilters(viewer);
- ScriptFrameSource frameSource= new ScriptFrameSource(fPart);
- fFrameList= new FrameList(frameSource);
+ ScriptFrameSource frameSource = new ScriptFrameSource(fPart);
+ fFrameList = new FrameList(frameSource);
frameSource.connectTo(fFrameList);
- fZoomInAction= new GoIntoAction(fFrameList);
- fBackAction= new BackAction(fFrameList);
- fForwardAction= new ForwardAction(fFrameList);
- fUpAction= new UpAction(fFrameList);
+ fZoomInAction = new GoIntoAction(fFrameList);
+ fBackAction = new BackAction(fFrameList);
+ fForwardAction = new ForwardAction(fFrameList);
+ fUpAction = new UpAction(fFrameList);
- //fGotoTypeAction= new GotoTypeAction(fPart);
- //fGotoPackageAction= new GotoPackageAction(fPart);
- //fGotoResourceAction= new GotoResourceAction(fPart);
- fCollapseAllAction= new CollapseAllAction(fPart);
+ // fGotoTypeAction= new GotoTypeAction(fPart);
+ // fGotoPackageAction= new GotoPackageAction(fPart);
+ // fGotoResourceAction= new GotoResourceAction(fPart);
+ fCollapseAllAction = new CollapseAllAction(fPart);
fToggleLinkingAction = new ToggleLinkingAction(fPart);
fGotoRequiredProjectAction = new GotoRequiredProjectAction(fPart);
}
@@ -141,8 +142,8 @@
super.dispose();
}
-
- //---- Persistent state -----------------------------------------------------------------------
+ // ---- Persistent state
+ // -----------------------------------------------------------------------
protected void restoreFilterAndSorterState(IMemento memento) {
fViewActionGroup.restoreState(memento);
@@ -154,7 +155,8 @@
fCustomFiltersActionGroup.saveState(memento);
}
- //---- Action Bars ----------------------------------------------------------------------------
+ // ---- Action Bars
+ // ----------------------------------------------------------------------------
@Override
public void fillActionBars(IActionBars actionBars) {
@@ -174,13 +176,20 @@
protected void setGlobalActionHandlers(IActionBars actionBars) {
// Navigate Go Into and Go To actions.
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, fZoomInAction);
- actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(), fBackAction);
- actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(), fForwardAction);
- actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP, fUpAction);
- //actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE, fGotoResourceAction);
- //actionBars.setGlobalActionHandler(DLTKActionConstants.GOTO_TYPE, fGotoTypeAction);
- //actionBars.setGlobalActionHandler(DLTKActionConstants.GOTO_PACKAGE, fGotoPackageAction);
+ actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO,
+ fZoomInAction);
+ actionBars.setGlobalActionHandler(ActionFactory.BACK.getId(),
+ fBackAction);
+ actionBars.setGlobalActionHandler(ActionFactory.FORWARD.getId(),
+ fForwardAction);
+ actionBars.setGlobalActionHandler(IWorkbenchActionConstants.UP,
+ fUpAction);
+ // actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_TO_RESOURCE,
+ // fGotoResourceAction);
+ // actionBars.setGlobalActionHandler(DLTKActionConstants.GOTO_TYPE,
+ // fGotoTypeAction);
+ // actionBars.setGlobalActionHandler(DLTKActionConstants.GOTO_PACKAGE,
+ // fGotoPackageAction);
fRefactorActionGroup.retargetFileMenuActions(actionBars);
}
@@ -200,19 +209,23 @@
menu.add(fToggleLinkingAction);
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
+ menu.add(
+ new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end"));//$NON-NLS-1$
}
- //---- Context menu -------------------------------------------------------------------------
+ // ---- Context menu
+ // -------------------------------------------------------------------------
@Override
public void fillContextMenu(IMenuManager menu) {
- IStructuredSelection selection= (IStructuredSelection)getContext().getSelection();
- int size= selection.size();
- Object element= selection.getFirstElement();
+ IStructuredSelection selection = (IStructuredSelection) getContext()
+ .getSelection();
+ int size = selection.size();
+ Object element = selection.getFirstElement();
if (element instanceof BuildPathContainer.RequiredProjectWrapper)
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fGotoRequiredProjectAction);
+ menu.appendToGroup(IContextMenuConstants.GROUP_SHOW,
+ fGotoRequiredProjectAction);
addGotoMenu(menu, element, size);
@@ -221,8 +234,10 @@
super.fillContextMenu(menu);
}
- protected void addGotoMenu(IMenuManager menu, Object element, int size) {
- boolean enabled= size == 1 && fPart.getTreeViewer().isExpandable(element) && (isGoIntoTarget(element) || element instanceof IContainer);
+ protected void addGotoMenu(IMenuManager menu, Object element, int size) {
+ boolean enabled = size == 1
+ && fPart.getTreeViewer().isExpandable(element)
+ && (isGoIntoTarget(element) || element instanceof IContainer);
fZoomInAction.setEnabled(enabled);
if (enabled)
menu.appendToGroup(IContextMenuConstants.GROUP_GOTO, fZoomInAction);
@@ -232,10 +247,10 @@
if (element == null)
return false;
if (element instanceof IModelElement) {
- int type= ((IModelElement)element).getElementType();
- return type == IModelElement.SCRIPT_PROJECT ||
- type == IModelElement.PROJECT_FRAGMENT ||
- type == IModelElement.SCRIPT_FOLDER;
+ int type = ((IModelElement) element).getElementType();
+ return type == IModelElement.SCRIPT_PROJECT
+ || type == IModelElement.PROJECT_FRAGMENT
+ || type == IModelElement.SCRIPT_FOLDER;
}
if (element instanceof IWorkingSet) {
return true;
@@ -245,49 +260,60 @@
protected void addOpenNewWindowAction(IMenuManager menu, Object element) {
if (element instanceof IModelElement) {
- element= ((IModelElement)element).getResource();
+ element = ((IModelElement) element).getResource();
}
- // fix for 64890 Package explorer out of sync when open/closing projects [package explorer] 64890
- if (element instanceof IProject && !((IProject)element).isOpen())
+ // fix for 64890 Package explorer out of sync when open/closing projects
+ // [package explorer] 64890
+ if (element instanceof IProject && !((IProject) element).isOpen())
return;
if (!(element instanceof IContainer))
return;
- menu.appendToGroup(
- IContextMenuConstants.GROUP_OPEN,
- new OpenInNewWindowAction(fPart.getSite().getWorkbenchWindow(), (IContainer)element));
+ menu.appendToGroup(IContextMenuConstants.GROUP_OPEN,
+ new OpenInNewWindowAction(fPart.getSite().getWorkbenchWindow(),
+ (IContainer) element));
}
- //---- Key board and mouse handling ------------------------------------------------------------
+ // ---- Key board and mouse handling
+ // ------------------------------------------------------------
protected void handleDoubleClick(DoubleClickEvent event) {
- TreeViewer viewer= fPart.getTreeViewer();
- IStructuredSelection selection= (IStructuredSelection)event.getSelection();
- Object element= selection.getFirstElement();
+ TreeViewer viewer = fPart.getTreeViewer();
+ IStructuredSelection selection = (IStructuredSelection) event
+ .getSelection();
+ Object element = selection.getFirstElement();
if (viewer.isExpandable(element)) {
if (doubleClickGoesInto()) {
// don't zoom into compilation units and class files
if (element instanceof ISourceModule)
return;
- if (element instanceof IOpenable || element instanceof IContainer || element instanceof IWorkingSet) {
+ if (element instanceof IOpenable
+ || element instanceof IContainer
+ || element instanceof IWorkingSet) {
fZoomInAction.run();
}
} else {
- IAction openAction= fNavigateActionGroup.getOpenAction();
- if (openAction != null && openAction.isEnabled() && OpenStrategy.getOpenMethod() == OpenStrategy.DOUBLE_CLICK)
+ IAction openAction = fNavigateActionGroup.getOpenAction();
+ if (openAction != null && openAction.isEnabled() && OpenStrategy
+ .getOpenMethod() == OpenStrategy.DOUBLE_CLICK)
return;
if (selection instanceof ITreeSelection) {
- TreePath[] paths= ((ITreeSelection)selection).getPathsFor(element);
- for (int i= 0; i < paths.length; i++) {
- viewer.setExpandedState(paths[i], !viewer.getExpandedState(paths[i]));
+ TreePath[] paths = ((ITreeSelection) selection)
+ .getPathsFor(element);
+ for (int i = 0; i < paths.length; i++) {
+ viewer.setExpandedState(paths[i],
+ !viewer.getExpandedState(paths[i]));
}
} else {
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
+ viewer.setExpandedState(element,
+ !viewer.getExpandedState(element));
}
}
- } else if (element instanceof IProject && !((IProject) element).isOpen()) {
- OpenProjectAction openProjectAction= fProjectActionGroup.getOpenProjectAction();
+ } else if (element instanceof IProject
+ && !((IProject) element).isOpen()) {
+ OpenProjectAction openProjectAction = fProjectActionGroup
+ .getOpenProjectAction();
if (openProjectAction.isEnabled()) {
openProjectAction.run();
}
@@ -295,7 +321,7 @@
}
protected void handleOpen(OpenEvent event) {
- IAction openAction= fNavigateActionGroup.getOpenAction();
+ IAction openAction = fNavigateActionGroup.getOpenAction();
if (openAction != null && openAction.isEnabled()) {
openAction.run();
return;
@@ -309,45 +335,49 @@
if (event.keyCode == SWT.BS) {
if (fUpAction != null && fUpAction.isEnabled()) {
fUpAction.run();
- event.doit= false;
+ event.doit = false;
}
}
}
protected void doWorkingSetChanged(PropertyChangeEvent event) {
if (ViewActionGroup.MODE_CHANGED.equals(event.getProperty())) {
- fPart.rootModeChanged(((Integer)event.getNewValue()).intValue());
- Object oldInput= null;
- Object newInput= null;
+ fPart.rootModeChanged(((Integer) event.getNewValue()).intValue());
+ Object oldInput = null;
+ Object newInput = null;
if (fPart.getRootMode() == ScriptExplorerPart.PROJECTS_AS_ROOTS) {
- oldInput= fPart.getWorkingSetModel();
- newInput= DLTKCore.create(ResourcesPlugin.getWorkspace().getRoot());
- } else if (fPart.getRootMode() == ScriptExplorerPart.WORKING_SETS_AS_ROOTS) {
- oldInput= DLTKCore.create(ResourcesPlugin.getWorkspace().getRoot());
- newInput= fPart.getWorkingSetModel();
+ oldInput = fPart.getWorkingSetModel();
+ newInput = DLTKCore
+ .create(ResourcesPlugin.getWorkspace().getRoot());
+ } else if (fPart
+ .getRootMode() == ScriptExplorerPart.WORKING_SETS_AS_ROOTS) {
+ oldInput = DLTKCore
+ .create(ResourcesPlugin.getWorkspace().getRoot());
+ newInput = fPart.getWorkingSetModel();
}
if (oldInput != null && newInput != null) {
Frame frame;
- for (int i= 0; (frame= fFrameList.getFrame(i)) != null; i++) {
+ for (int i = 0; (frame = fFrameList.getFrame(i)) != null; i++) {
if (frame instanceof TreeFrame) {
- TreeFrame treeFrame= (TreeFrame)frame;
+ TreeFrame treeFrame = (TreeFrame) frame;
if (oldInput.equals(treeFrame.getInput()))
treeFrame.setInput(newInput);
}
}
}
} else {
- IWorkingSet workingSet= (IWorkingSet) event.getNewValue();
+ IWorkingSet workingSet = (IWorkingSet) event.getNewValue();
- String workingSetLabel= null;
+ String workingSetLabel = null;
if (workingSet != null)
- workingSetLabel= workingSet.getLabel();
+ workingSetLabel = workingSet.getLabel();
fPart.setWorkingSetLabel(workingSetLabel);
fPart.updateTitle();
- String property= event.getProperty();
- if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- TreeViewer viewer= fPart.getTreeViewer();
+ String property = event.getProperty();
+ if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE
+ .equals(property)) {
+ TreeViewer viewer = fPart.getTreeViewer();
viewer.getControl().setRedraw(false);
viewer.refresh();
viewer.getControl().setRedraw(true);
@@ -356,7 +386,9 @@
}
private boolean doubleClickGoesInto() {
- return PreferenceConstants.DOUBLE_CLICK_GOES_INTO.equals(DLTKUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.DOUBLE_CLICK));
+ return PreferenceConstants.DOUBLE_CLICK_GOES_INTO
+ .equals(DLTKUIPlugin.getDefault().getPreferenceStore()
+ .getString(PreferenceConstants.DOUBLE_CLICK));
}
public FrameAction getUpAction() {
@@ -366,16 +398,17 @@
public FrameAction getBackAction() {
return fBackAction;
}
+
public FrameAction getForwardAction() {
return fForwardAction;
}
public ViewActionGroup getWorkingSetActionGroup() {
- return fViewActionGroup;
+ return fViewActionGroup;
}
public CustomFiltersActionGroup getCustomFilterActionGroup() {
- return fCustomFiltersActionGroup;
+ return fCustomFiltersActionGroup;
}
public FrameList getFrameList() {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
index 651db61..bd36b03 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/scriptview/ScriptExplorerPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -75,7 +75,6 @@
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
@@ -149,9 +148,6 @@
public static final int PROJECTS_AS_ROOTS = 1;
public static final int WORKING_SETS_AS_ROOTS = 2;
- @Deprecated
- public final static String VIEW_ID = DLTKUIPlugin.ID_SCRIPT_EXPLORER;
-
// Persistence tags.
private static final String TAG_LAYOUT = "layout"; //$NON-NLS-1$
private static final String TAG_GROUP_LIBRARIES = "group_libraries"; //$NON-NLS-1$
@@ -256,13 +252,6 @@
super.add(parentElement, childElements);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.AbstractTreeViewer#internalRefresh(java
- * .lang.Object, boolean)
- */
@Override
protected void internalRefresh(Object element, boolean updateLabels) {
try {
@@ -1429,20 +1418,6 @@
}
}
- /**
- * Sets the decorator for the package explorer.
- *
- * @param decorator
- * a label decorator or <code>null</code> for no decorations.
- * @deprecated To be removed
- */
- @Deprecated
- public void setLabelDecorator(ILabelDecorator decorator) {
- }
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
@Override
public void propertyChange(PropertyChangeEvent event) {
if (fViewer == null) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/NewSearchViewActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/NewSearchViewActionGroup.java
index bdba19f..df87db2 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/NewSearchViewActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/search/NewSearchViewActionGroup.java
@@ -1,11 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
-
*******************************************************************************/
package org.eclipse.dltk.internal.ui.search;
@@ -17,25 +16,23 @@
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionGroup;
-
class NewSearchViewActionGroup extends CompositeActionGroup {
NavigateActionGroup fNavigateActionGroup;
-
+
public NewSearchViewActionGroup(IViewPart part) {
- setGroups(new ActionGroup[]{
- fNavigateActionGroup= new NavigateActionGroup(part),
-// new GenerateActionGroup(part),
- new RefactorActionGroup(part),
-// new DLTKSearchActionGroup(part, toolkit)
- });
+ setGroups(new ActionGroup[] {
+ fNavigateActionGroup = new NavigateActionGroup(part),
+ // new GenerateActionGroup(part),
+ new RefactorActionGroup(part, null),
+ // new DLTKSearchActionGroup(part, toolkit)
+ });
}
-
+
public void handleOpen(OpenEvent event) {
- IAction openAction= fNavigateActionGroup.getOpenAction();
+ IAction openAction = fNavigateActionGroup.getOpenAction();
if (openAction != null && openAction.isEnabled()) {
openAction.run();
return;
}
}
}
-
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
index b6d9581..4eb213e 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/typehierarchy/TypeHierarchyViewPart.java
@@ -940,8 +940,8 @@
new OpenEditorActionGroup(this),
new OpenViewActionGroup(this), new CCPActionGroup(this),
// new GenerateActionGroup(this),
- new RefactorActionGroup(
- this) /*
+ new RefactorActionGroup(this,
+ null) /*
* , new DLTKSearchActionGroup(this,
* getLanguageToolkit())
*/
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BuildpathContainerWizard.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BuildpathContainerWizard.java
index fbf4e40..1c7b952 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BuildpathContainerWizard.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/BuildpathContainerWizard.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,8 +25,6 @@
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
-/**
- */
public class BuildpathContainerWizard extends Wizard {
private BuildpathContainerDescriptor fPageDesc;
@@ -74,27 +72,10 @@
setWindowTitle(title);
}
- /**
- * @deprecated use getNewEntries()
- */
- @Deprecated
- public IBuildpathEntry getNewEntry() {
- IBuildpathEntry[] entries = getNewEntries();
- if (entries != null) {
- return entries[0];
- }
- return null;
- }
-
public IBuildpathEntry[] getNewEntries() {
return fNewEntries;
}
- /*
- * (non-Javadoc)
- *
- * @see IWizard#performFinish()
- */
@Override
public boolean performFinish() {
if (fContainerPage != null) {
@@ -105,7 +86,8 @@
.getNewContainers();
} else {
IBuildpathEntry entry = fContainerPage.getSelection();
- fNewEntries = (entry != null) ? new IBuildpathEntry[] { entry }
+ fNewEntries = (entry != null)
+ ? new IBuildpathEntry[] { entry }
: null;
}
return true;
@@ -114,11 +96,6 @@
return false;
}
- /*
- * (non-Javadoc)
- *
- * @see IWizard#addPages()
- */
@Override
public void addPages() {
if (fPageDesc != null) {
@@ -187,8 +164,8 @@
}
if (containerPage instanceof IBuildpathContainerPageExtension) {
- ((IBuildpathContainerPageExtension) containerPage).initialize(
- fCurrProject, fCurrBuildpath);
+ ((IBuildpathContainerPageExtension) containerPage)
+ .initialize(fCurrProject, fCurrBuildpath);
}
containerPage.setSelection(fEntryToEdit);
@@ -196,11 +173,6 @@
return containerPage;
}
- /*
- * (non-Javadoc)
- *
- * @see IWizard#getNextPage(IWizardPage)
- */
@Override
public IWizardPage getNextPage(IWizardPage page) {
if (page == fSelectionWizardPage) {
@@ -241,11 +213,6 @@
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#dispose()
- */
@Override
public void dispose() {
if (fSelectionWizardPage != null) {
@@ -258,11 +225,6 @@
super.dispose();
}
- /*
- * (non-Javadoc)
- *
- * @see IWizard#canFinish()
- */
@Override
public boolean canFinish() {
if (fSelectionWizardPage != null) {
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java
index 2387cd8..a5f0fe6 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/internal/ui/wizards/buildpath/newsourcepage/DialogPackageExplorerActionGroup.java
@@ -41,7 +41,6 @@
import org.eclipse.dltk.internal.ui.util.ViewerPane;
import org.eclipse.dltk.internal.ui.wizards.NewWizardMessages;
import org.eclipse.dltk.ui.DLTKPluginImages;
-import org.eclipse.dltk.ui.DLTKUIPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
@@ -54,10 +53,11 @@
import org.eclipse.ui.actions.ActionContext;
/**
- * Action group for the package explorer. Creates and manages a set
- * of <code>BuildpathModifierOperation</code>s and creates a <code>ToolBarManager</code>
- * on request. Based on this operations, <code>BuildpathModifierAction</code>s are generated.
- * The available operations are:
+ * Action group for the package explorer. Creates and manages a set of
+ * <code>BuildpathModifierOperation</code>s and creates a
+ * <code>ToolBarManager</code> on request. Based on this operations,
+ * <code>BuildpathModifierAction</code>s are generated. The available operations
+ * are:
*
* @see org.eclipse.dltk.internal.corext.buildpath.AddSelectedSourceFolderOperation
* @see org.eclipse.dltk.internal.corext.buildpath.RemoveFromBuildpathOperation
@@ -70,192 +70,232 @@
*/
public class DialogPackageExplorerActionGroup extends CompositeActionGroup {
- public static class DialogExplorerActionContext extends ActionContext {
- private IScriptProject fScriptProject;
- private List fSelectedElements;
+ public static class DialogExplorerActionContext extends ActionContext {
+ private IScriptProject fScriptProject;
+ private List fSelectedElements;
- /**
- * Constructor to create an action context for the dialog package explorer.
- *
- * For reasons of completeness, the selection of the super class
- * <code>ActionContext</code> is also set, but is not intendet to be used.
- *
- * @param selection the current selection
- * @param jProject the element's script project
- */
- public DialogExplorerActionContext(ISelection selection, IScriptProject jProject) {
- super(null);
- fScriptProject= jProject;
- fSelectedElements= ((IStructuredSelection)selection).toList();
- IStructuredSelection structuredSelection= new StructuredSelection(new Object[] {fSelectedElements, jProject});
- super.setSelection(structuredSelection);
- }
+ /**
+ * Constructor to create an action context for the dialog package
+ * explorer.
+ *
+ * For reasons of completeness, the selection of the super class
+ * <code>ActionContext</code> is also set, but is not intendet to be
+ * used.
+ *
+ * @param selection
+ * the current selection
+ * @param jProject
+ * the element's script project
+ */
+ public DialogExplorerActionContext(ISelection selection,
+ IScriptProject jProject) {
+ super(null);
+ fScriptProject = jProject;
+ fSelectedElements = ((IStructuredSelection) selection).toList();
+ IStructuredSelection structuredSelection = new StructuredSelection(
+ new Object[] { fSelectedElements, jProject });
+ super.setSelection(structuredSelection);
+ }
- /**
- * Constructor to create an action context for the dialog package explorer.
- *
- * For reasons of completeness, the selection of the super class
- * <code>ActionContext</code> is also set, but is not intendet to be used.
- *
- * @param selectedElements a list of currently selected elements
- * @param jProject the element's script project
- */
- public DialogExplorerActionContext(List selectedElements, IScriptProject jProject) {
- super(null);
- fScriptProject= jProject;
- fSelectedElements= selectedElements;
- IStructuredSelection structuredSelection= new StructuredSelection(new Object[] {fSelectedElements, jProject});
- super.setSelection(structuredSelection);
- }
+ /**
+ * Constructor to create an action context for the dialog package
+ * explorer.
+ *
+ * For reasons of completeness, the selection of the super class
+ * <code>ActionContext</code> is also set, but is not intendet to be
+ * used.
+ *
+ * @param selectedElements
+ * a list of currently selected elements
+ * @param jProject
+ * the element's script project
+ */
+ public DialogExplorerActionContext(List selectedElements,
+ IScriptProject jProject) {
+ super(null);
+ fScriptProject = jProject;
+ fSelectedElements = selectedElements;
+ IStructuredSelection structuredSelection = new StructuredSelection(
+ new Object[] { fSelectedElements, jProject });
+ super.setSelection(structuredSelection);
+ }
- public IScriptProject getScriptProject() {
- return fScriptProject;
- }
+ public IScriptProject getScriptProject() {
+ return fScriptProject;
+ }
- public List getSelectedElements() {
- return fSelectedElements;
- }
- }
+ public List getSelectedElements() {
+ return fSelectedElements;
+ }
+ }
- /** script project */
- public static final int SCRIPT_PROJECT= 0x01;
- /** Package fragment root */
- public static final int PACKAGE_FRAGMENT_ROOT= 0x02;
- /** Package fragment */
- public static final int PACKAGE_FRAGMENT= 0x03;
- /** Compilation unit */
- public static final int SOURCE_MODULE= 0x04;
- /** File */
- public static final int FILE= 0x05;
- /** Normal folder */
- public static final int FOLDER= 0x06;
- /** Excluded folder */
- public static final int EXCLUDED_FOLDER= 0x07;
- /** Excluded file */
- public static final int EXCLUDED_FILE= 0x08;
- /** Included file */
- public static final int INCLUDED_FILE= 0xA;
- /** Included folder */
- public static final int INCLUDED_FOLDER= 0xB;
- /** An archive element */
- public static final int ARCHIVE= 0xD;
- /** A IProjectFragment with include/exclude filters set */
- public static final int MODIFIED_FRAGMENT_ROOT= 0xE;
- /** Default package fragment */
- public static final int DEFAULT_FRAGMENT= 0xF;
- /** Undefined type */
- public static final int UNDEFINED= 0x10;
- /** Multi selection */
- public static final int MULTI= 0x11;
- /** No elements selected */
- public static final int NULL_SELECTION= 0x12;
- /** Elements that are contained in an archive */
- public static final int ARCHIVE_RESOURCE= 0x13;
+ /** script project */
+ public static final int SCRIPT_PROJECT = 0x01;
+ /** Package fragment root */
+ public static final int PACKAGE_FRAGMENT_ROOT = 0x02;
+ /** Package fragment */
+ public static final int PACKAGE_FRAGMENT = 0x03;
+ /** Compilation unit */
+ public static final int SOURCE_MODULE = 0x04;
+ /** File */
+ public static final int FILE = 0x05;
+ /** Normal folder */
+ public static final int FOLDER = 0x06;
+ /** Excluded folder */
+ public static final int EXCLUDED_FOLDER = 0x07;
+ /** Excluded file */
+ public static final int EXCLUDED_FILE = 0x08;
+ /** Included file */
+ public static final int INCLUDED_FILE = 0xA;
+ /** Included folder */
+ public static final int INCLUDED_FOLDER = 0xB;
+ /** An archive element */
+ public static final int ARCHIVE = 0xD;
+ /** A IProjectFragment with include/exclude filters set */
+ public static final int MODIFIED_FRAGMENT_ROOT = 0xE;
+ /** Default package fragment */
+ public static final int DEFAULT_FRAGMENT = 0xF;
+ /** Undefined type */
+ public static final int UNDEFINED = 0x10;
+ /** Multi selection */
+ public static final int MULTI = 0x11;
+ /** No elements selected */
+ public static final int NULL_SELECTION = 0x12;
+ /** Elements that are contained in an archive */
+ public static final int ARCHIVE_RESOURCE = 0x13;
- public static final int EXTERNAL_RESOURCE= 0x15;
- /** Elements that represent Buildpath container (= libraries) */
- public static final int CONTAINER= 0x14;
+ public static final int EXTERNAL_RESOURCE = 0x15;
+ /** Elements that represent Buildpath container (= libraries) */
+ public static final int CONTAINER = 0x14;
- private BuildpathModifierAction[] fActions;
- private int fLastType;
- private List fListeners;
- private static final int fContextSensitiveActions= 5;
+ private BuildpathModifierAction[] fActions;
+ private int fLastType;
+ private List fListeners;
+ private static final int fContextSensitiveActions = 5;
- /**
- * Constructor which creates the operations and based on this
- * operations the actions.
- *
- * @param provider a information provider to pass necessary information
- * to the operations
- * @param listener a listener for the changes on Buildpath entries, that is
- * the listener will be notified whenever a Buildpath entry changed.
- * @see IBuildpathModifierListener
- */
- public DialogPackageExplorerActionGroup(IBuildpathInformationProvider provider, IBuildpathModifierListener listener) {
- super();
- fLastType= UNDEFINED;
- fListeners= new ArrayList();
- fActions= new BuildpathModifierAction[8];
- BuildpathModifierOperation op;
- op= new AddSelectedSourceFolderOperation(listener, provider);
- // TODO User disabled image when available
- addAction(new BuildpathModifierAction(op, DLTKPluginImages.DESC_ELCL_ADD_AS_SOURCE_FOLDER, null,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_label,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_tooltip, IAction.AS_PUSH_BUTTON),
- 0);
- op= new RemoveFromBuildpathOperation(listener, provider);
- addAction(new BuildpathModifierAction(op, DLTKPluginImages.DESC_ELCL_REMOVE_AS_SOURCE_FOLDER, DLTKPluginImages.DESC_DLCL_REMOVE_AS_SOURCE_FOLDER,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_label,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_tooltip, IAction.AS_PUSH_BUTTON),
- 1);
- op= new ExcludeOperation(listener, provider);
- addAction(new BuildpathModifierAction(op, DLTKPluginImages.DESC_ELCL_EXCLUDE_FROM_BUILDPATH, DLTKPluginImages.DESC_DLCL_EXCLUDE_FROM_BUILDPATH,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_label,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_tooltip, IAction.AS_PUSH_BUTTON),
- 2);
- op= new UnexcludeOperation(listener, provider);
- addAction(new BuildpathModifierAction(op, DLTKPluginImages.DESC_ELCL_INCLUDE_ON_BUILDPATH, DLTKPluginImages.DESC_DLCL_INCLUDE_ON_BUILDPATH,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Unexclude_label,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Unexclude_tooltip, IAction.AS_PUSH_BUTTON),
- 3);
- op= new EditFiltersOperation(listener, provider);
- BuildpathModifierAction action= new BuildpathModifierAction(op, DLTKPluginImages.DESC_ELCL_CONFIGURE_BUILDPATH_FILTERS, DLTKPluginImages.DESC_DLCL_CONFIGURE_BUILDPATH_FILTERS,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_label,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_tooltip, IAction.AS_PUSH_BUTTON);
- BuildpathModifierDropDownAction dropDown= new BuildpathModifierDropDownAction(action,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Configure_label,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Configure_tooltip);
- addAction(dropDown, 4);
+ /**
+ * Constructor which creates the operations and based on this operations the
+ * actions.
+ *
+ * @param provider
+ * a information provider to pass necessary information to the
+ * operations
+ * @param listener
+ * a listener for the changes on Buildpath entries, that is the
+ * listener will be notified whenever a Buildpath entry changed.
+ * @see IBuildpathModifierListener
+ */
+ public DialogPackageExplorerActionGroup(
+ IBuildpathInformationProvider provider,
+ IBuildpathModifierListener listener) {
+ super();
+ fLastType = UNDEFINED;
+ fListeners = new ArrayList();
+ fActions = new BuildpathModifierAction[8];
+ BuildpathModifierOperation op;
+ op = new AddSelectedSourceFolderOperation(listener, provider);
+ // TODO User disabled image when available
+ addAction(new BuildpathModifierAction(op,
+ DLTKPluginImages.DESC_ELCL_ADD_AS_SOURCE_FOLDER, null,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_tooltip,
+ IAction.AS_PUSH_BUTTON), 0);
+ op = new RemoveFromBuildpathOperation(listener, provider);
+ addAction(new BuildpathModifierAction(op,
+ DLTKPluginImages.DESC_ELCL_REMOVE_AS_SOURCE_FOLDER,
+ DLTKPluginImages.DESC_DLCL_REMOVE_AS_SOURCE_FOLDER,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_tooltip,
+ IAction.AS_PUSH_BUTTON), 1);
+ op = new ExcludeOperation(listener, provider);
+ addAction(new BuildpathModifierAction(op,
+ DLTKPluginImages.DESC_ELCL_EXCLUDE_FROM_BUILDPATH,
+ DLTKPluginImages.DESC_DLCL_EXCLUDE_FROM_BUILDPATH,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_tooltip,
+ IAction.AS_PUSH_BUTTON), 2);
+ op = new UnexcludeOperation(listener, provider);
+ addAction(new BuildpathModifierAction(op,
+ DLTKPluginImages.DESC_ELCL_INCLUDE_ON_BUILDPATH,
+ DLTKPluginImages.DESC_DLCL_INCLUDE_ON_BUILDPATH,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Unexclude_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Unexclude_tooltip,
+ IAction.AS_PUSH_BUTTON), 3);
+ op = new EditFiltersOperation(listener, provider);
+ BuildpathModifierAction action = new BuildpathModifierAction(op,
+ DLTKPluginImages.DESC_ELCL_CONFIGURE_BUILDPATH_FILTERS,
+ DLTKPluginImages.DESC_DLCL_CONFIGURE_BUILDPATH_FILTERS,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_tooltip,
+ IAction.AS_PUSH_BUTTON);
+ BuildpathModifierDropDownAction dropDown = new BuildpathModifierDropDownAction(
+ action,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Configure_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Configure_tooltip);
+ addAction(dropDown, 4);
- /*addAction(new BuildpathModifierAction(op, DLTKPluginImages.DESC_OBJS_TEXT_EDIT, DLTKPluginImages.DESC_DLCL_TEXT_EDIT,
- NewWizardMessages.getString("NewSourceContainerWorkbookPage.ToolBar.Edit.label"), //$NON-NLS-1$
- NewWizardMessages.getString("NewSourceContainerWorkbookPage.ToolBar.Edit.tooltip"), IAction.AS_PUSH_BUTTON), //$NON-NLS-1$
- IBuildpathInformationProvider.EDIT);*/
- op= new LinkedSourceFolderOperation(listener, provider);
- addAction(new BuildpathModifierAction(op, DLTKPluginImages.DESC_ELCL_ADD_LINKED_SOURCE_TO_BUILDPATH, DLTKPluginImages.DESC_DLCL_ADD_LINKED_SOURCE_TO_BUILDPATH,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_label,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_tooltip, IAction.AS_PUSH_BUTTON),
- 5);
- op= new CreateFolderOperation(listener, provider);
- addAction(new BuildpathModifierAction(op, DLTKPluginImages.DESC_OBJS_PACKFRAG_ROOT, null,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_CreateSrcFolder_label, NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_CreateSrcFolder_tooltip
- , IAction.AS_PUSH_BUTTON), 6);
- op= new ResetAllOperation(listener, provider);
- addAction(new BuildpathModifierAction(op, DLTKPluginImages.DESC_ELCL_CLEAR, DLTKPluginImages.DESC_DLCL_CLEAR,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_ClearAll_label,
- NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_ClearAll_tooltip, IAction.AS_PUSH_BUTTON),
- 7);
- }
+ /*
+ * addAction(new BuildpathModifierAction(op,
+ * DLTKPluginImages.DESC_OBJS_TEXT_EDIT,
+ * DLTKPluginImages.DESC_DLCL_TEXT_EDIT, NewWizardMessages.getString(
+ * "NewSourceContainerWorkbookPage.ToolBar.Edit.label"), //$NON-NLS-1$
+ * NewWizardMessages.getString(
+ * "NewSourceContainerWorkbookPage.ToolBar.Edit.tooltip"),
+ * IAction.AS_PUSH_BUTTON), //$NON-NLS-1$
+ * IBuildpathInformationProvider.EDIT);
+ */
+ op = new LinkedSourceFolderOperation(listener, provider);
+ addAction(new BuildpathModifierAction(op,
+ DLTKPluginImages.DESC_ELCL_ADD_LINKED_SOURCE_TO_BUILDPATH,
+ DLTKPluginImages.DESC_DLCL_ADD_LINKED_SOURCE_TO_BUILDPATH,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_tooltip,
+ IAction.AS_PUSH_BUTTON), 5);
+ op = new CreateFolderOperation(listener, provider);
+ addAction(new BuildpathModifierAction(op,
+ DLTKPluginImages.DESC_OBJS_PACKFRAG_ROOT, null,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_CreateSrcFolder_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_CreateSrcFolder_tooltip,
+ IAction.AS_PUSH_BUTTON), 6);
+ op = new ResetAllOperation(listener, provider);
+ addAction(new BuildpathModifierAction(op,
+ DLTKPluginImages.DESC_ELCL_CLEAR,
+ DLTKPluginImages.DESC_DLCL_CLEAR,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_ClearAll_label,
+ NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_ClearAll_tooltip,
+ IAction.AS_PUSH_BUTTON), 7);
+ }
- private void addAction(BuildpathModifierAction action, int index) {
- fActions[index]= action;
- }
+ private void addAction(BuildpathModifierAction action, int index) {
+ fActions[index] = action;
+ }
- /**
- * Get an action of the specified type
- *
- * @param type the type of the desired action, must be a
- * constante of <code>IBuildpathInformationProvider</code>
- * @return the requested action
- *
- * @see IBuildpathInformationProvider
- */
- public BuildpathModifierAction getAction(int type) {
- for (int i= 0; i < fActions.length; i++) {
+ /**
+ * Get an action of the specified type
+ *
+ * @param type
+ * the type of the desired action, must be a constante of
+ * <code>IBuildpathInformationProvider</code>
+ * @return the requested action
+ *
+ * @see IBuildpathInformationProvider
+ */
+ public BuildpathModifierAction getAction(int type) {
+ for (int i = 0; i < fActions.length; i++) {
if (fActions[i].getOperation().getTypeId() == type)
return fActions[i];
}
- throw new ArrayIndexOutOfBoundsException();
- }
+ throw new ArrayIndexOutOfBoundsException();
+ }
- public BuildpathModifierAction[] getActions() {
+ public BuildpathModifierAction[] getActions() {
List<BuildpathModifierAction> result = new ArrayList<BuildpathModifierAction>();
- for (int i= 0; i < fActions.length; i++) {
- BuildpathModifierAction action= fActions[i];
+ for (int i = 0; i < fActions.length; i++) {
+ BuildpathModifierAction action = fActions[i];
if (action instanceof BuildpathModifierDropDownAction) {
- BuildpathModifierDropDownAction dropDownAction= (BuildpathModifierDropDownAction)action;
- BuildpathModifierAction[] actions= dropDownAction.getActions();
- for (int j= 0; j < actions.length; j++) {
+ BuildpathModifierDropDownAction dropDownAction = (BuildpathModifierDropDownAction) action;
+ BuildpathModifierAction[] actions = dropDownAction.getActions();
+ for (int j = 0; j < actions.length; j++) {
result.add(actions[j]);
}
} else {
@@ -263,489 +303,534 @@
}
}
return result.toArray(new BuildpathModifierAction[result.size()]);
- }
+ }
+ /**
+ * Create a toolbar manager for a given <code>ViewerPane</code>
+ *
+ * @param pane
+ * the pane to create the <code>
+ * ToolBarManager</code> for.
+ * @return the created <code>ToolBarManager</code>
+ */
+ public ToolBarManager createLeftToolBarManager(ViewerPane pane) {
+ ToolBarManager tbm = pane.getToolBarManager();
+ for (int i = 0; i < fContextSensitiveActions; i++) {
+ tbm.add(fActions[i]);
+ if (i == 1 || i == 3)
+ tbm.add(new Separator());
+ }
+ tbm.update(true);
+ return tbm;
+ }
- /**
- * Create a toolbar manager for a given
- * <code>ViewerPane</code>
- *
- * @param pane the pane to create the <code>
- * ToolBarManager</code> for.
- * @return the created <code>ToolBarManager</code>
- */
- public ToolBarManager createLeftToolBarManager(ViewerPane pane) {
- ToolBarManager tbm= pane.getToolBarManager();
- for (int i= 0; i < fContextSensitiveActions; i++) {
- tbm.add(fActions[i]);
- if (i == 1 || i == 3)
- tbm.add(new Separator());
- }
- tbm.update(true);
- return tbm;
- }
-
- /**
- * Create a toolbar manager for a given
- * <code>ViewerPane</code>
- *
- * @param pane the pane to create the help toolbar for
- * @return the created <code>ToolBarManager</code>
- */
- public ToolBarManager createLeftToolBar(ViewerPane pane) {
- ToolBar tb= new ToolBar(pane, SWT.FLAT);
- pane.setTopRight(tb);
- ToolBarManager tbm= new ToolBarManager(tb);
- for (int i= fContextSensitiveActions; i < fActions.length; i++) {
- tbm.add(fActions[i]);
- }
- if (DLTKCore.DEBUG) {
+ /**
+ * Create a toolbar manager for a given <code>ViewerPane</code>
+ *
+ * @param pane
+ * the pane to create the help toolbar for
+ * @return the created <code>ToolBarManager</code>
+ */
+ public ToolBarManager createLeftToolBar(ViewerPane pane) {
+ ToolBar tb = new ToolBar(pane, SWT.FLAT);
+ pane.setTopRight(tb);
+ ToolBarManager tbm = new ToolBarManager(tb);
+ for (int i = fContextSensitiveActions; i < fActions.length; i++) {
+ tbm.add(fActions[i]);
+ }
+ if (DLTKCore.DEBUG) {
System.err.println("Add help support here..."); //$NON-NLS-1$
}
- //tbm.add(new HelpAction());
- tbm.update(true);
- return tbm;
- }
+ // tbm.add(new HelpAction());
+ tbm.update(true);
+ return tbm;
+ }
- /**
- * Forces the action group to recompute the available actions
- * and fire an event to all listeners
- * @throws ModelException
- *
- * @see #setContext(DialogExplorerActionContext)
- * @see #informListeners(String[], BuildpathModifierAction[])
- */
- public void refresh(DialogExplorerActionContext context) throws ModelException {
- super.setContext(context);
- if (context == null) // can happen when disposing
- return;
- List selectedElements= context.getSelectedElements();
- IScriptProject project= context.getScriptProject();
+ /**
+ * Forces the action group to recompute the available actions and fire an
+ * event to all listeners
+ *
+ * @throws ModelException
+ *
+ * @see #setContext(DialogExplorerActionContext)
+ * @see #informListeners(String[], BuildpathModifierAction[])
+ */
+ public void refresh(DialogExplorerActionContext context)
+ throws ModelException {
+ super.setContext(context);
+ if (context == null) // can happen when disposing
+ return;
+ List selectedElements = context.getSelectedElements();
+ IScriptProject project = context.getScriptProject();
- int type= MULTI;
- if (selectedElements.size() == 0) {
- type= NULL_SELECTION;
+ int type = MULTI;
+ if (selectedElements.size() == 0) {
+ type = NULL_SELECTION;
- if (type == fLastType)
- return;
- } else if (selectedElements.size() == 1 || identicalTypes(selectedElements, project)) {
- type= getType(selectedElements.get(0), project);
- }
+ if (type == fLastType)
+ return;
+ } else if (selectedElements.size() == 1
+ || identicalTypes(selectedElements, project)) {
+ type = getType(selectedElements.get(0), project);
+ }
- internalSetContext(selectedElements, project, type);
- }
+ internalSetContext(selectedElements, project, type);
+ }
- /**
- * Set the context of the action group. Note that this method is deprecated.
- * <ul><li>Clients should use DialogPackageExplorerActionGroup.setContext(DialogExplorerActionContext) instead</li>
- * <li>If this method is called, it is expected that the provided context is of type
- * <code>DialogExplorerActionContext</code>. If this is not the case, the caller will
- * end up with a <code>ClassCastException</code>.
- *
- * @deprecated use instead DialogPackageExplorerActionGroup.setContext(DialogExplorerActionContext)
- *
- * @see #setContext(DialogExplorerActionContext)
- */
- @Override
- @Deprecated
- public void setContext(ActionContext context) {
- try {
- setContext((DialogExplorerActionContext)context);
- } catch (ModelException e) {
- DLTKUIPlugin.log(e);
- }
- }
+ /**
+ * Set the context for the action group. This also includes updating the
+ * actions (that is, enable or disable them). The decision which actions
+ * should be enabled or disabled is based on the content of the
+ * <code>DialogExplorerActionContext</code>
+ *
+ * If the type of the selection changes, then listeners will be notified
+ * about the new set of available actions.
+ *
+ * Note: notification is only done if the TYPE changes (not the selected
+ * object as such). This means that if elements of the same type are
+ * selected (for example two times a folder), NO notification will take
+ * place. There might be situations where the type of two objects is the
+ * same but the set of available actions is not. However, if clients decide
+ * that upon some action a recomputation of the available actions has to be
+ * forced, then
+ * <code>PackageExplorerActionGroup.refresh(DialogExplorerActionContext)</code>
+ * can be called.
+ *
+ * @param context
+ * the action context
+ *
+ * @see IPackageExplorerActionListener
+ * @see PackageExplorerActionEvent
+ * @see DialogExplorerActionContext
+ * @see #addListener(IPackageExplorerActionListener)
+ * @see #refresh(DialogExplorerActionContext)
+ *
+ * @throws ModelException
+ * if there is a failure while computing the available actions.
+ */
+ public void setContext(DialogExplorerActionContext context)
+ throws ModelException {
+ super.setContext(context);
+ if (context == null) // can happen when disposing
+ return;
+ List selectedElements = context.getSelectedElements();
+ IScriptProject project = context.getScriptProject();
- /**
- * Set the context for the action group. This also includes
- * updating the actions (that is, enable or disable them).
- * The decision which actions should be enabled or disabled is based
- * on the content of the <code>DialogExplorerActionContext</code>
- *
- * If the type of the selection changes, then listeners will be notified
- * about the new set of available actions.
- *
- * Note: notification is only done if the TYPE changes (not the selected object
- * as such). This means that if elements of the same type are selected (for
- * example two times a folder), NO notification will take place. There might
- * be situations where the type of two objects is the same but the set of
- * available actions is not. However, if clients decide that upon some action
- * a recomputation of the available actions has to be forced, then
- * <code>PackageExplorerActionGroup.refresh(DialogExplorerActionContext)</code> can be
- * called.
- *
- * @param context the action context
- *
- * @see IPackageExplorerActionListener
- * @see PackageExplorerActionEvent
- * @see DialogExplorerActionContext
- * @see #addListener(IPackageExplorerActionListener)
- * @see #refresh(DialogExplorerActionContext)
- *
- * @throws ModelException if there is a failure while computing the available
- * actions.
- */
- public void setContext(DialogExplorerActionContext context) throws ModelException {
- super.setContext(context);
- if (context == null) // can happen when disposing
- return;
- List selectedElements= context.getSelectedElements();
- IScriptProject project= context.getScriptProject();
+ int type = MULTI;
+ if (selectedElements.size() == 0) {
+ type = NULL_SELECTION;
- int type= MULTI;
- if (selectedElements.size() == 0) {
- type= NULL_SELECTION;
+ if (type == fLastType)
+ return;
+ } else if (selectedElements.size() == 1
+ || identicalTypes(selectedElements, project)) {
+ type = getType(selectedElements.get(0), project);
- if (type == fLastType)
- return;
- }
- else if (selectedElements.size() == 1 || identicalTypes(selectedElements, project)) {
- type= getType(selectedElements.get(0), project);
+ if (selectedElements.size() > 1)
+ type = type | MULTI;
- if (selectedElements.size() > 1)
- type= type | MULTI;
+ if (type == fLastType)
+ return;
+ }
- if (type == fLastType)
- return;
- }
+ internalSetContext(selectedElements, project, type);
+ }
- internalSetContext(selectedElements, project, type);
- }
+ /**
+ * Get a description for the last selection explaining why no operation is
+ * possible.
+ * <p>
+ * This can be usefull if a context sensitive widget does not want to
+ * display all operations although some of them are valid.
+ *
+ * @return a description for the last selection that explains why no
+ * operation is available.
+ */
+ public String getNoActionDescription() {
+ String[] description = noAction(fLastType);
+ return description[0];
+ }
- /**
- * Get a description for the last selection explaining
- * why no operation is possible.<p>
- * This can be usefull if a context sensitive widget does
- * not want to display all operations although some of them
- * are valid.
- *
- * @return a description for the last selection that explains
- * why no operation is available.
- */
- public String getNoActionDescription() {
- String[] description= noAction(fLastType);
- return description[0];
- }
+ /**
+ * Internal method to set the context of the action group.
+ *
+ * @param selectedElements
+ * a list of selected elements, can be empty
+ * @param project
+ * the script project
+ * @param type
+ * the type of the selected element(s)
+ * @throws ModelException
+ */
+ private void internalSetContext(List selectedElements,
+ IScriptProject project, int type) throws ModelException {
+ fLastType = type;
+ List availableActions = getAvailableActions(selectedElements, project);
+ BuildpathModifierAction[] actions = new BuildpathModifierAction[availableActions
+ .size()];
+ String[] descriptions = new String[availableActions.size()];
+ if (availableActions.size() > 0) {
+ for (int i = 0; i < availableActions.size(); i++) {
+ BuildpathModifierAction action = (BuildpathModifierAction) availableActions
+ .get(i);
+ actions[i] = action;
+ descriptions[i] = action.getDescription(type);
+ }
+ } else
+ descriptions = noAction(type);
- /**
- * Internal method to set the context of the action group.
- *
- * @param selectedElements a list of selected elements, can be empty
- * @param project the script project
- * @param type the type of the selected element(s)
- * @throws ModelException
- */
- private void internalSetContext(List selectedElements, IScriptProject project, int type) throws ModelException {
- fLastType= type;
- List availableActions= getAvailableActions(selectedElements, project);
- BuildpathModifierAction[] actions= new BuildpathModifierAction[availableActions.size()];
- String[] descriptions= new String[availableActions.size()];
- if (availableActions.size() > 0) {
- for(int i= 0; i < availableActions.size(); i++) {
- BuildpathModifierAction action= (BuildpathModifierAction)availableActions.get(i);
- actions[i]= action;
- descriptions[i]= action.getDescription(type);
- }
- } else
- descriptions= noAction(type);
+ informListeners(descriptions, actions);
+ }
- informListeners(descriptions, actions);
- }
-
- /**
- * Finds out wheter the list of elements consists only of elements
- * having the same type (for example all are of type
- * DialogPackageExplorerActionGroup.COMPILATION_UNIT). This allows
- * to use a description for the available actions which is more
- * specific and therefore provides more information.
- *
- * @param elements a list of elements to be compared to each other
- * @param project the script project
- * @return <code>true</code> if all elements are of the same type,
- * <code>false</code> otherwise.
- * @throws ModelException
- */
- private boolean identicalTypes(List elements, IScriptProject project) throws ModelException {
+ /**
+ * Finds out wheter the list of elements consists only of elements having
+ * the same type (for example all are of type
+ * DialogPackageExplorerActionGroup.COMPILATION_UNIT). This allows to use a
+ * description for the available actions which is more specific and
+ * therefore provides more information.
+ *
+ * @param elements
+ * a list of elements to be compared to each other
+ * @param project
+ * the script project
+ * @return <code>true</code> if all elements are of the same type,
+ * <code>false</code> otherwise.
+ * @throws ModelException
+ */
+ private boolean identicalTypes(List elements, IScriptProject project)
+ throws ModelException {
if (elements.size() == 0) {
return false;
}
- Object firstElement= elements.get(0);
- int firstType= getType(firstElement, project);
- for(int i= 1; i < elements.size(); i++) {
- if(firstType != getType(elements.get(i), project))
- return false;
- }
- return true;
- }
-
- /**
- * Inform all listeners about new actions.
- *
- * @param descriptions an array of descriptions for each
- * actions, where the description at position 'i' belongs to
- * the action at position 'i'
- * @param actions an array of available actions
- */
- private void informListeners(String[] descriptions, BuildpathModifierAction[] actions) {
- Iterator iterator= fListeners.iterator();
- PackageExplorerActionEvent event= new PackageExplorerActionEvent(descriptions, actions);
- while(iterator.hasNext()) {
- IPackageExplorerActionListener listener= (IPackageExplorerActionListener)iterator.next();
- listener.handlePackageExplorerActionEvent(event);
- }
- }
-
- /**
- * Returns string array with only one element which contains a short reason to indicate
- * why there are no actions available.
- *
- * @return a description to explain why there are no actions available
- */
- private String[] noAction(int type) {
- String reason;
- switch(type) {
- case FILE: reason= NewWizardMessages.PackageExplorerActionGroup_NoAction_File; break;
- case FILE | MULTI: reason= NewWizardMessages.PackageExplorerActionGroup_NoAction_File; break;
- case DEFAULT_FRAGMENT: reason= NewWizardMessages.PackageExplorerActionGroup_NoAction_DefaultPackage; break;
- case DEFAULT_FRAGMENT | MULTI: reason= NewWizardMessages.PackageExplorerActionGroup_NoAction_DefaultPackage; break;
- case NULL_SELECTION: reason= NewWizardMessages.PackageExplorerActionGroup_NoAction_NullSelection; break;
- case MULTI: reason= NewWizardMessages.PackageExplorerActionGroup_NoAction_MultiSelection; break;
- case ARCHIVE_RESOURCE: reason= NewWizardMessages.PackageExplorerActionGroup_NoAction_ArchiveResource; break;
- default: reason= NewWizardMessages.PackageExplorerActionGroup_NoAction_NoReason;
- }
- return new String[] {reason};
- }
-
- /**
- * Computes the type based on the current selection. The type
- * can be usefull to set the content of the hint text group
- * properly.
- *
- * @param obj the object to get the type from
- * @return the type of the current selection or UNDEFINED if no
- * appropriate type could be found. Possible types are:<br>
- * PackageExplorerActionGroup.FOLDER<br>
- * PackageExplorerActionGroup.EXCLUDED_FOLDER;<br>
- * PackageExplorerActionGroup.EXCLUDED_FILE<br>
- * PackageExplorerActionGroup.DEFAULT_OUTPUT<br>
- * PackageExplorerActionGroup.INCLUDED_FILE<br>
- * PackageExplorerActionGroup.INCLUDED_FOLDER<br>
- * PackageExplorerActionGroup.OUTPUT<br>
- * PackageExplorerActionGroup.MODIFIED_FRAGMENT_ROOT<br>
- * PackageExplorerActionGroup.DEFAULT_FRAGMENT<br>
- * PackageExplorerActionGroup.JAVA_PROJECT<br>
- * PackageExplorerActionGroup.PACKAGE_FRAGMENT_ROOT<br>
- * PackageExplorerActionGroup.PACKAGE_FRAGMENT<br>
- * PackageExplorerActionGroup.COMPILATION_UNIT<br>
- * PackageExplorerActionGroup.FILE<br>
- * @throws ModelException
- */
- public static int getType(Object obj, IScriptProject project) throws ModelException {
- if (obj instanceof IScriptProject)
- return SCRIPT_PROJECT;
- if (obj instanceof BuildPathContainer)
- return CONTAINER;
- if (obj instanceof IProjectFragment)
- return BuildpathModifier.filtersSet((IProjectFragment)obj) ? MODIFIED_FRAGMENT_ROOT : PACKAGE_FRAGMENT_ROOT;
- if (obj instanceof IScriptFolder) {
- if (BuildpathModifier.isDefaultFragment((IScriptFolder)obj)) {
- if (((IProjectFragment)((IModelElement)obj).getAncestor(IModelElement.PROJECT_FRAGMENT)).isArchive())
- return ARCHIVE_RESOURCE;
- return DEFAULT_FRAGMENT;
- }
- if (BuildpathModifier.isIncluded((IModelElement)obj, project, null))
- return INCLUDED_FOLDER;
- if (((IProjectFragment)((IModelElement)obj).getAncestor(IModelElement.PROJECT_FRAGMENT)).isArchive())
- return ARCHIVE_RESOURCE;
- if (((IProjectFragment)((IModelElement)obj).getAncestor(IModelElement.PROJECT_FRAGMENT)).isExternal())
- return EXTERNAL_RESOURCE;
- return PACKAGE_FRAGMENT;
- }
- if (obj instanceof ISourceModule) {
- if (((IProjectFragment)((IModelElement)obj).getAncestor(IModelElement.PROJECT_FRAGMENT)).isArchive()) {
- return ARCHIVE_RESOURCE;
- }
- if (((IProjectFragment)((IModelElement)obj).getAncestor(IModelElement.PROJECT_FRAGMENT)).isExternal()) {
- return EXTERNAL_RESOURCE;
- }
- return BuildpathModifier.isIncluded((IModelElement)obj, project, null) ? INCLUDED_FILE : SOURCE_MODULE;
- }
- if (obj instanceof IFolder) {
- return getFolderType((IFolder)obj, project);
- }
- if (obj instanceof IFile)
- return getFileType((IFile)obj, project);
- return UNDEFINED;
- }
-
- /**
- * Get the type of the folder
- *
- * @param folder folder to get the type from
- * @return the type code for the folder. Possible types are:<br>
- * PackageExplorerActionGroup.FOLDER<br>
- * PackageExplorerActionGroup.EXCLUDED_FOLDER;<br>
- * @throws ModelException
- */
- private static int getFolderType(IFolder folder, IScriptProject project) throws ModelException {
- IContainer folderParent= folder.getParent();
- if (folderParent.getFullPath().equals(project.getPath()))
- return FOLDER;
- if (BuildpathModifier.getFragment(folderParent) != null)
- return EXCLUDED_FOLDER;
- IProjectFragment fragmentRoot= BuildpathModifier.getFragmentRoot(folder, project, null);
- if (fragmentRoot == null)
- return FOLDER;
- if (fragmentRoot.equals(DLTKCore.create(folderParent)))
- return EXCLUDED_FOLDER;
- return FOLDER;
- }
-
- /**
- * Get the type of the file
- *
- * @param file file to get the type from
- * @return the type code for the file. Possible types are:<br>
- * PackageExplorerActionGroup.EXCLUDED_FILE<br>
- * PackageExplorerActionGroup.FILE
- * @throws ModelException
- */
- private static int getFileType(IFile file, IScriptProject project) throws ModelException {
- if (BuildpathModifier.isArchive(file, project))
- return ARCHIVE;
- if (DLTKCore.DEBUG) {
- System.err.println("DialogPackageExplorerActionGroup:: Add some filters here"); //$NON-NLS-1$
+ Object firstElement = elements.get(0);
+ int firstType = getType(firstElement, project);
+ for (int i = 1; i < elements.size(); i++) {
+ if (firstType != getType(elements.get(i), project))
+ return false;
}
-// if (!DLTKCore.isScriptLikeFileName(file.getName()))
-// return FILE;
- IContainer fileParent= file.getParent();
- if (fileParent.getFullPath().equals(project.getPath())) {
- if (project.isOnBuildpath(project))
- return EXCLUDED_FILE;
- return FILE;
- }
- IProjectFragment fragmentRoot= BuildpathModifier.getFragmentRoot(file, project, null);
- if (fragmentRoot == null)
- return FILE;
- if (fragmentRoot.isArchive())
- return ARCHIVE_RESOURCE;
- if (fragmentRoot.equals(DLTKCore.create(fileParent)))
- return EXCLUDED_FILE;
- if (BuildpathModifier.getFragment(fileParent) == null) {
- if (BuildpathModifier.parentExcluded(fileParent, project))
- return FILE;
- return EXCLUDED_FILE;
- }
- return EXCLUDED_FILE;
- }
+ return true;
+ }
- /**
- * Based on the given list of elements, get the list of available
- * actions that can be applied on this elements
- *
- * @param selectedElements the list of elements to get the actions for
- * @param project the script project
- * @return a list of <code>BuildpathModifierAction</code>s
- * @throws ModelException
- */
- private List getAvailableActions(List selectedElements, IScriptProject project) throws ModelException {
+ /**
+ * Inform all listeners about new actions.
+ *
+ * @param descriptions
+ * an array of descriptions for each actions, where the
+ * description at position 'i' belongs to the action at position
+ * 'i'
+ * @param actions
+ * an array of available actions
+ */
+ private void informListeners(String[] descriptions,
+ BuildpathModifierAction[] actions) {
+ Iterator iterator = fListeners.iterator();
+ PackageExplorerActionEvent event = new PackageExplorerActionEvent(
+ descriptions, actions);
+ while (iterator.hasNext()) {
+ IPackageExplorerActionListener listener = (IPackageExplorerActionListener) iterator
+ .next();
+ listener.handlePackageExplorerActionEvent(event);
+ }
+ }
+
+ /**
+ * Returns string array with only one element which contains a short reason
+ * to indicate why there are no actions available.
+ *
+ * @return a description to explain why there are no actions available
+ */
+ private String[] noAction(int type) {
+ String reason;
+ switch (type) {
+ case FILE:
+ reason = NewWizardMessages.PackageExplorerActionGroup_NoAction_File;
+ break;
+ case FILE | MULTI:
+ reason = NewWizardMessages.PackageExplorerActionGroup_NoAction_File;
+ break;
+ case DEFAULT_FRAGMENT:
+ reason = NewWizardMessages.PackageExplorerActionGroup_NoAction_DefaultPackage;
+ break;
+ case DEFAULT_FRAGMENT | MULTI:
+ reason = NewWizardMessages.PackageExplorerActionGroup_NoAction_DefaultPackage;
+ break;
+ case NULL_SELECTION:
+ reason = NewWizardMessages.PackageExplorerActionGroup_NoAction_NullSelection;
+ break;
+ case MULTI:
+ reason = NewWizardMessages.PackageExplorerActionGroup_NoAction_MultiSelection;
+ break;
+ case ARCHIVE_RESOURCE:
+ reason = NewWizardMessages.PackageExplorerActionGroup_NoAction_ArchiveResource;
+ break;
+ default:
+ reason = NewWizardMessages.PackageExplorerActionGroup_NoAction_NoReason;
+ }
+ return new String[] { reason };
+ }
+
+ /**
+ * Computes the type based on the current selection. The type can be usefull
+ * to set the content of the hint text group properly.
+ *
+ * @param obj
+ * the object to get the type from
+ * @return the type of the current selection or UNDEFINED if no appropriate
+ * type could be found. Possible types are:<br>
+ * PackageExplorerActionGroup.FOLDER<br>
+ * PackageExplorerActionGroup.EXCLUDED_FOLDER;<br>
+ * PackageExplorerActionGroup.EXCLUDED_FILE<br>
+ * PackageExplorerActionGroup.DEFAULT_OUTPUT<br>
+ * PackageExplorerActionGroup.INCLUDED_FILE<br>
+ * PackageExplorerActionGroup.INCLUDED_FOLDER<br>
+ * PackageExplorerActionGroup.OUTPUT<br>
+ * PackageExplorerActionGroup.MODIFIED_FRAGMENT_ROOT<br>
+ * PackageExplorerActionGroup.DEFAULT_FRAGMENT<br>
+ * PackageExplorerActionGroup.JAVA_PROJECT<br>
+ * PackageExplorerActionGroup.PACKAGE_FRAGMENT_ROOT<br>
+ * PackageExplorerActionGroup.PACKAGE_FRAGMENT<br>
+ * PackageExplorerActionGroup.COMPILATION_UNIT<br>
+ * PackageExplorerActionGroup.FILE<br>
+ * @throws ModelException
+ */
+ public static int getType(Object obj, IScriptProject project)
+ throws ModelException {
+ if (obj instanceof IScriptProject)
+ return SCRIPT_PROJECT;
+ if (obj instanceof BuildPathContainer)
+ return CONTAINER;
+ if (obj instanceof IProjectFragment)
+ return BuildpathModifier.filtersSet((IProjectFragment) obj)
+ ? MODIFIED_FRAGMENT_ROOT
+ : PACKAGE_FRAGMENT_ROOT;
+ if (obj instanceof IScriptFolder) {
+ if (BuildpathModifier.isDefaultFragment((IScriptFolder) obj)) {
+ if (((IProjectFragment) ((IModelElement) obj)
+ .getAncestor(IModelElement.PROJECT_FRAGMENT))
+ .isArchive())
+ return ARCHIVE_RESOURCE;
+ return DEFAULT_FRAGMENT;
+ }
+ if (BuildpathModifier.isIncluded((IModelElement) obj, project,
+ null))
+ return INCLUDED_FOLDER;
+ if (((IProjectFragment) ((IModelElement) obj)
+ .getAncestor(IModelElement.PROJECT_FRAGMENT)).isArchive())
+ return ARCHIVE_RESOURCE;
+ if (((IProjectFragment) ((IModelElement) obj)
+ .getAncestor(IModelElement.PROJECT_FRAGMENT)).isExternal())
+ return EXTERNAL_RESOURCE;
+ return PACKAGE_FRAGMENT;
+ }
+ if (obj instanceof ISourceModule) {
+ if (((IProjectFragment) ((IModelElement) obj)
+ .getAncestor(IModelElement.PROJECT_FRAGMENT)).isArchive()) {
+ return ARCHIVE_RESOURCE;
+ }
+ if (((IProjectFragment) ((IModelElement) obj)
+ .getAncestor(IModelElement.PROJECT_FRAGMENT))
+ .isExternal()) {
+ return EXTERNAL_RESOURCE;
+ }
+ return BuildpathModifier.isIncluded((IModelElement) obj, project,
+ null) ? INCLUDED_FILE : SOURCE_MODULE;
+ }
+ if (obj instanceof IFolder) {
+ return getFolderType((IFolder) obj, project);
+ }
+ if (obj instanceof IFile)
+ return getFileType((IFile) obj, project);
+ return UNDEFINED;
+ }
+
+ /**
+ * Get the type of the folder
+ *
+ * @param folder
+ * folder to get the type from
+ * @return the type code for the folder. Possible types are:<br>
+ * PackageExplorerActionGroup.FOLDER<br>
+ * PackageExplorerActionGroup.EXCLUDED_FOLDER;<br>
+ * @throws ModelException
+ */
+ private static int getFolderType(IFolder folder, IScriptProject project)
+ throws ModelException {
+ IContainer folderParent = folder.getParent();
+ if (folderParent.getFullPath().equals(project.getPath()))
+ return FOLDER;
+ if (BuildpathModifier.getFragment(folderParent) != null)
+ return EXCLUDED_FOLDER;
+ IProjectFragment fragmentRoot = BuildpathModifier
+ .getFragmentRoot(folder, project, null);
+ if (fragmentRoot == null)
+ return FOLDER;
+ if (fragmentRoot.equals(DLTKCore.create(folderParent)))
+ return EXCLUDED_FOLDER;
+ return FOLDER;
+ }
+
+ /**
+ * Get the type of the file
+ *
+ * @param file
+ * file to get the type from
+ * @return the type code for the file. Possible types are:<br>
+ * PackageExplorerActionGroup.EXCLUDED_FILE<br>
+ * PackageExplorerActionGroup.FILE
+ * @throws ModelException
+ */
+ private static int getFileType(IFile file, IScriptProject project)
+ throws ModelException {
+ if (BuildpathModifier.isArchive(file, project))
+ return ARCHIVE;
+ if (DLTKCore.DEBUG) {
+ System.err.println(
+ "DialogPackageExplorerActionGroup:: Add some filters here"); //$NON-NLS-1$
+ }
+ // if (!DLTKCore.isScriptLikeFileName(file.getName()))
+ // return FILE;
+ IContainer fileParent = file.getParent();
+ if (fileParent.getFullPath().equals(project.getPath())) {
+ if (project.isOnBuildpath(project))
+ return EXCLUDED_FILE;
+ return FILE;
+ }
+ IProjectFragment fragmentRoot = BuildpathModifier.getFragmentRoot(file,
+ project, null);
+ if (fragmentRoot == null)
+ return FILE;
+ if (fragmentRoot.isArchive())
+ return ARCHIVE_RESOURCE;
+ if (fragmentRoot.equals(DLTKCore.create(fileParent)))
+ return EXCLUDED_FILE;
+ if (BuildpathModifier.getFragment(fileParent) == null) {
+ if (BuildpathModifier.parentExcluded(fileParent, project))
+ return FILE;
+ return EXCLUDED_FILE;
+ }
+ return EXCLUDED_FILE;
+ }
+
+ /**
+ * Based on the given list of elements, get the list of available actions
+ * that can be applied on this elements
+ *
+ * @param selectedElements
+ * the list of elements to get the actions for
+ * @param project
+ * the script project
+ * @return a list of <code>BuildpathModifierAction</code>s
+ * @throws ModelException
+ */
+ private List getAvailableActions(List selectedElements,
+ IScriptProject project) throws ModelException {
if (project == null || !project.exists()) {
return new ArrayList();
}
- List actions= new ArrayList();
- int[] types= new int[selectedElements.size()];
- for(int i= 0; i < types.length; i++) {
- types[i]= getType(selectedElements.get(i), project);
- }
- for(int i= 0; i < fActions.length; i++) {
- if(fActions[i] instanceof BuildpathModifierDropDownAction) {
- if(changeEnableState(fActions[i], selectedElements, types)) {
- BuildpathModifierAction[] dropDownActions= ((BuildpathModifierDropDownAction)fActions[i]).getActions();
- for(int j= 0; j < dropDownActions.length; j++) {
- if(changeEnableState(dropDownActions[j], selectedElements, types))
- actions.add(dropDownActions[j]);
- }
- }
- }
- else if(changeEnableState(fActions[i], selectedElements, types)) {
- actions.add(fActions[i]);
- }
- }
- return actions;
- }
+ List actions = new ArrayList();
+ int[] types = new int[selectedElements.size()];
+ for (int i = 0; i < types.length; i++) {
+ types[i] = getType(selectedElements.get(i), project);
+ }
+ for (int i = 0; i < fActions.length; i++) {
+ if (fActions[i] instanceof BuildpathModifierDropDownAction) {
+ if (changeEnableState(fActions[i], selectedElements, types)) {
+ BuildpathModifierAction[] dropDownActions = ((BuildpathModifierDropDownAction) fActions[i])
+ .getActions();
+ for (int j = 0; j < dropDownActions.length; j++) {
+ if (changeEnableState(dropDownActions[j],
+ selectedElements, types))
+ actions.add(dropDownActions[j]);
+ }
+ }
+ } else if (changeEnableState(fActions[i], selectedElements,
+ types)) {
+ actions.add(fActions[i]);
+ }
+ }
+ return actions;
+ }
- /**
- * Changes the enabled state of an action if necessary.
- *
- * @param action the action to change it's state for
- * @param selectedElements a list of selected elements
- * @param types an array of types corresponding to the types of
- * the selected elements
- * @return <code>true</code> if the action is valid (= enabled), <code>false</code> otherwise
- * @throws ModelException
- */
- private boolean changeEnableState(BuildpathModifierAction action, List selectedElements, int[] types) throws ModelException {
- if(action.isValid(selectedElements, types)) {
- if (!action.isEnabled())
- action.setEnabled(true);
- return true;
- } else {
- if (action.isEnabled())
- action.setEnabled(false);
- return false;
- }
- }
+ /**
+ * Changes the enabled state of an action if necessary.
+ *
+ * @param action
+ * the action to change it's state for
+ * @param selectedElements
+ * a list of selected elements
+ * @param types
+ * an array of types corresponding to the types of the selected
+ * elements
+ * @return <code>true</code> if the action is valid (= enabled),
+ * <code>false</code> otherwise
+ * @throws ModelException
+ */
+ private boolean changeEnableState(BuildpathModifierAction action,
+ List selectedElements, int[] types) throws ModelException {
+ if (action.isValid(selectedElements, types)) {
+ if (!action.isEnabled())
+ action.setEnabled(true);
+ return true;
+ } else {
+ if (action.isEnabled())
+ action.setEnabled(false);
+ return false;
+ }
+ }
- /**
- * Fill the context menu with the available actions
- *
- * @param menu the menu to be filled up with actions
- */
- @Override
+ /**
+ * Fill the context menu with the available actions
+ *
+ * @param menu
+ * the menu to be filled up with actions
+ */
+ @Override
public void fillContextMenu(IMenuManager menu) {
- for (int i= 0; i < fContextSensitiveActions; i++) {
- IAction action= getAction(i);
- if (action instanceof BuildpathModifierDropDownAction) {
- if (action.isEnabled()) {
- IAction[] actions= ((BuildpathModifierDropDownAction)action).getActions();
- for(int j= 0; j < actions.length; j++) {
- if(actions[j].isEnabled())
- menu.add(actions[j]);
- }
- }
- }
- else if (action.isEnabled())
- menu.add(action);
- }
- super.fillContextMenu(menu);
- }
+ for (int i = 0; i < fContextSensitiveActions; i++) {
+ IAction action = getAction(i);
+ if (action instanceof BuildpathModifierDropDownAction) {
+ if (action.isEnabled()) {
+ IAction[] actions = ((BuildpathModifierDropDownAction) action)
+ .getActions();
+ for (int j = 0; j < actions.length; j++) {
+ if (actions[j].isEnabled())
+ menu.add(actions[j]);
+ }
+ }
+ } else if (action.isEnabled())
+ menu.add(action);
+ }
+ super.fillContextMenu(menu);
+ }
- /**
- * Add listeners for the <code>PackageExplorerActionEvent</code>.
- *
- * @param listener the listener to be added
- *
- * @see PackageExplorerActionEvent
- * @see IPackageExplorerActionListener
- */
- public void addListener(IPackageExplorerActionListener listener) {
- fListeners.add(listener);
- }
+ /**
+ * Add listeners for the <code>PackageExplorerActionEvent</code>.
+ *
+ * @param listener
+ * the listener to be added
+ *
+ * @see PackageExplorerActionEvent
+ * @see IPackageExplorerActionListener
+ */
+ public void addListener(IPackageExplorerActionListener listener) {
+ fListeners.add(listener);
+ }
- /**
- * Remove the listener from the list of registered listeners.
- *
- * @param listener the listener to be removed
- */
- public void removeListener(IPackageExplorerActionListener listener) {
- fListeners.remove(listener);
- }
+ /**
+ * Remove the listener from the list of registered listeners.
+ *
+ * @param listener
+ * the listener to be removed
+ */
+ public void removeListener(IPackageExplorerActionListener listener) {
+ fListeners.remove(listener);
+ }
- @Override
+ @Override
public void dispose() {
- fListeners.clear();
- super.dispose();
- }
+ fListeners.clear();
+ super.dispose();
+ }
}
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java
index 679fb14..39556a2 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ScriptBrowsingPart.java
@@ -605,15 +605,16 @@
}
protected void createActions() {
- fActionGroups = new CompositeActionGroup(new ActionGroup[] {
- new NewWizardsActionGroup(this.getSite()),
- fOpenEditorGroup = new OpenEditorActionGroup(this),
- new OpenViewActionGroup(this),
- fCCPActionGroup = new CCPActionGroup(this),
- // new GenerateActionGroup(this),
- new RefactorActionGroup(this), new ImportActionGroup(this),
- fBuildActionGroup = new BuildActionGroup(this),
- new SearchActionGroup(this, this.getToolkit()) });
+ fActionGroups = new CompositeActionGroup(
+ new ActionGroup[] { new NewWizardsActionGroup(this.getSite()),
+ fOpenEditorGroup = new OpenEditorActionGroup(this),
+ new OpenViewActionGroup(this),
+ fCCPActionGroup = new CCPActionGroup(this),
+ // new GenerateActionGroup(this),
+ new RefactorActionGroup(this, null),
+ new ImportActionGroup(this),
+ fBuildActionGroup = new BuildActionGroup(this),
+ new SearchActionGroup(this, this.getToolkit()) });
if (fHasWorkingSetFilter) {
String viewId = getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
diff --git a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java
index f489eff..7a9a023 100644
--- a/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java
+++ b/core/plugins/org.eclipse.dltk.ui/src/org/eclipse/dltk/ui/browsing/ext/ExtendedClassesView.java
@@ -230,15 +230,16 @@
}
protected void createActions() {
- fActionGroups = new CompositeActionGroup(new ActionGroup[] {
- new NewWizardsActionGroup(this.getSite()),
- fOpenEditorGroup = new OpenEditorActionGroup(this),
- new OpenViewActionGroup(this),
- fCCPActionGroup = new CCPActionGroup(this),
- // new GenerateActionGroup(this),
- new RefactorActionGroup(this), new ImportActionGroup(this),
- fBuildActionGroup = new BuildActionGroup(this),
- new SearchActionGroup(this, this.fToolkit) });
+ fActionGroups = new CompositeActionGroup(
+ new ActionGroup[] { new NewWizardsActionGroup(this.getSite()),
+ fOpenEditorGroup = new OpenEditorActionGroup(this),
+ new OpenViewActionGroup(this),
+ fCCPActionGroup = new CCPActionGroup(this),
+ // new GenerateActionGroup(this),
+ new RefactorActionGroup(this, null),
+ new ImportActionGroup(this),
+ fBuildActionGroup = new BuildActionGroup(this),
+ new SearchActionGroup(this, this.fToolkit) });
// fToggleLinkingAction = new ToggleLinkingAction(this);
}