+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
+Package
+
+
+
+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
+
Interfaces (italic)
Classes
Enums
Exceptions
Errors
Annotation Types
+
+
+Class/Interface
+
+
+
+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+
Class inheritance diagram
Direct Subclasses
All Known Subinterfaces
All Known Implementing Classes
Class/interface declaration
Class/interface description
+
+
Nested Class Summary
Field Summary
Constructor Summary
Method Summary
+
+
Field Detail
Constructor Detail
Method Detail
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+
+
+Annotation Type
+
+
+
+Each annotation type has its own separate page with the following sections:
+
Annotation Type declaration
Annotation Type description
Required Element Summary
Optional Element Summary
Element Detail
+
+
+
+Enum
+
+
+
+Each enum has its own separate page with the following sections:
+
Enum declaration
Enum description
Enum Constant Summary
Enum Constant Detail
+
+
+Use
+
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+
+Tree (Class Hierarchy)
+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.
+
When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
+
+
+Deprecated API
+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+
+Index
+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+
+Prev/Next
+These links take you to the next or previous class, interface, package, or related page.
+Frames/No Frames
+These links show and hide the HTML frames. All pages are available with or without frames.
+
+
+Serialized Form
+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+
The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at http://www.eclipse.org/legal/epl-v10.html.
+For purposes of the EPL, "Program" will mean the Content.
+
+
If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at http://www.eclipse.org.
+
+
+
\ No newline at end of file
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/build.properties b/base_commons/net.heartsome.cat.common.ui.navigator.resources/build.properties
new file mode 100644
index 0000000..6ffe5c2
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/build.properties
@@ -0,0 +1,10 @@
+javacDefaultEncoding.. = UTF-8
+source.. = src/
+bin.includes = META-INF/,\
+ plugin.xml,\
+ .api_description,\
+ about.html,\
+ icons/,\
+ plugin.properties,\
+ .
+jre.compilation.profile = J2SE-1.5
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/clcl16/collapseall.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/clcl16/collapseall.gif
new file mode 100644
index 0000000..0bae56c
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/clcl16/collapseall.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/clcl16/synced.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/clcl16/synced.gif
new file mode 100644
index 0000000..f865f3a
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/clcl16/synced.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/cview16/filenav_nav.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/cview16/filenav_nav.gif
new file mode 100644
index 0000000..91b9d5a
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/cview16/filenav_nav.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/collapseall.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/collapseall.gif
new file mode 100644
index 0000000..a2d80a9
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/collapseall.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/filter_ps.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/filter_ps.gif
new file mode 100644
index 0000000..a4c9e60
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/filter_ps.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/synced.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/synced.gif
new file mode 100644
index 0000000..870934b
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/elcl16/synced.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/eview16/resource_persp.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/eview16/resource_persp.gif
new file mode 100644
index 0000000..1b8fe00
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/eview16/resource_persp.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/folder.png b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/folder.png
new file mode 100644
index 0000000..8213901
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/folder.png differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/prj_close.png b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/prj_close.png
new file mode 100644
index 0000000..c204fa3
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/prj_close.png differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/prj_open.png b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/prj_open.png
new file mode 100644
index 0000000..c60efc3
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/prj_open.png differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/workingsets.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/workingsets.gif
new file mode 100644
index 0000000..fa8c9f7
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/obj16/workingsets.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/ovr16/error_co.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/ovr16/error_co.gif
new file mode 100644
index 0000000..8612eaf
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/ovr16/error_co.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/ovr16/warning_co.gif b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/ovr16/warning_co.gif
new file mode 100644
index 0000000..3af228c
Binary files /dev/null and b/base_commons/net.heartsome.cat.common.ui.navigator.resources/icons/full/ovr16/warning_co.gif differ
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/plugin.properties b/base_commons/net.heartsome.cat.common.ui.navigator.resources/plugin.properties
new file mode 100644
index 0000000..7bfc3e3
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/plugin.properties
@@ -0,0 +1,28 @@
+###############################################################################
+# Copyright (c) 2003, 2010 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
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+Plugin.name = Navigator Workbench Components
+Plugin.providerName = Eclipse.org
+
+resource.extension.name=Resources
+resourceGoTo.extension.name=Resources Go To
+workingsets.extension.name=Working Sets
+Common_Resource_Navigator=Project Explorer
+
+filters.startsWithDot.name=.* resources
+filters.startsWithDot.description=Hides resources that begin with "."
+filters.endsWithClass.name=*.class resources
+filters.endsWithClass.description=Hides resources that end with ".class"
+filters.closedProject.name=Closed projects
+filters.closedProject.description=Hides closed projects
+filters.workingSet.name=Working sets [not visible in UI]
+filters.workingSet.description=Hides unselected working sets [not visible in UI]
+
+Resource=Resource
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/plugin.xml b/base_commons/net.heartsome.cat.common.ui.navigator.resources/plugin.xml
new file mode 100644
index 0000000..ac74437
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/plugin.xml
@@ -0,0 +1,382 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/readme.txt b/base_commons/net.heartsome.cat.common.ui.navigator.resources/readme.txt
new file mode 100644
index 0000000..408888e
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/readme.txt
@@ -0,0 +1,5 @@
+æ¤æ’件修改自 org.eclipse.ui.navigator.resources(3.4.300.I20110421-1800)
+为了去除对 org.eclipse.ltk.ui.refactoring æ’件的引用。
+
+具体改动之处,请看:
+org.eclipse.ui.navigator.resources.ResourceDropAdapterAssistant.performResourceMove(CommonDropAdapter, IResource[])
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/ResourceToItemsMapper.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/ResourceToItemsMapper.java
new file mode 100644
index 0000000..5bfa784
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/ResourceToItemsMapper.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Stack;
+
+import org.eclipse.swt.widgets.Item;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonViewerMapper;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * Adds a supplemental map for the CommonViewer to efficiently handle resource
+ * changes. When objects are added to the Viewer's map, this is called to see
+ * if there is an associated resource. If so, it's added to the map here.
+ * When resource change notifications happen, this map is checked, and if the
+ * resource is found, this class causes the Viewer to be updated. If the
+ * resource is not found, the notification can be ignored because the object
+ * corresponding to the resource is not present in the viewer.
+ *
+ */
+public class ResourceToItemsMapper implements ICommonViewerMapper {
+
+ private static final int NUMBER_LIST_REUSE = 10;
+
+ // map from resource to item
+ private HashMap _resourceToItem;
+ private Stack _reuseLists;
+
+ private CommonViewer _commonViewer;
+
+ public ResourceToItemsMapper(CommonViewer viewer) {
+ _resourceToItem = new HashMap();
+ _reuseLists = new Stack();
+
+ _commonViewer = viewer;
+ viewer.setMapper(this);
+ }
+
+ public void addToMap(Object element, Item item) {
+ IResource resource = getCorrespondingResource(element);
+ if (resource != null) {
+ Object existingMapping = _resourceToItem.get(resource);
+ if (existingMapping == null) {
+ _resourceToItem.put(resource, item);
+ } else if (existingMapping instanceof Item) {
+ if (existingMapping != item) {
+ List list = getNewList();
+ list.add(existingMapping);
+ list.add(item);
+ _resourceToItem.put(resource, list);
+ }
+ } else { // List
+ List list = (List) existingMapping;
+ if (!list.contains(item)) {
+ list.add(item);
+ }
+ }
+ }
+ }
+
+ public void removeFromMap(Object element, Item item) {
+ IResource resource = getCorrespondingResource(element);
+ if (resource != null) {
+ Object existingMapping = _resourceToItem.get(resource);
+ if (existingMapping == null) {
+ return;
+ } else if (existingMapping instanceof Item) {
+ _resourceToItem.remove(resource);
+ } else { // List
+ List list = (List) existingMapping;
+ list.remove(item);
+ if (list.isEmpty()) {
+ _resourceToItem.remove(list);
+ releaseList(list);
+ }
+ }
+ }
+ }
+
+ public void clearMap() {
+ _resourceToItem.clear();
+ }
+
+ public boolean isEmpty() {
+ return _resourceToItem.isEmpty();
+ }
+
+ private List getNewList() {
+ if (!_reuseLists.isEmpty()) {
+ return (List) _reuseLists.pop();
+ }
+ return new ArrayList(2);
+ }
+
+ private void releaseList(List list) {
+ if (_reuseLists.size() < NUMBER_LIST_REUSE) {
+ _reuseLists.push(list);
+ }
+ }
+
+ public boolean handlesObject(Object object) {
+ return object instanceof IResource;
+ }
+
+
+ /**
+ * Must be called from the UI thread.
+ *
+ * @param changedResource
+ * Changed resource
+ */
+ public void objectChanged(Object changedResource) {
+ Object obj = _resourceToItem.get(changedResource);
+ if (obj == null) {
+ // not mapped
+ } else if (obj instanceof Item) {
+ updateItem((Item) obj);
+ } else { // List of Items
+ List list = (List) obj;
+ for (int k = 0; k < list.size(); k++) {
+ updateItem((Item) list.get(k));
+ }
+ }
+ }
+
+ private void updateItem(Item item) {
+ if (!item.isDisposed()) {
+ _commonViewer.doUpdateItem(item);
+ }
+ }
+
+ private static IResource getCorrespondingResource(Object element) {
+ if (element instanceof IResource)
+ return (IResource) element;
+ if (element instanceof IAdaptable)
+ return (IResource) ((IAdaptable) element).getAdapter(IResource.class);
+ return null;
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/CopyAction.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/CopyAction.java
new file mode 100644
index 0000000..bd73e43
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/CopyAction.java
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWTError;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.part.ResourceTransfer;
+
+/**
+ * Standard action for copying the currently selected resources to the clipboard.
+ *
+ * This class may be instantiated; it is not intended to be subclassed.
+ *
+ *
+ * @since 2.0
+ */
+/*package*/class CopyAction extends SelectionListenerAction {
+
+ /**
+ * The id of this action.
+ */
+ public static final String ID = PlatformUI.PLUGIN_ID + ".CopyAction"; //$NON-NLS-1$
+
+ /**
+ * The shell in which to show any dialogs.
+ */
+ private Shell shell;
+
+ /**
+ * System clipboard
+ */
+ private Clipboard clipboard;
+
+ /**
+ * Associated paste action. May be null
+ */
+ private PasteAction pasteAction;
+
+ /**
+ * Creates a new action.
+ *
+ * @param shell the shell for any dialogs
+ * @param clipboard a platform clipboard
+ */
+ public CopyAction(Shell shell, Clipboard clipboard) {
+ super(WorkbenchNavigatorMessages.actions_CopyAction_Cop_);
+ Assert.isNotNull(shell);
+ Assert.isNotNull(clipboard);
+ this.shell = shell;
+ this.clipboard = clipboard;
+ setToolTipText(WorkbenchNavigatorMessages.actions_CopyAction_Copy_selected_resource_s_);
+ setId(CopyAction.ID);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, "CopyHelpId"); //$NON-NLS-1$
+ // TODO INavigatorHelpContextIds.COPY_ACTION);
+ }
+
+ /**
+ * Creates a new action.
+ *
+ * @param shell the shell for any dialogs
+ * @param clipboard a platform clipboard
+ * @param pasteAction a paste action
+ *
+ * @since 2.0
+ */
+ public CopyAction(Shell shell, Clipboard clipboard, PasteAction pasteAction) {
+ this(shell, clipboard);
+ this.pasteAction = pasteAction;
+ }
+
+ /**
+ * The CopyAction implementation of this method defined
+ * on IAction copies the selected resources to the
+ * clipboard.
+ */
+ public void run() {
+ List selectedResources = getSelectedResources();
+ IResource[] resources = (IResource[]) selectedResources
+ .toArray(new IResource[selectedResources.size()]);
+
+ // Get the file names and a string representation
+ final int length = resources.length;
+ int actualLength = 0;
+ String[] fileNames = new String[length];
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ IPath location = resources[i].getLocation();
+ // location may be null. See bug 29491.
+ if (location != null) {
+ fileNames[actualLength++] = location.toOSString();
+ }
+ if (i > 0) {
+ buf.append("\n"); //$NON-NLS-1$
+ }
+ buf.append(resources[i].getName());
+ }
+ // was one or more of the locations null?
+ if (actualLength < length) {
+ String[] tempFileNames = fileNames;
+ fileNames = new String[actualLength];
+ for (int i = 0; i < actualLength; i++) {
+ fileNames[i] = tempFileNames[i];
+ }
+ }
+ setClipboard(resources, fileNames, buf.toString());
+
+ // update the enablement of the paste action
+ // workaround since the clipboard does not suppot callbacks
+ if (pasteAction != null && pasteAction.getStructuredSelection() != null) {
+ pasteAction.selectionChanged(pasteAction.getStructuredSelection());
+ }
+ }
+
+ /**
+ * Set the clipboard contents. Prompt to retry if clipboard is busy.
+ *
+ * @param resources the resources to copy to the clipboard
+ * @param fileNames file names of the resources to copy to the clipboard
+ * @param names string representation of all names
+ */
+ private void setClipboard(IResource[] resources, String[] fileNames,
+ String names) {
+ try {
+ // set the clipboard contents
+ if (fileNames.length > 0) {
+ clipboard.setContents(new Object[] { resources, fileNames,
+ names },
+ new Transfer[] { ResourceTransfer.getInstance(),
+ FileTransfer.getInstance(),
+ TextTransfer.getInstance() });
+ } else {
+ clipboard.setContents(new Object[] { resources, names },
+ new Transfer[] { ResourceTransfer.getInstance(),
+ TextTransfer.getInstance() });
+ }
+ } catch (SWTError e) {
+ if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD) {
+ throw e;
+ }
+ if (MessageDialog
+ .openQuestion(
+ shell,
+ WorkbenchNavigatorMessages.actions_CopyAction_msgTitle, // TODO ResourceNavigatorMessages.CopyToClipboardProblemDialog_title, //$NON-NLS-1$
+ WorkbenchNavigatorMessages.actions_CopyAction_msg)) { //$NON-NLS-1$
+ setClipboard(resources, fileNames, names);
+ }
+ }
+ }
+
+ /**
+ * The CopyAction implementation of this
+ * SelectionListenerAction method enables this action if
+ * one or more resources of compatible types are selected.
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ if (!super.updateSelection(selection)) {
+ return false;
+ }
+
+ if (getSelectedNonResources().size() > 0) {
+ return false;
+ }
+
+ List selectedResources = getSelectedResources();
+ if (selectedResources.size() == 0) {
+ return false;
+ }
+
+ boolean projSelected = selectionIsOfType(IResource.PROJECT);
+ boolean fileFoldersSelected = selectionIsOfType(IResource.FILE
+ | IResource.FOLDER);
+ if (!projSelected && !fileFoldersSelected) {
+ return false;
+ }
+
+ // selection must be homogeneous
+ if (projSelected && fileFoldersSelected) {
+ return false;
+ }
+
+ // must have a common parent
+ IContainer firstParent = ((IResource) selectedResources.get(0))
+ .getParent();
+ if (firstParent == null) {
+ return false;
+ }
+
+ Iterator resourcesEnum = selectedResources.iterator();
+ while (resourcesEnum.hasNext()) {
+ IResource currentResource = (IResource) resourcesEnum.next();
+ if (!currentResource.getParent().equals(firstParent)) {
+ return false;
+ }
+ // resource location must exist
+ if (currentResource.getLocationURI() == null) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+}
+
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/DeleteResourceAndCloseEditorAction.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/DeleteResourceAndCloseEditorAction.java
new file mode 100644
index 0000000..ea0bd09
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/DeleteResourceAndCloseEditorAction.java
@@ -0,0 +1,752 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Benjamin Muskalla
+ * - Fix for bug 172574 - [IDE] DeleteProjectDialog inconsequent selection behavior
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.heartsome.cat.common.util.CommonFunction;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.SelectionListenerAction;
+import org.eclipse.ui.ide.undo.DeleteResourcesOperation;
+import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
+import org.eclipse.ui.internal.ide.actions.LTKLauncher;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.progress.WorkbenchJob;
+
+import com.ximpleware.AutoPilot;
+import com.ximpleware.VTDGen;
+import com.ximpleware.VTDNav;
+
+/**
+ * Standard action for deleting the currently selected resources.
+ *
+ * This class may be instantiated; it is not intended to be subclassed.
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class DeleteResourceAndCloseEditorAction extends SelectionListenerAction {
+
+
+ /**
+ * 修改BUG,é»˜è®¤åˆ é™¤é¡¹ç›®çš„å†…å®¹
+ * @author robert
+ */
+ static class DeleteProjectDialog extends MessageDialog {
+
+ private IResource[] projects;
+
+ private boolean deleteContent = false;
+
+ /**
+ * Control testing mode. In testing mode, it returns true to delete contents and does not pop up the dialog.
+ */
+ private boolean fIsTesting = false;
+
+// private Button radio1;
+//
+// private Button radio2;
+
+
+ DeleteProjectDialog(Shell parentShell, IResource[] projects) {
+ super(parentShell, getTitle(projects), null, // accept the
+ // default window
+ // icon
+ getMessage(projects), MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL,
+ IDialogConstants.NO_LABEL }, 0); // yes is the
+ // default
+ this.projects = projects;
+ setShellStyle(getShellStyle() | SWT.SHEET);
+ }
+
+ static String getTitle(IResource[] projects) {
+ if (projects.length == 1) {
+ return IDEWorkbenchMessages.DeleteResourceAction_titleProject1;
+ }
+ return IDEWorkbenchMessages.DeleteResourceAction_titleProjectN;
+ }
+
+ static String getMessage(IResource[] projects) {
+ if (projects.length == 1) {
+ IProject project = (IProject) projects[0];
+ return NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmProject1, project.getName());
+ }
+ return NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmProjectN, new Integer(projects.length));
+ }
+
+ /*
+ * (non-Javadoc) Method declared on Window.
+ */
+ protected void configureShell(Shell newShell) {
+ super.configureShell(newShell);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IIDEHelpContextIds.DELETE_PROJECT_DIALOG);
+ }
+
+ /*
+ *
+
+ protected Control createCustomArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ radio1 = new Button(composite, SWT.RADIO);
+ radio1.addSelectionListener(selectionListener);
+ String text1;
+ if (projects.length == 1) {
+ IProject project = (IProject) projects[0];
+ if (project == null || project.getLocation() == null) {
+ text1 = IDEWorkbenchMessages.DeleteResourceAction_deleteContentsN;
+ } else {
+ text1 = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_deleteContents1, project.getLocation()
+ .toOSString());
+ }
+ } else {
+ text1 = IDEWorkbenchMessages.DeleteResourceAction_deleteContentsN;
+ }
+ radio1.setText(text1);
+ radio1.setFont(parent.getFont());
+
+ // Add explanatory label that the action cannot be undone.
+ // We can't put multi-line formatted text in a radio button,
+ // so we have to create a separate label.
+ Label detailsLabel = new Label(composite, SWT.LEFT);
+ detailsLabel.setText(IDEWorkbenchMessages.DeleteResourceAction_deleteContentsDetails);
+ detailsLabel.setFont(parent.getFont());
+ // indent the explanatory label
+ GridData data = new GridData();
+ data.horizontalIndent = IDialogConstants.INDENT;
+ detailsLabel.setLayoutData(data);
+ // add a listener so that clicking on the label selects the
+ // corresponding radio button.
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=172574
+ detailsLabel.addMouseListener(new MouseAdapter() {
+ public void mouseUp(MouseEvent e) {
+ deleteContent = true;
+ radio1.setSelection(deleteContent);
+ radio2.setSelection(!deleteContent);
+ }
+ });
+ // Add a spacer label
+ new Label(composite, SWT.LEFT);
+
+ radio2 = new Button(composite, SWT.RADIO);
+ radio2.addSelectionListener(selectionListener);
+ String text2 = IDEWorkbenchMessages.DeleteResourceAction_doNotDeleteContents;
+ radio2.setText(text2);
+ radio2.setFont(parent.getFont());
+
+ // set initial state
+ radio1.setSelection(deleteContent);
+ radio2.setSelection(!deleteContent);
+
+ return composite;
+ }
+
+ */
+ protected Control createCustomArea(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout());
+ String text1;
+ if (projects.length == 1) {
+ IProject project = (IProject) projects[0];
+ if (project == null || project.getLocation() == null) {
+ text1 = IDEWorkbenchMessages.DeleteResourceAction_deleteContentsN;
+ } else {
+ text1 = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_deleteContents1, project.getLocation()
+ .toOSString());
+ }
+ } else {
+ text1 = IDEWorkbenchMessages.DeleteResourceAction_deleteContentsN;
+ }
+
+ Label tipLbl = new Label(composite, SWT.NONE);
+ tipLbl.setFont(parent.getFont());
+ tipLbl.setText(text1);
+ deleteContent = true;
+
+ Label detailsLabel = new Label(composite, SWT.LEFT);
+ detailsLabel.setText(IDEWorkbenchMessages.DeleteResourceAction_deleteContentsDetails);
+ detailsLabel.setFont(parent.getFont());
+ // indent the explanatory label
+ GridData data = new GridData();
+ data.horizontalIndent = IDialogConstants.INDENT;
+ detailsLabel.setLayoutData(data);
+ // add a listener so that clicking on the label selects the
+ // corresponding radio button.
+ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=172574
+ // Add a spacer label
+ new Label(composite, SWT.LEFT);
+
+
+
+
+ return composite;
+ }
+
+ /*
+ private SelectionListener selectionListener = new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ Button button = (Button) e.widget;
+ if (button.getSelection()) {
+ deleteContent = (button == radio1);
+ }
+ }
+ };
+ */
+
+ boolean getDeleteContent() {
+ return deleteContent;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.window.Window#open()
+ */
+ public int open() {
+ // Override Window#open() to allow for non-interactive testing.
+ if (fIsTesting) {
+ deleteContent = true;
+ return Window.OK;
+ }
+ return super.open();
+ }
+
+ /**
+ * Set this delete dialog into testing mode. It won't pop up, and it returns true for deleteContent.
+ * @param t
+ * the testing mode
+ */
+ void setTestingMode(boolean t) {
+ fIsTesting = t;
+ }
+ }
+
+ /**
+ * The id of this action.
+ */
+ public static final String ID = PlatformUI.PLUGIN_ID + ".DeleteResourceAction";//$NON-NLS-1$
+
+ private IShellProvider shellProvider = null;
+
+ /**
+ * Whether or not we are deleting content for projects.
+ */
+ private boolean deleteContent = false;
+
+ /**
+ * Flag that allows testing mode ... it won't pop up the project delete dialog, and will return
+ * "delete all content".
+ */
+ protected boolean fTestingMode = false;
+
+ private String[] modelProviderIds;
+
+ /**
+ * Creates a new delete resource action.
+ * @param shell
+ * the shell for any dialogs
+ * @deprecated Should take an IShellProvider, see {@link #DeleteResourceAction(IShellProvider)}
+ */
+ public DeleteResourceAndCloseEditorAction(final Shell shell) {
+ super(IDEWorkbenchMessages.DeleteResourceAction_text);
+ Assert.isNotNull(shell);
+ initAction();
+ setShellProvider(new IShellProvider() {
+ public Shell getShell() {
+ return shell;
+ }
+ });
+ }
+
+ /**
+ * Creates a new delete resource action.
+ * @param provider
+ * the shell provider to use. Must not be null.
+ * @since 3.4
+ */
+ public DeleteResourceAndCloseEditorAction(IShellProvider provider) {
+ super(IDEWorkbenchMessages.DeleteResourceAction_text);
+ Assert.isNotNull(provider);
+ initAction();
+ setShellProvider(provider);
+ }
+
+ /**
+ * Action initialization.
+ */
+ private void initAction() {
+ setToolTipText(IDEWorkbenchMessages.DeleteResourceAction_toolTip);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IIDEHelpContextIds.DELETE_RESOURCE_ACTION);
+ setId(ID);
+ }
+
+ private void setShellProvider(IShellProvider provider) {
+ shellProvider = provider;
+ }
+
+ /**
+ * Returns whether delete can be performed on the current selection.
+ * @param resources
+ * the selected resources
+ * @return true if the resources can be deleted, and false if the selection contains
+ * non-resources or phantom resources
+ */
+ private boolean canDelete(IResource[] resources) {
+ // allow only projects or only non-projects to be selected;
+ // note that the selection may contain multiple types of resource
+ if (!(containsOnlyProjects(resources) || containsOnlyNonProjects(resources))) {
+ return false;
+ }
+
+ if (resources.length == 0) {
+ return false;
+ }
+ // Return true if everything in the selection exists.
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (resource.isPhantom()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns whether the selection contains linked resources.
+ * @param resources
+ * the selected resources
+ * @return true if the resources contain linked resources, and false otherwise
+ */
+ private boolean containsLinkedResource(IResource[] resources) {
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (resource.isLinked()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns whether the selection contains only non-projects.
+ * @param resources
+ * the selected resources
+ * @return true if the resources contains only non-projects, and false otherwise
+ */
+ private boolean containsOnlyNonProjects(IResource[] resources) {
+ int types = getSelectedResourceTypes(resources);
+ // check for empty selection
+ if (types == 0) {
+ return false;
+ }
+ // note that the selection may contain multiple types of resource
+ return (types & IResource.PROJECT) == 0;
+ }
+
+ /**
+ * Returns whether the selection contains only projects.
+ * @param resources
+ * the selected resources
+ * @return true if the resources contains only projects, and false otherwise
+ */
+ private boolean containsOnlyProjects(IResource[] resources) {
+ int types = getSelectedResourceTypes(resources);
+ // note that the selection may contain multiple types of resource
+ return types == IResource.PROJECT;
+ }
+
+ /**
+ * Asks the user to confirm a delete operation.
+ * @param resources
+ * the selected resources
+ * @return true if the user says to go ahead, and false if the deletion should be
+ * abandoned
+ */
+ private boolean confirmDelete(IResource[] resources) {
+ if (containsOnlyProjects(resources)) {
+ return confirmDeleteProjects(resources);
+ }
+ return confirmDeleteNonProjects(resources);
+
+ }
+
+ /**
+ * Asks the user to confirm a delete operation, where the selection contains no projects.
+ * @param resources
+ * the selected resources
+ * @return true if the user says to go ahead, and false if the deletion should be
+ * abandoned
+ */
+ private boolean confirmDeleteNonProjects(IResource[] resources) {
+ String title;
+ String msg;
+ if (resources.length == 1) {
+ title = IDEWorkbenchMessages.DeleteResourceAction_title1;
+ IResource resource = resources[0];
+ if (resource.isLinked()) {
+ msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResource1, resource.getName());
+ } else {
+ msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirm1, resource.getName());
+ }
+ } else {
+ title = IDEWorkbenchMessages.DeleteResourceAction_titleN;
+ if (containsLinkedResource(resources)) {
+ msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmLinkedResourceN, new Integer(
+ resources.length));
+ } else {
+ msg = NLS.bind(IDEWorkbenchMessages.DeleteResourceAction_confirmN, new Integer(resources.length));
+ }
+ }
+ return MessageDialog.openQuestion(shellProvider.getShell(), title, msg);
+ }
+
+ /**
+ * Asks the user to confirm a delete operation, where the selection contains only projects. Also remembers whether
+ * project content should be deleted.
+ * @param resources
+ * the selected resources
+ * @return true if the user says to go ahead, and false if the deletion should be
+ * abandoned
+ */
+ private boolean confirmDeleteProjects(IResource[] resources) {
+ DeleteProjectDialog dialog = new DeleteProjectDialog(shellProvider.getShell(), resources);
+ dialog.setTestingMode(fTestingMode);
+ int code = dialog.open();
+ deleteContent = dialog.getDeleteContent();
+ return code == 0; // YES
+ }
+
+ /**
+ * Return an array of the currently selected resources.
+ * @return the selected resources
+ */
+ private IResource[] getSelectedResourcesArray() {
+ List selection = getSelectedResources();
+ IResource[] resources = new IResource[selection.size()];
+ selection.toArray(resources);
+ return resources;
+ }
+
+ /**
+ * Returns a bit-mask containing the types of resources in the selection.
+ * @param resources
+ * the selected resources
+ */
+ private int getSelectedResourceTypes(IResource[] resources) {
+ int types = 0;
+ for (int i = 0; i < resources.length; i++) {
+ types |= resources[i].getType();
+ }
+ return types;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IAction.
+ */
+ public void run() {
+ final IResource[] resources = getSelectedResourcesArray();
+
+ if (!fTestingMode) {
+ if (LTKLauncher.openDeleteWizard(getStructuredSelection())) {
+ return;
+ }
+ }
+
+ // WARNING: do not query the selected resources more than once
+ // since the selection may change during the run,
+ // e.g. due to window activation when the prompt dialog is dismissed.
+ // For more details, see Bug 60606 [Navigator] (data loss) Navigator
+ // deletes/moves the wrong file
+ if (!confirmDelete(resources)) {
+ return;
+ }
+
+ Job deletionCheckJob = new Job(IDEWorkbenchMessages.DeleteResourceAction_checkJobName) {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IStatus run(IProgressMonitor monitor) {
+ if (resources.length == 0)
+ return Status.CANCEL_STATUS;
+ closeRelatedEditors();
+ scheduleDeleteJob(resources);
+ return Status.OK_STATUS;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
+ */
+ public boolean belongsTo(Object family) {
+ if (IDEWorkbenchMessages.DeleteResourceAction_jobName.equals(family)) {
+ return true;
+ }
+ return super.belongsTo(family);
+ }
+ };
+
+ deletionCheckJob.schedule();
+
+ }
+
+ /**
+ * Schedule a job to delete the resources to delete.
+ * @param resourcesToDelete
+ */
+ private void scheduleDeleteJob(final IResource[] resourcesToDelete) {
+ // use a non-workspace job with a runnable inside so we can avoid
+ // periodic updates
+ Job deleteJob = new Job(IDEWorkbenchMessages.DeleteResourceAction_jobName) {
+ public IStatus run(final IProgressMonitor monitor) {
+ try {
+ final DeleteResourcesOperation op = new DeleteResourcesOperation(resourcesToDelete,
+ IDEWorkbenchMessages.DeleteResourceAction_operationLabel, deleteContent);
+ op.setModelProviderIds(getModelProviderIds());
+ // If we are deleting projects and their content, do not
+ // execute the operation in the undo history, since it cannot be
+ // properly restored. Just execute it directly so it won't be
+ // added to the undo history.
+ if (deleteContent && containsOnlyProjects(resourcesToDelete)) {
+ // We must compute the execution status first so that any user prompting
+ // or validation checking occurs. Do it in a syncExec because
+ // we are calling this from a Job.
+ WorkbenchJob statusJob = new WorkbenchJob("Status checking") { //$NON-NLS-1$
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ return op.computeExecutionStatus(monitor);
+ }
+
+ };
+
+ statusJob.setSystem(true);
+ statusJob.schedule();
+ try {// block until the status is ready
+ statusJob.join();
+ } catch (InterruptedException e) {
+ // Do nothing as status will be a cancel
+ }
+
+ if (statusJob.getResult().isOK()) {
+ return op.execute(monitor, WorkspaceUndoUtil.getUIInfoAdapter(shellProvider.getShell()));
+ }
+ return statusJob.getResult();
+ }
+ return PlatformUI.getWorkbench().getOperationSupport().getOperationHistory()
+ .execute(op, monitor, WorkspaceUndoUtil.getUIInfoAdapter(shellProvider.getShell()));
+ } catch (ExecutionException e) {
+ if (e.getCause() instanceof CoreException) {
+ return ((CoreException) e.getCause()).getStatus();
+ }
+ return new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, e.getMessage(), e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object)
+ */
+ public boolean belongsTo(Object family) {
+ if (IDEWorkbenchMessages.DeleteResourceAction_jobName.equals(family)) {
+ return true;
+ }
+ return super.belongsTo(family);
+ }
+
+ };
+ deleteJob.setUser(true);
+ deleteJob.schedule();
+ }
+
+ /**
+ * åˆ é™¤æ–‡ä»¶æ—¶ï¼Œå¦‚æžœæ–‡ä»¶åœ¨ç¼–è¾‘å™¨ä¸å·²æ‰“开,则关é—æ¤æ–‡ä»¶ã€‚ ;
+ */
+ private void closeRelatedEditors() {
+ IWorkbenchPage page = null;
+ for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
+ if (window != null) {
+ page = window.getActivePage();
+ break;
+ }
+ }
+ if (page == null) {
+ return;
+ }
+ IEditorReference[] editorReferences = page.getEditorReferences();
+ final List selectionResource = getSelectedResources();
+ final List lstCloseEditor = new ArrayList();
+ final VTDGen vg = new VTDGen();
+ final AutoPilot ap = new AutoPilot();
+ final List inputList = new ArrayList();
+ for (final IEditorReference reference : editorReferences) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ IFile file = ((FileEditorInput) reference.getEditor(true).getEditorInput()).getFile();
+ if ("xlp".equals(file.getFileExtension())) {
+ if (vg.parseFile(file.getLocation().toOSString(), true)) {
+ VTDNav vn = vg.getNav();
+ ap.bind(vn);
+ try {
+ ap.selectXPath("/mergerFiles/mergerFile/@filePath");
+ int index = -1;
+ merge: while ((index = ap.evalXPath()) != -1) {
+ String fileLC = vn.toString(index + 1);
+ if (fileLC != null && !"".equals(fileLC)) {
+ for (IResource resource : selectionResource) {
+ if (resource instanceof IProject || resource instanceof IFolder) {
+ if (fileLC.startsWith(resource.getLocation().toOSString()
+ + File.separator)) {
+ lstCloseEditor.add(reference);
+ inputList.add(reference.getEditorInput());
+ break merge;
+ }
+ } else if (resource instanceof IFile) {
+ if (resource.getLocation().toOSString().equals(fileLC)) {
+ lstCloseEditor.add(reference);
+ inputList.add(reference.getEditorInput());
+ break merge;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ } else {
+ try {
+ for (IResource resource : selectionResource) {
+ if (resource instanceof IProject) {
+ if (resource.getLocation().toOSString()
+ .equals(file.getProject().getLocation().toOSString())) {
+ lstCloseEditor.add(reference);
+ inputList.add(reference.getEditorInput());
+ break;
+ }
+ } else if (resource instanceof IFolder) {
+ if (file.getLocation().toOSString()
+ .startsWith(resource.getLocation().toOSString() + File.separator)) {
+ lstCloseEditor.add(reference);
+ inputList.add(reference.getEditorInput());
+ break;
+ }
+ } else if (resource instanceof IFile) {
+ if (resource.getLocation().toOSString().equals(file.getLocation().toOSString())) {
+ lstCloseEditor.add(reference);
+ inputList.add(reference.getEditorInput());
+ break;
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+
+ final IWorkbenchPage page2 = page;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ IEditorReference[] arrEditorReference = new IEditorReference[lstCloseEditor.size()];
+ page2.closeEditors(lstCloseEditor.toArray(arrEditorReference), false);
+
+ // åˆ é™¤æ–‡ä»¶æ—¶ï¼Œåˆ·æ–°è®¿é—®è®°å½• robert 2012-11-20
+ for (IEditorInput input : inputList) {
+ System.out.println("input = " + input);
+ CommonFunction.refreshHistoryWhenDelete(input);
+ }
+ }
+ });
+ }
+
+ /**
+ * The DeleteResourceAction implementation of this SelectionListenerAction method disables
+ * the action if the selection contains phantom resources or non-resources
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ return super.updateSelection(selection) && canDelete(getSelectedResourcesArray());
+ }
+
+ /**
+ * Returns the model provider ids that are known to the client that instantiated this operation.
+ * @return the model provider ids that are known to the client that instantiated this operation.
+ * @since 3.2
+ */
+ public String[] getModelProviderIds() {
+ return modelProviderIds;
+ }
+
+ /**
+ * Sets the model provider ids that are known to the client that instantiated this operation. Any potential side
+ * effects reported by these models during validation will be ignored.
+ * @param modelProviderIds
+ * the model providers known to the client who is using this operation.
+ * @since 3.2
+ */
+ public void setModelProviderIds(String[] modelProviderIds) {
+ this.modelProviderIds = modelProviderIds;
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/EditActionGroup.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/EditActionGroup.java
new file mode 100644
index 0000000..956fb52
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/EditActionGroup.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.TextActionHandler;
+import org.eclipse.ui.ide.ResourceSelectionUtil;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+/**
+ * @since 3.2
+ */
+public class EditActionGroup extends ActionGroup {
+
+ private Clipboard clipboard;
+
+ private CopyAction copyAction;
+
+ private DeleteResourceAndCloseEditorAction deleteAction;
+
+ private PasteAction pasteAction;
+
+ private TextActionHandler textActionHandler;
+
+ private Shell shell;
+
+ /**
+ * @param aShell
+ */
+ public EditActionGroup(Shell aShell) {
+ shell = aShell;
+ makeActions();
+ }
+
+ public void dispose() {
+ if (clipboard != null) {
+ clipboard.dispose();
+ clipboard = null;
+ }
+ super.dispose();
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+
+ boolean anyResourceSelected = !selection.isEmpty()
+ && ResourceSelectionUtil.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER
+ | IResource.FILE);
+
+ copyAction.selectionChanged(selection);
+ // menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, copyAction);
+ pasteAction.selectionChanged(selection);
+ // menu.insertAfter(copyAction.getId(), pasteAction);
+ // menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, pasteAction);
+
+ if (anyResourceSelected) {
+ deleteAction.selectionChanged(selection);
+ // menu.insertAfter(pasteAction.getId(), deleteAction);
+ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, deleteAction);
+ }
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+
+ if (textActionHandler == null) {
+ textActionHandler = new TextActionHandler(actionBars); // hook
+ // handlers
+ }
+ textActionHandler.setCopyAction(copyAction);
+ textActionHandler.setPasteAction(pasteAction);
+ textActionHandler.setDeleteAction(deleteAction);
+ // renameAction.setTextActionHandler(textActionHandler);
+ updateActionBars();
+
+ textActionHandler.updateActionBars();
+ }
+
+ /**
+ * Handles a key pressed event by invoking the appropriate action.
+ * @param event
+ * The Key Event
+ */
+ public void handleKeyPressed(KeyEvent event) {
+ if (event.character == SWT.DEL && event.stateMask == 0) {
+ if (deleteAction.isEnabled()) {
+ deleteAction.run();
+ }
+
+ // Swallow the event.
+ event.doit = false;
+ }
+ }
+
+ protected void makeActions() {
+ clipboard = new Clipboard(shell.getDisplay());
+
+ pasteAction = new PasteAction(shell, clipboard);
+ pasteAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_pasteAction);
+ ISharedImages images = PlatformUI.getWorkbench().getSharedImages();
+ pasteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED));
+ pasteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_PASTE));
+ pasteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
+
+ copyAction = new CopyAction(shell, clipboard, pasteAction);
+ copyAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_copyAction);
+ copyAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED));
+ copyAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
+ copyAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
+
+ IShellProvider sp = new IShellProvider() {
+ public Shell getShell() {
+ return shell;
+ }
+ };
+
+ deleteAction = new DeleteResourceAndCloseEditorAction(sp);
+ deleteAction.setText(WorkbenchNavigatorMessages.actions_EditActionGroup_deleteAction);
+ deleteAction.setDisabledImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ deleteAction.setImageDescriptor(images.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+ deleteAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
+ }
+
+ public void updateActionBars() {
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+
+ copyAction.selectionChanged(selection);
+ pasteAction.selectionChanged(selection);
+ deleteAction.selectionChanged(selection);
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/EditActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/EditActionProvider.java
new file mode 100644
index 0000000..8d58dba
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/EditActionProvider.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+
+/**
+ * @since 3.2
+ *
+ */
+public class EditActionProvider extends CommonActionProvider {
+
+ private EditActionGroup editGroup;
+
+ private ICommonActionExtensionSite site;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+ */
+ public void init(ICommonActionExtensionSite anActionSite) {
+ site = anActionSite;
+ editGroup = new EditActionGroup(site.getViewSite().getShell());
+
+ }
+
+ public void dispose() {
+ editGroup.dispose();
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ editGroup.fillActionBars(actionBars);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ editGroup.fillContextMenu(menu);
+ }
+
+ public void setContext(ActionContext context) {
+ editGroup.setContext(context);
+ }
+
+ public void updateActionBars() {
+ editGroup.updateActionBars();
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoActionProvider.java
new file mode 100644
index 0000000..28c80cc
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoActionProvider.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Oakland Software (Francis Upton - francisu@ieee.org)
+ * bug 214271 Undo/redo not enabled if nothing selected
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+
+/**
+ * @since 3.3
+ *
+ */
+public class GotoActionProvider extends CommonActionProvider {
+
+ private GotoResourceAction gotoAction;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+ */
+ public void init(ICommonActionExtensionSite anActionSite) {
+ gotoAction = new GotoResourceAction(anActionSite.getViewSite().getShell(), (CommonViewer)anActionSite.getStructuredViewer());
+ }
+
+
+ public void fillActionBars(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler(
+ IWorkbenchActionConstants.GO_TO_RESOURCE, gotoAction);
+ updateActionBars();
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoResourceAction.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoResourceAction.java
new file mode 100644
index 0000000..87fb857
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoResourceAction.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.navigator.INavigatorHelpContextIds;
+
+/**
+ * Implements the go to resource action. Opens a dialog and set the navigator
+ * selection with the resource selected by the user.
+ */
+public class GotoResourceAction extends Action {
+
+ protected Shell shell;
+
+ protected TreeViewer viewer;
+
+ /**
+ * @param shell
+ * @param viewer
+ */
+ public GotoResourceAction(Shell shell, TreeViewer viewer) {
+ this.shell = shell;
+ this.viewer = viewer;
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+ INavigatorHelpContextIds.GOTO_RESOURCE_ACTION);
+ }
+
+ /**
+ * Collect all resources in the workbench open a dialog asking the user to
+ * select a resource and change the selection in the navigator.
+ */
+ public void run() {
+ GotoResourceDialog dialog = new GotoResourceDialog(shell,
+ ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE
+ | IResource.FOLDER | IResource.PROJECT);
+ dialog.open();
+ Object[] result = dialog.getResult();
+ if (result == null || result.length == 0
+ || result[0] instanceof IResource == false) {
+ return;
+ }
+
+ IResource selection = (IResource) result[0];
+ viewer.setSelection(new StructuredSelection(selection), true);
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoResourceDialog.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoResourceDialog.java
new file mode 100644
index 0000000..2facfac
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/GotoResourceDialog.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog;
+import org.eclipse.ui.internal.navigator.INavigatorHelpContextIds;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+
+/**
+ * Shows a list of resources to the user with a text entry field for a string
+ * pattern used to filter the list of resources.
+ *
+ */
+/* package */class GotoResourceDialog extends FilteredResourcesSelectionDialog {
+
+ /**
+ * Creates a new instance of the class.
+ */
+ protected GotoResourceDialog(Shell parentShell, IContainer container,
+ int typesMask) {
+ super(parentShell, false, container, typesMask);
+ setTitle(WorkbenchNavigatorMessages.actions_GotoResourceDialog_GoToTitle);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(parentShell,
+ INavigatorHelpContextIds.GOTO_RESOURCE_DIALOG);
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/NewActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/NewActionProvider.java
new file mode 100644
index 0000000..7b4a4d2
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/NewActionProvider.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.navigator.WizardActionGroup;
+import org.eclipse.ui.wizards.IWizardCategory;
+import org.eclipse.ui.wizards.IWizardRegistry;
+
+/**
+ * Provides the new (artifact creation) menu options for a context menu.
+ *
+ *
+ * The added submenu has the following structure
+ *
+ *
+ *
+ *
a new generic project wizard shortcut action,
+ *
a separator,
+ *
a set of context senstive wizard shortcuts (as defined by
+ * org.eclipse.ui.navigator.commonWizard),
+ *
another separator,
+ *
a generic examples wizard shortcut action, and finally
+ *
a generic "Other" new wizard shortcut action
+ *
+ *
+ * @since 3.2
+ *
+ */
+public class NewActionProvider extends CommonActionProvider {
+
+ private static final String FULL_EXAMPLES_WIZARD_CATEGORY = "org.eclipse.ui.Examples"; //$NON-NLS-1$
+
+ private static final String NEW_MENU_NAME = "common.new.menu";//$NON-NLS-1$
+
+ private ActionFactory.IWorkbenchAction showDlgAction;
+
+ private IAction newProjectAction;
+
+ private IAction newExampleAction;
+
+ private WizardActionGroup newWizardActionGroup;
+
+ private boolean contribute = false;
+
+ public void init(ICommonActionExtensionSite anExtensionSite) {
+
+ if (anExtensionSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+ IWorkbenchWindow window = ((ICommonViewerWorkbenchSite) anExtensionSite.getViewSite()).getWorkbenchWindow();
+ showDlgAction = ActionFactory.NEW_WIZARD_DROP_DOWN.create(window);
+ showDlgAction.setText(WorkbenchNavigatorMessages.actions_NewActionProvider_NewMenu_label);
+ contribute = true;
+ }
+ }
+
+ /**
+ * Adds a submenu to the given menu with the name "group.new" see
+ * {@link ICommonMenuConstants#GROUP_NEW}). The submenu contains the following structure:
+ *
+ *
+ *
a new generic project wizard shortcut action,
+ *
a separator,
+ *
a set of context senstive wizard shortcuts (as defined by
+ * org.eclipse.ui.navigator.commonWizard),
+ *
another separator,
+ *
a generic examples wizard shortcut action, and finally
+ * This class may be instantiated; it is not intended to be subclassed.
+ *
+ *
+ * @since 2.0
+ */
+/*package*/class PasteAction extends SelectionListenerAction {
+
+ /**
+ * The id of this action.
+ */
+ public static final String ID = PlatformUI.PLUGIN_ID + ".PasteAction";//$NON-NLS-1$
+
+ /**
+ * The shell in which to show any dialogs.
+ */
+ private Shell shell;
+
+ /**
+ * System clipboard
+ */
+ private Clipboard clipboard;
+
+ /**
+ * Creates a new action.
+ *
+ * @param shell the shell for any dialogs
+ * @param clipboard the clipboard
+ */
+ public PasteAction(Shell shell, Clipboard clipboard) {
+ super(WorkbenchNavigatorMessages.actions_PasteAction_Past_);
+ Assert.isNotNull(shell);
+ Assert.isNotNull(clipboard);
+ this.shell = shell;
+ this.clipboard = clipboard;
+ setToolTipText(WorkbenchNavigatorMessages.actions_PasteAction_Paste_selected_resource_s_);
+ setId(PasteAction.ID);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this, "HelpId"); //$NON-NLS-1$
+ // TODO INavigatorHelpContextIds.PASTE_ACTION);
+ }
+
+ /**
+ * Returns the actual target of the paste action. Returns null
+ * if no valid target is selected.
+ *
+ * @return the actual target of the paste action
+ */
+ private IResource getTarget() {
+ List selectedResources = getSelectedResources();
+
+ for (int i = 0; i < selectedResources.size(); i++) {
+ IResource resource = (IResource) selectedResources.get(i);
+
+ if (resource instanceof IProject && !((IProject) resource).isOpen()) {
+ return null;
+ }
+ if (resource.getType() == IResource.FILE) {
+ resource = resource.getParent();
+ }
+ if (resource != null) {
+ return resource;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns whether any of the given resources are linked resources.
+ *
+ * @param resources resource to check for linked type. may be null
+ * @return true=one or more resources are linked. false=none of the
+ * resources are linked
+ */
+ private boolean isLinked(IResource[] resources) {
+ for (int i = 0; i < resources.length; i++) {
+ if (resources[i].isLinked()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Implementation of method defined on IAction.
+ */
+ public void run() {
+ // try a resource transfer
+ ResourceTransfer resTransfer = ResourceTransfer.getInstance();
+ IResource[] resourceData = (IResource[]) clipboard
+ .getContents(resTransfer);
+
+ if (resourceData != null && resourceData.length > 0) {
+ if (resourceData[0].getType() == IResource.PROJECT) {
+ // enablement checks for all projects
+ for (int i = 0; i < resourceData.length; i++) {
+ CopyProjectOperation operation = new CopyProjectOperation(
+ this.shell);
+ operation.copyProject((IProject) resourceData[i]);
+ }
+ } else {
+ // enablement should ensure that we always have access to a container
+ IContainer container = getContainer();
+
+ CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
+ this.shell);
+ operation.copyResources(resourceData, container);
+ }
+ return;
+ }
+
+ // try a file transfer
+ FileTransfer fileTransfer = FileTransfer.getInstance();
+ String[] fileData = (String[]) clipboard.getContents(fileTransfer);
+
+ if (fileData != null) {
+ // enablement should ensure that we always have access to a container
+ IContainer container = getContainer();
+
+ CopyFilesAndFoldersOperation operation = new CopyFilesAndFoldersOperation(
+ this.shell);
+ operation.copyFiles(fileData, container);
+ }
+ }
+
+ /**
+ * Returns the container to hold the pasted resources.
+ */
+ private IContainer getContainer() {
+ List selection = getSelectedResources();
+ if (selection.get(0) instanceof IFile) {
+ return ((IFile) selection.get(0)).getParent();
+ }
+ return (IContainer) selection.get(0);
+ }
+
+ /**
+ * The PasteAction implementation of this
+ * SelectionListenerAction method enables this action if
+ * a resource compatible with what is on the clipboard is selected.
+ *
+ * -Clipboard must have IResource or java.io.File
+ * -Projects can always be pasted if they are open
+ * -Workspace folder may not be copied into itself
+ * -Files and folders may be pasted to a single selected folder in open
+ * project or multiple selected files in the same folder
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ if (!super.updateSelection(selection)) {
+ return false;
+ }
+
+ final IResource[][] clipboardData = new IResource[1][];
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ // clipboard must have resources or files
+ ResourceTransfer resTransfer = ResourceTransfer.getInstance();
+ clipboardData[0] = (IResource[]) clipboard
+ .getContents(resTransfer);
+ }
+ });
+ IResource[] resourceData = clipboardData[0];
+ boolean isProjectRes = resourceData != null && resourceData.length > 0
+ && resourceData[0].getType() == IResource.PROJECT;
+
+ if (isProjectRes) {
+ for (int i = 0; i < resourceData.length; i++) {
+ // make sure all resource data are open projects
+ // can paste open projects regardless of selection
+ if (resourceData[i].getType() != IResource.PROJECT
+ || ((IProject) resourceData[i]).isOpen() == false) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ if (getSelectedNonResources().size() > 0) {
+ return false;
+ }
+
+ IResource targetResource = getTarget();
+ // targetResource is null if no valid target is selected (e.g., open project)
+ // or selection is empty
+ if (targetResource == null) {
+ return false;
+ }
+
+ // can paste files and folders to a single selection (file, folder,
+ // open project) or multiple file selection with the same parent
+ List selectedResources = getSelectedResources();
+ if (selectedResources.size() > 1) {
+ for (int i = 0; i < selectedResources.size(); i++) {
+ IResource resource = (IResource) selectedResources.get(i);
+ if (resource.getType() != IResource.FILE) {
+ return false;
+ }
+ if (!targetResource.equals(resource.getParent())) {
+ return false;
+ }
+ }
+ }
+ if (resourceData != null) {
+ // linked resources can only be pasted into projects
+ if (isLinked(resourceData)
+ && targetResource.getType() != IResource.PROJECT
+ && targetResource.getType() != IResource.FOLDER) {
+ return false;
+ }
+
+ if (targetResource.getType() == IResource.FOLDER) {
+ // don't try to copy folder to self
+ for (int i = 0; i < resourceData.length; i++) {
+ if (targetResource.equals(resourceData[i])) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ TransferData[] transfers = clipboard.getAvailableTypes();
+ FileTransfer fileTransfer = FileTransfer.getInstance();
+ for (int i = 0; i < transfers.length; i++) {
+ if (fileTransfer.isSupportedType(transfers[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
+
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/PortingActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/PortingActionProvider.java
new file mode 100644
index 0000000..f469d21
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/PortingActionProvider.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Sebastian Davids - Collapse all action
+ * Sebastian Davids - Images for menu items
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import java.net.URL;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ExportResourcesAction;
+import org.eclipse.ui.actions.ImportResourcesAction;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.navigator.WizardActionGroup;
+
+/**
+ * Adds actions for Import/Export wizards. The group is smart, in that it will
+ * either add actions for Import and Export, or if there are context sensitive
+ * options available (as defined by org.eclipse.ui.navigator.commonWizard),
+ * then it will compound these options into a submenu with the appropriate lead
+ * text ("Import" or "Export").
+ *
+ *
+ * EXPERIMENTAL. This class or interface has been added as
+ * part of a work in progress. There is a guarantee neither that this API will
+ * work nor that it will remain the same. Please do not use this API without
+ * consulting with the Platform/UI team.
+ *
+ *
+ * @since 3.2
+ */
+public class PortingActionProvider extends CommonActionProvider {
+
+ private static final String COMMON_NAVIGATOR_IMPORT_MENU = "common.import.menu"; //$NON-NLS-1$
+
+ private static final String COMMON_NAVIGATOR_EXPORT_MENU = "common.export.menu"; //$NON-NLS-1$
+
+ private ImportResourcesAction importAction;
+
+ private ExportResourcesAction exportAction;
+
+ private WizardActionGroup importWizardActionGroup;
+
+ private WizardActionGroup exportWizardActionGroup;
+
+ private boolean disposed = false;
+
+ private boolean contribute= false;
+
+ public void init(ICommonActionExtensionSite anExtensionSite) {
+
+ Assert.isTrue(!disposed);
+
+ if (anExtensionSite.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+
+ IWorkbenchWindow window = ((ICommonViewerWorkbenchSite) anExtensionSite
+ .getViewSite()).getWorkbenchWindow();
+ importAction = new ImportResourcesAction(window);
+ importAction.setText(WorkbenchNavigatorMessages.PortingActionProvider_ImportResourcesMenu_label);
+ exportAction = new ExportResourcesAction(window);
+ exportAction.setText(WorkbenchNavigatorMessages.PortingActionProvider_ExportResourcesMenu_label);
+ importWizardActionGroup = new WizardActionGroup(window, PlatformUI
+ .getWorkbench().getImportWizardRegistry(),
+ WizardActionGroup.TYPE_IMPORT, anExtensionSite.getContentService());
+ exportWizardActionGroup = new WizardActionGroup(window, PlatformUI
+ .getWorkbench().getExportWizardRegistry(),
+ WizardActionGroup.TYPE_EXPORT, anExtensionSite.getContentService());
+ contribute = true;
+ }
+ }
+
+ /**
+ * Extends the superclass implementation to dispose the subgroups.
+ */
+ public void dispose() {
+ if(!contribute) {
+ return;
+ }
+ importWizardActionGroup.dispose();
+ exportWizardActionGroup.dispose();
+ importAction = null;
+ exportAction = null;
+ disposed = true;
+ }
+
+ public void fillContextMenu(IMenuManager aMenu) {
+ if(!contribute) {
+ return;
+ }
+
+ Assert.isTrue(!disposed);
+
+ ISelection selection = getContext().getSelection();
+ if (!(selection instanceof IStructuredSelection) || ((IStructuredSelection) selection).size() > 1) {
+ addSimplePortingMenus(aMenu);
+ } else {
+ addImportMenu(aMenu);
+ addExportMenu(aMenu);
+ }
+ }
+
+ /**
+ * Returns the image descriptor with the given relative path.
+ */
+ protected ImageDescriptor getImageDescriptor(String relativePath) {
+ String iconPath = "icons/full/"; //$NON-NLS-1$
+ URL url = FileLocator.find(WorkbenchNavigatorPlugin.getDefault().getBundle(), new Path(iconPath + relativePath), Collections.EMPTY_MAP);
+ if (url == null) {
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+ return ImageDescriptor.createFromURL(url);
+ }
+
+ private void addSimplePortingMenus(IMenuManager aMenu) {
+ aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, importAction);
+ aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, exportAction);
+ }
+
+ private void addImportMenu(IMenuManager aMenu) {
+
+ importWizardActionGroup.setContext(getContext());
+ if (importWizardActionGroup.getWizardActionIds().length == 0) {
+ aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, importAction);
+ return;
+ }
+
+ IMenuManager submenu = new MenuManager(
+ WorkbenchNavigatorMessages.PortingActionProvider_ImportResourcesMenu_label,
+ COMMON_NAVIGATOR_IMPORT_MENU);
+ importWizardActionGroup.fillContextMenu(submenu);
+
+ submenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
+ submenu.add(new Separator());
+ submenu.add(importAction);
+ aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, submenu);
+ }
+
+ private void addExportMenu(IMenuManager aMenu) {
+
+ exportWizardActionGroup.setContext(getContext());
+ if (exportWizardActionGroup.getWizardActionIds().length == 0) {
+ aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, exportAction);
+ return;
+ }
+ IMenuManager submenu = new MenuManager(
+ WorkbenchNavigatorMessages.PortingActionProvider_ExportResourcesMenu_label,
+ COMMON_NAVIGATOR_EXPORT_MENU);
+ exportWizardActionGroup.fillContextMenu(submenu);
+
+ submenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
+ submenu.add(new Separator());
+ submenu.add(exportAction);
+ aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, submenu);
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/PropertiesActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/PropertiesActionProvider.java
new file mode 100644
index 0000000..e170973
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/PropertiesActionProvider.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.dialogs.PropertyDialogAction;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+/**
+ * Adds the properties action to the menu.
+ *
+ * @since 3.2
+ *
+ */
+public class PropertiesActionProvider extends CommonActionProvider {
+
+ private PropertyDialogAction propertiesAction;
+ private ISelectionProvider delegateSelectionProvider;
+
+ public void init(final ICommonActionExtensionSite aSite) {
+
+ delegateSelectionProvider = new DelegateSelectionProvider( aSite.getViewSite().getSelectionProvider());
+ propertiesAction = new PropertyDialogAction(new IShellProvider() {
+ public Shell getShell() {
+ return aSite.getViewSite().getShell();
+ }
+ },delegateSelectionProvider);
+ propertiesAction.setText("属性");
+ propertiesAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ super.fillContextMenu(menu);
+
+ if (propertiesAction.isApplicableForSelection()) {
+ menu.appendToGroup(ICommonMenuConstants.GROUP_PROPERTIES,
+ propertiesAction);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars
+ * )
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ super.fillActionBars(actionBars);
+
+ actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(),
+ propertiesAction);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.ActionContext)
+ */
+ public void setContext(ActionContext context) {
+ super.setContext(context);
+
+ propertiesAction.selectionChanged(delegateSelectionProvider
+ .getSelection());
+
+ }
+
+ private class DelegateIAdaptable implements IAdaptable {
+
+ private Object delegate;
+
+ private DelegateIAdaptable(Object o) {
+ delegate = o;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter.isInstance(delegate) || delegate == null) {
+ return delegate;
+ }
+ return Platform.getAdapterManager().getAdapter(delegate, adapter);
+ }
+ }
+
+ private class DelegateSelectionProvider implements ISelectionProvider {
+
+ private ISelectionProvider delegate;
+
+ private DelegateSelectionProvider(ISelectionProvider s) {
+ delegate = s;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
+ */
+ public void addSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ delegate.addSelectionChangedListener(listener);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
+ */
+ public ISelection getSelection() {
+ if (delegate.getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection sSel = (IStructuredSelection) delegate
+ .getSelection();
+ if (sSel.getFirstElement() instanceof IAdaptable) {
+ return sSel;
+ }
+
+ return new StructuredSelection(new DelegateIAdaptable(sSel
+ .getFirstElement()));
+ }
+ return delegate.getSelection();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
+ */
+ public void removeSelectionChangedListener(
+ ISelectionChangedListener listener) {
+ delegate.removeSelectionChangedListener(listener);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
+ */
+ public void setSelection(ISelection selection) {
+ delegate.setSelection(selection);
+
+ }
+
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RefactorActionGroup.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RefactorActionGroup.java
new file mode 100644
index 0000000..cd66295
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RefactorActionGroup.java
@@ -0,0 +1,122 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2010 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Sebastian Davids - Images for menu items (27481)
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.actions.MoveResourceAction;
+import org.eclipse.ui.actions.RenameResourceAction;
+import org.eclipse.ui.ide.ResourceSelectionUtil;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+
+/**
+ * This is the action group for refactor actions, including global action
+ * handlers for copy, paste and delete.
+ *
+ * @since 2.0
+ */
+public class RefactorActionGroup extends ActionGroup {
+
+ private RenameResourceAndCloseEditorAction renameAction;
+
+ private MoveResourceAction moveAction;
+
+ private Shell shell;
+
+ private Tree tree;
+
+ /**
+ *
+ * @param aShell
+ * @param aTree
+ */
+ public RefactorActionGroup(Shell aShell, Tree aTree) {
+ shell = aShell;
+ tree = aTree;
+ makeActions();
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+
+ boolean anyResourceSelected = !selection.isEmpty()
+ && ResourceSelectionUtil.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER | IResource.FILE);
+
+ if (anyResourceSelected) {
+ moveAction.selectionChanged(selection);
+// menu.appendToGroup(ICommonMenuConstants.GROUP_REORGANIZE, moveAction);
+ renameAction.selectionChanged(selection);
+// menu.insertAfter(moveAction.getId(), renameAction);
+ }
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+
+ // renameAction.setTextActionHandler(textActionHandler);
+ updateActionBars();
+
+ actionBars.setGlobalActionHandler(ActionFactory.MOVE.getId(), moveAction);
+ actionBars.setGlobalActionHandler(ActionFactory.RENAME.getId(), renameAction);
+ }
+
+ /**
+ * Handles a key pressed event by invoking the appropriate action.
+ *
+ * @param event
+ * The Key Event
+ */
+ public void handleKeyPressed(KeyEvent event) {
+
+ if (event.keyCode == SWT.F2 && event.stateMask == 0) {
+ if (renameAction.isEnabled()) {
+ renameAction.run();
+ }
+
+ // Swallow the event.
+ event.doit = false;
+ }
+ }
+
+ protected void makeActions() {
+ IShellProvider sp = new IShellProvider() {
+ public Shell getShell() {
+ return shell;
+ }
+ };
+
+ moveAction = new MoveResourceAction(sp);
+ moveAction.setText(WorkbenchNavigatorMessages.actions_RefactorActionGroup_moveAction);
+ moveAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_MOVE);
+
+ renameAction = new RenameResourceAndCloseEditorAction(sp, tree);
+ renameAction.setText(WorkbenchNavigatorMessages.actions_RefactorActionGroup_renameAction);
+ renameAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_RENAME);
+ }
+
+ public void updateActionBars() {
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+
+ moveAction.selectionChanged(selection);
+ renameAction.selectionChanged(selection);
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RefactorActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RefactorActionProvider.java
new file mode 100644
index 0000000..2662ffe
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RefactorActionProvider.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Oakland Software (Francis Upton - francisu@ieee.org)
+ * bug 214271 Undo/redo not enabled if nothing selected
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+
+/**
+ * @since 3.2
+ *
+ */
+public class RefactorActionProvider extends CommonActionProvider {
+
+ private RefactorActionGroup refactorGroup;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+ */
+ public void init(ICommonActionExtensionSite anActionSite) {
+ refactorGroup = new RefactorActionGroup(anActionSite.getViewSite().getShell(), (Tree)anActionSite.getStructuredViewer().getControl());
+ }
+
+ public void dispose() {
+ refactorGroup.dispose();
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ refactorGroup.fillActionBars(actionBars);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ refactorGroup.fillContextMenu(menu);
+ }
+
+ public void setContext(ActionContext context) {
+ refactorGroup.setContext(context);
+ }
+
+ public void updateActionBars() {
+ refactorGroup.updateActionBars();
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RenameResourceAndCloseEditorAction.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RenameResourceAndCloseEditorAction.java
new file mode 100644
index 0000000..39dc568
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/RenameResourceAndCloseEditorAction.java
@@ -0,0 +1,797 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2008 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TreeEditor;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceAction;
+import org.eclipse.ui.ide.undo.MoveResourcesOperation;
+import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
+import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
+import org.eclipse.ui.internal.ide.actions.LTKLauncher;
+import org.eclipse.ui.internal.navigator.TextActionHandler;
+import org.eclipse.ui.part.FileEditorInput;
+
+import com.ximpleware.AutoPilot;
+import com.ximpleware.VTDGen;
+import com.ximpleware.VTDNav;
+
+/**
+ * Standard action for renaming the selected resources.
+ *
+ * This class may be instantiated; it is not intended to be subclassed.
+ *
+ * @noextend This class is not intended to be subclassed by clients.
+ */
+public class RenameResourceAndCloseEditorAction extends WorkspaceAction {
+
+ /*
+ * The tree editing widgets. If treeEditor is null then edit using the
+ * dialog. We keep the editorText around so that we can close it if a new
+ * selection is made.
+ */
+ private TreeEditor treeEditor;
+
+ private Tree navigatorTree;
+
+ private Text textEditor;
+
+ private Composite textEditorParent;
+
+ private TextActionHandler textActionHandler;
+
+ // The resource being edited if this is being done inline
+ private IResource inlinedResource;
+
+ private boolean saving = false;
+
+ /**
+ * The id of this action.
+ */
+ public static final String ID = PlatformUI.PLUGIN_ID
+ + ".RenameResourceAction";//$NON-NLS-1$
+
+ /**
+ * The new path.
+ */
+ private IPath newPath;
+
+ private String[] modelProviderIds;
+
+ private static final String CHECK_RENAME_TITLE = IDEWorkbenchMessages.RenameResourceAction_checkTitle;
+
+ private static final String CHECK_RENAME_MESSAGE = IDEWorkbenchMessages.RenameResourceAction_readOnlyCheck;
+
+ private static String RESOURCE_EXISTS_TITLE = IDEWorkbenchMessages.RenameResourceAction_resourceExists;
+
+ private static String RESOURCE_EXISTS_MESSAGE = IDEWorkbenchMessages.RenameResourceAction_overwriteQuestion;
+
+ private static String PROJECT_EXISTS_MESSAGE = IDEWorkbenchMessages.RenameResourceAction_overwriteProjectQuestion;
+
+ private static String PROJECT_EXISTS_TITLE = IDEWorkbenchMessages.RenameResourceAction_projectExists;
+
+ private IShellProvider shellProvider;
+ /**
+ * Creates a new action. Using this constructor directly will rename using a
+ * dialog rather than the inline editor of a ResourceNavigator.
+ *
+ * @param shell
+ * the shell for any dialogs
+ * @deprecated see {@link #RenameResourceAction(IShellProvider)}
+ */
+ public RenameResourceAndCloseEditorAction(Shell shell) {
+ super(shell, IDEWorkbenchMessages.RenameResourceAction_text);
+ initAction();
+ }
+
+ /**
+ * Creates a new action. Using this constructor directly will rename using a
+ * dialog rather than the inline editor of a ResourceNavigator.
+ *
+ * @param provider
+ * the IShellProvider for any dialogs
+ * @since 3.4
+ */
+ public RenameResourceAndCloseEditorAction(IShellProvider provider){
+ super(provider, IDEWorkbenchMessages.RenameResourceAction_text);
+ shellProvider = provider;
+ initAction();
+ }
+
+ private void initAction(){
+ setToolTipText(IDEWorkbenchMessages.RenameResourceAction_toolTip);
+ setId(ID);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
+ IIDEHelpContextIds.RENAME_RESOURCE_ACTION);
+ }
+ /**
+ * Creates a new action.
+ *
+ * @param shell
+ * the shell for any dialogs
+ * @param tree
+ * the tree
+ * @deprecated see {@link #RenameResourceAction(IShellProvider, Tree)}
+ */
+ public RenameResourceAndCloseEditorAction(Shell shell, Tree tree) {
+ this(shell);
+ this.navigatorTree = tree;
+ this.treeEditor = new TreeEditor(tree);
+ }
+
+ /**
+ * Creates a new action.
+ *
+ * @param provider
+ * the shell provider for any dialogs
+ * @param tree
+ * the tree
+ * @since 3.4
+ */
+ public RenameResourceAndCloseEditorAction(IShellProvider provider, Tree tree) {
+ this(provider);
+ this.navigatorTree = tree;
+ this.treeEditor = new TreeEditor(tree);
+ }
+
+ /**
+ * Check if the user wishes to overwrite the supplied resource
+ *
+ * @returns true if there is no collision or delete was successful
+ * @param shell
+ * the shell to create the dialog in
+ * @param destination -
+ * the resource to be overwritten
+ */
+ private boolean checkOverwrite(final Shell shell,
+ final IResource destination) {
+
+ final boolean[] result = new boolean[1];
+
+ // Run it inside of a runnable to make sure we get to parent off of the
+ // shell as we are not in the UI thread.
+
+ Runnable query = new Runnable() {
+ public void run() {
+ String pathName = destination.getFullPath().makeRelative()
+ .toString();
+ String message = RESOURCE_EXISTS_MESSAGE;
+ String title = RESOURCE_EXISTS_TITLE;
+ if (destination.getType() == IResource.PROJECT) {
+ message = PROJECT_EXISTS_MESSAGE;
+ title = PROJECT_EXISTS_TITLE;
+ }
+ result[0] = MessageDialog.openQuestion(shell,
+ title, MessageFormat.format(message,
+ new Object[] { pathName }));
+ }
+
+ };
+
+ shell.getDisplay().syncExec(query);
+ return result[0];
+ }
+
+ /**
+ * Check if the supplied resource is read only or null. If it is then ask
+ * the user if they want to continue. Return true if the resource is not
+ * read only or if the user has given permission.
+ *
+ * @return boolean
+ */
+ private boolean checkReadOnlyAndNull(IResource currentResource) {
+ // Do a quick read only and null check
+ if (currentResource == null) {
+ return false;
+ }
+
+ // Do a quick read only check
+ final ResourceAttributes attributes = currentResource
+ .getResourceAttributes();
+ if (attributes != null && attributes.isReadOnly()) {
+ return MessageDialog.openQuestion(shellProvider.getShell(), CHECK_RENAME_TITLE,
+ MessageFormat.format(CHECK_RENAME_MESSAGE,
+ new Object[] { currentResource.getName() }));
+ }
+
+ return true;
+ }
+
+ Composite createParent() {
+ Tree tree = getTree();
+ Composite result = new Composite(tree, SWT.NONE);
+ TreeItem[] selectedItems = tree.getSelection();
+ treeEditor.horizontalAlignment = SWT.LEFT;
+ treeEditor.grabHorizontal = true;
+ treeEditor.setEditor(result, selectedItems[0]);
+ return result;
+ }
+
+ /**
+ * Get the inset used for cell editors
+ * @param c the Control
+ * @return int
+ */
+ private static int getCellEditorInset(Control c) {
+ return 1; // one pixel wide black border
+ }
+
+ /**
+ * Create the text editor widget.
+ *
+ * @param resource
+ * the resource to rename
+ */
+ private void createTextEditor(final IResource resource) {
+ // Create text editor parent. This draws a nice bounding rect.
+ textEditorParent = createParent();
+ textEditorParent.setVisible(false);
+ final int inset = getCellEditorInset(textEditorParent);
+ if (inset > 0) {
+ textEditorParent.addListener(SWT.Paint, new Listener() {
+ public void handleEvent(Event e) {
+ Point textSize = textEditor.getSize();
+ Point parentSize = textEditorParent.getSize();
+ e.gc.drawRectangle(0, 0, Math.min(textSize.x + 4,
+ parentSize.x - 1), parentSize.y - 1);
+ }
+ });
+ }
+ // Create inner text editor.
+ textEditor = new Text(textEditorParent, SWT.NONE);
+ textEditor.setFont(navigatorTree.getFont());
+ textEditorParent.setBackground(textEditor.getBackground());
+ textEditor.addListener(SWT.Modify, new Listener() {
+ public void handleEvent(Event e) {
+ Point textSize = textEditor.computeSize(SWT.DEFAULT,
+ SWT.DEFAULT);
+ textSize.x += textSize.y; // Add extra space for new
+ // characters.
+ Point parentSize = textEditorParent.getSize();
+ textEditor.setBounds(2, inset, Math.min(textSize.x,
+ parentSize.x - 4), parentSize.y - 2 * inset);
+ textEditorParent.redraw();
+ }
+ });
+ textEditor.addListener(SWT.Traverse, new Listener() {
+ public void handleEvent(Event event) {
+
+ // Workaround for Bug 20214 due to extra
+ // traverse events
+ switch (event.detail) {
+ case SWT.TRAVERSE_ESCAPE:
+ // Do nothing in this case
+ disposeTextWidget();
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ case SWT.TRAVERSE_RETURN:
+ saveChangesAndDispose(resource);
+ event.doit = true;
+ event.detail = SWT.TRAVERSE_NONE;
+ break;
+ }
+ }
+ });
+ textEditor.addFocusListener(new FocusAdapter() {
+ public void focusLost(FocusEvent fe) {
+ saveChangesAndDispose(resource);
+ closeRelatedEditors();
+ }
+ });
+
+ if (textActionHandler != null) {
+ textActionHandler.addText(textEditor);
+ }
+ }
+
+ /**
+ * Close the text widget and reset the editorText field.
+ */
+ private void disposeTextWidget() {
+ if (textActionHandler != null) {
+ textActionHandler.removeText(textEditor);
+ }
+
+ if (textEditorParent != null) {
+ textEditorParent.dispose();
+ textEditorParent = null;
+ textEditor = null;
+ treeEditor.setEditor(null, null);
+ }
+ }
+
+ /**
+ * Returns the elements that the action is to be performed on. Return the
+ * resource cached by the action as we cannot rely on the selection being
+ * correct for inlined text.
+ *
+ * @return list of resource elements (element type: IResource)
+ */
+ protected List getActionResources() {
+ if (inlinedResource == null) {
+ return super.getActionResources();
+ }
+
+ List actionResources = new ArrayList();
+ actionResources.add(inlinedResource);
+ return actionResources;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on WorkspaceAction.
+ */
+ protected String getOperationMessage() {
+ return IDEWorkbenchMessages.RenameResourceAction_progress;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on WorkspaceAction.
+ */
+ protected String getProblemsMessage() {
+ return IDEWorkbenchMessages.RenameResourceAction_problemMessage;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on WorkspaceAction.
+ */
+ protected String getProblemsTitle() {
+ return IDEWorkbenchMessages.RenameResourceAction_problemTitle;
+ }
+
+ /**
+ * Get the Tree being edited.
+ *
+ * @returnTree
+ */
+ private Tree getTree() {
+ return this.navigatorTree;
+ }
+
+ /**
+ * Return the new name to be given to the target resource.
+ *
+ * @return java.lang.String
+ * @param resource
+ * the resource to query status on
+ */
+ protected String queryNewResourceName(final IResource resource) {
+ final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
+ final IPath prefix = resource.getFullPath().removeLastSegments(1);
+ IInputValidator validator = new IInputValidator() {
+ public String isValid(String string) {
+ if (resource.getName().equals(string)) {
+ return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
+ }
+ IStatus status = workspace.validateName(string, resource
+ .getType());
+ if (!status.isOK()) {
+ return status.getMessage();
+ }
+ if (workspace.getRoot().exists(prefix.append(string))) {
+ return IDEWorkbenchMessages.RenameResourceAction_nameExists;
+ }
+ return null;
+ }
+ };
+
+ InputDialog dialog = new InputDialog(shellProvider.getShell(),
+ IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle,
+ IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage,
+ resource.getName(), validator);
+ dialog.setBlockOnOpen(true);
+ int result = dialog.open();
+ if (result == Window.OK)
+ return dialog.getValue();
+ return null;
+ }
+
+ /**
+ * Return the new name to be given to the target resource or
+ * null
+ * if the query was canceled. Rename the currently selected resource using the table editor.
+ * Continue the action when the user is done.
+ *
+ * @param resource the resource to rename
+ */
+ private void queryNewResourceNameInline(final IResource resource) {
+ // Make sure text editor is created only once. Simply reset text
+ // editor when action is executed more than once. Fixes bug 22269.
+ if (textEditorParent == null) {
+ createTextEditor(resource);
+ }
+ textEditor.setText(resource.getName());
+
+ // Open text editor with initial size.
+ textEditorParent.setVisible(true);
+ Point textSize = textEditor.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ textSize.x += textSize.y; // Add extra space for new characters.
+ Point parentSize = textEditorParent.getSize();
+ int inset = getCellEditorInset(textEditorParent);
+ textEditor.setBounds(2, inset, Math.min(textSize.x, parentSize.x - 4),
+ parentSize.y - 2 * inset);
+ textEditorParent.redraw();
+ textEditor.selectAll();
+ textEditor.setFocus();
+ }
+
+ /*
+ * (non-Javadoc) Method declared on IAction; overrides method on
+ * WorkspaceAction.
+ */
+ public void run() {
+ IResource currentResource = getCurrentResource();
+ if (currentResource == null || !currentResource.exists()) {
+ return;
+ }
+ if (LTKLauncher.openRenameWizard(getStructuredSelection())) {
+ return;
+ }
+
+ if (this.navigatorTree == null) {
+ // Do a quick read only and null check
+ if (!checkReadOnlyAndNull(currentResource)) {
+ return;
+ }
+ String newName = queryNewResourceName(currentResource);
+ if (newName == null || newName.equals("")) { //$NON-NLS-1$
+ return;
+ }
+ newPath = currentResource.getFullPath().removeLastSegments(1)
+ .append(newName);
+ super.run();
+ } else {
+ runWithInlineEditor();
+ }
+ }
+
+ /**
+ * é‡å‘½å文件时,如果文件在编辑器ä¸å·²æ‰“开,则关é—æ¤æ–‡ä»¶ã€‚ ;
+ */
+ private void closeRelatedEditors() {
+ IWorkbenchPage page = null;
+ for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
+ if (window != null) {
+ page = window.getActivePage();
+ break;
+ }
+ }
+ if (page == null) {
+ return;
+ }
+ IEditorReference[] editorReferences = page.getEditorReferences();
+ List selectionResource = getSelectedResources();
+ final List lstCloseEditor = new ArrayList();
+ VTDGen vg = new VTDGen();
+ AutoPilot ap = new AutoPilot();
+ for (IEditorReference reference : editorReferences) {
+ IFile file = ((FileEditorInput) reference.getEditor(true).getEditorInput()).getFile();
+ if ("xlp".equals(file.getFileExtension())) {
+ if (vg.parseFile(file.getLocation().toOSString(), true)) {
+ VTDNav vn = vg.getNav();
+ ap.bind(vn);
+ try {
+ ap.selectXPath("/mergerFiles/mergerFile/@filePath");
+ int index = -1;
+ merge: while ((index = ap.evalXPath()) != -1) {
+ String fileLC = vn.toString(index + 1);
+ if (fileLC != null && !"".equals(fileLC)) {
+ for (IResource resource : selectionResource) {
+ if (resource instanceof IProject || resource instanceof IFolder) {
+ if (fileLC.startsWith(resource.getLocation().toOSString() + File.separator)) {
+ lstCloseEditor.add(reference);
+ break merge;
+ }
+ } else if (resource instanceof IFile) {
+ if (resource.getLocation().toOSString().equals(fileLC)) {
+ lstCloseEditor.add(reference);
+ break merge;
+ }
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ } else {
+ for (IResource resource : selectionResource) {
+ if (resource instanceof IProject) {
+ if (resource.getLocation().toOSString().equals(file.getProject().getLocation().toOSString())) {
+ lstCloseEditor.add(reference);
+ break;
+ }
+ } else if (resource instanceof IFolder) {
+ if (file.getLocation().toOSString()
+ .startsWith(resource.getLocation().toOSString() + File.separator)) {
+ lstCloseEditor.add(reference);
+ break;
+ }
+ } else if (resource instanceof IFile) {
+ if (resource.getLocation().toOSString().equals(file.getLocation().toOSString())) {
+ lstCloseEditor.add(reference);
+ break;
+ }
+ }
+ }
+ }
+ }
+ final IWorkbenchPage page2 = page;
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ IEditorReference[] arrEditorReference = new IEditorReference[lstCloseEditor.size()];
+ page2.closeEditors(lstCloseEditor.toArray(arrEditorReference), false);
+ }
+ });
+ }
+
+ /*
+ * Run the receiver using an inline editor from the supplied navigator. The
+ * navigator will tell the action when the path is ready to run.
+ */
+ private void runWithInlineEditor() {
+ IResource currentResource = getCurrentResource();
+ if (!checkReadOnlyAndNull(currentResource)) {
+ return;
+ }
+ queryNewResourceNameInline(currentResource);
+ }
+
+ /**
+ * Return the currently selected resource. Only return an IResouce if there
+ * is one and only one resource selected.
+ *
+ * @return IResource or null if there is zero or more than
+ * one resources selected.
+ */
+ private IResource getCurrentResource() {
+ List resources = getSelectedResources();
+ if (resources.size() == 1) {
+ return (IResource) resources.get(0);
+ }
+ return null;
+
+ }
+
+ /**
+ * @param path
+ * the path
+ * @param resource
+ * the resource
+ */
+ protected void runWithNewPath(IPath path, IResource resource) {
+ this.newPath = path;
+ super.run();
+ }
+
+ void displayError(String message) {
+ if (message == null) {
+ message = IDEWorkbenchMessages.WorkbenchAction_internalError;
+ }
+ MessageDialog.openError(shellProvider.getShell(), getProblemsTitle(), message);
+ }
+
+ /**
+ * Save the changes and dispose of the text widget.
+ *
+ * @param resource -
+ * the resource to move.
+ */
+ private void saveChangesAndDispose(IResource resource) {
+ if (saving == true) {
+ return;
+ }
+
+ saving = true;
+ // Cache the resource to avoid selection loss since a selection of
+ // another item can trigger this method
+ inlinedResource = resource;
+ final String newName = textEditor.getText();
+ // Run this in an async to make sure that the operation that triggered
+ // this action is completed. Otherwise this leads to problems when the
+ // icon of the item being renamed is clicked (i.e., which causes the
+ // rename
+ // text widget to lose focus and trigger this method).
+ Runnable query = new Runnable() {
+ public void run() {
+ try {
+ if (!newName.equals(inlinedResource.getName())) {
+ IWorkspace workspace = IDEWorkbenchPlugin
+ .getPluginWorkspace();
+ IStatus status = workspace.validateName(newName,
+ inlinedResource.getType());
+ if (!status.isOK()) {
+ displayError(status.getMessage());
+ } else {
+ IPath newPath = inlinedResource.getFullPath()
+ .removeLastSegments(1).append(newName);
+ runWithNewPath(newPath, inlinedResource);
+ }
+ }
+ inlinedResource = null;
+ // Dispose the text widget regardless
+ disposeTextWidget();
+ // Ensure the Navigator tree has focus, which it may not if
+ // the
+ // text widget previously had focus.
+ if (navigatorTree != null && !navigatorTree.isDisposed()) {
+ navigatorTree.setFocus();
+ }
+ } finally {
+ saving = false;
+ }
+ }
+ };
+ getTree().getShell().getDisplay().asyncExec(query);
+ }
+
+ /**
+ * The RenameResourceAction implementation of this
+ * SelectionListenerAction method ensures that this action is
+ * disabled if any of the selections are not resources or resources that are
+ * not local.
+ */
+ protected boolean updateSelection(IStructuredSelection selection) {
+ disposeTextWidget();
+
+ if (selection.size() > 1) {
+ return false;
+ }
+ if (!super.updateSelection(selection)) {
+ return false;
+ }
+
+ IResource currentResource = getCurrentResource();
+ if (currentResource == null || !currentResource.exists()) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Set the text action handler.
+ *
+ * @param actionHandler
+ * the action handler
+ */
+ public void setTextActionHandler(TextActionHandler actionHandler) {
+ textActionHandler = actionHandler;
+ }
+
+ /**
+ * Returns the model provider ids that are known to the client that
+ * instantiated this operation.
+ *
+ * @return the model provider ids that are known to the client that
+ * instantiated this operation.
+ * @since 3.2
+ */
+ public String[] getModelProviderIds() {
+ return modelProviderIds;
+ }
+
+ /**
+ * Sets the model provider ids that are known to the client that
+ * instantiated this operation. Any potential side effects reported by these
+ * models during validation will be ignored.
+ *
+ * @param modelProviderIds
+ * the model providers known to the client who is using this
+ * operation.
+ * @since 3.2
+ */
+ public void setModelProviderIds(String[] modelProviderIds) {
+ this.modelProviderIds = modelProviderIds;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.actions.WorkspaceAction#createOperation(org.eclipse.core.runtime.IStatus[])
+ *
+ * Overridden to create and execute an undoable operation that performs the
+ * rename.
+ * @since 3.3
+ */
+ protected IRunnableWithProgress createOperation(final IStatus[] errorStatus) {
+ return new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor) {
+ IResource[] resources = (IResource[]) getActionResources()
+ .toArray(new IResource[getActionResources().size()]);
+ // Rename is only valid for a single resource. This has already
+ // been validated.
+ if (resources.length == 1) {
+ // check for overwrite
+ IWorkspaceRoot workspaceRoot = resources[0].getWorkspace()
+ .getRoot();
+ IResource newResource = workspaceRoot.findMember(newPath);
+ boolean go = true;
+ if (newResource != null) {
+ go = checkOverwrite(shellProvider.getShell(), newResource);
+ }
+ if (go) {
+ MoveResourcesOperation op = new MoveResourcesOperation(
+ resources[0],
+ newPath,
+ IDEWorkbenchMessages.RenameResourceAction_operationTitle);
+ op.setModelProviderIds(getModelProviderIds());
+ try {
+ PlatformUI
+ .getWorkbench()
+ .getOperationSupport()
+ .getOperationHistory()
+ .execute(
+ op,
+ monitor,
+ WorkspaceUndoUtil
+ .getUIInfoAdapter(shellProvider.getShell()));
+ } catch (ExecutionException e) {
+ if (e.getCause() instanceof CoreException) {
+ errorStatus[0] = ((CoreException) e.getCause())
+ .getStatus();
+ } else {
+ errorStatus[0] = new Status(IStatus.ERROR,
+ PlatformUI.PLUGIN_ID,
+ getProblemsMessage(), e);
+ }
+ }
+ }
+ }
+ }
+ };
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java
new file mode 100644
index 0000000..4f27c9d
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/ResourceMgmtActionProvider.java
@@ -0,0 +1,267 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchCommandConstants;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.CloseResourceAction;
+import org.eclipse.ui.actions.OpenResourceAction;
+import org.eclipse.ui.actions.RefreshAction;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
+import org.eclipse.ui.internal.navigator.NavigatorPlugin;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+
+/**
+ * @since 3.2
+ */
+public class ResourceMgmtActionProvider extends CommonActionProvider {
+
+ // private BuildAction buildAction;
+ //
+ private OpenResourceAction openProjectAction;
+ //
+ private CloseResourceAction closeProjectAction;
+ //
+ // private CloseUnrelatedProjectsAction closeUnrelatedProjectsAction;
+
+ private RefreshAction refreshAction;
+
+ private Shell shell;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator .ICommonActionExtensionSite)
+ */
+ public void init(ICommonActionExtensionSite aSite) {
+ super.init(aSite);
+ shell = aSite.getViewSite().getShell();
+ makeActions();
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction);
+ // actionBars.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), buildAction);
+ actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), openProjectAction);
+ actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), closeProjectAction);
+ // actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_UNRELATED_PROJECTS.getId(),
+ // closeUnrelatedProjectsAction);
+ updateActionBars();
+ }
+
+ /**
+ * Adds the build, open project, close project and refresh resource actions to the context menu.
+ *
+ * The following conditions apply: build-only projects selected, auto build disabled, at least one builder present
+ * open project-only projects selected, at least one closed project close project-only projects selected, at least
+ * one open project refresh-no closed project selected
+ *
+ *
+ * Both the open project and close project action may be on the menu at the same time.
+ *
+ *
+ * No disabled action should be on the context menu.
+ *
+ * @param menu
+ * context menu to add actions to
+ */
+ public void fillContextMenu(IMenuManager menu) {
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+ boolean isProjectSelection = true;
+ boolean hasOpenProjects = false;
+ boolean hasClosedProjects = false;
+ boolean hasBuilder = true; // false if any project is closed or does not
+ // have builder
+ Iterator resources = selection.iterator();
+
+ while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) {
+ Object next = resources.next();
+ IProject project = null;
+
+ if (next instanceof IProject) {
+ project = (IProject) next;
+ } else if (next instanceof IAdaptable) {
+ project = (IProject) ((IAdaptable) next).getAdapter(IProject.class);
+ }
+
+ if (project == null) {
+ isProjectSelection = false;
+ continue;
+ }
+ if (project.isOpen()) {
+ hasOpenProjects = true;
+ if (hasBuilder && !hasBuilder(project)) {
+ hasBuilder = false;
+ }
+ } else {
+ hasClosedProjects = true;
+ hasBuilder = false;
+ }
+ }
+ // if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding() &&
+ // hasBuilder) {
+ // // Allow manual incremental build only if auto build is off.
+ // buildAction.selectionChanged(selection);
+ // menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction);
+ // }
+ if (isProjectSelection) {
+ if (hasClosedProjects) {
+ openProjectAction.selectionChanged(selection);
+ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, openProjectAction);
+ }
+ if (hasOpenProjects) {
+ closeProjectAction.selectionChanged(selection);
+ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, closeProjectAction);
+ // closeUnrelatedProjectsAction.selectionChanged(selection);
+ // menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeUnrelatedProjectsAction);
+ }
+ }
+ if (!hasClosedProjects) {
+ refreshAction.selectionChanged(selection);
+ refreshAction.setEnabled(!selection.isEmpty());
+ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, refreshAction);
+ }
+ }
+
+ /**
+ * Returns whether there are builders configured on the given project.
+ * @return true if it has builders, false if not, or if this could not be determined
+ */
+ boolean hasBuilder(IProject project) {
+ try {
+ ICommand[] commands = project.getDescription().getBuildSpec();
+ if (commands.length > 0) {
+ return true;
+ }
+ } catch (CoreException e) {
+ // Cannot determine if project has builders. Project is closed
+ // or does not exist. Fall through to return false.
+ }
+ return false;
+ }
+
+ protected void makeActions() {
+ IShellProvider sp = new IShellProvider() {
+ public Shell getShell() {
+ return shell;
+ }
+ };
+
+ openProjectAction = new OpenResourceAction(sp);
+ openProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_openProjectAction);
+
+ closeProjectAction = new CloseResourceAction(sp);
+ closeProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_closeProjectAction);
+ //
+ // closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(sp);
+ // closeUnrelatedProjectsAction.setText("å…³é—æ— å…³çš„é¡¹ç›®");
+
+ refreshAction = new RefreshAction(sp) {
+ public void run() {
+ final IStatus[] errorStatus = new IStatus[1];
+ errorStatus[0] = Status.OK_STATUS;
+ final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus);
+ WorkspaceJob job = new WorkspaceJob("refresh") { //$NON-NLS-1$
+
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ try {
+ op.run(monitor);
+ if (shell != null && !shell.isDisposed()) {
+ shell.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ StructuredViewer viewer = getActionSite().getStructuredViewer();
+ if (viewer != null && viewer.getControl() != null
+ && !viewer.getControl().isDisposed()) {
+ viewer.refresh();
+ }
+ }
+ });
+ }
+ } catch (InvocationTargetException e) {
+ String msg = NLS.bind(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_logTitle,
+ getClass().getName(), e.getTargetException());
+ throw new CoreException(new Status(IStatus.ERROR, NavigatorPlugin.PLUGIN_ID, IStatus.ERROR,
+ msg, e.getTargetException()));
+ } catch (InterruptedException e) {
+ return Status.CANCEL_STATUS;
+ }
+ return errorStatus[0];
+ }
+
+ };
+ ISchedulingRule rule = op.getRule();
+ if (rule != null) {
+ job.setRule(rule);
+ }
+ job.setUser(true);
+ job.schedule();
+ }
+ };
+ refreshAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_refreshAction);
+ refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));//$NON-NLS-1$
+ refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));//$NON-NLS-1$
+ refreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH);
+ if (getContext() == null) {
+ refreshAction.setEnabled(false);
+ } else {
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+ refreshAction.selectionChanged(selection);
+ refreshAction.setEnabled(!selection.isEmpty());
+ }
+
+ // buildAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD);
+ // buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT);
+ }
+
+ /**
+ * Returns the image descriptor with the given relative path.
+ */
+ protected ImageDescriptor getImageDescriptor(String relativePath) {
+ return IDEWorkbenchPlugin.getIDEImageDescriptor(relativePath);
+
+ }
+
+ public void updateActionBars() {
+ IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
+ refreshAction.selectionChanged(selection);
+ // buildAction.selectionChanged(selection);
+ openProjectAction.selectionChanged(selection);
+ // closeUnrelatedProjectsAction.selectionChanged(selection);
+ closeProjectAction.selectionChanged(selection);
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/UndoRedoActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/UndoRedoActionProvider.java
new file mode 100644
index 0000000..ea15c80
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/UndoRedoActionProvider.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2008 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * (was originally RefactorActionProvider.java)
+ * Oakland Software (Francis Upton - francisu@ieee.org)
+ * bug 214271 Undo/redo not enabled if nothing selected
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.operations.UndoRedoActionGroup;
+
+/**
+ * @since 3.4
+ *
+ */
+public class UndoRedoActionProvider extends CommonActionProvider {
+
+ private UndoRedoActionGroup undoRedoGroup;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+ */
+ public void init(ICommonActionExtensionSite anActionSite) {
+ IUndoContext workspaceContext = (IUndoContext) ResourcesPlugin
+ .getWorkspace().getAdapter(IUndoContext.class);
+ undoRedoGroup = new UndoRedoActionGroup(((ICommonViewerWorkbenchSite) anActionSite.getViewSite()).getSite(),
+ workspaceContext, true);
+ }
+
+ public void dispose() {
+ undoRedoGroup.dispose();
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ undoRedoGroup.fillActionBars(actionBars);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ undoRedoGroup.fillContextMenu(menu);
+ }
+
+ public void setContext(ActionContext context) {
+ undoRedoGroup.setContext(context);
+ }
+
+ public void updateActionBars() {
+ undoRedoGroup.updateActionBars();
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkManagementActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkManagementActionProvider.java
new file mode 100644
index 0000000..5eaa640
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkManagementActionProvider.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2008 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionContext;
+import org.eclipse.ui.actions.AddBookmarkAction;
+import org.eclipse.ui.actions.AddTaskAction;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+
+/**
+ * Supports Add Task and Add Bookmark actions.
+ *
+ * @since 3.2
+ *
+ */
+public class WorkManagementActionProvider extends CommonActionProvider {
+
+ private AddTaskAction addTaskAction;
+
+ private AddBookmarkAction addBookmarkAction;
+
+ public void init(ICommonActionExtensionSite aSite) {
+ final Shell shell = aSite.getViewSite().getShell();
+ IShellProvider sp = new IShellProvider() {
+ public Shell getShell() {
+ return shell;
+ }
+ };
+ addBookmarkAction = new AddBookmarkAction(sp, true);
+ addTaskAction = new AddTaskAction(sp);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars
+ * )
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ super.fillActionBars(actionBars);
+ actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction);
+ actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.
+ * ActionContext)
+ */
+ public void setContext(ActionContext context) {
+ super.setContext(context);
+ if (context != null && context.getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection sSel = (IStructuredSelection) context.getSelection();
+ addBookmarkAction.selectionChanged(sSel);
+ addTaskAction.selectionChanged(sSel);
+ } else {
+ addBookmarkAction.selectionChanged(StructuredSelection.EMPTY);
+ addTaskAction.selectionChanged(StructuredSelection.EMPTY);
+ }
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkingSetActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkingSetActionProvider.java
new file mode 100644
index 0000000..025f4ac
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkingSetActionProvider.java
@@ -0,0 +1,403 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * anton.leherbauer@windriver.com - bug 212389 [CommonNavigator] working set issues:
+ * missing project, window working set inconsistency
+ *******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IAggregateWorkingSet;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkbenchPreferenceConstants;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ResourceWorkingSetFilter;
+import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
+import org.eclipse.ui.internal.navigator.NavigatorFilterService;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.internal.navigator.workingsets.WorkingSetsContentProvider;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.IExtensionActivationListener;
+import org.eclipse.ui.navigator.IExtensionStateModel;
+import org.eclipse.ui.navigator.INavigatorContentService;
+
+/**
+ * @since 3.2
+ *
+ */
+public class WorkingSetActionProvider extends CommonActionProvider {
+
+ private static final String TAG_CURRENT_WORKING_SET_NAME = "currentWorkingSetName"; //$NON-NLS-1$
+
+ private static final String WORKING_SET_FILTER_ID = "org.eclipse.ui.navigator.resources.filters.workingSet"; //$NON-NLS-1$
+
+ private boolean contributedToViewMenu = false;
+
+ private CommonViewer viewer;
+
+ private INavigatorContentService contentService;
+
+ private NavigatorFilterService filterService;
+
+ private WorkingSetFilterActionGroup workingSetActionGroup;
+ private WorkingSetRootModeActionGroup workingSetRootModeActionGroup;
+
+ private Object originalViewerInput = ResourcesPlugin.getWorkspace().getRoot();
+
+ private IExtensionStateModel extensionStateModel;
+
+ private boolean emptyWorkingSet;
+ private IWorkingSet workingSet;
+
+ private IPropertyChangeListener topLevelModeListener;
+
+ private boolean ignoreFilterChangeEvents;
+
+ /**
+ * Provides a smart listener to monitor changes to the Working Set Manager.
+ *
+ */
+ public class WorkingSetManagerListener implements IPropertyChangeListener {
+
+ private boolean listening = false;
+
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ Object newValue = event.getNewValue();
+ Object oldValue = event.getOldValue();
+
+ String newLabel = null;
+ if (IWorkingSetManager.CHANGE_WORKING_SET_REMOVE.equals(property) && oldValue == workingSet) {
+ newLabel = ""; //$NON-NLS-1$
+ setWorkingSet(null);
+ } else if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property) && newValue == workingSet) {
+ newLabel = workingSet.getLabel();
+ } else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property) && newValue == workingSet) {
+ if (workingSet.isAggregateWorkingSet() && workingSet.isEmpty()) {
+ // act as if the working set has been made null
+ if (!emptyWorkingSet) {
+ emptyWorkingSet = true;
+ setWorkingSetFilter(null);
+ newLabel = null;
+ }
+ } else {
+ // we've gone from empty to non-empty on our set.
+ // Restore it.
+ if (emptyWorkingSet) {
+ emptyWorkingSet = false;
+ setWorkingSetFilter(workingSet);
+ newLabel = workingSet.getLabel();
+ }
+ }
+ }
+ if (viewer != null) {
+ if (newLabel != null)
+ viewer.getCommonNavigator().setWorkingSetLabel(newLabel);
+ viewer.getFrameList().reset();
+ viewer.refresh();
+ }
+ }
+
+ /**
+ * Begin listening to the correct source if not already listening.
+ */
+ public synchronized void listen() {
+ if (!listening) {
+ PlatformUI.getWorkbench().getWorkingSetManager().addPropertyChangeListener(managerChangeListener);
+ listening = true;
+ }
+ }
+
+ /**
+ * Begin listening to the correct source if not already listening.
+ */
+ public synchronized void ignore() {
+ if (listening) {
+ PlatformUI.getWorkbench().getWorkingSetManager().removePropertyChangeListener(managerChangeListener);
+ listening = false;
+ }
+ }
+ }
+
+ private IPropertyChangeListener filterChangeListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+
+ if (ignoreFilterChangeEvents)
+ return;
+
+ IWorkingSet newWorkingSet = (IWorkingSet) event.getNewValue();
+
+ setWorkingSet(newWorkingSet);
+ if (newWorkingSet != null) {
+ if (!contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
+ contentService.getActivationService().activateExtensions(
+ new String[] { WorkingSetsContentProvider.EXTENSION_ID }, false);
+ contentService.getActivationService().persistExtensionActivations();
+ }
+ if (newWorkingSet.isAggregateWorkingSet()) {
+ IAggregateWorkingSet agWs = (IAggregateWorkingSet) newWorkingSet;
+ IWorkingSet[] comps = agWs.getComponents();
+ if (comps.length > 1) {
+ viewer.getCommonNavigator().setWorkingSetLabel(
+ WorkbenchNavigatorMessages.actions_WorkingSetActionProvider_multipleWorkingSets);
+ } else if (comps.length > 0) {
+ viewer.getCommonNavigator().setWorkingSetLabel(comps[0].getLabel());
+ } else {
+ viewer.getCommonNavigator().setWorkingSetLabel(null);
+ }
+ } else
+ viewer.getCommonNavigator().setWorkingSetLabel(workingSet.getLabel());
+ } else {
+ viewer.getCommonNavigator().setWorkingSetLabel(null);
+ }
+
+ viewer.getFrameList().reset();
+ }
+ };
+
+ private WorkingSetManagerListener managerChangeListener = new WorkingSetManagerListener();
+
+ private IExtensionActivationListener activationListener = new IExtensionActivationListener() {
+
+ private IWorkingSet savedWorkingSet;
+
+ public void onExtensionActivation(String aViewerId, String[] theNavigatorExtensionIds, boolean isActive) {
+
+ for (int i = 0; i < theNavigatorExtensionIds.length; i++) {
+ if (WorkingSetsContentProvider.EXTENSION_ID.equals(theNavigatorExtensionIds[i])) {
+ if (isActive) {
+ extensionStateModel = contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);
+ workingSetRootModeActionGroup.setStateModel(extensionStateModel);
+ extensionStateModel.addPropertyChangeListener(topLevelModeListener);
+
+ if (savedWorkingSet != null) {
+ setWorkingSet(savedWorkingSet);
+ }
+ managerChangeListener.listen();
+
+ } else {
+ savedWorkingSet = workingSet;
+ setWorkingSet(null);
+ viewer.getCommonNavigator().setWorkingSetLabel(null);
+ managerChangeListener.ignore();
+ workingSetRootModeActionGroup.setShowTopLevelWorkingSets(false);
+ extensionStateModel.removePropertyChangeListener(topLevelModeListener);
+
+ }
+ }
+ }
+ }
+
+ };
+
+ public void init(ICommonActionExtensionSite aSite) {
+ viewer = (CommonViewer) aSite.getStructuredViewer();
+ contentService = aSite.getContentService();
+ filterService = (NavigatorFilterService) contentService.getFilterService();
+
+ extensionStateModel = contentService.findStateModel(WorkingSetsContentProvider.EXTENSION_ID);
+
+ workingSetActionGroup = new WorkingSetFilterActionGroup(aSite.getViewSite().getShell(), filterChangeListener);
+ workingSetRootModeActionGroup = new WorkingSetRootModeActionGroup(viewer, extensionStateModel);
+
+ topLevelModeListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ setWorkingSet(workingSet);
+ viewer.getFrameList().reset();
+ }
+ };
+
+ if (contentService.isActive(WorkingSetsContentProvider.EXTENSION_ID)) {
+ managerChangeListener.listen();
+ extensionStateModel.addPropertyChangeListener(topLevelModeListener);
+ }
+
+ contentService.getActivationService().addExtensionActivationListener(activationListener);
+ }
+
+ /**
+ * Restores the working set filter from the persistence store.
+ */
+ protected void initWorkingSetFilter(String workingSetName) {
+ IWorkingSet workingSet = null;
+
+ if (workingSetName != null && workingSetName.length() > 0) {
+ IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ workingSet = workingSetManager.getWorkingSet(workingSetName);
+ } else if (PlatformUI.getPreferenceStore().getBoolean(
+ IWorkbenchPreferenceConstants.USE_WINDOW_WORKING_SET_BY_DEFAULT)) {
+ // use the window set by default if the global preference is set
+ workingSet = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getAggregateWorkingSet();
+ }
+
+ if (workingSet != null) {
+ setWorkingSet(workingSet);
+ }
+ }
+
+ private void setWorkingSetFilter(IWorkingSet workingSet) {
+ setWorkingSetFilter(workingSet, FIRST_TIME);
+ }
+
+ private static final boolean FIRST_TIME = true;
+
+ private void setWorkingSetFilter(IWorkingSet workingSet, boolean firstTime) {
+ ResourceWorkingSetFilter workingSetFilter = null;
+ ViewerFilter[] filters = viewer.getFilters();
+ for (int i = 0; i < filters.length; i++) {
+ if (filters[i] instanceof ResourceWorkingSetFilter) {
+ workingSetFilter = (ResourceWorkingSetFilter) filters[i];
+ break;
+ }
+ }
+ if (workingSetFilter == null) {
+ if (firstTime) {
+ filterService.addActiveFilterIds(new String[] { WORKING_SET_FILTER_ID });
+ filterService.updateViewer();
+ setWorkingSetFilter(workingSet, !FIRST_TIME);
+ return;
+ }
+ WorkbenchNavigatorPlugin.log("Required filter " + WORKING_SET_FILTER_ID + //$NON-NLS-1$
+ " is not present. Working set support will not function correctly.", //$NON-NLS-1$
+ new Status(IStatus.ERROR, WorkbenchNavigatorPlugin.PLUGIN_ID, "")); //$NON-NLS-1$
+ return;
+ }
+ workingSetFilter.setWorkingSet(emptyWorkingSet ? null : workingSet);
+ }
+
+ /**
+ * Set current active working set.
+ *
+ * @param workingSet
+ * working set to be activated, may be null
+ */
+ protected void setWorkingSet(IWorkingSet workingSet) {
+ this.workingSet = workingSet;
+ emptyWorkingSet = workingSet != null && workingSet.isAggregateWorkingSet() && workingSet.isEmpty();
+
+ ignoreFilterChangeEvents = true;
+ try {
+ workingSetActionGroup.setWorkingSet(workingSet);
+ } finally {
+ ignoreFilterChangeEvents = false;
+ }
+
+ if (viewer != null) {
+ setWorkingSetFilter(workingSet);
+ if (workingSet == null || emptyWorkingSet
+ || !extensionStateModel.getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS)) {
+ if (viewer.getInput() != originalViewerInput) {
+ viewer.setInput(originalViewerInput);
+ } else {
+ viewer.refresh();
+ }
+ } else {
+ if (!workingSet.isAggregateWorkingSet()) {
+ IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
+ viewer.setInput(workingSetManager.createAggregateWorkingSet(
+ "", "", new IWorkingSet[] { workingSet })); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ viewer.setInput(workingSet);
+ }
+ }
+ }
+ }
+
+ public void restoreState(final IMemento aMemento) {
+ super.restoreState(aMemento);
+
+ // Need to run this async to avoid being reentered when processing a selection change
+ viewer.getControl().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ boolean showWorkingSets = true;
+ if (aMemento != null) {
+ Integer showWorkingSetsInt = aMemento
+ .getInteger(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS);
+ showWorkingSets = showWorkingSetsInt == null || showWorkingSetsInt.intValue() == 1;
+ extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
+ showWorkingSets);
+ workingSetRootModeActionGroup.setShowTopLevelWorkingSets(showWorkingSets);
+
+ String lastWorkingSetName = aMemento.getString(TAG_CURRENT_WORKING_SET_NAME);
+ initWorkingSetFilter(lastWorkingSetName);
+ } else {
+ showWorkingSets = false;
+
+ extensionStateModel.setBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
+ showWorkingSets);
+ workingSetRootModeActionGroup.setShowTopLevelWorkingSets(showWorkingSets);
+ }
+ }
+ });
+ }
+
+ public void saveState(IMemento aMemento) {
+ super.saveState(aMemento);
+
+ if (aMemento != null) {
+ int showWorkingSets = extensionStateModel
+ .getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS) ? 1 : 0;
+ aMemento.putInteger(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS, showWorkingSets);
+
+ if (workingSet != null) {
+ aMemento.putString(TAG_CURRENT_WORKING_SET_NAME, workingSet.getName());
+ }
+ }
+
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ if (!contributedToViewMenu) {
+ try {
+ super.fillActionBars(actionBars);
+ workingSetActionGroup.fillActionBars(actionBars);
+ if (workingSetRootModeActionGroup != null) {
+ workingSetRootModeActionGroup.fillActionBars(actionBars);
+ }
+ } finally {
+ contributedToViewMenu = true;
+ }
+ }
+ }
+
+ public void dispose() {
+ super.dispose();
+ workingSetActionGroup.dispose();
+ if (workingSetRootModeActionGroup != null) {
+ workingSetRootModeActionGroup.dispose();
+ }
+
+ managerChangeListener.ignore();
+ extensionStateModel.removePropertyChangeListener(topLevelModeListener);
+
+ contentService.getActivationService().removeExtensionActivationListener(activationListener);
+ }
+
+ /**
+ * This is used only for the tests.
+ *
+ * @return a PropertyChangeListener
+ */
+ public IPropertyChangeListener getFilterChangeListener() {
+ return filterChangeListener;
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkingSetRootModeActionGroup.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkingSetRootModeActionGroup.java
new file mode 100644
index 0000000..e40f837
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/actions/WorkingSetRootModeActionGroup.java
@@ -0,0 +1,230 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.ActionGroup;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.internal.navigator.workingsets.WorkingSetsContentProvider;
+import org.eclipse.ui.navigator.IExtensionStateModel;
+
+/**
+ *
+ * Provides the radio buttons at the top of the view menu that control the root
+ * of the ProjectExplorer, which is either working sets of projects. When the
+ * state is changed through the actions, the WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS
+ * property in the extension state model is updated.
+ *
+ * This is installed by the WorkingSetActionProvider.
+ *
+ * @since 3.2
+ *
+ */
+public class WorkingSetRootModeActionGroup extends ActionGroup {
+
+ private IExtensionStateModel stateModel;
+ private StructuredViewer structuredViewer;
+
+ private boolean hasContributedToViewMenu = false;
+ private IAction workingSetsAction = null;
+ private IAction projectsAction = null;
+ private IAction[] actions;
+ private int currentSelection;
+ private MenuItem[] items;
+
+ private class TopLevelContentAction extends Action {
+
+ private final boolean groupWorkingSets;
+
+ /**
+ * Construct an Action that represents a toggle-able state between
+ * Showing top level Working Sets and Projects.
+ *
+ * @param toGroupWorkingSets
+ */
+ public TopLevelContentAction(boolean toGroupWorkingSets) {
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+ groupWorkingSets = toGroupWorkingSets;
+ }
+
+ /*
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run() {
+ if (stateModel
+ .getBooleanProperty(WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS) != groupWorkingSets) {
+ stateModel.setBooleanProperty(
+ WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
+ groupWorkingSets);
+
+ structuredViewer.getControl().setRedraw(false);
+ try {
+ structuredViewer.refresh();
+ } finally {
+ structuredViewer.getControl().setRedraw(true);
+ }
+ }
+ }
+ }
+
+ /**
+ * Create an action group that will listen to the stateModel and update the
+ * structuredViewer when necessary.
+ *
+ * @param aStructuredViewer
+ * @param aStateModel
+ */
+ public WorkingSetRootModeActionGroup(StructuredViewer aStructuredViewer,
+ IExtensionStateModel aStateModel) {
+ super();
+ structuredViewer = aStructuredViewer;
+ stateModel = aStateModel;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see ActionGroup#fillActionBars(IActionBars)
+ */
+ public void fillActionBars(IActionBars actionBars) {
+ if (hasContributedToViewMenu)
+ return;
+ IMenuManager topLevelSubMenu = new MenuManager(
+ WorkbenchNavigatorMessages.actions_WorkingSetRootModeActionGroup_Top_Level_Element_);
+ addActions(topLevelSubMenu);
+ actionBars.getMenuManager().insertBefore(IWorkbenchActionConstants.MB_ADDITIONS, topLevelSubMenu);
+ hasContributedToViewMenu = true;
+ }
+
+ /**
+ * Adds the actions to the given menu manager.
+ */
+ protected void addActions(IMenuManager viewMenu) {
+ if (actions == null)
+ actions = createActions();
+
+ viewMenu.add(new Separator());
+ items = new MenuItem[actions.length];
+
+ for (int i = 0; i < actions.length; i++) {
+ final int j = i;
+
+ viewMenu.add(new ContributionItem() {
+
+ public void fill(Menu menu, int index) {
+
+ int style = SWT.CHECK;
+ if ((actions[j].getStyle() & IAction.AS_RADIO_BUTTON) != 0)
+ style = SWT.RADIO;
+
+ final MenuItem mi = new MenuItem(menu, style, index);
+ items[j] = mi;
+ mi.setText(actions[j].getText());
+ mi.setSelection(currentSelection == j);
+ mi.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if (currentSelection == j) {
+ items[currentSelection].setSelection(true);
+ return;
+ }
+ actions[j].run();
+
+ // Update checked state
+ items[currentSelection].setSelection(false);
+ currentSelection = j;
+ items[currentSelection].setSelection(true);
+ }
+
+ });
+
+ }
+
+ public boolean isDynamic() {
+ return false;
+ }
+ });
+ }
+ }
+
+ private IAction[] createActions() {
+
+ ISharedImages sharedImages = PlatformUI.getWorkbench()
+ .getSharedImages();
+
+ projectsAction = new TopLevelContentAction(false);
+ projectsAction
+ .setText(WorkbenchNavigatorMessages.actions_WorkingSetRootModeActionGroup_Project_);
+ projectsAction.setImageDescriptor(sharedImages
+ .getImageDescriptor(IDE.SharedImages.IMG_OBJ_PROJECT));
+
+ workingSetsAction = new TopLevelContentAction(true);
+ workingSetsAction
+ .setText(WorkbenchNavigatorMessages.actions_WorkingSetRootModeActionGroup_Working_Set_);
+ workingSetsAction.setImageDescriptor(WorkbenchNavigatorPlugin
+ .getDefault().getImageRegistry().getDescriptor(
+ "full/obj16/workingsets.gif")); //$NON-NLS-1$
+
+ return new IAction[] { projectsAction, workingSetsAction };
+ }
+
+ /**
+ * Toggle whether top level working sets should be displayed as a group or
+ * collapse to just show their contents.
+ *
+ * @param showTopLevelWorkingSets
+ */
+ public void setShowTopLevelWorkingSets(boolean showTopLevelWorkingSets) {
+ if (actions == null)
+ actions = createActions();
+
+ currentSelection = showTopLevelWorkingSets ? 1 : 0;
+ workingSetsAction.setChecked(showTopLevelWorkingSets);
+ projectsAction.setChecked(!showTopLevelWorkingSets);
+
+ if (items != null) {
+ for (int i = 0; i < items.length; i++) {
+ if(items[i] != null && actions[i] != null)
+ items[i].setSelection(actions[i].isChecked());
+ }
+ }
+ if (stateModel != null) {
+ stateModel.setBooleanProperty(
+ WorkingSetsContentProvider.SHOW_TOP_LEVEL_WORKING_SETS,
+ showTopLevelWorkingSets);
+ }
+ }
+
+ /**
+ * @param sStateModel
+ */
+ public void setStateModel(IExtensionStateModel sStateModel) {
+ stateModel = sStateModel;
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/NavigatorUIPluginImages.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/NavigatorUIPluginImages.java
new file mode 100644
index 0000000..67fd4c5
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/NavigatorUIPluginImages.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2008 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.plugin;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.internal.navigator.NavigatorPlugin;
+
+/**
+ * Handles all images and icons for the ui.
+ *
+ *
+ * EXPERIMENTAL. This class or interface has been added as part
+ * of a work in progress. There is a guarantee neither that this API will work
+ * nor that it will remain the same. Please do not use this API without
+ * consulting with the Platform/UI team.
+ *
+ *
+ * @since 3.2
+ */
+public class NavigatorUIPluginImages {
+
+ private static URL fgIconLocation;
+
+ // Create image registry
+ private final static ImageRegistry NAVIGATORUIPLUGIN_REGISTRY = NavigatorPlugin.getDefault().getImageRegistry();
+
+ // Create the icon location
+ static {
+ String pathSuffix = "icons/full/"; //$NON-NLS-1$
+ fgIconLocation = FileLocator.find(NavigatorPlugin.getDefault().getBundle(), new Path(pathSuffix), Collections.EMPTY_MAP);
+ }
+
+ /**
+ * Gets the current image.
+ *
+ * @param key
+ * - Name of the icon.
+ * @return Image
+ */
+ public static Image get(String key) {
+ return NAVIGATORUIPLUGIN_REGISTRY.get(key);
+ }
+
+ /**
+ * Create and returns a image descriptor.
+ *
+ * @param prefix
+ * - Icon dir structure.
+ * @param name
+ * - The name of the icon.
+ * @return ImageDescriptor
+ */
+ private static ImageDescriptor create(String prefix, String name) {
+ return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name));
+ }
+
+ /**
+ * Creates the icon url
+ *
+ * @param prefix
+ * - Icon dir structure.
+ * @param name
+ * - The name of the icon.
+ * @return URL
+ */
+ private static URL makeIconFileURL(String prefix, String name) {
+ StringBuffer buffer = new StringBuffer(prefix);
+ buffer.append(name);
+ try {
+ return new URL(fgIconLocation, buffer.toString());
+ } catch (MalformedURLException ex) {
+
+ return null;
+ }
+ }
+
+ /**
+ * Sets the three image descriptors for enabled, disabled, and hovered to an
+ * action. The actions are retrieved from the *lcl16 folders.
+ *
+ * @param action
+ * the action
+ * @param iconName
+ * the icon name
+ */
+ public static void setLocalImageDescriptors(IAction action, String iconName) {
+ setImageDescriptors(action, "lcl16/", iconName); //$NON-NLS-1$
+ }
+
+ /**
+ * Sets all available image descriptors for the given action.
+ *
+ * @param action
+ * - The action associated with the icon.
+ * @param type
+ * - The type of icon.
+ * @param relPath
+ * - The relative path of the icon.
+ */
+ public static void setImageDescriptors(IAction action, String type, String relPath) {
+ // /*relPath= relPath.substring(NAVIGATORUI_NAME_PREFIX_LENGTH);*/
+ // action.setDisabledImageDescriptor(create("d" + type, relPath));
+ // //$NON-NLS-1$
+ // action.setHoverImageDescriptor(create("c" + type, relPath));
+ // //$NON-NLS-1$
+ action.setImageDescriptor(create("e" + type, relPath)); //$NON-NLS-1$
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/WorkbenchNavigatorPlugin.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/WorkbenchNavigatorPlugin.java
new file mode 100644
index 0000000..656b409
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/plugin/WorkbenchNavigatorPlugin.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.plugin;
+
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * The main plugin class for the workbench Navigator.
+ *
+ * @since 3.2
+ */
+public class WorkbenchNavigatorPlugin extends AbstractUIPlugin {
+ // The shared instance.
+ private static WorkbenchNavigatorPlugin plugin;
+
+ /** The plugin id */
+ public static String PLUGIN_ID = "org.eclipse.ui.navigator.resources"; //$NON-NLS-1$
+
+ /**
+ * Creates a new instance of the receiver
+ */
+ public WorkbenchNavigatorPlugin() {
+ super();
+ plugin = this;
+ }
+
+ /**
+ * @return the shared instance.
+ */
+ public static WorkbenchNavigatorPlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * @return the workspace instance.
+ */
+ public static IWorkspace getWorkspace() {
+ return ResourcesPlugin.getWorkspace();
+ }
+
+ /**
+ * Logs errors.
+ * @param message The message to log
+ * @param status The status to log
+ */
+ public static void log(String message, IStatus status) {
+ if (message != null) {
+ getDefault().getLog().log(
+ new Status(IStatus.ERROR, PLUGIN_ID, 0, message, null));
+ System.err.println(message + "\nReason:"); //$NON-NLS-1$
+ }
+ if(status != null) {
+ getDefault().getLog().log(status);
+ System.err.println(status.getMessage());
+ }
+ }
+
+ /**
+ * Create a status associated with this plugin.
+ *
+ * @param severity
+ * @param aCode
+ * @param aMessage
+ * @param exception
+ * @return A status configured with this plugin's id and the given
+ * parameters.
+ */
+ public static IStatus createStatus(int severity, int aCode,
+ String aMessage, Throwable exception) {
+ return new Status(severity, PLUGIN_ID, aCode,
+ aMessage != null ? aMessage : "No message.", exception); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @param aCode
+ * @param aMessage
+ * @param exception
+ * @return A status configured with this plugin's id and the given
+ * parameters.
+ */
+ public static IStatus createErrorStatus(int aCode, String aMessage,
+ Throwable exception) {
+ return createStatus(IStatus.ERROR, aCode, aMessage, exception);
+ }
+
+
+ /**
+ *
+ * @param aMessage
+ * @param exception
+ * @return A status configured with this plugin's id and the given
+ * parameters.
+ */
+ public static IStatus createErrorStatus(String aMessage, Throwable exception) {
+ return createStatus(IStatus.ERROR, 0, aMessage, exception);
+ }
+
+ /**
+ *
+ * @param aMessage
+ * @return A status configured with this plugin's id and the given
+ * parameters.
+ */
+ public static IStatus createErrorStatus(String aMessage) {
+ return createStatus(IStatus.ERROR, 0, aMessage, null);
+ }
+
+
+ /**
+ *
+ * @param aMessage
+ * @return A status configured with this plugin's id and the given
+ * parameters.
+ */
+ public static IStatus createInfoStatus(String aMessage) {
+ return createStatus(IStatus.INFO, 0, aMessage, null);
+ }
+
+
+ /**
+ *
+ * @param aMessage
+ * @return A status configured with this plugin's id and the given
+ * parameters.
+ */
+ public static IStatus createWarningStatus(String aMessage) {
+ return createStatus(IStatus.WARNING, 0, aMessage, null);
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/WorkbenchNavigatorMessages.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/WorkbenchNavigatorMessages.java
new file mode 100644
index 0000000..08822cb
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/WorkbenchNavigatorMessages.java
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.resource;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Utility class which helps managing messages
+ *
+ *
+ * @since 3.2
+ */
+public class WorkbenchNavigatorMessages extends NLS {
+ /** The bundle properties file */
+ public static final String BUNDLE_NAME = "org.eclipse.ui.internal.navigator.resources.resource.messages"; //$NON-NLS-1$
+
+ public static String navigator_all_dialog_warning;
+ public static String PortingActionProvider_ImportResourcesMenu_label;
+
+ public static String PortingActionProvider_ExportResourcesMenu_label;
+
+ public static String actions_NewActionProvider_NewMenu_label;
+
+ public static String actions_OpenActionProvider_OpenWithMenu_label;
+
+ public static String resources_ResourceDropAdapterAssistant_title;
+ public static String resources_ResourceDropAdapterAssistant_problemImporting;
+ public static String resources_ResourceDropAdapterAssistant_problemsMoving;
+ public static String resources_ResourceDropAdapterAssistant_targetMustBeResource;
+ public static String resources_ResourceDropAdapterAssistant_canNotDropIntoClosedProject;
+ public static String resources_ResourceDropAdapterAssistant_resourcesCanNotBeSiblings;
+ public static String resources_ResourceDropAdapterAssistant_canNotDropProjectIntoProject;
+ public static String resources_ResourceDropAdapterAssistant_dropOperationErrorOther;
+
+ public static String resources_ResourceDropAdapterAssistant_MoveResourceAction_title;
+ public static String resources_ResourceDropAdapterAssistant_MoveResourceAction_checkMoveMessage;
+
+ public static String actions_ResourceMgmtActionProvider_logTitle;
+
+ public static String actions_WorkingSetRootModeActionGroup_Top_Level_Element_;
+ public static String actions_WorkingSetRootModeActionGroup_Project_;
+ public static String actions_WorkingSetRootModeActionGroup_Working_Set_;
+ public static String actions_WorkingSetActionProvider_multipleWorkingSets;
+
+ public static String actions_CopyAction_Cop_;
+ public static String actions_CopyAction_Copy_selected_resource_s_;
+
+ public static String actions_PasteAction_Past_;
+ public static String actions_PasteAction_Paste_selected_resource_s_;
+
+ public static String actions_GotoResourceDialog_GoToTitle;
+
+ public static String resources_ProjectExplorer_toolTip;
+ public static String resources_ProjectExplorer_toolTip2;
+ public static String resources_ProjectExplorer_toolTip3;
+
+ public static String resources_ProjectExplorerPart_workspace;
+ public static String resources_ProjectExplorerPart_workingSetModel;
+
+ public static String actions_CopyAction_msgTitle;
+ public static String actions_CopyAction_msg;
+ public static String actions_EditActionGroup_pasteAction;
+ public static String actions_EditActionGroup_copyAction;
+ public static String actions_EditActionGroup_deleteAction;
+ public static String actions_OpenActionProvider_openFileAction;
+ public static String actions_RefactorActionGroup_moveAction;
+ public static String actions_RefactorActionGroup_renameAction;
+ public static String actions_ResourceMgmtActionProvider_openProjectAction;
+ public static String actions_ResourceMgmtActionProvider_closeProjectAction;
+ public static String actions_ResourceMgmtActionProvider_refreshAction;
+ public static String actions_OpenFileWithValidAction_notFindProgram;
+
+ static {
+ initializeMessages(BUNDLE_NAME, WorkbenchNavigatorMessages.class);
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages.properties b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages.properties
new file mode 100644
index 0000000..0f9c664
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages.properties
@@ -0,0 +1,43 @@
+navigator_all_dialog_warning = \u8b66\u544a
+resources_ResourceDropAdapterAssistant_title=\u62d6\u653e\u9519\u8bef
+actions_OpenActionProvider_OpenWithMenu_label=\u6253\u5f00\u65b9\u5f0f
+actions_WorkingSetRootModeActionGroup_Top_Level_Element_=\u9876\u5c42\u5143\u7d20
+actions_WorkingSetRootModeActionGroup_Project_=\u9879\u76ee
+resources_ResourceDropAdapterAssistant_resourcesCanNotBeSiblings=\u8d44\u6e90\u4e0d\u80fd\u662f\u9879\u76ee\u7684\u540c\u4ee3
+PortingActionProvider_ImportResourcesMenu_label=\u5bfc\u5165(&I)
+resources_ResourceDropAdapterAssistant_MoveResourceAction_title=\u68c0\u67e5\u79fb\u52a8
+PortingActionProvider_ExportResourcesMenu_label=\u5bfc\u51fa(&X)
+actions_WorkingSetRootModeActionGroup_Working_Set_=\u5de5\u4f5c\u96c6
+resources_ResourceDropAdapterAssistant_targetMustBeResource=\u76ee\u6807\u5fc5\u987b\u662f\u8d44\u6e90
+resources_ResourceDropAdapterAssistant_problemImporting=\u5bfc\u5165\u8d44\u6e90\u65f6\u51fa\u73b0\u9519\u8bef\u3002
+resources_ResourceDropAdapterAssistant_MoveResourceAction_checkMoveMessage=\u6587\u4ef6 ''{0}'' \u4e3a\u53ea\u8bfb\u6587\u4ef6\u3002\u786e\u5b9a\u8981\u79fb\u52a8\u5b83\u5417\uff1f
+resources_ResourceDropAdapterAssistant_canNotDropIntoClosedProject=\u4e0d\u80fd\u5c06\u8d44\u6e90\u653e\u5165\u5df2\u5173\u95ed\u7684\u9879\u76ee\u4e2d\u3002
+resources_ResourceDropAdapterAssistant_canNotDropProjectIntoProject=\u65e0\u6cd5\u5c06\u9879\u76ee\u653e\u5165\u53e6\u4e00\u4e2a\u9879\u76ee\u4e2d\u3002
+resources_ResourceDropAdapterAssistant_problemsMoving=\u79fb\u52a8\u8d44\u6e90\u65f6\u51fa\u73b0\u9519\u8bef\u3002
+resources_ResourceDropAdapterAssistant_dropOperationErrorOther=\u6267\u884c\u653e\u5165\u64cd\u4f5c\u671f\u95f4\u51fa\u73b0\u9519\u8bef\u3002
+actions_NewActionProvider_NewMenu_label=\u65b0\u5efa
+actions_CopyAction_Cop_=\u590d\u5236
+actions_CopyAction_Copy_selected_resource_s_=\u590d\u5236\u6240\u9009\u7684\u8d44\u6e90
+actions_PasteAction_Past_=\u7c98\u8d34
+actions_PasteAction_Paste_selected_resource_s_=\u7c98\u8d34\u6240\u9009\u7684\u8d44\u6e90
+actions_GotoResourceDialog_GoToTitle=\u8f6c\u81f3\u8d44\u6e90
+actions_WorkingSetActionProvider_multipleWorkingSets=\u591a\u4e2a\u5de5\u4f5c\u96c6
+resources_ProjectExplorer_toolTip= \u5de5\u4f5c\u96c6\uff1a{0}
+resources_ProjectExplorer_toolTip2= {0} - \u5de5\u4f5c\u96c6\uff1a{1}
+resources_ProjectExplorer_toolTip3= {0}/{1}
+resources_ProjectExplorerPart_workspace=\u5de5\u4f5c\u7a7a\u95f4
+resources_ProjectExplorerPart_workingSetModel=\u5de5\u4f5c\u96c6
+actions_ResourceMgmtActionProvider_logTitle= \u7c7b {0} \u51fa\u73b0\u5f02\u5e38\u3002\u8fd0\u884c\u65f6\u5806\u6808\uff1a{1}
+
+actions_CopyAction_msgTitle = \u590d\u5236\u51fa\u73b0\u9519\u8bef
+actions_CopyAction_msg = \u590d\u5236\u65f6\u51fa\u73b0\u9519\u8bef\u3002
+actions_EditActionGroup_pasteAction = \u7c98\u8d34
+actions_EditActionGroup_copyAction = \u590d\u5236
+actions_EditActionGroup_deleteAction = \u5220\u9664
+actions_OpenActionProvider_openFileAction = \u6253\u5f00\u6587\u4ef6
+actions_OpenFileWithValidAction_notFindProgram = \u65e0\u6cd5\u6253\u5f00\u6b64\u6587\u4ef6\uff1a\u6587\u4ef6\u683c\u5f0f {0} \u6ca1\u6709\u5173\u8054\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\n\u8bf7\u5728\u7cfb\u7edf\u4e2d\u4e3a\u8be5\u6587\u4ef6\u683c\u5f0f\u8bbe\u7f6e\u5173\u8054\u7a0b\u5e8f\uff0c\u7136\u540e\u518d\u91cd\u8bd5\u3002
+actions_RefactorActionGroup_moveAction = \u79fb\u52a8...
+actions_RefactorActionGroup_renameAction = \u91cd\u547d\u540d...
+actions_ResourceMgmtActionProvider_openProjectAction = \u6fc0\u6d3b\u9879\u76ee
+actions_ResourceMgmtActionProvider_closeProjectAction = \u5173\u95ed\u9879\u76ee
+actions_ResourceMgmtActionProvider_refreshAction = \u5237\u65b0
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages_en.properties b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages_en.properties
new file mode 100644
index 0000000..354f3c6
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages_en.properties
@@ -0,0 +1,43 @@
+navigator_all_dialog_warning = Warning
+resources_ResourceDropAdapterAssistant_title=Drag and drop error
+actions_OpenActionProvider_OpenWithMenu_label=Open
+actions_WorkingSetRootModeActionGroup_Top_Level_Element_=Top level element
+actions_WorkingSetRootModeActionGroup_Project_=Project
+resources_ResourceDropAdapterAssistant_resourcesCanNotBeSiblings=Resources can not be the siblings of the project.
+PortingActionProvider_ImportResourcesMenu_label=&Import
+resources_ResourceDropAdapterAssistant_MoveResourceAction_title=Check Move
+PortingActionProvider_ExportResourcesMenu_label=&Export
+actions_WorkingSetRootModeActionGroup_Working_Set_=Working set
+resources_ResourceDropAdapterAssistant_targetMustBeResource=Target must be a resource.
+resources_ResourceDropAdapterAssistant_problemImporting=An error occured when importing resources.
+resources_ResourceDropAdapterAssistant_MoveResourceAction_checkMoveMessage=File ''{0}'' is read-only. Are you sure you want to move it?
+resources_ResourceDropAdapterAssistant_canNotDropIntoClosedProject=Can not drag and drop resources to a closed project.
+resources_ResourceDropAdapterAssistant_canNotDropProjectIntoProject=Can not put one project into another.
+resources_ResourceDropAdapterAssistant_problemsMoving=An error occured when moving resources.
+resources_ResourceDropAdapterAssistant_dropOperationErrorOther=An error occured while performing drag and drop operation.
+actions_NewActionProvider_NewMenu_label=New
+actions_CopyAction_Cop_=Copy
+actions_CopyAction_Copy_selected_resource_s_=Copy selected resources
+actions_PasteAction_Past_=Paste
+actions_PasteAction_Paste_selected_resource_s_=Paste selected resources
+actions_GotoResourceDialog_GoToTitle=Go to resources
+actions_WorkingSetActionProvider_multipleWorkingSets=Multiple Working set
+resources_ProjectExplorer_toolTip= Working set: {0}
+resources_ProjectExplorer_toolTip2= {0} - Working set: {1}
+resources_ProjectExplorer_toolTip3= {0}/{1}
+resources_ProjectExplorerPart_workspace=Workspace
+resources_ProjectExplorerPart_workingSetModel=Working set
+actions_ResourceMgmtActionProvider_logTitle= Exceptions occurred at class {0} Run-time stack: {1}
+
+actions_CopyAction_msgTitle = An error occured when copying...
+actions_CopyAction_msg = An error occured when copying...
+actions_EditActionGroup_pasteAction = Paste
+actions_EditActionGroup_copyAction = Copy
+actions_EditActionGroup_deleteAction = Delete
+actions_OpenActionProvider_openFileAction = Open
+actions_OpenFileWithValidAction_notFindProgram = Unable to open: the file format {0} is not associated with any application.\nPlease associate the file format with a suitable application, and then retry.
+actions_RefactorActionGroup_moveAction = Move...
+actions_RefactorActionGroup_renameAction = Rename...
+actions_ResourceMgmtActionProvider_openProjectAction = Activate Project
+actions_ResourceMgmtActionProvider_closeProjectAction = Close Project
+actions_ResourceMgmtActionProvider_refreshAction = Refresh
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages_zh.properties b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages_zh.properties
new file mode 100644
index 0000000..0f9c664
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/resource/messages_zh.properties
@@ -0,0 +1,43 @@
+navigator_all_dialog_warning = \u8b66\u544a
+resources_ResourceDropAdapterAssistant_title=\u62d6\u653e\u9519\u8bef
+actions_OpenActionProvider_OpenWithMenu_label=\u6253\u5f00\u65b9\u5f0f
+actions_WorkingSetRootModeActionGroup_Top_Level_Element_=\u9876\u5c42\u5143\u7d20
+actions_WorkingSetRootModeActionGroup_Project_=\u9879\u76ee
+resources_ResourceDropAdapterAssistant_resourcesCanNotBeSiblings=\u8d44\u6e90\u4e0d\u80fd\u662f\u9879\u76ee\u7684\u540c\u4ee3
+PortingActionProvider_ImportResourcesMenu_label=\u5bfc\u5165(&I)
+resources_ResourceDropAdapterAssistant_MoveResourceAction_title=\u68c0\u67e5\u79fb\u52a8
+PortingActionProvider_ExportResourcesMenu_label=\u5bfc\u51fa(&X)
+actions_WorkingSetRootModeActionGroup_Working_Set_=\u5de5\u4f5c\u96c6
+resources_ResourceDropAdapterAssistant_targetMustBeResource=\u76ee\u6807\u5fc5\u987b\u662f\u8d44\u6e90
+resources_ResourceDropAdapterAssistant_problemImporting=\u5bfc\u5165\u8d44\u6e90\u65f6\u51fa\u73b0\u9519\u8bef\u3002
+resources_ResourceDropAdapterAssistant_MoveResourceAction_checkMoveMessage=\u6587\u4ef6 ''{0}'' \u4e3a\u53ea\u8bfb\u6587\u4ef6\u3002\u786e\u5b9a\u8981\u79fb\u52a8\u5b83\u5417\uff1f
+resources_ResourceDropAdapterAssistant_canNotDropIntoClosedProject=\u4e0d\u80fd\u5c06\u8d44\u6e90\u653e\u5165\u5df2\u5173\u95ed\u7684\u9879\u76ee\u4e2d\u3002
+resources_ResourceDropAdapterAssistant_canNotDropProjectIntoProject=\u65e0\u6cd5\u5c06\u9879\u76ee\u653e\u5165\u53e6\u4e00\u4e2a\u9879\u76ee\u4e2d\u3002
+resources_ResourceDropAdapterAssistant_problemsMoving=\u79fb\u52a8\u8d44\u6e90\u65f6\u51fa\u73b0\u9519\u8bef\u3002
+resources_ResourceDropAdapterAssistant_dropOperationErrorOther=\u6267\u884c\u653e\u5165\u64cd\u4f5c\u671f\u95f4\u51fa\u73b0\u9519\u8bef\u3002
+actions_NewActionProvider_NewMenu_label=\u65b0\u5efa
+actions_CopyAction_Cop_=\u590d\u5236
+actions_CopyAction_Copy_selected_resource_s_=\u590d\u5236\u6240\u9009\u7684\u8d44\u6e90
+actions_PasteAction_Past_=\u7c98\u8d34
+actions_PasteAction_Paste_selected_resource_s_=\u7c98\u8d34\u6240\u9009\u7684\u8d44\u6e90
+actions_GotoResourceDialog_GoToTitle=\u8f6c\u81f3\u8d44\u6e90
+actions_WorkingSetActionProvider_multipleWorkingSets=\u591a\u4e2a\u5de5\u4f5c\u96c6
+resources_ProjectExplorer_toolTip= \u5de5\u4f5c\u96c6\uff1a{0}
+resources_ProjectExplorer_toolTip2= {0} - \u5de5\u4f5c\u96c6\uff1a{1}
+resources_ProjectExplorer_toolTip3= {0}/{1}
+resources_ProjectExplorerPart_workspace=\u5de5\u4f5c\u7a7a\u95f4
+resources_ProjectExplorerPart_workingSetModel=\u5de5\u4f5c\u96c6
+actions_ResourceMgmtActionProvider_logTitle= \u7c7b {0} \u51fa\u73b0\u5f02\u5e38\u3002\u8fd0\u884c\u65f6\u5806\u6808\uff1a{1}
+
+actions_CopyAction_msgTitle = \u590d\u5236\u51fa\u73b0\u9519\u8bef
+actions_CopyAction_msg = \u590d\u5236\u65f6\u51fa\u73b0\u9519\u8bef\u3002
+actions_EditActionGroup_pasteAction = \u7c98\u8d34
+actions_EditActionGroup_copyAction = \u590d\u5236
+actions_EditActionGroup_deleteAction = \u5220\u9664
+actions_OpenActionProvider_openFileAction = \u6253\u5f00\u6587\u4ef6
+actions_OpenFileWithValidAction_notFindProgram = \u65e0\u6cd5\u6253\u5f00\u6b64\u6587\u4ef6\uff1a\u6587\u4ef6\u683c\u5f0f {0} \u6ca1\u6709\u5173\u8054\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\n\u8bf7\u5728\u7cfb\u7edf\u4e2d\u4e3a\u8be5\u6587\u4ef6\u683c\u5f0f\u8bbe\u7f6e\u5173\u8054\u7a0b\u5e8f\uff0c\u7136\u540e\u518d\u91cd\u8bd5\u3002
+actions_RefactorActionGroup_moveAction = \u79fb\u52a8...
+actions_RefactorActionGroup_renameAction = \u91cd\u547d\u540d...
+actions_ResourceMgmtActionProvider_openProjectAction = \u6fc0\u6d3b\u9879\u76ee
+actions_ResourceMgmtActionProvider_closeProjectAction = \u5173\u95ed\u9879\u76ee
+actions_ResourceMgmtActionProvider_refreshAction = \u5237\u65b0
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionContentProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionContentProvider.java
new file mode 100644
index 0000000..37c68dc
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionContentProvider.java
@@ -0,0 +1,311 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.workbench;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+
+/**
+ * @since 3.2
+ */
+public class ResourceExtensionContentProvider extends WorkbenchContentProvider {
+
+ private static final Object[] NO_CHILDREN = new Object[0];
+ private Viewer viewer;
+
+ /**
+ *
+ */
+ public ResourceExtensionContentProvider() {
+ super();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.model.BaseWorkbenchContentProvider#getElements(java.lang.Object)
+ */
+ public Object[] getElements(Object element) {
+ return super.getChildren(element);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.model.BaseWorkbenchContentProvider#getChildren(java.lang.Object)
+ */
+ public Object[] getChildren(Object element) {
+ if(element instanceof IResource)
+ return super.getChildren(element);
+ return NO_CHILDREN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.BaseWorkbenchContentProvider#hasChildren(java.lang.Object)
+ */
+ public boolean hasChildren(Object element) {
+ try {
+ if (element instanceof IContainer) {
+ IContainer c = (IContainer) element;
+ if (!c.isAccessible())
+ return false;
+ return c.members().length > 0;
+ }
+ } catch (CoreException ex) {
+ WorkbenchNavigatorPlugin.getDefault().getLog().log(
+ new Status(IStatus.ERROR, WorkbenchNavigatorPlugin.PLUGIN_ID, 0, ex.getMessage(), ex));
+ return false;
+ }
+
+ return super.hasChildren(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.model.WorkbenchContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ super.inputChanged(viewer, oldInput, newInput);
+ this.viewer = viewer;
+ }
+
+
+ /**
+ * Process the resource delta.
+ *
+ * @param delta
+ */
+ protected void processDelta(IResourceDelta delta) {
+
+ Control ctrl = viewer.getControl();
+ if (ctrl == null || ctrl.isDisposed()) {
+ return;
+ }
+
+
+ final Collection runnables = new ArrayList();
+ processDelta(delta, runnables);
+
+ if (runnables.isEmpty()) {
+ return;
+ }
+
+ //Are we in the UIThread? If so spin it until we are done
+ if (ctrl.getDisplay().getThread() == Thread.currentThread()) {
+ runUpdates(runnables);
+ } else {
+ ctrl.getDisplay().asyncExec(new Runnable(){
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ public void run() {
+ //Abort if this happens after disposes
+ Control ctrl = viewer.getControl();
+ if (ctrl == null || ctrl.isDisposed()) {
+ return;
+ }
+
+ runUpdates(runnables);
+ }
+ });
+ }
+
+ }
+
+ /**
+ * Process a resource delta. Add any runnables
+ */
+ private void processDelta(IResourceDelta delta, Collection runnables) {
+ //he widget may have been destroyed
+ // by the time this is run. Check for this and do nothing if so.
+ Control ctrl = viewer.getControl();
+ if (ctrl == null || ctrl.isDisposed()) {
+ return;
+ }
+
+ // Get the affected resource
+ final IResource resource = delta.getResource();
+
+ // If any children have changed type, just do a full refresh of this
+ // parent,
+ // since a simple update on such children won't work,
+ // and trying to map the change to a remove and add is too dicey.
+ // The case is: folder A renamed to existing file B, answering yes to
+ // overwrite B.
+ IResourceDelta[] affectedChildren = delta
+ .getAffectedChildren(IResourceDelta.CHANGED);
+ for (int i = 0; i < affectedChildren.length; i++) {
+ if ((affectedChildren[i].getFlags() & IResourceDelta.TYPE) != 0) {
+ runnables.add(getRefreshRunnable(resource));
+ return;
+ }
+ }
+
+ // Check the flags for changes the Navigator cares about.
+ // See ResourceLabelProvider for the aspects it cares about.
+ // Notice we don't care about F_CONTENT or F_MARKERS currently.
+ int changeFlags = delta.getFlags();
+ if ((changeFlags & (IResourceDelta.OPEN | IResourceDelta.SYNC
+ | IResourceDelta.TYPE | IResourceDelta.DESCRIPTION)) != 0) {
+// Runnable updateRunnable = new Runnable(){
+// public void run() {
+// ((StructuredViewer) viewer).update(resource, null);
+// }
+// };
+// runnables.add(updateRunnable);
+
+ /* support the Closed Projects filter;
+ * when a project is closed, it may need to be removed from the view.
+ */
+ runnables.add(getRefreshRunnable(resource.getParent()));
+ }
+ // Replacing a resource may affect its label and its children
+ if ((changeFlags & IResourceDelta.REPLACED) != 0) {
+ runnables.add(getRefreshRunnable(resource));
+ return;
+ }
+
+
+ // Handle changed children .
+ for (int i = 0; i < affectedChildren.length; i++) {
+ processDelta(affectedChildren[i], runnables);
+ }
+
+ // @issue several problems here:
+ // - should process removals before additions, to avoid multiple equal
+ // elements in viewer
+ // - Kim: processing removals before additions was the indirect cause of
+ // 44081 and its varients
+ // - Nick: no delta should have an add and a remove on the same element,
+ // so processing adds first is probably OK
+ // - using setRedraw will cause extra flashiness
+ // - setRedraw is used even for simple changes
+ // - to avoid seeing a rename in two stages, should turn redraw on/off
+ // around combined removal and addition
+ // - Kim: done, and only in the case of a rename (both remove and add
+ // changes in one delta).
+
+ IResourceDelta[] addedChildren = delta
+ .getAffectedChildren(IResourceDelta.ADDED);
+ IResourceDelta[] removedChildren = delta
+ .getAffectedChildren(IResourceDelta.REMOVED);
+
+ if (addedChildren.length == 0 && removedChildren.length == 0) {
+ return;
+ }
+
+ final Object[] addedObjects;
+ final Object[] removedObjects;
+
+ // Process additions before removals as to not cause selection
+ // preservation prior to new objects being added
+ // Handle added children. Issue one update for all insertions.
+ int numMovedFrom = 0;
+ int numMovedTo = 0;
+ if (addedChildren.length > 0) {
+ addedObjects = new Object[addedChildren.length];
+ for (int i = 0; i < addedChildren.length; i++) {
+ addedObjects[i] = addedChildren[i].getResource();
+ if ((addedChildren[i].getFlags() & IResourceDelta.MOVED_FROM) != 0) {
+ ++numMovedFrom;
+ }
+ }
+ } else {
+ addedObjects = new Object[0];
+ }
+
+ // Handle removed children. Issue one update for all removals.
+ if (removedChildren.length > 0) {
+ removedObjects = new Object[removedChildren.length];
+ for (int i = 0; i < removedChildren.length; i++) {
+ removedObjects[i] = removedChildren[i].getResource();
+ if ((removedChildren[i].getFlags() & IResourceDelta.MOVED_TO) != 0) {
+ ++numMovedTo;
+ }
+ }
+ } else {
+ removedObjects = new Object[0];
+ }
+ // heuristic test for items moving within same folder (i.e. renames)
+ final boolean hasRename = numMovedFrom > 0 && numMovedTo > 0;
+
+ Runnable addAndRemove = new Runnable(){
+ public void run() {
+ if (viewer instanceof AbstractTreeViewer) {
+ AbstractTreeViewer treeViewer = (AbstractTreeViewer) viewer;
+ // Disable redraw until the operation is finished so we don't
+ // get a flash of both the new and old item (in the case of
+ // rename)
+ // Only do this if we're both adding and removing files (the
+ // rename case)
+ if (hasRename) {
+ treeViewer.getControl().setRedraw(false);
+ }
+ try {
+ if (addedObjects.length > 0) {
+ treeViewer.add(resource, addedObjects);
+ }
+ if (removedObjects.length > 0) {
+ treeViewer.remove(removedObjects);
+ }
+ }
+ finally {
+ if (hasRename) {
+ treeViewer.getControl().setRedraw(true);
+ }
+ }
+ } else {
+ ((StructuredViewer) viewer).refresh(resource);
+ }
+ }
+ };
+ runnables.add(addAndRemove);
+ }
+
+ /**
+ * Return a runnable for refreshing a resource.
+ * @param resource
+ * @return Runnable
+ */
+ private Runnable getRefreshRunnable(final IResource resource) {
+ return new Runnable(){
+ public void run() {
+ ((StructuredViewer) viewer).refresh(resource);
+ }
+ };
+ }
+
+ /**
+ * Run all of the runnables that are the widget updates
+ * @param runnables
+ */
+ private void runUpdates(Collection runnables) {
+ Iterator runnableIterator = runnables.iterator();
+ while(runnableIterator.hasNext()){
+ ((Runnable)runnableIterator.next()).run();
+ }
+
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionLabelProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionLabelProvider.java
new file mode 100644
index 0000000..860de43
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionLabelProvider.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.workbench;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonLabelProvider;
+
+/**
+ *
+ * EXPERIMENTAL. This class or interface has been added as
+ * part of a work in progress. There is a guarantee neither that this API will
+ * work nor that it will remain the same. Please do not use this API without
+ * consulting with the Platform/UI team.
+ *
+ * @since 3.2
+ */
+public class ResourceExtensionLabelProvider extends WorkbenchLabelProvider implements ICommonLabelProvider {
+
+
+ public void init(ICommonContentExtensionSite aConfig) {
+ //init
+ }
+
+
+ public String getDescription(Object anElement) {
+
+ if (anElement instanceof IResource) {
+ return ((IResource) anElement).getFullPath().makeRelative().toString();
+ }
+ return null;
+ }
+
+ public void restoreState(IMemento aMemento) {
+
+ }
+
+ public void saveState(IMemento aMemento) {
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionSorter.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionSorter.java
new file mode 100644
index 0000000..a3c7904
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceExtensionSorter.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.workbench;
+
+// Sadly, there is nothing that can be done about these warnings, as
+// the INavigatorSorterService has a method that returns a ViewerSorter, so
+// we can't convert this to a ViewerComparator.
+import org.eclipse.ui.views.navigator.ResourceSorter;
+
+/**
+ * TODO - This refers to the deprecated ResourceSorter, however we are stuck with this
+ * for the time being because the CommonSorter extension point uses a ViewerSorter.
+ * We should provide an option for a ViewerComparator and then we can remove this
+ * class.
+ *
+ * @since 3.2
+ *
+ */
+public class ResourceExtensionSorter extends ResourceSorter {
+
+ /**
+ * Construct a sorter that uses the name of the resource as its sorting
+ * criteria.
+ *
+ */
+ public ResourceExtensionSorter() {
+ super(ResourceSorter.NAME);
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceLinkHelper.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceLinkHelper.java
new file mode 100644
index 0000000..a374dbd
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/ResourceLinkHelper.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2007 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.workbench;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.navigator.ILinkHelper;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ *
+ * Links IFileEditorInput to IFiles, and vice versa.
+ *
+ * @since 3.2
+ *
+ */
+public class ResourceLinkHelper implements ILinkHelper {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.ILinkHelper#findSelection(org.eclipse.ui.IEditorInput)
+ */
+ public IStructuredSelection findSelection(IEditorInput anInput) {
+ IFile file = ResourceUtil.getFile(anInput);
+ if (file != null) {
+ return new StructuredSelection(file);
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.ILinkHelper#activateEditor(org.eclipse.ui.IWorkbenchPage, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void activateEditor(IWorkbenchPage aPage,
+ IStructuredSelection aSelection) {
+ if (aSelection == null || aSelection.isEmpty())
+ return;
+ if (aSelection.getFirstElement() instanceof IFile) {
+ IEditorInput fileInput = new FileEditorInput((IFile) aSelection.getFirstElement());
+ IEditorPart editor = null;
+ if ((editor = aPage.findEditor(fileInput)) != null)
+ aPage.bringToTop(editor);
+ }
+
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetAdapterFactory.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetAdapterFactory.java
new file mode 100644
index 0000000..4ea9453
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetAdapterFactory.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2010 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.workbench;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+/**
+ * An property sheet page adapter factory for the Project Explorer.
+ *
+ * @since 3.2
+ */
+public class TabbedPropertySheetAdapterFactory
+ implements IAdapterFactory {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
+ * java.lang.Class)
+ */
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adaptableObject instanceof ProjectExplorer) {
+ if (IPropertySheetPage.class == adapterType)
+ return new TabbedPropertySheetPage(
+ new TabbedPropertySheetProjectExplorerContributor(
+ (CommonNavigator) adaptableObject));
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ public Class[] getAdapterList() {
+ return new Class[] {IPropertySheetPage.class};
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetProjectExplorerContributor.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetProjectExplorerContributor.java
new file mode 100644
index 0000000..2eb2b3e
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetProjectExplorerContributor.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.workbench;
+
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+
+/**
+ * A tabbed property view contributor for the Project Explorer.
+ *
+ * @since 3.2
+ */
+public class TabbedPropertySheetProjectExplorerContributor implements
+ ITabbedPropertySheetPageContributor {
+
+ private final String contributorId;
+
+ protected TabbedPropertySheetProjectExplorerContributor(CommonNavigator aCommonNavigator) {
+ contributorId = aCommonNavigator.getViewSite().getId();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId()
+ */
+ public String getContributorId() {
+ return contributorId;
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetTitleProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetTitleProvider.java
new file mode 100644
index 0000000..2a7371e
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/TabbedPropertySheetTitleProvider.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.resources.workbench;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
+import org.eclipse.ui.navigator.IDescriptionProvider;
+import org.eclipse.ui.navigator.INavigatorContentService;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+
+/**
+ * Defines a label provider for the title bar in the tabbed properties view.
+ *
+ * @since 3.2
+ */
+public class TabbedPropertySheetTitleProvider extends LabelProvider {
+
+ private ILabelProvider labelProvider;
+
+ private IDescriptionProvider descriptionProvider;
+
+ /**
+ * Constructor for CommonNavigatorTitleProvider.
+ */
+ public TabbedPropertySheetTitleProvider() {
+ super();
+ IWorkbenchPart part = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage().findView(ProjectExplorer.VIEW_ID);
+
+ INavigatorContentService contentService = (INavigatorContentService) part
+ .getAdapter(INavigatorContentService.class);
+
+ if (contentService != null) {
+ labelProvider = contentService.createCommonLabelProvider();
+ descriptionProvider = contentService
+ .createCommonDescriptionProvider();
+ } else {
+ WorkbenchNavigatorPlugin.log(
+ "Could not acquire INavigatorContentService from part (\"" //$NON-NLS-1$
+ + part.getTitle() + "\").", null); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+ */
+ public Image getImage(Object object) {
+ return labelProvider != null ? labelProvider.getImage(object) : null;
+ }
+
+ /**
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ */
+ public String getText(Object object) {
+ return descriptionProvider != null ? descriptionProvider
+ .getDescription(object) : null;
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/WorkbenchLabelProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/WorkbenchLabelProvider.java
new file mode 100644
index 0000000..c7e49b0
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/resources/workbench/WorkbenchLabelProvider.java
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Fair Isaac Corporation - http://bugs.eclipse.org/326695
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.resources.workbench;
+
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.resource.ColorDescriptor;
+import org.eclipse.jface.resource.FontDescriptor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.resource.LocalResourceManager;
+import org.eclipse.jface.resource.ResourceManager;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.StyledString.Styler;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.ui.IEditorRegistry;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.util.Util;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.model.IWorkbenchAdapter2;
+import org.eclipse.ui.model.IWorkbenchAdapter3;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * Provides basic labels for adaptable objects that have the IWorkbenchAdapter adapter associated with
+ * them. All dispensed images are cached until the label provider is explicitly disposed. This class provides a facility
+ * for subclasses to define annotations on the labels and icons of adaptable objects.
+ */
+public class WorkbenchLabelProvider extends LabelProvider implements IColorProvider, IFontProvider,
+ IStyledLabelProvider {
+
+ /**
+ * Returns a workbench label provider that is hooked up to the decorator mechanism.
+ * @return a new DecoratingLabelProvider which wraps a
+ * new WorkbenchLabelProvider
+ */
+ public static ILabelProvider getDecoratingWorkbenchLabelProvider() {
+ return new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench()
+ .getDecoratorManager().getLabelDecorator());
+ }
+
+ /**
+ * Listener that tracks changes to the editor registry and does a full update when it changes, since many workbench
+ * adapters derive their icon from the file associations in the registry.
+ */
+ private IPropertyListener editorRegistryListener = new IPropertyListener() {
+ public void propertyChanged(Object source, int propId) {
+ if (propId == IEditorRegistry.PROP_CONTENTS) {
+ fireLabelProviderChanged(new LabelProviderChangedEvent(WorkbenchLabelProvider.this));
+ }
+ }
+ };
+ private ResourceManager resourceManager;
+
+ /**
+ * Creates a new workbench label provider.
+ */
+ public WorkbenchLabelProvider() {
+ PlatformUI.getWorkbench().getEditorRegistry().addPropertyListener(editorRegistryListener);
+ }
+
+ /**
+ * Returns an image descriptor that is based on the given descriptor, but decorated with additional information
+ * relating to the state of the provided object. Subclasses may reimplement this method to decorate an object's
+ * image.
+ * @param input
+ * The base image to decorate.
+ * @param element
+ * The element used to look up decorations.
+ * @return the resuling ImageDescriptor.
+ * @see org.eclipse.jface.resource.CompositeImageDescriptor
+ */
+ protected ImageDescriptor decorateImage(ImageDescriptor input, Object element) {
+ return input;
+ }
+
+ /**
+ * Returns a label that is based on the given label, but decorated with additional information relating to the state
+ * of the provided object. Subclasses may implement this method to decorate an object's label.
+ * @param input
+ * The base text to decorate.
+ * @param element
+ * The element used to look up decorations.
+ * @return the resulting text
+ */
+ protected String decorateText(String input, Object element) {
+ return input;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on ILabelProvider
+ */
+ public void dispose() {
+ PlatformUI.getWorkbench().getEditorRegistry().removePropertyListener(editorRegistryListener);
+ if (resourceManager != null)
+ resourceManager.dispose();
+ resourceManager = null;
+ super.dispose();
+ }
+
+ /**
+ * Returns the implementation of IWorkbenchAdapter for the given object.
+ * @param o
+ * the object to look up.
+ * @return IWorkbenchAdapter ornull if the adapter is not defined or the object is not adaptable.
+ */
+ protected final IWorkbenchAdapter getAdapter(Object o) {
+ return (IWorkbenchAdapter) Util.getAdapter(o, IWorkbenchAdapter.class);
+ }
+
+ /**
+ * Returns the implementation of IWorkbenchAdapter2 for the given object.
+ * @param o
+ * the object to look up.
+ * @return IWorkbenchAdapter2 ornull if the adapter is not defined or the object is not adaptable.
+ */
+ protected final IWorkbenchAdapter2 getAdapter2(Object o) {
+ return (IWorkbenchAdapter2) Util.getAdapter(o, IWorkbenchAdapter2.class);
+ }
+
+ /**
+ * Returns the implementation of IWorkbenchAdapter3 for the given object.
+ * @param o
+ * the object to look up.
+ * @return IWorkbenchAdapter3 ornull if the adapter is not defined or the object is not adaptable.
+ * @since 3.7
+ */
+ protected final IWorkbenchAdapter3 getAdapter3(Object o) {
+ return (IWorkbenchAdapter3) Util.getAdapter(o, IWorkbenchAdapter3.class);
+ }
+
+ /**
+ * Lazy load the resource manager
+ * @return The resource manager, create one if necessary
+ */
+ private ResourceManager getResourceManager() {
+ if (resourceManager == null) {
+ resourceManager = new LocalResourceManager(JFaceResources.getResources());
+ }
+
+ return resourceManager;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on ILabelProvider
+ */
+ public final Image getImage(Object element) {
+ // obtain the base image by querying the element
+ ImageDescriptor descriptor = null;
+ if (element instanceof IProject) {
+ IProject project = (IProject) element;
+ if (project.isOpen()) {
+ descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
+ "net.heartsome.cat.common.ui.navigator.resources", "icons/full/obj16/prj_open.png");
+ }else {
+ descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
+ "net.heartsome.cat.common.ui.navigator.resources", "icons/full/obj16/prj_close.png");
+ }
+ } else if(element instanceof IFolder){
+ descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
+ "net.heartsome.cat.common.ui.navigator.resources", "icons/full/obj16/folder.png");
+ }
+
+ else {
+ IWorkbenchAdapter adapter = getAdapter(element);
+ if (adapter == null) {
+ return null;
+ }
+ descriptor = adapter.getImageDescriptor(element);
+ if (descriptor == null) {
+ return null;
+ }
+
+ // add any annotations to the image descriptor
+ descriptor = decorateImage(descriptor, element);
+ }
+ return (Image) getResourceManager().get(descriptor);
+ }
+
+ /**
+ * The default implementation of this returns the styled text label for the given element.
+ * @param element
+ * the element to evaluate the styled string for
+ * @return the styled string.
+ * @since 3.7
+ */
+ public StyledString getStyledText(Object element) {
+ IWorkbenchAdapter3 adapter = getAdapter3(element);
+ if (adapter == null) {
+ // If adapter class doesn't implement IWorkbenchAdapter3 than use
+ // StyledString with text of element. Since the output of getText is
+ // already decorated, so we don't need to call decorateText again
+ // here.
+ return new StyledString(getText(element));
+ }
+ StyledString styledString = adapter.getStyledText(element);
+ // Now, re-use any existing decorateText implementation, to decorate
+ // this styledString.
+ String decorated = decorateText(styledString.getString(), element);
+ Styler styler = getDecorationStyle(element);
+ return StyledCellLabelProvider.styleDecoratedString(decorated, styler, styledString);
+ }
+
+ /**
+ * Sets the {@link org.eclipse.jface.viewers.StyledString.Styler} to be used for string decorations. By default the
+ * {@link StyledString#DECORATIONS_STYLER decoration style}. Clients can override.
+ * @param element
+ * the element that has been decorated
+ * @return return the decoration style
+ * @since 3.7
+ */
+ protected Styler getDecorationStyle(Object element) {
+ return StyledString.DECORATIONS_STYLER;
+ }
+
+ /*
+ * (non-Javadoc) Method declared on ILabelProvider
+ */
+ public final String getText(Object element) {
+ // query the element for its label
+ IWorkbenchAdapter adapter = getAdapter(element);
+ if (adapter == null) {
+ return ""; //$NON-NLS-1$
+ }
+ String label = adapter.getLabel(element);
+
+ // return the decorated label
+ return decorateText(label, element);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ public Color getForeground(Object element) {
+ return getColor(element, true);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+ */
+ public Color getBackground(Object element) {
+ return getColor(element, false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
+ */
+ public Font getFont(Object element) {
+ IWorkbenchAdapter2 adapter = getAdapter2(element);
+ if (adapter == null) {
+ return null;
+ }
+
+ FontData descriptor = adapter.getFont(element);
+ if (descriptor == null) {
+ return null;
+ }
+
+ return (Font) getResourceManager().get(FontDescriptor.createFrom(descriptor));
+ }
+
+ private Color getColor(Object element, boolean forground) {
+ IWorkbenchAdapter2 adapter = getAdapter2(element);
+ if (adapter == null) {
+ return null;
+ }
+ RGB descriptor = forground ? adapter.getForeground(element) : adapter.getBackground(element);
+ if (descriptor == null) {
+ return null;
+ }
+
+ return (Color) getResourceManager().get(ColorDescriptor.createFrom(descriptor));
+ }
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetSorter.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetSorter.java
new file mode 100644
index 0000000..8f0417e
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetSorter.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2006 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.internal.navigator.workingsets;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * @since 3.2
+ *
+ */
+public class WorkingSetSorter extends ViewerSorter {
+
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if(viewer instanceof StructuredViewer) {
+ ILabelProvider labelProvider = (ILabelProvider) ((StructuredViewer)viewer).getLabelProvider();
+ String text1 = labelProvider.getText(e1);
+ String text2 = labelProvider.getText(e2);
+ if(text1 != null) {
+ return text1.compareTo(text2);
+ }
+ }
+ return -1;
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetsContentProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetsContentProvider.java
new file mode 100644
index 0000000..eacb7de
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetsContentProvider.java
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.workingsets;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.ui.IAggregateWorkingSet;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.internal.navigator.NavigatorContentService;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+import org.eclipse.ui.navigator.IExtensionStateModel;
+import org.eclipse.ui.navigator.resources.ProjectExplorer;
+
+/**
+ * Provides children and parents for IWorkingSets.
+ *
+ * @since 3.2.1
+ *
+ */
+public class WorkingSetsContentProvider implements ICommonContentProvider {
+
+ /**
+ * The extension id for the WorkingSet extension.
+ */
+ public static final String EXTENSION_ID = "org.eclipse.ui.navigator.resources.workingSets"; //$NON-NLS-1$
+
+ /**
+ * A key used by the Extension State Model to keep track of whether top level Working Sets or
+ * Projects should be shown in the viewer.
+ */
+ public static final String SHOW_TOP_LEVEL_WORKING_SETS = EXTENSION_ID + ".showTopLevelWorkingSets"; //$NON-NLS-1$
+
+
+ private static final Object[] NO_CHILDREN = new Object[0];
+
+ private WorkingSetHelper helper;
+ private IAggregateWorkingSet workingSetRoot;
+ private IExtensionStateModel extensionStateModel;
+ private CommonNavigator projectExplorer;
+ private CommonViewer viewer;
+
+ private IPropertyChangeListener rootModeListener = new IPropertyChangeListener() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if(SHOW_TOP_LEVEL_WORKING_SETS.equals(event.getProperty())) {
+ updateRootMode();
+ }
+ }
+
+ };
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
+ */
+ public void init(ICommonContentExtensionSite aConfig) {
+ NavigatorContentService cs = (NavigatorContentService) aConfig.getService();
+ viewer = (CommonViewer) cs.getViewer();
+ projectExplorer = viewer.getCommonNavigator();
+
+ extensionStateModel = aConfig.getExtensionStateModel();
+ extensionStateModel.addPropertyChangeListener(rootModeListener);
+ updateRootMode();
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
+ */
+ public void restoreState(IMemento aMemento) {
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
+ */
+ public void saveState(IMemento aMemento) {
+
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IWorkingSet) {
+ IWorkingSet workingSet = (IWorkingSet) parentElement;
+ if (workingSet.isAggregateWorkingSet() && projectExplorer != null) {
+ switch (projectExplorer.getRootMode()) {
+ case ProjectExplorer.WORKING_SETS :
+ return ((IAggregateWorkingSet) workingSet).getComponents();
+ case ProjectExplorer.PROJECTS :
+ return getWorkingSetElements(workingSet);
+ }
+ }
+ return getWorkingSetElements(workingSet);
+ }
+ return NO_CHILDREN;
+ }
+
+ private IAdaptable[] getWorkingSetElements(IWorkingSet workingSet) {
+ IAdaptable[] children = workingSet.getElements();
+ for (int i = 0; i < children.length; i++) {
+ Object resource = children[i].getAdapter(IResource.class);
+ if (resource instanceof IProject)
+ children[i] = (IProject) resource;
+ }
+ return children;
+ }
+
+ public Object getParent(Object element) {
+ if (helper != null)
+ return helper.getParent(element);
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ return true;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ helper = null;
+ extensionStateModel.removePropertyChangeListener(rootModeListener);
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ if (newInput instanceof IWorkingSet) {
+ IWorkingSet rootSet = (IWorkingSet) newInput;
+ helper = new WorkingSetHelper(rootSet);
+ }
+ }
+
+ private void updateRootMode() {
+ if (projectExplorer == null) {
+ return;
+ }
+ if( extensionStateModel.getBooleanProperty(SHOW_TOP_LEVEL_WORKING_SETS) )
+ projectExplorer.setRootMode(ProjectExplorer.WORKING_SETS);
+ else
+ projectExplorer.setRootMode(ProjectExplorer.PROJECTS);
+ }
+
+ protected class WorkingSetHelper {
+
+ private final IWorkingSet workingSet;
+ private final Map parents = new WeakHashMap();
+
+ /**
+ * Create a Helper class for the given working set
+ *
+ * @param set
+ * The set to use to build the item to parent map.
+ */
+ public WorkingSetHelper(IWorkingSet set) {
+ workingSet = set;
+
+ if (workingSet.isAggregateWorkingSet()) {
+ IAggregateWorkingSet aggregateSet = (IAggregateWorkingSet) workingSet;
+ if (workingSetRoot == null)
+ workingSetRoot = aggregateSet;
+
+ IWorkingSet[] components = aggregateSet.getComponents();
+
+ for (int componentIndex = 0; componentIndex < components.length; componentIndex++) {
+ IAdaptable[] elements = getWorkingSetElements(components[componentIndex]);
+ for (int elementsIndex = 0; elementsIndex < elements.length; elementsIndex++) {
+ parents.put(elements[elementsIndex], components[componentIndex]);
+ }
+ parents.put(components[componentIndex], aggregateSet);
+
+ }
+ } else {
+ IAdaptable[] elements = getWorkingSetElements(workingSet);
+ for (int elementsIndex = 0; elementsIndex < elements.length; elementsIndex++) {
+ parents.put(elements[elementsIndex], workingSet);
+ }
+ }
+ }
+
+ /**
+ *
+ * @param element
+ * An element from the viewer
+ * @return The parent associated with the element, if any.
+ */
+ public Object getParent(Object element) {
+ if (element instanceof IWorkingSet && element != workingSetRoot)
+ return workingSetRoot;
+ return parents.get(element);
+ }
+ }
+
+
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetsLabelProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetsLabelProvider.java
new file mode 100644
index 0000000..6da3a8b
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/internal/navigator/workingsets/WorkingSetsLabelProvider.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.internal.navigator.workingsets;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+
+/**
+ * Provides a text label and icon for Working Sets.
+ *
+ */
+public class WorkingSetsLabelProvider implements ILabelProvider {
+
+ private WorkbenchLabelProvider labelProvider = new WorkbenchLabelProvider();
+
+ public Image getImage(Object element) {
+ if (element instanceof IWorkingSet)
+ return labelProvider.getImage(element);
+ return null;
+ }
+
+ public String getText(Object element) {
+ if (element instanceof IWorkingSet)
+ return ((IWorkingSet) element).getLabel();
+ return null;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/GoIntoActionProvider.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/GoIntoActionProvider.java
new file mode 100644
index 0000000..63cb38e
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/GoIntoActionProvider.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Oakland Software (Francis Upton - francisu@ieee.org)
+ * bug 214271 Undo/redo not enabled if nothing selected
+ ******************************************************************************/
+
+package org.eclipse.ui.navigator.resources;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.internal.navigator.framelist.GoIntoAction;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+
+/**
+ * Provides the Go Into action for the {@link ProjectExplorer}
+ *
+ * @since 3.4
+ *
+ */
+public class GoIntoActionProvider extends CommonActionProvider {
+
+ private GoIntoAction goIntoAction;
+
+ public void init(ICommonActionExtensionSite anActionSite) {
+ anActionSite.getViewSite().getShell();
+ CommonViewer viewer = (CommonViewer) anActionSite.getStructuredViewer();
+ goIntoAction = new GoIntoAction(viewer.getFrameList());
+ }
+
+ public void dispose() {
+ goIntoAction.dispose();
+ }
+
+ public void fillActionBars(IActionBars actionBars) {
+ actionBars.setGlobalActionHandler(IWorkbenchActionConstants.GO_INTO, goIntoAction);
+ }
+
+ public void fillContextMenu(IMenuManager menu) {
+ menu.appendToGroup("group.new", goIntoAction); //$NON-NLS-1$
+ }
+
+ public void updateActionBars() {
+ goIntoAction.update();
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ProjectExplorer.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ProjectExplorer.java
new file mode 100644
index 0000000..9c1f3cf
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ProjectExplorer.java
@@ -0,0 +1,218 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+package org.eclipse.ui.navigator.resources;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IAggregateWorkingSet;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.navigator.framelist.Frame;
+import org.eclipse.ui.internal.navigator.framelist.FrameList;
+import org.eclipse.ui.internal.navigator.framelist.TreeFrame;
+import org.eclipse.ui.internal.navigator.resources.ResourceToItemsMapper;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.INavigatorContentService;
+
+/**
+ *
+ * @see CommonNavigator
+ * @see INavigatorContentService
+ * @since 3.2
+ *
+ */
+public final class ProjectExplorer extends CommonNavigator {
+
+ /**
+ * Provides a constant for the standard instance of the Common Navigator.
+ *
+ * @see PlatformUI#getWorkbench()
+ * @see IWorkbench#getActiveWorkbenchWindow()
+ * @see IWorkbenchWindow#getActivePage()
+ *
+ * @see IWorkbenchPage#findView(String)
+ * @see IWorkbenchPage#findViewReference(String)
+ */
+ public static final String VIEW_ID = IPageLayout.ID_PROJECT_EXPLORER;
+
+ /**
+ * @since 3.4
+ */
+ public static final int WORKING_SETS = 0;
+
+ /**
+ * @since 3.4
+ */
+ public static final int PROJECTS = 1;
+
+ private int rootMode;
+
+ /**
+ * Used only in the case of top level = PROJECTS and only when some
+ * working sets are selected.
+ */
+ private String workingSetLabel;
+
+ public void createPartControl(Composite aParent) {
+ super.createPartControl(aParent);
+
+ if (!false)
+ getCommonViewer().setMapper(new ResourceToItemsMapper(getCommonViewer()));
+ }
+
+ /**
+ * The superclass does not deal with the content description, handle it
+ * here.
+ *
+ * @noreference
+ */
+ public void updateTitle() {
+ super.updateTitle();
+ Object input = getCommonViewer().getInput();
+
+ if (input == null || input instanceof IAggregateWorkingSet) {
+ setContentDescription(""); //$NON-NLS-1$
+ return;
+ }
+
+ if (!(input instanceof IResource)) {
+ if (input instanceof IAdaptable) {
+ IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) input)
+ .getAdapter(IWorkbenchAdapter.class);
+ if (wbadapter != null) {
+ setContentDescription(wbadapter.getLabel(input));
+ return;
+ }
+ }
+ setContentDescription(input.toString());
+ return;
+ }
+
+ IResource res = (IResource) input;
+ setContentDescription(res.getName());
+ }
+
+ /**
+ * Returns the tool tip text for the given element.
+ *
+ * @param element
+ * the element
+ * @return the tooltip
+ * @noreference
+ */
+ public String getFrameToolTipText(Object element) {
+ String result;
+ if (!(element instanceof IResource)) {
+ if (element instanceof IAggregateWorkingSet) {
+ result = WorkbenchNavigatorMessages.resources_ProjectExplorerPart_workingSetModel;
+ } else if (element instanceof IWorkingSet) {
+ result = ((IWorkingSet) element).getLabel();
+ } else {
+ result = super.getFrameToolTipText(element);
+ }
+ } else {
+ IPath path = ((IResource) element).getFullPath();
+ if (path.isRoot()) {
+ result = WorkbenchNavigatorMessages.resources_ProjectExplorerPart_workspace;
+ } else {
+ result = path.makeRelative().toString();
+ }
+ }
+
+ if (rootMode == PROJECTS) {
+ if (workingSetLabel == null)
+ return result;
+ if (result.length() == 0)
+ return NLS.bind(WorkbenchNavigatorMessages.resources_ProjectExplorer_toolTip,
+ new String[] { workingSetLabel });
+ return NLS.bind(WorkbenchNavigatorMessages.resources_ProjectExplorer_toolTip2, new String[] {
+ result, workingSetLabel });
+ }
+
+ // Working set mode. During initialization element and viewer can
+ // be null.
+ if (element != null && !(element instanceof IWorkingSet)
+ && getCommonViewer() != null) {
+ FrameList frameList = getCommonViewer().getFrameList();
+ // Happens during initialization
+ if (frameList == null)
+ return result;
+ int index = frameList.getCurrentIndex();
+ IWorkingSet ws = null;
+ while (index >= 0) {
+ Frame frame = frameList.getFrame(index);
+ if (frame instanceof TreeFrame) {
+ Object input = ((TreeFrame) frame).getInput();
+ if (input instanceof IWorkingSet && !(input instanceof IAggregateWorkingSet)) {
+ ws = (IWorkingSet) input;
+ break;
+ }
+ }
+ index--;
+ }
+ if (ws != null) {
+ return NLS.bind(WorkbenchNavigatorMessages.resources_ProjectExplorer_toolTip3,
+ new String[] { ws.getLabel(), result });
+ }
+ return result;
+ }
+ return result;
+
+ }
+
+ /**
+ * @param mode
+ * @noreference This method is not intended to be referenced by clients.
+ * @since 3.4
+ */
+ public void setRootMode(int mode) {
+ rootMode = mode;
+ }
+
+ /**
+ * @return the root mode
+ * @noreference This method is not intended to be referenced by clients.
+ * @since 3.4
+ */
+ public int getRootMode() {
+ return rootMode;
+ }
+
+ /**
+ * @param label
+ * @noreference This method is not intended to be referenced by clients.
+ * @since 3.4
+ */
+ public void setWorkingSetLabel(String label) {
+ workingSetLabel = label;
+ }
+
+ /**
+ * @return the working set label
+ * @noreference This method is not intended to be referenced by clients.
+ * @since 3.4
+ */
+ public String getWorkingSetLabel() {
+ return workingSetLabel;
+ }
+
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ResourceDragAdapterAssistant.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ResourceDragAdapterAssistant.java
new file mode 100644
index 0000000..363946f
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ResourceDragAdapterAssistant.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2009 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ * Anton Leherbauer (Wind River Systems) - http://bugs.eclipse.org/247294
+ ******************************************************************************/
+
+package org.eclipse.ui.navigator.resources;
+
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.ui.internal.navigator.Policy;
+import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
+import org.eclipse.ui.navigator.INavigatorDnDService;
+import org.eclipse.ui.part.ResourceTransfer;
+
+/**
+ * Clients may reference this class in the dragAssistant element of a
+ * org.eclipse.ui.navigator.viewer extension point.
+ *
+ *
+ * Clients may not extend or instantiate this class for any purpose other than
+ * {@link INavigatorDnDService#bindDragAssistant(CommonDragAdapterAssistant)}.
+ * Clients may have no direct dependencies on the contract of this class.
+ *
+ *
+ * @since 3.2
+ * @noextend This class is not intended to be subclassed by clients.
+ *
+ */
+public class ResourceDragAdapterAssistant extends
+ CommonDragAdapterAssistant {
+
+ private static final Transfer[] SUPPORTED_TRANSFERS = new Transfer[] {
+ ResourceTransfer.getInstance(),
+ FileTransfer.getInstance() };
+
+ private static final Class IRESOURCE_TYPE = IResource.class;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#getSupportedTransferTypes()
+ */
+ public Transfer[] getSupportedTransferTypes() {
+ return SUPPORTED_TRANSFERS;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public boolean setDragData(DragSourceEvent anEvent,
+ IStructuredSelection aSelection) {
+
+ IResource[] resources = getSelectedResources(aSelection);
+ if (resources.length > 0) {
+ if (ResourceTransfer.getInstance().isSupportedType(anEvent.dataType)) {
+ anEvent.data = resources;
+ if (Policy.DEBUG_DND) {
+ System.out
+ .println("ResourceDragAdapterAssistant.dragSetData set ResourceTransfer"); //$NON-NLS-1$
+ }
+ return true;
+ }
+
+ if (FileTransfer.getInstance().isSupportedType(anEvent.dataType)) {
+ // Get the path of each file and set as the drag data
+ final int length = resources.length;
+ int actualLength = 0;
+ String[] fileNames = new String[length];
+ for (int i = 0; i < length; i++) {
+ IPath location = resources[i].getLocation();
+ // location may be null. See bug 29491.
+ if (location != null) {
+ fileNames[actualLength++] = location.toOSString();
+ }
+ }
+ if (actualLength > 0) {
+ // was one or more of the locations null?
+ if (actualLength < length) {
+ String[] tempFileNames = fileNames;
+ fileNames = new String[actualLength];
+ for (int i = 0; i < actualLength; i++)
+ fileNames[i] = tempFileNames[i];
+ }
+ anEvent.data = fileNames;
+
+ if (Policy.DEBUG_DND)
+ System.out
+ .println("ResourceDragAdapterAssistant.dragSetData set FileTransfer"); //$NON-NLS-1$
+ return true;
+ }
+ }
+ }
+ return false;
+
+ }
+
+ private IResource[] getSelectedResources(IStructuredSelection aSelection) {
+ Set resources = new LinkedHashSet();
+ IResource resource = null;
+ for (Iterator iter = aSelection.iterator(); iter.hasNext();) {
+ Object selected = iter.next();
+ resource = adaptToResource(selected);
+ if (resource != null) {
+ resources.add(resource);
+ }
+ }
+ return (IResource[]) resources.toArray(new IResource[resources.size()]);
+ }
+
+ private IResource adaptToResource(Object selected) {
+ IResource resource;
+ if (selected instanceof IResource) {
+ resource = (IResource) selected;
+ } else if (selected instanceof IAdaptable) {
+ resource = (IResource) ((IAdaptable) selected)
+ .getAdapter(IRESOURCE_TYPE);
+ } else {
+ resource = (IResource) Platform.getAdapterManager().getAdapter(
+ selected, IRESOURCE_TYPE);
+ }
+ return resource;
+ }
+
+}
diff --git a/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ResourceDropAdapterAssistant.java b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ResourceDropAdapterAssistant.java
new file mode 100644
index 0000000..c43217d
--- /dev/null
+++ b/base_commons/net.heartsome.cat.common.ui.navigator.resources/src/org/eclipse/ui/navigator/resources/ResourceDropAdapterAssistant.java
@@ -0,0 +1,718 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ui.navigator.resources;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ltk.core.refactoring.CheckConditionsOperation;
+import org.eclipse.ltk.core.refactoring.PerformRefactoringOperation;
+import org.eclipse.ltk.core.refactoring.Refactoring;
+import org.eclipse.ltk.core.refactoring.RefactoringContribution;
+import org.eclipse.ltk.core.refactoring.RefactoringCore;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
+import org.eclipse.ltk.core.refactoring.resource.MoveResourcesDescriptor;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.FileTransfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.CopyFilesAndFoldersOperation;
+import org.eclipse.ui.actions.MoveFilesAndFoldersOperation;
+import org.eclipse.ui.actions.ReadOnlyStateChecker;
+import org.eclipse.ui.internal.navigator.Policy;
+import org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin;
+import org.eclipse.ui.internal.navigator.resources.resource.WorkbenchNavigatorMessages;
+import org.eclipse.ui.navigator.CommonDropAdapter;
+import org.eclipse.ui.navigator.CommonDropAdapterAssistant;
+import org.eclipse.ui.part.ResourceTransfer;
+
+
+/**
+ *
+ * Clients may reference this class in the dropAssistant element of a
+ * org.eclipse.ui.navigator.navigatorContent extension point.
+ *
+ *
+ * Clients may not extend or instantiate this class for any purpose.
+ * Clients may have no direct dependencies on the contract of this class.
+ *