Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'development/org.eclipse.wst.jsdt.jseview/src/org')
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/EditorUtility.java80
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/JEPluginImages.java49
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/JEViewPlugin.java86
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/ClasspathEntryProperties.java185
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/GenericProperty.java53
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JarEntryResourceProperties.java86
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementFinder.java142
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementProperties.java705
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/MarkerProperties.java221
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/ResourceProperties.java103
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Error.java91
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEAttribute.java33
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEClasspathEntry.java157
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEJarEntryResource.java119
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEMarker.java93
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEResource.java155
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JERoot.java99
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEViewContentProvider.java51
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEViewLabelProvider.java99
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElement.java581
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementChildrenProperty.java89
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementProperty.java114
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementView.java953
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Mapper.java33
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Null.java73
-rw-r--r--development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/TreeCopyAction.java180
26 files changed, 0 insertions, 4630 deletions
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/EditorUtility.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/EditorUtility.java
deleted file mode 100644
index 0d500414..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/EditorUtility.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.wst.jsdt.jseview;
-
-
-import org.eclipse.core.runtime.Assert;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IOpenable;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-/**
- *
- */
-public class EditorUtility {
- private EditorUtility() {
- super();
- }
-
- public static IEditorPart getActiveEditor() {
- IWorkbenchWindow window= JEViewPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page= window.getActivePage();
- if (page != null) {
- return page.getActiveEditor();
- }
- }
- return null;
- }
-
-
- public static IOpenable getJavaInput(IEditorPart part) {
- IEditorInput editorInput= part.getEditorInput();
- if (editorInput != null) {
- IJavaScriptElement input= javaUIgetEditorInputJavaElement(editorInput);
- if (input instanceof IOpenable) {
- return (IOpenable) input;
- }
- }
- return null;
- }
-
- /**
- * Note: This is an inlined version of {@link JavaUI#getEditorInputJavaElement(IEditorInput)},
- * which is not available in 3.1.
- */
- private static IJavaScriptElement javaUIgetEditorInputJavaElement(IEditorInput editorInput) {
- Assert.isNotNull(editorInput);
- IJavaScriptElement je= JavaScriptUI.getWorkingCopyManager().getWorkingCopy(editorInput);
- if (je != null)
- return je;
-
- /*
- * This needs works, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=120340
- */
- return (IJavaScriptElement)editorInput.getAdapter(IJavaScriptElement.class);
- }
-
- public static void selectInEditor(ITextEditor editor, int offset, int length) {
- IEditorPart active = getActiveEditor();
- if (active != editor) {
- editor.getSite().getPage().activate(editor);
- }
- editor.selectAndReveal(offset, length);
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/JEPluginImages.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/JEPluginImages.java
deleted file mode 100644
index 731f7fc6..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/JEPluginImages.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.wst.jsdt.jseview;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-
-public class JEPluginImages {
-
- private static URL fgIconBaseURL= null;
- static {
- fgIconBaseURL= JEViewPlugin.getDefault().getBundle().getEntry("/icons/c/"); //$NON-NLS-1$
- }
-
- public static final String CHILDREN= "children.png";
- public static final String INFO= "info.png";
- public static final String PROPERTIES= "properties.gif";
- public static final String REFRESH= "refresh.gif";
- public static final String SET_FOCUS= "setfocus.gif";
- public static final String CODE_SELECT= "codeSelect.gif";
-
- public static final ImageDescriptor IMG_CHILDREN= create(CHILDREN);
- public static final ImageDescriptor IMG_INFO= create(INFO);
-
- public static final ImageDescriptor IMG_PROPERTIES= create(PROPERTIES);
- public static final ImageDescriptor IMG_REFRESH= create(REFRESH);
- public static final ImageDescriptor IMG_SET_FOCUS= create(SET_FOCUS);
- public static final ImageDescriptor IMG_SET_FOCUS_CODE_SELECT= create(CODE_SELECT);
-
- private static ImageDescriptor create(String name) {
- try {
- return ImageDescriptor.createFromURL(new URL(fgIconBaseURL, name));
- } catch (MalformedURLException e) {
- return ImageDescriptor.getMissingImageDescriptor();
- }
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/JEViewPlugin.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/JEViewPlugin.java
deleted file mode 100644
index 74fca129..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/JEViewPlugin.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.wst.jsdt.jseview;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-import org.osgi.framework.BundleContext;
-
-public class JEViewPlugin extends AbstractUIPlugin {
-
- private static JEViewPlugin fDefault;
-
- public JEViewPlugin() {
- fDefault= this;
- }
-
- public static String getPluginId() {
- return "org.eclipse.wst.jsdt.jseview"; //$NON-NLS-1$
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- fDefault= null;
- }
-
- /**
- * @return the shared instance
- */
- public static JEViewPlugin getDefault() {
- return fDefault;
- }
-
- /**
- * @return the workspace instance
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void logErrorMessage(String message) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, null));
- }
-
- public static void logMessage(String message) {
- log(new Status(IStatus.INFO, getPluginId(), IStatus.INFO, message, null));
- }
-
- public static void logErrorStatus(String message, IStatus status) {
- if (status == null) {
- logErrorMessage(message);
- return;
- }
- MultiStatus multi= new MultiStatus(getPluginId(), IStatus.ERROR, message, null);
- multi.add(status);
- log(multi);
- }
-
- public static void log(String message, Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, message, e));
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, e.getLocalizedMessage(), e));
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/ClasspathEntryProperties.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/ClasspathEntryProperties.java
deleted file mode 100644
index f7379c8b..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/ClasspathEntryProperties.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*******************************************************************************
- * 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.wst.jsdt.jseview.properties;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map.Entry;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.jseview.JEViewPlugin;
-
-public class ClasspathEntryProperties implements IPropertySource {
-
- private static abstract class Property extends GenericProperty<IIncludePathEntry> {
- public Property(String name) {
- super(IIncludePathEntry.class, name);
- }
- }
-
- private static HashMap<String, Property> fgIdToProperty= new HashMap<String, Property>();
- private static LinkedHashMap<Class<?>, List<Property>> fgTypeToProperty= new LinkedHashMap<Class<?>, List<Property>>();
-
- static {
- addProperty(new Property("combineAccessRules") {
- @Override public Object compute(IIncludePathEntry entry) {
- return entry.combineAccessRules();
- }
- });
- addProperty(new Property("getContentKind") {
- @Override public Object compute(IIncludePathEntry entry) {
- return getContentKindString(entry.getContentKind());
- }
- });
- addProperty(new Property("getEntryKind") {
- @Override public Object compute(IIncludePathEntry entry) {
- return getEntryKindString(entry.getEntryKind());
- }
- });
-// addProperty(new Property("getOutputLocation") {
-// @Override public Object compute(IIncludePathEntry entry) {
-// return entry.getOutputLocation();
-// }
-// });
- addProperty(new Property("getPath") {
- @Override public Object compute(IIncludePathEntry entry) {
- return entry.getPath();
- }
- });
- addProperty(new Property("getSourceAttachmentPath") {
- @Override public Object compute(IIncludePathEntry entry) {
- return entry.getSourceAttachmentPath();
- }
- });
- addProperty(new Property("getSourceAttachmentRootPath") {
- @Override public Object compute(IIncludePathEntry entry) {
- return entry.getSourceAttachmentRootPath();
- }
- });
- addProperty(new Property("isExported") {
- @Override public Object compute(IIncludePathEntry entry) {
- return entry.isExported();
- }
- });
- }
-
- private static void addProperty(Property property) {
- fgIdToProperty.put(property.getId(), property);
- List<Property> properties= fgTypeToProperty.get(property.getType());
- if (properties == null) {
- properties= new ArrayList<Property>();
- fgTypeToProperty.put(property.getType(), properties);
- }
- properties.add(property);
- }
-
- static String getContentKindString(int kind) {
- String name;
- switch (kind) {
- case IPackageFragmentRoot.K_SOURCE :
- name= "K_SOURCE";
- break;
- case IPackageFragmentRoot.K_BINARY :
- name= "K_BINARY";
- break;
- default :
- name= "UNKNOWN";
- break;
- }
- return kind + " (" + name + ")";
- }
-
- static String getEntryKindString(int kind) {
- String name;
- switch (kind) {
- case IIncludePathEntry.CPE_CONTAINER :
- name= "CPE_CONTAINER";
- break;
- case IIncludePathEntry.CPE_LIBRARY :
- name= "CPE_LIBRARY";
- break;
- case IIncludePathEntry.CPE_PROJECT :
- name= "CPE_PROJECT";
- break;
- case IIncludePathEntry.CPE_SOURCE :
- name= "CPE_SOURCE";
- break;
- case IIncludePathEntry.CPE_VARIABLE :
- name= "CPE_VARIABLE";
- break;
- default :
- name= "UNKNOWN";
- break;
- }
- return kind + " (" + name + ")";
- }
-
-
- protected IIncludePathEntry fEntry;
-
- public ClasspathEntryProperties(IIncludePathEntry entry) {
- fEntry= entry;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- List<IPropertyDescriptor> result= new ArrayList<IPropertyDescriptor>();
- for (Entry<Class<?>, List<Property>> entry : fgTypeToProperty.entrySet()) {
- if (entry.getKey().isAssignableFrom(fEntry.getClass())) {
- for (Property property : entry.getValue()) {
- result.add(property.getDescriptor());
- }
- }
- }
- return result.toArray(new IPropertyDescriptor[result.size()]);
- }
-
- public Object getPropertyValue(Object id) {
- Property property= fgIdToProperty.get(id);
- if (property == null) {
- return null;
- } else {
- try {
- return property.compute(fEntry);
- } catch (JavaScriptModelException e) {
- if (e.isDoesNotExist()) {
- return "JavaModelException: " + e.getLocalizedMessage();
- } else {
- JEViewPlugin.log("error calculating property '" + property.getType().getSimpleName() + '#' + property.getName() + '\'', e);
- return "Error: " + e.getLocalizedMessage();
- }
- }
- }
- }
-
- public void setPropertyValue(Object name, Object value) {
- // do nothing
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public boolean isPropertySet(Object property) {
- return false;
- }
-
- public void resetPropertyValue(Object property) {
- // do nothing
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/GenericProperty.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/GenericProperty.java
deleted file mode 100644
index 312a1540..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/GenericProperty.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 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.wst.jsdt.jseview.properties;
-
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-
-public abstract class GenericProperty<T> {
-
- private final Class<T> fType;
- private final String fName;
- private final String fId;
- private final PropertyDescriptor fDescriptor;
-
- public GenericProperty(Class<T> type, String name) {
- fType= type;
- fName= name;
- fId= "org.eclipse.wst.jsdt.jseview." + type.getSimpleName() + "." + name;
- fDescriptor= new PropertyDescriptor(fId, fName);
- fDescriptor.setAlwaysIncompatible(true);
- fDescriptor.setCategory(type.getSimpleName());
- }
-
- public abstract Object compute(T element) throws JavaScriptModelException;
-
-
- public Class<T> getType() {
- return fType;
- }
-
-
- public String getName() {
- return fName;
- }
-
- public String getId() {
- return fId;
- }
-
- public PropertyDescriptor getDescriptor() {
- return fDescriptor;
- }
-
-} \ No newline at end of file
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JarEntryResourceProperties.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JarEntryResourceProperties.java
deleted file mode 100644
index 5b3af4af..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JarEntryResourceProperties.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.wst.jsdt.jseview.properties;
-
-import java.util.ArrayList;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-import org.eclipse.wst.jsdt.core.IJarEntryResource;
-
-public class JarEntryResourceProperties implements IPropertySource {
-
- private static final String C_JAR_ENTRY_RESOURCE= "IJarEntryResource";
-
- private static final String P_NAME= "org.eclipse.wst.jsdt.jseview.IJarEntryResource.name";
- private static final String P_FULL_PATH= "org.eclipse.wst.jsdt.jseview.IJarEntryResource.fullPath";
- private static final String P_IS_FILE= "org.eclipse.wst.jsdt.jseview.IJarEntryResource.isFile";
- private static final String P_IS_READ_ONLY= "org.eclipse.wst.jsdt.jseview.IJarEntryResource.isReadOnly";
-
- protected IJarEntryResource fJarEntryResource;
-
- private static final ArrayList<IPropertyDescriptor> JAR_ENTRY_RESOURCE_PROPERTY_DESCRIPTORS= new ArrayList<IPropertyDescriptor>();
- static {
- addResourceDescriptor(new PropertyDescriptor(P_NAME, "name"));
- addResourceDescriptor(new PropertyDescriptor(P_FULL_PATH, "fullPath"));
- addResourceDescriptor(new PropertyDescriptor(P_IS_FILE, "isFile"));
- addResourceDescriptor(new PropertyDescriptor(P_IS_READ_ONLY, "isReadOnly"));
- }
-
- private static void addResourceDescriptor(PropertyDescriptor descriptor) {
- descriptor.setAlwaysIncompatible(true);
- descriptor.setCategory(C_JAR_ENTRY_RESOURCE);
- JAR_ENTRY_RESOURCE_PROPERTY_DESCRIPTORS.add(descriptor);
- }
-
-
- public JarEntryResourceProperties(IJarEntryResource jarEntryResource) {
- fJarEntryResource= jarEntryResource;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- ArrayList<IPropertyDescriptor> result= new ArrayList<IPropertyDescriptor>(JAR_ENTRY_RESOURCE_PROPERTY_DESCRIPTORS);
- return result.toArray(new IPropertyDescriptor[result.size()]);
- }
-
- public Object getPropertyValue(Object name) {
- if (name.equals(P_NAME)) {
- return fJarEntryResource.getName();
- } else if (name.equals(P_FULL_PATH)) {
- return fJarEntryResource.getFullPath();
- } else if (name.equals(P_IS_FILE)) {
- return fJarEntryResource.isFile();
- } else if (name.equals(P_IS_READ_ONLY)) {
- return fJarEntryResource.isReadOnly();
- }
-
- return null;
- }
-
- public void setPropertyValue(Object name, Object value) {
- // do nothing
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public boolean isPropertySet(Object property) {
- return false;
- }
-
- public void resetPropertyValue(Object property) {
- // do nothing
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementFinder.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementFinder.java
deleted file mode 100644
index 565fa0cc..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementFinder.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-
-package org.eclipse.wst.jsdt.jseview.properties;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IOpenable;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.core.Signature;
-import org.eclipse.wst.jsdt.core.WorkingCopyOwner;
-import org.eclipse.wst.jsdt.core.compiler.CharOperation;
-import org.eclipse.wst.jsdt.internal.compiler.util.SuffixConstants;
-import org.eclipse.wst.jsdt.internal.core.BinaryType;
-import org.eclipse.wst.jsdt.internal.core.JavaProject;
-import org.eclipse.wst.jsdt.internal.core.util.BindingKeyParser;
-
-public class JavaElementFinder extends BindingKeyParser {
-
- private JavaProject project;
- private WorkingCopyOwner owner;
- public IJavaScriptElement element;
- public JavaScriptModelException exception;
- private ArrayList types = new ArrayList();
-
- public JavaElementFinder(String key, JavaProject project, WorkingCopyOwner owner) {
- super(key);
- this.project = project;
- this.owner = owner;
- }
-
- private JavaElementFinder(BindingKeyParser parser, JavaProject project, WorkingCopyOwner owner) {
- super(parser);
- this.project = project;
- this.owner = owner;
- }
-
- public void consumeField(char[] fieldName) {
- if (!(this.element instanceof IType)) return;
- this.element = ((IType) this.element).getField(new String(fieldName));
- }
-
- public void consumeFullyQualifiedName(char[] fullyQualifiedName) {
- try {
- this.element = this.project.findType(new String(CharOperation.replaceOnCopy(fullyQualifiedName, '/', '.')), this.owner);
- } catch (JavaScriptModelException e) {
- this.exception = e;
- }
- }
-
- public void consumeLocalType(char[] uniqueKey) {
- if (this.element == null) return;
- if (this.element instanceof BinaryType) {
- int lastSlash = CharOperation.lastIndexOf('/', uniqueKey);
- int end = CharOperation.indexOf(';', uniqueKey, lastSlash+1);
- char[] localName = CharOperation.subarray(uniqueKey, lastSlash+1, end);
- IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaScriptElement.PACKAGE_FRAGMENT);
- this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_java);
- } else {
- int firstDollar = CharOperation.indexOf('$', uniqueKey);
- int end = CharOperation.indexOf('$', uniqueKey, firstDollar+1);
- if (end == -1)
- end = CharOperation.indexOf(';', uniqueKey, firstDollar+1);
- char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar+1, end);
- int position = Integer.parseInt(new String(sourceStart));
- try {
- this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position);
- } catch (JavaScriptModelException e) {
- this.exception = e;
- }
- }
- }
-
- public void consumeMemberType(char[] simpleTypeName) {
- if (!(this.element instanceof IType)) return;
- this.element = ((IType) this.element).getType(new String(simpleTypeName));
- }
-
- public void consumeMethod(char[] selector, char[] signature) {
- if (!(this.element instanceof IType)) return;
- String[] parameterTypes = Signature.getParameterTypes(new String(signature));
- IType type = (IType) this.element;
- IFunction method = type.getFunction(new String(selector), parameterTypes);
- IFunction[] methods = type.findMethods(method);
- if (methods.length > 0)
- this.element = methods[0];
- }
-
- public void consumePackage(char[] pkgName) {
-// pkgName = CharOperation.replaceOnCopy(pkgName, '/', '.');
- try {
-// this.element = this.project.findPackageFragment(new String(pkgName));
- this.element = this.project.findPackageFragment(new Path(new String(pkgName)));
- } catch (JavaScriptModelException e) {
- this.exception = e;
- }
- }
-
- public void consumeParser(BindingKeyParser parser) {
- this.types.add(parser);
- }
-
- public void consumeSecondaryType(char[] simpleTypeName) {
- if (this.element == null) return;
- IOpenable openable = this.element.getOpenable();
- if (!(openable instanceof IJavaScriptUnit)) return;
- this.element = ((IJavaScriptUnit) openable).getType(new String(simpleTypeName));
- }
-
- public void consumeTypeVariable(char[] position, char[] typeVariableName) {
- if (this.element == null) return;
- switch (this.element.getElementType()) {
- case IJavaScriptElement.TYPE:
-// this.element = ((IType) this.element).getTypeParameter(new String(typeVariableName));
- break;
- case IJavaScriptElement.METHOD:
-// this.element = ((IMethod) this.element).getTypeParameter(new String(typeVariableName));
- break;
- }
- }
-
- public BindingKeyParser newParser() {
- return new JavaElementFinder(this, this.project, this.owner);
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementProperties.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementProperties.java
deleted file mode 100644
index 03a2b7db..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/JavaElementProperties.java
+++ /dev/null
@@ -1,705 +0,0 @@
-/*******************************************************************************
- * 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.wst.jsdt.jseview.properties;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map.Entry;
-
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-import org.eclipse.wst.jsdt.core.BindingKey;
-import org.eclipse.wst.jsdt.core.Flags;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IField;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IImportDeclaration;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.ILocalVariable;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IOpenable;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.jseview.JEViewPlugin;
-
-public class JavaElementProperties implements IPropertySource {
-
- private static HashMap<String, Property> fgIdToProperty= new HashMap<String, Property>();
- private static LinkedHashMap<Class<?>, List<Property>> fgTypeToProperty= new LinkedHashMap<Class<?>, List<Property>>();
-
-
- private static abstract class Property {
- private final Class<?> fType;
- private final String fName;
- private final String fId;
- private final PropertyDescriptor fDescriptor;
-
- public Property(Class<?> type, String name) {
- fType= type;
- fName= name;
- fId= "org.eclipse.wst.jsdt.jseview." + type.getSimpleName() + "." + name;
- fDescriptor= new PropertyDescriptor(fId, fName);
- fDescriptor.setAlwaysIncompatible(true);
- fDescriptor.setCategory(type.getSimpleName());
- }
-
- public abstract Object compute(IJavaScriptElement javaElement) throws JavaScriptModelException ;
-
-
- public Class<?> getType() {
- return fType;
- }
-
-
- public String getName() {
- return fName;
- }
-
- public String getId() {
- return fId;
- }
-
- public PropertyDescriptor getDescriptor() {
- return fDescriptor;
- }
-
- }
-
- static {
- addJavaElementProperties();
- addClassFileProperties();
- addCompilationUnitProperties();
- addImportDeclarationProperties();
- addJavaProjectProperties();
- addLocalVariableProperties();
- addMemberProperties();
- addFieldProperties();
- addMethodProperties();
- addTypeProperties();
- addAnnotationProperties();
- addPackageFragmentProperties();
- addPackageFragmentRootProperties();
-// addTypeParammeterProperties();
- addParentProperties();
- addSourceReferenceProperties();
- addOpenableProperties();
- }
-
- private static void addJavaElementProperties() {
- addProperty(new Property(IJavaScriptElement.class, "elementName") {
- @Override public Object compute(IJavaScriptElement element) {
- return element.getElementName();
- }
- });
- addProperty(new Property(IJavaScriptElement.class, "elementType") {
- @Override public Object compute(IJavaScriptElement element) {
- return getElementTypeString(element.getElementType());
- }
- });
- addProperty(new Property(IJavaScriptElement.class, "exists") {
- @Override public Object compute(IJavaScriptElement element) {
- return element.exists();
- }
- });
- addProperty(new Property(IJavaScriptElement.class, "isReadOnly") {
- @Override public Object compute(IJavaScriptElement element) {
- return element.isReadOnly();
- }
- });
- addProperty(new Property(IJavaScriptElement.class, "isStructureKnown") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return element.isStructureKnown();
- }
- });
- addProperty(new Property(IJavaScriptElement.class, "handleIdentifier") {
- @Override public Object compute(IJavaScriptElement element) {
- return element.getHandleIdentifier();
- }
- });
- addProperty(new Property(IJavaScriptElement.class, "path") {
- @Override public Object compute(IJavaScriptElement element) {
- return element.getPath();
- }
- });
- addProperty(new Property(IJavaScriptElement.class, "schedulingRule") {
- @Override public Object compute(IJavaScriptElement element) {
- return getSchedulingRuleString(element.getSchedulingRule());
- }
- });
- }
-
- private static void addClassFileProperties() {
- addProperty(new Property(IClassFile.class, "isClass") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IClassFile) element).isClass();
- }
- });
-// addProperty(new Property(IClassFile.class, "isInterface") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return ((IClassFile) element).isInterface();
-// }
-// });
- }
-
- private static void addCompilationUnitProperties() {
- addProperty(new Property(IJavaScriptUnit.class, "hasResourceChanged") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IJavaScriptUnit) element).hasResourceChanged();
- }
- });
- addProperty(new Property(IJavaScriptUnit.class, "isWorkingCopy") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IJavaScriptUnit) element).isWorkingCopy();
- }
- });
- }
-
- private static void addImportDeclarationProperties() {
- addProperty(new Property(IImportDeclaration.class, "flags") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return getFlagsString(((IImportDeclaration) element).getFlags(), IImportDeclaration.class);
- }
- });
- addProperty(new Property(IImportDeclaration.class, "isOnDemand") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IImportDeclaration) element).isOnDemand();
- }
- });
- }
-
- private static void addJavaProjectProperties() {
- addProperty(new Property(IJavaScriptProject.class, "hasBuildState") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IJavaScriptProject) element).hasBuildState();
- }
- });
-// addProperty(new Property(IJavaScriptProject.class, "getOutputLocation") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return ((IJavaScriptProject) element).getOutputLocation();
-// }
-// });
-// addProperty(new Property(IJavaScriptProject.class, "readOutputLocation") {
-// @Override public Object compute(IJavaScriptElement element) {
-// return ((IJavaScriptProject) element).readOutputLocation();
-// }
-// });
- }
-
- private static void addLocalVariableProperties() {
- addProperty(new Property(ILocalVariable.class, "nameRange") {
- @Override public Object compute(IJavaScriptElement element) {
- return getSourceRangeString(((ILocalVariable) element).getNameRange());
- }
- });
- addProperty(new Property(ILocalVariable.class, "typeSignature") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((ILocalVariable) element).getTypeSignature();
- }
- });
- }
-
- private static void addAnnotationProperties() {
-// addProperty(new Property(IAnnotation.class, "nameRange") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return getSourceRangeString(((IAnnotation) element).getNameRange());
-// }
-// });
-// addProperty(new Property(IAnnotation.class, "occurrenceCount") {
-// @Override public Object compute(IJavaScriptElement element) {
-// return ((IAnnotation) element).getOccurrenceCount();
-// }
-// });
- }
-
- private static void addMemberProperties() {
- addProperty(new Property(IMember.class, "nameRange") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return getSourceRangeString(((IMember) element).getNameRange());
- }
- });
- addProperty(new Property(IMember.class, "javadocRange") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return getSourceRangeString(((IMember) element).getJSdocRange());
- }
- });
- addProperty(new Property(IMember.class, "flags") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return getFlagsString(((IMember) element).getFlags(), element.getClass());
- }
- });
- addProperty(new Property(IMember.class, "isBinary") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IMember) element).isBinary();
- }
- });
- addProperty(new Property(IMember.class, "occurrenceCount") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IMember) element).getOccurrenceCount();
- }
- });
- }
-
- private static void addFieldProperties() {
- addProperty(new Property(IField.class, "isResolved") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IField) element).isResolved();
- }
- });
- addProperty(new Property(IField.class, "key") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IField) element).getKey();
- }
- });
- addProperty(new Property(IField.class, "typeSignature") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IField) element).getTypeSignature();
- }
- });
-// addProperty(new Property(IField.class, "constant") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return ((IField) element).getConstant();
-// }
-// });
-// addProperty(new Property(IField.class, "isEnumConstant") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return ((IField) element).isEnumConstant();
-// }
-// });
- }
-
- private static void addMethodProperties() {
- addProperty(new Property(IFunction.class, "isResolved") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IFunction) element).isResolved();
- }
- });
- addProperty(new Property(IFunction.class, "key") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IFunction) element).getKey();
- }
- });
- addProperty(new Property(IFunction.class, "key - signature") {
- @Override public Object compute(IJavaScriptElement element) {
- String key= ((IFunction) element).getKey();
- if (key != null)
- return new BindingKey(key).toSignature();
- else
- return "<no key>";
- }
- });
- addProperty(new Property(IFunction.class, "numberOfParameters") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IFunction) element).getNumberOfParameters();
- }
- });
- addProperty(new Property(IFunction.class, "signature") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IFunction) element).getSignature();
- }
- });
- addProperty(new Property(IFunction.class, "returnType") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IFunction) element).getReturnType();
- }
- });
- addProperty(new Property(IFunction.class, "isConstructor") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IFunction) element).isConstructor();
- }
- });
-// addProperty(new Property(IFunction.class, "isMainMethod") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return ((IFunction) element).isMainMethod();
-// }
-// });
- }
-
- private static void addTypeProperties() {
- addProperty(new Property(IType.class, "isResolved") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IType) element).isResolved();
- }
- });
- addProperty(new Property(IType.class, "key") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IType) element).getKey();
- }
- });
- addProperty(new Property(IType.class, "fullyQualifiedName") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IType) element).getFullyQualifiedName();
- }
- });
- addProperty(new Property(IType.class, "fullyQualifiedName('*')") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IType) element).getFullyQualifiedName('*');
- }
- });
- addProperty(new Property(IType.class, "fullyQualifiedParameterizedName") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IType) element).getFullyQualifiedParameterizedName();
- }
- });
- addProperty(new Property(IType.class, "typeQualifiedName") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IType) element).getTypeQualifiedName();
- }
- });
- addProperty(new Property(IType.class, "typeQualifiedName('*')") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IType) element).getTypeQualifiedName('*');
- }
- });
-// addProperty(new Property(IType.class, "isAnnotation") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return ((IType) element).isAnnotation();
-// }
-// });
- addProperty(new Property(IType.class, "isClass") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IType) element).isClass();
- }
- });
-// addProperty(new Property(IType.class, "isEnum") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return ((IType) element).isEnum();
-// }
-// });
-// addProperty(new Property(IType.class, "isInterface") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return ((IType) element).isInterface();
-// }
-// });
- addProperty(new Property(IType.class, "isAnonymous") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IType) element).isAnonymous();
- }
- });
- addProperty(new Property(IType.class, "isLocal") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IType) element).isLocal();
- }
- });
- addProperty(new Property(IType.class, "isMember") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IType) element).isMember();
- }
- });
- }
-
- private static void addPackageFragmentProperties() {
- addProperty(new Property(IPackageFragment.class, "containsJavaResources") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IPackageFragment) element).containsJavaResources();
- }
- });
- addProperty(new Property(IPackageFragment.class, "kind") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return getPFRKindString(((IPackageFragment) element).getKind());
- }
- });
- addProperty(new Property(IPackageFragment.class, "hasSubpackages") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IPackageFragment) element).hasSubpackages();
- }
- });
- addProperty(new Property(IPackageFragment.class, "isDefaultPackage") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IPackageFragment) element).isDefaultPackage();
- }
- });
- }
-
- private static void addPackageFragmentRootProperties() {
- addProperty(new Property(IPackageFragmentRoot.class, "kind") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return getPFRKindString(((IPackageFragmentRoot) element).getKind());
- }
- });
- addProperty(new Property(IPackageFragmentRoot.class, "sourceAttachmentPath") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IPackageFragmentRoot) element).getSourceAttachmentPath();
- }
- });
- addProperty(new Property(IPackageFragmentRoot.class, "sourceAttachmentRootPath") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IPackageFragmentRoot) element).getSourceAttachmentRootPath();
- }
- });
- addProperty(new Property(IPackageFragmentRoot.class, "isArchive") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IPackageFragmentRoot) element).isArchive();
- }
- });
- addProperty(new Property(IPackageFragmentRoot.class, "isExternal") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IPackageFragmentRoot) element).isExternal();
- }
- });
- }
-
-// private static void addTypeParammeterProperties() {
-// addProperty(new Property(ITypeParameter.class, "nameRange") {
-// @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
-// return getSourceRangeString(((ITypeParameter) element).getNameRange());
-// }
-// });
-// }
-
- private static void addParentProperties() {
- addProperty(new Property(IParent.class, "hasChildren") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IParent) element).hasChildren();
- }
- });
- }
-
- private static void addSourceReferenceProperties() {
- addProperty(new Property(ISourceReference.class, "sourceRange") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return getSourceRangeString(((ISourceReference) element).getSourceRange());
- }
- });
- }
-
- private static void addOpenableProperties() {
- addProperty(new Property(IOpenable.class, "hasUnsavedChanges") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IOpenable) element).hasUnsavedChanges();
- }
- });
- addProperty(new Property(IOpenable.class, "isConsistent") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- return ((IOpenable) element).isConsistent();
- }
- });
- addProperty(new Property(IOpenable.class, "isOpen") {
- @Override public Object compute(IJavaScriptElement element) {
- return ((IOpenable) element).isOpen();
- }
- });
- addProperty(new Property(IOpenable.class, "findRecommendedLineSeparator") {
- @Override public Object compute(IJavaScriptElement element) throws JavaScriptModelException {
- String lineSeparator= ((IOpenable) element).findRecommendedLineSeparator();
- lineSeparator= lineSeparator.replace("\r", "\\r").replace("\n", "\\n");
- return lineSeparator;
- }
- });
- }
-
- private static void addProperty(Property property) {
- fgIdToProperty.put(property.getId(), property);
- List<Property> properties= fgTypeToProperty.get(property.getType());
- if (properties == null) {
- properties= new ArrayList<Property>();
- fgTypeToProperty.put(property.getType(), properties);
- }
- properties.add(property);
- }
-
- protected IJavaScriptElement fJavaElement;
-
- public JavaElementProperties(IJavaScriptElement javaElement) {
- fJavaElement= javaElement;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- List<IPropertyDescriptor> result= new ArrayList<IPropertyDescriptor>();
- for (Entry<Class<?>, List<Property>> entry : fgTypeToProperty.entrySet()) {
- if (entry.getKey().isAssignableFrom(fJavaElement.getClass())) {
- for (Property property : entry.getValue()) {
- result.add(property.getDescriptor());
- }
- }
- }
- return result.toArray(new IPropertyDescriptor[result.size()]);
- }
-
- public Object getPropertyValue(Object id) {
- Property property= fgIdToProperty.get(id);
- if (property == null) {
- return null;
- } else {
- try {
- return property.compute(fJavaElement);
- } catch (JavaScriptModelException e) {
- if (e.isDoesNotExist()) {
- return "JavaScriptModelException: " + e.getLocalizedMessage();
- } else {
- JEViewPlugin.log("error calculating property '" + property.getType().getSimpleName() + '#' + property.getName() + '\'', e);
- return "Error: " + e.getLocalizedMessage();
- }
- }
- }
- }
-
- static String getElementTypeString(int elementType) {
- String name;
- switch (elementType) {
- case IJavaScriptElement.JAVASCRIPT_MODEL :
- name= "IJavaModel";
- break;
- case IJavaScriptElement.JAVASCRIPT_PROJECT :
- name= "IJavaScriptProject";
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT :
- name= "IPackageFragmentRoot";
- break;
- case IJavaScriptElement.PACKAGE_FRAGMENT :
- name= "IPackageFragment";
- break;
- case IJavaScriptElement.JAVASCRIPT_UNIT :
- name= "IJavaScriptUnit";
- break;
- case IJavaScriptElement.CLASS_FILE :
- name= "IClassFile";
- break;
- case IJavaScriptElement.TYPE :
- name= "IType";
- break;
- case IJavaScriptElement.FIELD :
- name= "IField";
- break;
- case IJavaScriptElement.METHOD :
- name= "IFunction";
- break;
- case IJavaScriptElement.INITIALIZER :
- name= "IInitializer";
- break;
-// case IJavaScriptElement.PACKAGE_DECLARATION :
-// name= "IPackageDeclaration";
-// break;
- case IJavaScriptElement.IMPORT_CONTAINER :
- name= "IImportContainer";
- break;
- case IJavaScriptElement.IMPORT_DECLARATION :
- name= "IImportDeclaration";
- break;
- case IJavaScriptElement.LOCAL_VARIABLE :
- name= "ILocalVariable";
- break;
-// case IJavaScriptElement.TYPE_PARAMETER :
-// name= "ITypeParameter";
-// break;
-// case IJavaScriptElement.ANNOTATION :
-// name= "IAnnotation";
-// break;
- default :
- name= "UNKNOWN";
- break;
- }
- return elementType + " (" + name + ")";
- }
-
- static String getSourceRangeString(ISourceRange range) {
- return range == null ? "null" : range.getOffset() + " + " + range.getLength();
- }
-
- static String getFlagsString(int flags, Class<? extends IJavaScriptElement> clazz) {
- StringBuffer sb = new StringBuffer().append("0x").append(Integer.toHexString(flags)).append(" (");
- int prologLen= sb.length();
- int rest= flags;
-
- rest&= ~ appendFlag(sb, flags, Flags.AccPublic, "public ");
- rest&= ~ appendFlag(sb, flags, Flags.AccPrivate, "private ");
- rest&= ~ appendFlag(sb, flags, Flags.AccProtected, "protected ");
- rest&= ~ appendFlag(sb, flags, Flags.AccStatic, "static ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccFinal, "final ");
- if (IFunction.class.isAssignableFrom(clazz)) {
-// rest&= ~ appendFlag(sb, flags, Flags.AccSynchronized, "synchronized ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccBridge, "bridge ");
- rest&= ~ appendFlag(sb, flags, Flags.AccVarargs, "varargs ");
- } else {
- rest&= ~ appendFlag(sb, flags, Flags.AccSuper, "super ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccVolatile, "volatile ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccTransient, "transient ");
- }
-// rest&= ~ appendFlag(sb, flags, Flags.AccNative, "native ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccInterface, "interface ");
- rest&= ~ appendFlag(sb, flags, Flags.AccAbstract, "abstract ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccStrictfp, "strictfp ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccSynthetic, "synthetic ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccAnnotation, "annotation ");
-// rest&= ~ appendFlag(sb, flags, Flags.AccEnum, "enum ");
- rest&= ~ appendFlag(sb, flags, Flags.AccDeprecated, "deprecated ");
-
- if (rest != 0)
- sb.append("unknown:0x").append(Integer.toHexString(rest));
- int len = sb.length();
- if (len != prologLen)
- sb.setLength(len - 1);
- sb.append(")");
- return sb.toString();
- }
-
- private static int appendFlag(StringBuffer sb, int flags, int flag, String name) {
- if ((flags & flag) != 0) {
- sb.append(name);
- return flag;
- } else {
- return 0;
- }
- }
-
- static String getPFRKindString(int kind) {
- StringBuffer sb = new StringBuffer().append("0x").append(Integer.toHexString(kind)).append(" (");
- int prologLen= sb.length();
- int rest= kind;
-
- rest&= ~ appendFlag(sb, kind, IPackageFragmentRoot.K_BINARY, "binary ");
- rest&= ~ appendFlag(sb, kind, IPackageFragmentRoot.K_SOURCE, "source ");
-
- if (rest != 0)
- sb.append("unknown:0x").append(Integer.toHexString(rest));
- int len = sb.length();
- if (len != prologLen)
- sb.setLength(len - 1);
- sb.append(")");
- return sb.toString();
- }
-
- static String getSchedulingRuleString(ISchedulingRule schedulingRule) {
- if (schedulingRule == null)
- return null;
- else
- return schedulingRule.getClass().getSimpleName() + ": " + schedulingRule.toString();
- }
-
- public void setPropertyValue(Object name, Object value) {
- // do nothing
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public boolean isPropertySet(Object property) {
- return false;
- }
-
- public void resetPropertyValue(Object property) {
- // do nothing
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/MarkerProperties.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/MarkerProperties.java
deleted file mode 100644
index cd4461bf..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/MarkerProperties.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.wst.jsdt.jseview.properties;
-
-import java.lang.reflect.Field;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.core.resources.IMarker;
-
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-import org.eclipse.wst.jsdt.core.IJavaScriptModelMarker;
-import org.eclipse.wst.jsdt.core.compiler.IProblem;
-
-public class MarkerProperties implements IPropertySource {
-
- private static final AttributeDescriptor[] NO_DESCRIPTORS= new AttributeDescriptor[0];
-
- private final IMarker fMarker;
-
- private AttributeDescriptor[] fPropertyDescriptors;
-
- public MarkerProperties(IMarker marker) {
- fMarker= marker;
- }
-
- public AttributeDescriptor[] getPropertyDescriptors() {
- if (fPropertyDescriptors != null)
- return fPropertyDescriptors;
-
- Map<String, Object> attributes= null;
- boolean isJavaMarker= false;
- try {
- @SuppressWarnings("unchecked")
- Map<String, Object> uncheckedAttributes= fMarker.getAttributes();
- attributes= uncheckedAttributes;
- isJavaMarker= IJavaScriptModelMarker.JAVASCRIPT_MODEL_PROBLEM_MARKER.equals(fMarker.getType());
- } catch (CoreException e) {
- // no attributes today
- }
- if (attributes == null) {
- fPropertyDescriptors= NO_DESCRIPTORS;
- } else {
- fPropertyDescriptors= new AttributeDescriptor[attributes.size() + 4];
- int i= 0;
- for (Entry<String, Object> entry : attributes.entrySet()) {
- String key= entry.getKey();
- Object value= entry.getValue();
- AttributeDescriptor propertyDescriptor;
- if (isJavaMarker && IJavaScriptModelMarker.ID.equals(key)) {
- propertyDescriptor= new ProblemIdAttributeDescriptor(key, value);
- } else {
- propertyDescriptor= new AttributeDescriptor(key, value);
- }
- propertyDescriptor.setAlwaysIncompatible(true);
- propertyDescriptor.setCategory("Attributes");
- fPropertyDescriptors[i++]= propertyDescriptor;
- }
-
- MarkerPropertyDescriptor propertyDescriptor= new MarkerPropertyDescriptor("exists", fMarker.exists());
- propertyDescriptor.setAlwaysIncompatible(true);
- fPropertyDescriptors[i++]= propertyDescriptor;
-
- String type;
- try {
- type= fMarker.getType();
- } catch (CoreException e) {
- type= e.getLocalizedMessage();
- }
- propertyDescriptor= new MarkerPropertyDescriptor("type", type);
- propertyDescriptor.setAlwaysIncompatible(true);
- fPropertyDescriptors[i++]= propertyDescriptor;
-
- String time;
- try {
- time= DateFormat.getDateTimeInstance().format(new Date(fMarker.getCreationTime()));
- } catch (CoreException e) {
- time= e.getLocalizedMessage();
- }
- propertyDescriptor= new MarkerPropertyDescriptor("creationTime", time);
- propertyDescriptor.setAlwaysIncompatible(true);
- fPropertyDescriptors[i++]= propertyDescriptor;
-
- propertyDescriptor= new MarkerPropertyDescriptor("markerId", fMarker.getId());
- propertyDescriptor.setAlwaysIncompatible(true);
- fPropertyDescriptors[i++]= propertyDescriptor;
-
- }
- return fPropertyDescriptors;
- }
-
- public Object getPropertyValue(Object id) {
- AttributeDescriptor[] propertyDescriptors= getPropertyDescriptors();
- for (int i= 0; i < propertyDescriptors.length; i++) {
- AttributeDescriptor descriptor= propertyDescriptors[i];
- if (descriptor.getId().equals(id))
- return descriptor.getValue();
- }
- return null;
- }
-
-
- public void setPropertyValue(Object name, Object value) {
- // do nothing
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public boolean isPropertySet(Object property) {
- return false;
- }
-
- public void resetPropertyValue(Object property) {
- // do nothing
- }
-
-
- private static class AttributeDescriptor extends PropertyDescriptor {
- private final Object fValue;
-
- public AttributeDescriptor(String name, Object value) {
- this("org.eclipse.wst.jsdt.jseview.IMarker." + name, name, value);
- }
-
- protected AttributeDescriptor(String key, String name, Object value) {
- super(key, name);
- fValue= value;
- }
-
- public Object getValue() {
- return fValue;
- }
- }
-
- private static class ProblemIdAttributeDescriptor extends AttributeDescriptor {
- public ProblemIdAttributeDescriptor(String key, Object value) {
- super(key, value);
- }
-
- @Override
- public Object getValue() {
- return getErrorLabel();
- }
-
- private String getErrorLabel() {
- int id= (Integer) super.getValue();
- StringBuffer buf= new StringBuffer(getConstantName(id)).append(" = ");
-
- if ((id & IProblem.TypeRelated) != 0) {
- buf.append("TypeRelated + ");
- }
- if ((id & IProblem.FieldRelated) != 0) {
- buf.append("FieldRelated + ");
- }
- if ((id & IProblem.ConstructorRelated) != 0) {
- buf.append("ConstructorRelated + ");
- }
- if ((id & IProblem.MethodRelated) != 0) {
- buf.append("MethodRelated + ");
- }
- if ((id & IProblem.ImportRelated) != 0) {
- buf.append("ImportRelated + ");
- }
- if ((id & IProblem.Internal) != 0) {
- buf.append("Internal + ");
- }
- if ((id & IProblem.Syntax) != 0) {
- buf.append("Syntax + ");
- }
- if ((id & IProblem.Javadoc) != 0) {
- buf.append("Javadoc + ");
- }
- buf.append(id & IProblem.IgnoreCategoriesMask);
-
- buf.append(" = 0x").append(Integer.toHexString(id)).append(" = ").append(id);
-
- return buf.toString();
- }
-
- private static String getConstantName(int id) {
- Field[] fields= IProblem.class.getFields();
- for (int i= 0; i < fields.length; i++) {
- Field f= fields[i];
- try {
- if (f.getType() == int.class && f.getInt(f) == id) {
- return "IProblem." + f.getName();
- }
- } catch (IllegalArgumentException e) {
- // does not happen
- } catch (IllegalAccessException e) {
- // does not happen
- }
- }
- return "<UNKNOWN CONSTANT>";
- }
-
- }
-
- private static class MarkerPropertyDescriptor extends AttributeDescriptor {
- public MarkerPropertyDescriptor(String key, Object value) {
- super("org.eclipse.wst.jsdt.jseview.IMarker.property." + key, key, value);
- }
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/ResourceProperties.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/ResourceProperties.java
deleted file mode 100644
index ffcf09d7..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/properties/ResourceProperties.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.wst.jsdt.jseview.properties;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-public class ResourceProperties implements IPropertySource {
-
- private static final String C_RESOURCE= "IResource";
-
- private static final String P_NAME= "org.eclipse.wst.jsdt.jseview.IResource.name";
- private static final String P_FULL_PATH= "org.eclipse.wst.jsdt.jseview.IResource.fullPath";
- private static final String P_LOCATION= "org.eclipse.wst.jsdt.jseview.IResource.location";
- private static final String P_PROJECT_RELATIVE_PATH= "org.eclipse.wst.jsdt.jseview.IResource.projectRelativePath";
- private static final String P_RAW_LOCATION= "org.eclipse.wst.jsdt.jseview.IResource.rawLocation";
- private static final String P_LOCAL_TIME_STAMP= "org.eclipse.wst.jsdt.jseview.IResource.localTimeStamp";
- private static final String P_MODIFICATION_STAMP= "org.eclipse.wst.jsdt.jseview.IResource.modificationStamp";
-
- protected IResource fResource;
-
- private static final ArrayList<IPropertyDescriptor> RESOURCE_PROPERTY_DESCRIPTORS= new ArrayList<IPropertyDescriptor>();
- static {
- addResourceDescriptor(new PropertyDescriptor(P_NAME, "name"));
- addResourceDescriptor(new PropertyDescriptor(P_FULL_PATH, "fullPath"));
- addResourceDescriptor(new PropertyDescriptor(P_LOCATION, "location"));
- addResourceDescriptor(new PropertyDescriptor(P_PROJECT_RELATIVE_PATH, "projectRelativePath"));
- addResourceDescriptor(new PropertyDescriptor(P_RAW_LOCATION, "rawLocation"));
- addResourceDescriptor(new PropertyDescriptor(P_LOCAL_TIME_STAMP, "localTimeStamp"));
- addResourceDescriptor(new PropertyDescriptor(P_MODIFICATION_STAMP, "modificationStamp"));
- }
-
- private static void addResourceDescriptor(PropertyDescriptor descriptor) {
- descriptor.setAlwaysIncompatible(true);
- descriptor.setCategory(C_RESOURCE);
- RESOURCE_PROPERTY_DESCRIPTORS.add(descriptor);
- }
-
-
- public ResourceProperties(IResource resource) {
- fResource= resource;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors() {
- ArrayList<IPropertyDescriptor> result= new ArrayList<IPropertyDescriptor>(RESOURCE_PROPERTY_DESCRIPTORS);
-// if (fJavaElement instanceof IMember)
-// result.addAll(MEMBER_PROPERTY_DESCRIPTORS);
-// if (fJavaElement instanceof IParent)
-// result.addAll(PARENT_PROPERTY_DESCRIPTORS);
-
- return result.toArray(new IPropertyDescriptor[result.size()]);
- }
-
- public Object getPropertyValue(Object name) {
- if (name.equals(P_NAME)) {
- return fResource.getName();
- } else if (name.equals(P_FULL_PATH)) {
- return fResource.getFullPath();
- } else if (name.equals(P_LOCATION)) {
- return fResource.getLocation();
- } else if (name.equals(P_PROJECT_RELATIVE_PATH)) {
- return fResource.getProjectRelativePath();
- } else if (name.equals(P_RAW_LOCATION)) {
- return fResource.getRawLocation();
- } else if (name.equals(P_LOCAL_TIME_STAMP)) {
- return fResource.getLocalTimeStamp();
- } else if (name.equals(P_MODIFICATION_STAMP)) {
- return fResource.getModificationStamp();
- }
-
- return null;
- }
-
- public void setPropertyValue(Object name, Object value) {
- // do nothing
- }
-
- public Object getEditableValue() {
- return this;
- }
-
- public boolean isPropertySet(Object property) {
- return false;
- }
-
- public void resetPropertyValue(Object property) {
- // do nothing
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Error.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Error.java
deleted file mode 100644
index dd9560c7..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Error.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.wst.jsdt.jseview.views;
-
-
-
-public class Error extends JEAttribute {
- public static final String ERROR= "ERROR";
-
- private final JEAttribute fParent;
- private final String fName;
- private final Exception fException;
-
- public Error(JEAttribute parent, String name, Exception exception) {
- fParent= parent;
- fName= name;
- fException= exception;
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- Error other= (Error) obj;
- if (fParent == null) {
- if (other.fParent != null)
- return false;
- } else if (! fParent.equals(other.fParent)) {
- return false;
- }
-
- if (fName == null) {
- if (other.fName != null)
- return false;
- } else if (! fName.equals(other.fName)) {
- return false;
- }
-
- if (fException == null) {
- if (other.fException != null)
- return false;
- } else if (! fException.equals(other.fException)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return (fParent != null ? fParent.hashCode() : 0)
- + (fName != null ? fName.hashCode() : 0)
- + (fException != null ? fException.hashCode() : 0);
- }
-
- @Override
- public JEAttribute[] getChildren() {
- return EMPTY;
- }
-
- @Override
- public String getLabel() {
- return (fName == null ? "" : fName + ": ") + fException.toString();
- }
-
- public Exception getException() {
- return fException;
- }
-
- @Override
- public Object getWrappedObject() {
- return fException;
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEAttribute.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEAttribute.java
deleted file mode 100644
index 0c49f82d..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEAttribute.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.wst.jsdt.jseview.views;
-
-
-/**
- *
- */
-public abstract class JEAttribute {
-
- protected static final JEAttribute[] EMPTY= new JEAttribute[0];
-
- public abstract JEAttribute getParent();
- public abstract JEAttribute[] getChildren();
- public abstract String getLabel();
-
- public abstract Object getWrappedObject();
-
- @Override
- public abstract boolean equals(Object obj);
-
- @Override
- public abstract int hashCode();
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEClasspathEntry.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEClasspathEntry.java
deleted file mode 100644
index 3ede80f9..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEClasspathEntry.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * 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.wst.jsdt.jseview.views;
-
-import java.util.ArrayList;
-import java.util.concurrent.Callable;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.wst.jsdt.core.IAccessRule;
-import org.eclipse.wst.jsdt.core.IIncludePathAttribute;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-
-public class JEClasspathEntry extends JEAttribute {
-
- private final JEAttribute fParent; // can be null
- private final String fName; // can be null
- final IIncludePathEntry fEntry;
-
- JEClasspathEntry(JEAttribute parent, String name, IIncludePathEntry entry) {
- Assert.isNotNull(entry);
- fParent= parent;
- fName= name;
- fEntry= entry;
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- JEClasspathEntry other= (JEClasspathEntry) obj;
- if (fParent == null) {
- if (other.fParent != null)
- return false;
- } else if (! fParent.equals(other.fParent)) {
- return false;
- }
-
- if (fName == null) {
- if (other.fName != null)
- return false;
- } else if (! fName.equals(other.fName)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return (fParent != null ? fParent.hashCode() : 0)
- + (fName != null ? fName.hashCode() : 0)
- + fEntry.hashCode();
- }
-
- @Override
- public Object getWrappedObject() {
- return fEntry;
- }
-
- @Override
- public JEAttribute[] getChildren() {
- ArrayList<JEAttribute> result= new ArrayList<JEAttribute>();
-
- result.add(new JavaElementChildrenProperty(this, "ACCESS RULES") {
- @Override protected JEAttribute[] computeChildren() throws CoreException {
- IAccessRule[] accessRules= fEntry.getAccessRules();
- JEAttribute[] children= new JEAttribute[accessRules.length];
- for (int i= 0; i < accessRules.length; i++) {
- children[i]= new JavaElementProperty(this, null, accessRules[i]);
- }
- return children;
- }
- });
- result.add(new JavaElementChildrenProperty(this, "EXCLUSION PATTERNS") {
- @Override protected JEAttribute[] computeChildren() throws CoreException {
- IPath[] exclusionPatterns= fEntry.getExclusionPatterns();
- JEAttribute[] children= new JEAttribute[exclusionPatterns.length];
- for (int i= 0; i < exclusionPatterns.length; i++) {
- children[i]= new JavaElementProperty(this, null, exclusionPatterns[i]);
- }
- return children;
- }
- });
- result.add(new JavaElementChildrenProperty(this, "INCLUSION PATTERNS") {
- @Override protected JEAttribute[] computeChildren() throws CoreException {
- IPath[] inclusionPatterns= fEntry.getInclusionPatterns();
- JEAttribute[] children= new JEAttribute[inclusionPatterns.length];
- for (int i= 0; i < inclusionPatterns.length; i++) {
- children[i]= new JavaElementProperty(this, null, inclusionPatterns[i]);
- }
- return children;
- }
- });
- result.add(new JavaElementChildrenProperty(this, "EXTRA ATTRIBUTES") {
- @Override protected JEAttribute[] computeChildren() throws CoreException {
- IIncludePathAttribute[] extraAttributes= fEntry.getExtraAttributes();
- JEAttribute[] children= new JEAttribute[extraAttributes.length];
- for (int i= 0; i < extraAttributes.length; i++) {
- children[i]= new JavaElementProperty(this, null, extraAttributes[i]);
- }
- return children;
- }
- });
- result.add(new JEClasspathEntry(this, "getResolvedIncludePathEntry(this)", JavaScriptCore.getResolvedIncludepathEntry(fEntry)));
-
- return result.toArray(new JEAttribute[result.size()]);
- }
-
- @Override
- public String getLabel() {
- String label= fEntry.toString();
- if (fName != null)
- label= fName + ": " + label;
- return label;
- }
-
- public static JEAttribute compute(JEAttribute parent, String name, Callable<IIncludePathEntry> computer) {
- try {
- IIncludePathEntry entry= computer.call();
- return create(parent, name, entry);
- } catch (Exception e) {
- return new Error(parent, name, e);
- }
- }
-
- public static JEAttribute create(JEAttribute parent, String name, IIncludePathEntry entry) {
- if (entry == null) {
- return new Null(parent, name);
- } else {
- return new JEClasspathEntry(parent, name, entry);
- }
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEJarEntryResource.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEJarEntryResource.java
deleted file mode 100644
index 4094f036..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEJarEntryResource.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.wst.jsdt.jseview.views;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.wst.jsdt.core.IJarEntryResource;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-
-public class JEJarEntryResource extends JEAttribute {
-
- private final JEAttribute fParent; // can be null
- private final String fName; // can be null
- private IJarEntryResource fJarEntryResource;
-
- JEJarEntryResource(JEAttribute parent, String name, IJarEntryResource jarEntryResource) {
- Assert.isNotNull(jarEntryResource);
- fParent= parent;
- fName= name;
- fJarEntryResource= jarEntryResource;
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- JEJarEntryResource other= (JEJarEntryResource) obj;
- if (fParent == null) {
- if (other.fParent != null)
- return false;
- } else if (! fParent.equals(other.fParent)) {
- return false;
- }
-
- if (fName == null) {
- if (other.fName != null)
- return false;
- } else if (! fName.equals(other.fName)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return (fParent != null ? fParent.hashCode() : 0)
- + (fName != null ? fName.hashCode() : 0)
- + fJarEntryResource.hashCode();
- }
-
- @Override
- public Object getWrappedObject() {
- return fJarEntryResource;
- }
-
- public IJarEntryResource getJarEntryResource() {
- return fJarEntryResource;
- }
-
- @Override
- public JEAttribute[] getChildren() {
- ArrayList<JEAttribute> result= new ArrayList<JEAttribute>();
-
- Object parent= fJarEntryResource.getParent();
- if (parent instanceof IJarEntryResource)
- result.add(new JEJarEntryResource(this, "PARENT", (IJarEntryResource) parent));
- else
- result.add(new JavaElement(this, "PARENT", (IJavaScriptElement) parent));
-
- result.add(new JavaElement(this, "PACKAGE FRAGMENT ROOT", fJarEntryResource.getPackageFragmentRoot()));
-
- result.add(new JavaElementChildrenProperty(this, "CHILDREN") {
- @Override protected JEAttribute[] computeChildren() throws CoreException {
- IJarEntryResource[] jarEntryResources= getJarEntryResource().getChildren();
- JEAttribute[] children= new JEAttribute[jarEntryResources.length];
- for (int i= 0; i < jarEntryResources.length; i++) {
- children[i]= new JEJarEntryResource(this, null, jarEntryResources[i]);
- }
- return children;
- }
- });
- return result.toArray(new JEAttribute[result.size()]);
- }
-
- @Override
- public String getLabel() {
- StringBuilder sb= new StringBuilder();
- if (fName != null)
- sb.append(fName).append(": ");
- String classname= fJarEntryResource.getClass().getName();
- sb.append(classname.substring(classname.lastIndexOf('.') + 1)).append(": ");
- sb.append(fJarEntryResource.getName());
- return sb.toString();
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEMarker.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEMarker.java
deleted file mode 100644
index dd7322f4..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEMarker.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.wst.jsdt.jseview.views;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.core.resources.IMarker;
-
-
-public class JEMarker extends JEAttribute {
-
- private JEAttribute fParent;
- private String fName;
- private IMarker fMarker;
-
- JEMarker(JEAttribute parent, String name, IMarker marker) {
- Assert.isNotNull(parent);
- Assert.isNotNull(name);
- Assert.isNotNull(marker);
- fParent= parent;
- fName= name;
- fMarker= marker;
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- @Override
- public JEAttribute[] getChildren() {
- return EMPTY;
- }
-
- @Override
- public String getLabel() {
- return fName + ": (" + getMarkerAttribute(IMarker.SEVERITY) + ") " + getMarkerAttribute(IMarker.MESSAGE);
- }
-
- public Object getMarkerAttribute(String attributeName) {
- try {
- return fMarker.getAttribute(attributeName);
- } catch (CoreException e) {
- return e.getClass().getSimpleName();
- }
- }
-
- public IMarker getMarker() {
- return fMarker;
- }
-
- @Override
- public Object getWrappedObject() {
- return fMarker;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- JEMarker other= (JEMarker) obj;
- if (! fParent.equals(other.fParent)) {
- return false;
- }
- if (! fName.equals(other.fName)) {
- return false;
- }
- if (! fMarker.equals(other.fMarker)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return fParent.hashCode() + fName.hashCode() + fMarker.hashCode();
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEResource.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEResource.java
deleted file mode 100644
index d5097e3c..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEResource.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.wst.jsdt.jseview.views;
-
-import java.util.ArrayList;
-import java.util.concurrent.Callable;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-
-
-public class JEResource extends JEAttribute {
-
- private final JEAttribute fParent; // can be null
- private final String fName; // can be null
- private IResource fResource;
-
- JEResource(JEAttribute parent, String name, IResource resource) {
- Assert.isNotNull(resource);
- fParent= parent;
- fName= name;
- fResource= resource;
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- JEResource other= (JEResource) obj;
- if (fParent == null) {
- if (other.fParent != null)
- return false;
- } else if (! fParent.equals(other.fParent)) {
- return false;
- }
-
- if (fName == null) {
- if (other.fName != null)
- return false;
- } else if (! fName.equals(other.fName)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return (fParent != null ? fParent.hashCode() : 0)
- + (fName != null ? fName.hashCode() : 0)
- + fResource.hashCode();
- }
-
- @Override
- public Object getWrappedObject() {
- return fResource;
- }
-
- public IResource getResource() {
- return fResource;
- }
-
- @Override
- public JEAttribute[] getChildren() {
- ArrayList<JEAttribute> result= new ArrayList<JEAttribute>();
-
- IContainer parent= fResource.getParent();
- if (parent != null )
- result.add(new JEResource(this, "PARENT", parent));
- else
- result.add(new JavaElementProperty(this, "PARENT", parent));
-
- result.add(new JavaElement(this, "JavaCore.create(..)", JavaScriptCore.create(fResource)));
-
- if (fResource instanceof IContainer) {
- final IContainer container= (IContainer) fResource;
-// result.add(new JavaElementProperty(this, "ModificationStamp") {
-// @Override protected Object computeValue() throws CoreException {
-// return container.getDefaultCharset();
-// }
-// });
- result.add(new JavaElementChildrenProperty(this, "MEMBERS") {
- @Override protected JEAttribute[] computeChildren() throws CoreException {
- IResource[] resources= container.members();
- JEAttribute[] children= new JEAttribute[resources.length];
- for (int i= 0; i < resources.length; i++) {
- children[i]= new JEResource(this, null, resources[i]);
- }
- return children;
- }
- });
- }
- result.add(new JavaElementChildrenProperty(this, "FIND MARKERS (DEPTH_ZERO)") {
- @Override protected JEAttribute[] computeChildren() throws CoreException {
- IMarker[] markers= getResource().findMarkers(null, true, IResource.DEPTH_ZERO);
- JEAttribute[] children= new JEAttribute[markers.length];
- for (int i= 0; i < markers.length; i++) {
- children[i]= new JEMarker(this, "[" + i + "]", markers[i]);
- }
- return children;
- }
- });
- return result.toArray(new JEAttribute[result.size()]);
- }
-
- @Override
- public String getLabel() {
- String label= fResource.getName();
- if (fName != null)
- label= fName + ": " + label;
- return label;
- }
-
- public static JEAttribute compute(JEAttribute parent, String name, Callable<IResource> computer) {
- try {
- IResource resource= computer.call();
- return create(parent, name, resource);
- } catch (Exception e) {
- return new Error(parent, name, e);
- }
- }
-
- public static JEAttribute create(JEAttribute parent, String name, IResource resource) {
- if (resource == null) {
- return new Null(parent, name);
- } else {
- return new JEResource(parent, name, resource);
- }
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JERoot.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JERoot.java
deleted file mode 100644
index 0a65550b..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JERoot.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.wst.jsdt.jseview.views;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.wst.jsdt.core.IJarEntryResource;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-
-
-public class JERoot extends JEAttribute {
-
- private final List<JEAttribute> fJEAttributes;
-
- public JERoot(Collection<?> javaElementsOrResources) {
- fJEAttributes= new Mapper<Object, JEAttribute>() {
- @Override public JEAttribute map(Object element) {
- if (element instanceof IJavaScriptElement)
- return new JavaElement(null, (IJavaScriptElement) element);
- else if (element instanceof IResource)
- return new JEResource(null, null, (IResource) element);
- else if (element instanceof IJarEntryResource)
- return new JEJarEntryResource(null, null, (IJarEntryResource) element);
- else
- throw new IllegalArgumentException(String.valueOf(element));
-
- }
- }.mapToList(javaElementsOrResources);
-
-// fJavaElements= Mapper.build(javaElements, new Mapper<IJavaScriptElement, JavaElement>() {
-// @Override public JavaElement map(IJavaScriptElement element) {
-// return new JavaElement(null, element);
-// }
-// });
-
-// fJavaElements= new ArrayList<JavaElement>(javaElements.size());
-// for (IJavaScriptElement javaElement : javaElements) {
-// fJavaElements.add(new JavaElement(null, javaElement));
-// }
- }
-
- @Override
- public JEAttribute getParent() {
- return null;
- }
-
- @Override
- public JEAttribute[] getChildren() {
- return fJEAttributes.toArray(new JEAttribute[fJEAttributes.size()]);
- }
-
- @Override
- public Object getWrappedObject() {
- return null;
- }
-
- @Override
- public String getLabel() {
- StringBuffer buf = new StringBuffer("root: ");
- boolean first= true;
- for (JEAttribute att : fJEAttributes) {
- if (! first)
- buf.append(", ");
- buf.append(att.getLabel());
- first= false;
- }
- return buf.toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- JERoot other= (JERoot) obj;
- return fJEAttributes.equals(other.fJEAttributes);
- }
-
- @Override
- public int hashCode() {
- return fJEAttributes.hashCode();
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEViewContentProvider.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEViewContentProvider.java
deleted file mode 100644
index b994a2d9..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEViewContentProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.wst.jsdt.jseview.views;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-
-public class JEViewContentProvider implements ITreeContentProvider {
-
- public Object[] getChildren(Object element) {
- if (element instanceof JEAttribute)
- return ((JEAttribute) element).getChildren();
- return JEAttribute.EMPTY;
- }
-
- public Object getParent(Object element) {
- if (element instanceof JEAttribute)
- return ((JEAttribute) element).getParent();
- return null;
- }
-
- public boolean hasChildren(Object element) {
- if (element instanceof JEAttribute)
- return ((JEAttribute) element).getChildren().length > 0;
- return false;
- }
-
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof JEAttribute)
- return ((JEAttribute) inputElement).getChildren();
- return JEAttribute.EMPTY;
- }
-
- public void dispose() {
- // do nothing
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // do nothing
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEViewLabelProvider.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEViewLabelProvider.java
deleted file mode 100644
index a0f98525..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JEViewLabelProvider.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * 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.wst.jsdt.jseview.views;
-
-import org.eclipse.core.resources.IMarker;
-
-import org.eclipse.swt.graphics.Image;
-
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-import org.eclipse.wst.jsdt.jseview.JEPluginImages;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-
-
-
-public class JEViewLabelProvider extends LabelProvider /*implements IColorProvider, IFontProvider*/ {
-
- JavaScriptElementLabelProvider fJavaElementLabelProvider;
- private Image fChildrenImg;
- private Image fInfoImg;
-
- public JEViewLabelProvider() {
- fChildrenImg= JEPluginImages.IMG_CHILDREN.createImage();
- fInfoImg= JEPluginImages.IMG_INFO.createImage();
- fJavaElementLabelProvider= new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_SMALL_ICONS);
- }
-
-
- @Override
- public String getText(Object element) {
- if (element instanceof JEAttribute)
- return ((JEAttribute) element).getLabel();
- return super.getText(element);
- }
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof JavaElement) {
- return fJavaElementLabelProvider.getImage(((JavaElement) element).getJavaElement());
-
- } else if (element instanceof JEResource) {
- return fJavaElementLabelProvider.getImage(((JEResource) element).getResource());
-
- } else if (element instanceof JEJarEntryResource) {
- return fJavaElementLabelProvider.getImage(((JEJarEntryResource) element).getJarEntryResource());
-
- } else if (element instanceof JavaElementProperty) {
- return fInfoImg;
-
- } else if (element instanceof JavaElementChildrenProperty) {
- return fChildrenImg;
-
- } else if (element instanceof JEClasspathEntry) {
- return fChildrenImg;
-
- } else if (element instanceof Error) {
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
-
- } else if (element instanceof JEMarker) {
- JEMarker marker= (JEMarker) element;
- Object severity= marker.getMarkerAttribute(IMarker.SEVERITY);
- if (severity instanceof Integer) {
- Integer sev= (Integer) severity;
- switch (sev.intValue()) {
- case IMarker.SEVERITY_INFO:
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
- case IMarker.SEVERITY_WARNING:
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- case IMarker.SEVERITY_ERROR:
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
- }
- }
- return null;
-
- } else {
- return super.getImage(element);
- }
- }
-
- @Override
- public void dispose() {
- super.dispose();
- fChildrenImg.dispose();
- fInfoImg.dispose();
- fJavaElementLabelProvider.dispose();
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElement.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElement.java
deleted file mode 100644
index 394399f2..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElement.java
+++ /dev/null
@@ -1,581 +0,0 @@
-/*******************************************************************************
- * 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.wst.jsdt.jseview.views;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.Callable;
-
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.IFunction;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJarEntryResource;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.IMember;
-import org.eclipse.wst.jsdt.core.IPackageFragment;
-import org.eclipse.wst.jsdt.core.IPackageFragmentRoot;
-import org.eclipse.wst.jsdt.core.IParent;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.ITypeRoot;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabels;
-
-
-public class JavaElement extends JEAttribute {
-
- private static final long LABEL_OPTIONS= JavaScriptElementLabels.F_APP_TYPE_SIGNATURE | JavaScriptElementLabels.M_PARAMETER_TYPES | JavaScriptElementLabels.M_APP_RETURNTYPE | JavaScriptElementLabels.ALL_FULLY_QUALIFIED | JavaScriptElementLabels.T_TYPE_PARAMETERS | JavaScriptElementLabels.USE_RESOLVED;
-
- private final JEAttribute fParent; //can be null
- private final String fName; //can be null
- private final IJavaScriptElement fJavaElement; //can be null
-
- public JavaElement(JEAttribute parent, String name, IJavaScriptElement element) {
- fParent= parent;
- fName= name;
- fJavaElement= element;
- }
-
- public JavaElement(JEAttribute parent, IJavaScriptElement element) {
- this(parent, null, element);
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- public IJavaScriptElement getJavaElement() {
- return fJavaElement;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- JavaElement other= (JavaElement) obj;
- if (fParent == null) {
- if (other.fParent != null)
- return false;
- } else if (! fParent.equals(other.fParent)) {
- return false;
- }
-
- if (fName == null) {
- if (other.fName != null)
- return false;
- } else if (! fName.equals(other.fName)) {
- return false;
- }
-
- if (fJavaElement == null) {
- if (other.fJavaElement != null)
- return false;
- } else if (! fJavaElement.equals(other.fJavaElement)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return (fParent != null ? fParent.hashCode() : 0)
- + (fName != null ? fName.hashCode() : 0)
- + (fJavaElement != null ? fJavaElement.hashCode() : 0);
- }
-
- @Override
- public Object getWrappedObject() {
- return fJavaElement;
- }
-
- @Override
- public String getLabel() {
- StringBuffer sb= new StringBuffer();
- if (fName != null)
- sb.append(fName).append(": ");
-
- if (fJavaElement == null) {
- sb.append("java element: null");
- } else {
- String classname= fJavaElement.getClass().getName();
- sb.append(classname.substring(classname.lastIndexOf('.') + 1)).append(": ");
- sb.append(JavaScriptElementLabels.getElementLabel(fJavaElement, LABEL_OPTIONS));
- if (! fJavaElement.exists())
- sb.append(" (does not exist)");
- }
- return sb.toString();
- }
-
- @Override
- public JEAttribute[] getChildren() {
- if (fJavaElement == null)
- return EMPTY;
-
- ArrayList<JEAttribute> result= new ArrayList<JEAttribute>();
-
- if (fJavaElement instanceof IParent) {
- addParentChildren(result, (IParent) fJavaElement);
- }
-
- addJavaElementChildren(result, fJavaElement);
-
- if (fJavaElement instanceof IJavaScriptModel)
- addJavaModelChildren(result, (IJavaScriptModel) fJavaElement);
- if (fJavaElement instanceof IJavaScriptProject)
- addJavaProjectChildren(result, (IJavaScriptProject) fJavaElement);
- if (fJavaElement instanceof IPackageFragmentRoot)
- addPackageFragmentRootChildren(result, (IPackageFragmentRoot) fJavaElement);
- if (fJavaElement instanceof IPackageFragment)
- addPackageFragmentChildren(result, (IPackageFragment) fJavaElement);
-
- if (fJavaElement instanceof ITypeRoot)
- addTypeRootChildren(result, (ITypeRoot) fJavaElement);
- if (fJavaElement instanceof IClassFile)
- addClassFileChildren(result, (IClassFile) fJavaElement);
- if (fJavaElement instanceof IJavaScriptUnit)
- addCompilationUnitChildren(result, (IJavaScriptUnit) fJavaElement);
-
- if (fJavaElement instanceof IType)
- addTypeChildren(result, (IType) fJavaElement);
- if (fJavaElement instanceof IFunction)
- addMethodChildren(result, (IFunction) fJavaElement);
- if (fJavaElement instanceof IMember)
- addMemberChildren(result, (IMember) fJavaElement);
-
-// if (fJavaElement instanceof ITypeParameter)
-// addTypeParameterChildren(result, (ITypeParameter) fJavaElement);
-//
-// if (fJavaElement instanceof IAnnotation)
-// addAnnotationChildren(result, (IAnnotation) fJavaElement);
-// if (fJavaElement instanceof IAnnotatable)
-// addAnnotatableChildren(result, (IAnnotatable) fJavaElement);
-
- return result.toArray(new JEAttribute[result.size()]);
-
- }
-
- private void addParentChildren(ArrayList<JEAttribute> result, final IParent parent) {
- result.add(new JavaElementChildrenProperty(this, "CHILDREN") {
- @Override
- public JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, parent.getChildren());
- }
- });
- }
-
- private void addJavaElementChildren(ArrayList<JEAttribute> result, final IJavaScriptElement javaElement) {
- result.add(new JavaElement(this, "PARENT", javaElement.getParent()));
- result.add(new JavaElement(this, "PRIMARY ELEMENT", javaElement.getPrimaryElement()));
- result.add(new JavaElement(this, "JAVA MODEL", javaElement.getJavaScriptModel()));
- result.add(new JavaElement(this, "JAVA PROJECT", javaElement.getJavaScriptProject()));
- result.add(JEResource.create(this, "RESOURCE", javaElement.getResource()));
- result.add(JEResource.compute(this, "CORRESPONDING RESOURCE", new Callable<IResource>() {
- public IResource call() throws JavaScriptModelException {
- return javaElement.getCorrespondingResource();
- }
- }));
- result.add(JEResource.compute(this, "UNDERLYING RESOURCE", new Callable<IResource>() {
- public IResource call() throws JavaScriptModelException {
- return javaElement.getUnderlyingResource();
- }
- }));
- }
-
- private void addJavaModelChildren(ArrayList<JEAttribute> result, final IJavaScriptModel javaModel) {
- result.add(new JavaElementChildrenProperty(this, "JAVA PROJECTS") {
- @Override
- public JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, javaModel.getJavaScriptProjects());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "NON JAVA RESOURCES") {
- @Override
- public JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createResources(this, javaModel.getNonJavaScriptResources());
- }
- });
- }
-
- private void addJavaProjectChildren(ArrayList<JEAttribute> result, final IJavaScriptProject project) {
- result.add(new JavaElementChildrenProperty(this, "ALL PACKAGE FRAGMENT ROOTS") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, project.getAllPackageFragmentRoots());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "PACKAGE FRAGMENT ROOTS") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, project.getPackageFragmentRoots());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "PACKAGE FRAGMENTS") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, project.getPackageFragments());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "NON JAVA RESOURCES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createResources(this, project.getNonJavaScriptResources());
- }
- });
- result.add(JEResource.create(this, "PROJECT", project.getProject()));
- result.add(new JavaElementChildrenProperty(this, "REQUIRED PROJECT NAMES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createStrings(this, project.getRequiredProjectNames());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "OPTIONS(FALSE)") {
- @SuppressWarnings("unchecked")
- @Override
- protected JEAttribute[] computeChildren() {
- return createOptions(this, project.getOptions(false));
- }
- });
- result.add(new JavaElementChildrenProperty(this, "OPTIONS(TRUE)") {
- @SuppressWarnings("unchecked")
- @Override
- protected JEAttribute[] computeChildren() {
- return createOptions(this, project.getOptions(true));
- }
- });
- result.add(new JavaElementChildrenProperty(this, "RAW INCLUDEPATH") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createCPEntries(this, project.getRawIncludepath());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "RESOLVED INCLUDEPATH") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createCPEntries(this, project.getResolvedIncludepath(false));
- }
- });
- }
-
- private void addPackageFragmentRootChildren(ArrayList<JEAttribute> result, final IPackageFragmentRoot packageFragmentRoot) {
- result.add(new JavaElementChildrenProperty(this, "NON JAVA RESOURCES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createResources(this, packageFragmentRoot.getNonJavaScriptResources());
- }
- });
- result.add(JEClasspathEntry.compute(this, "RAW INCLUDEPATH ENTRY", new Callable<IIncludePathEntry>() {
- public IIncludePathEntry call() throws JavaScriptModelException {
- return packageFragmentRoot.getRawIncludepathEntry();
- }
- }));
- }
-
- private void addPackageFragmentChildren(ArrayList<JEAttribute> result, final IPackageFragment packageFragment) {
- result.add(new JavaElementChildrenProperty(this, "COMPILATION UNITS") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, packageFragment.getJavaScriptUnits());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "CLASS FILES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, packageFragment.getClassFiles());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "NON JAVA RESOURCES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createResources(this, packageFragment.getNonJavaScriptResources());
- }
- });
- }
-
- private void addTypeRootChildren(ArrayList<JEAttribute> result, final ITypeRoot typeRoot) {
- result.add(JavaElement.compute(this, "FIND PRIMARY TYPE", new Callable<IJavaScriptElement>() {
- public IJavaScriptElement call() {
- return typeRoot.findPrimaryType();
- }
- }));
- }
-
- private void addClassFileChildren(ArrayList<JEAttribute> result, final IClassFile classFile) {
- result.add(JavaElement.compute(this, "TYPE", new Callable<IJavaScriptElement>() {
- public IJavaScriptElement call() throws JavaScriptModelException {
- return classFile.getType();
- }
- }));
- }
-
- private void addCompilationUnitChildren(ArrayList<JEAttribute> result, final IJavaScriptUnit compilationUnit) {
- //TODO: WorkingCopyOwner
- result.add(new JavaElement(this, "PRIMARY", compilationUnit.getPrimary()));
- result.add(new JavaElementChildrenProperty(this, "TYPES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, compilationUnit.getTypes());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "ALL TYPES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, compilationUnit.getAllTypes());
- }
- });
-// result.add(new JavaElement(this, "IMPORT CONTAINER", compilationUnit.getImportContainer()));
-// result.add(new JavaElementChildrenProperty(this, "IMPORTS") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createJavaElements(this, compilationUnit.getImports());
-// }
-// });
-// result.add(new JavaElementChildrenProperty(this, "PACKAGE DECLARATIONS") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createJavaElements(this, compilationUnit.getPackageDeclarations());
-// }
-// });
- }
-
- private void addMemberChildren(ArrayList<JEAttribute> result, final IMember member) {
- result.add(new JavaElement(this, "CLASS FILE", member.getClassFile()));
- result.add(new JavaElement(this, "COMPILATION UNIT", member.getJavaScriptUnit()));
- result.add(new JavaElement(this, "TYPE ROOT", member.getTypeRoot()));
- result.add(new JavaElement(this, "DECLARING TYPE", member.getDeclaringType()));
- result.add(new JavaElementChildrenProperty(this, "CATEGORIES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createStrings(this, member.getCategories());
- }
- });
- }
-
-// private void addAnnotationChildren(ArrayList<JEAttribute> result, final IAnnotation annotation) {
-// result.add(new JavaElementChildrenProperty(this, "MEMBER VALUE PAIRS") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// IMemberValuePair[] memberValuePairs= annotation.getMemberValuePairs();
-// return createMemberValuePairs(this, memberValuePairs);
-// }
-// });
-// }
-//
-// private void addAnnotatableChildren(ArrayList<JEAttribute> result, final IAnnotatable annotatable) {
-// result.add(new JavaElementChildrenProperty(this, "ANNOTATIONS") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// IAnnotation[] annotations= annotatable.getAnnotations();
-// return createJavaElements(this, annotations);
-// }
-// });
-// }
-
- private void addTypeChildren(ArrayList<JEAttribute> result, final IType type) {
- result.add(new JavaElementProperty(this, "IS RESOLVED", type.isResolved()));
- result.add(new JavaElementProperty(this, "KEY", type.getKey()));
- result.add(new JavaElement(this, "PACKAGE FRAGMENT", type.getPackageFragment()));
-// result.add(new JavaElementChildrenProperty(this, "TYPE PARAMETERS") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createJavaElements(this, type.getTypeParameters());
-// }
-// });
-// result.add(new JavaElementChildrenProperty(this, "TYPE PARAMETER SIGNATURES") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createStrings(this, type.getTypeParameterSignatures());
-// }
-// });
-
- result.add(new JavaElementProperty(this, "SUPERCLASS NAME") {
- @Override
- protected Object computeValue() throws Exception {
- return type.getSuperclassName();
- }
- });
-
- result.add(new JavaElementProperty(this, "SUPERCLASS TYPE SIGNATURE") {
- @Override
- protected Object computeValue() throws Exception {
- return type.getSuperclassTypeSignature();
- }
- });
-// result.add(new JavaElementChildrenProperty(this, "SUPER INTERFACE NAMES") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createStrings(this, type.getSuperInterfaceNames());
-// }
-// });
-// result.add(new JavaElementChildrenProperty(this, "SUPER INTERFACE TYPE SIGNATURES") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createStrings(this, type.getSuperInterfaceTypeSignatures());
-// }
-// });
-
- result.add(new JavaElementChildrenProperty(this, "FIELDS") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, type.getFields());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "INITIALIZERS") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, type.getInitializers());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "METHODS") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, type.getFunctions());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "TYPES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createJavaElements(this, type.getTypes());
- }
- });
- }
-
- private void addMethodChildren(ArrayList<JEAttribute> result, final IFunction method) {
-// result.add(new JavaElementChildrenProperty(this, "EXCEPTION TYPES") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createStrings(this, method.getExceptionTypes());
-// }
-// });
- result.add(new JavaElementChildrenProperty(this, "PARAMETER NAMES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createStrings(this, method.getParameterNames());
- }
- });
- result.add(new JavaElementChildrenProperty(this, "PARAMETER TYPES") {
- @Override
- protected JEAttribute[] computeChildren() throws JavaScriptModelException {
- return createStrings(this, method.getParameterTypes());
- }
- });
-// result.add(new JavaElementChildrenProperty(this, "TYPE PARAMETERS") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createJavaElements(this, method.getTypeParameters());
-// }
-// });
- }
-
-// private void addTypeParameterChildren(ArrayList<JEAttribute> result, final ITypeParameter typeParameter) {
-// result.add(new JavaElement(this, "DECLARING MEMBER", typeParameter.getDeclaringMember()));
-// result.add(new JavaElementChildrenProperty(this, "BOUNDS") {
-// @Override
-// protected JEAttribute[] computeChildren() throws JavaScriptModelException {
-// return createStrings(this, typeParameter.getBounds());
-// }
-// });
-// }
-
- static JavaElement[] createJavaElements(JEAttribute parent, Object[] javaElements) {
- JavaElement[] jeChildren= new JavaElement[javaElements.length];
- for (int i= 0; i < javaElements.length; i++) {
- jeChildren[i]= new JavaElement(parent, (IJavaScriptElement) javaElements[i]);
- }
- return jeChildren;
- }
-
- static JavaElement[] createJavaElements(JEAttribute parent, IJavaScriptElement[] javaElements) {
- JavaElement[] jeChildren= new JavaElement[javaElements.length];
- for (int i= 0; i < javaElements.length; i++) {
- jeChildren[i]= new JavaElement(parent, javaElements[i]);
- }
- return jeChildren;
- }
-
- static JEAttribute[] createResources(JEAttribute parent, Object[] resources) {
- JEAttribute[] resourceChildren= new JEAttribute[resources.length];
- for (int i= 0; i < resources.length; i++) {
- Object resource= resources[i];
- if (resource instanceof IResource)
- resourceChildren[i]= new JEResource(parent, null, (IResource) resource);
- else if (resource instanceof IJarEntryResource)
- resourceChildren[i]= new JEJarEntryResource(parent, null, (IJarEntryResource) resource);
- else
- resourceChildren[i]= new JavaElementProperty(parent, null, resource);
- }
- return resourceChildren;
- }
-
-
- static JEAttribute[] createCPEntries(JEAttribute parent, IIncludePathEntry[] entries) {
- JEAttribute[] entryChildren= new JEAttribute[entries.length];
- for (int i= 0; i < entries.length; i++) {
- IIncludePathEntry entry= entries[i];
- entryChildren[i]= new JEClasspathEntry(parent, null, entry);
- }
- return entryChildren;
- }
-
- static JEAttribute[] createOptions(JEAttribute parent, Map<String, String> options) {
- ArrayList<Entry<String, String>> entries= new ArrayList<Entry<String, String>>(options.entrySet());
- Collections.sort(entries, new Comparator<Entry<String, String>>() {
- public int compare(Entry<String, String> o1, Entry<String, String> o2) {
- return o1.getKey().compareTo(o2.getKey());
- }
- });
-
- JEAttribute[] children= new JEAttribute[entries.size()];
- for (int i= 0; i < entries.size(); i++) {
- Entry<String, String> entry= entries.get(i);
- children[i]= new JavaElementProperty(parent, entry.getKey(), entry.getValue());
- }
- return children;
- }
-
- static JEAttribute[] createStrings(JEAttribute parent, String[] strings) {
- JEAttribute[] children= new JEAttribute[strings.length];
- for (int i= 0; i < strings.length; i++) {
- children[i]= new JavaElementProperty(parent, null, strings[i]);
- }
- return children;
- }
-
- public static JEAttribute compute(JEAttribute parent, String name, Callable<IJavaScriptElement> computer) {
- try {
- IJavaScriptElement javaElement= computer.call();
- return create(parent, name, javaElement);
- } catch (Exception e) {
- return new Error(parent, name, e);
- }
- }
-
- public static JEAttribute create(JEAttribute parent, String name, IJavaScriptElement javaElement) {
- if (javaElement == null) {
- return new Null(parent, name);
- } else {
- return new JavaElement(parent, name, javaElement);
- }
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementChildrenProperty.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementChildrenProperty.java
deleted file mode 100644
index c300d3be..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementChildrenProperty.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.wst.jsdt.jseview.views;
-
-
-public abstract class JavaElementChildrenProperty extends JEAttribute {
-
- private final JEAttribute fParent;
- private final String fName;
-
- public JavaElementChildrenProperty(JEAttribute parent, String name) {
- fParent= parent;
- fName= name;
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- JavaElementChildrenProperty other= (JavaElementChildrenProperty) obj;
- if (fParent == null) {
- if (other.fParent != null)
- return false;
- } else if (! fParent.equals(other.fParent)) {
- return false;
- }
-
- if (fName == null) {
- if (other.fName != null)
- return false;
- } else if (! fName.equals(other.fName)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return (fParent != null ? fParent.hashCode() : 0)
- + (fName != null ? fName.hashCode() : 0);
- }
-
- @Override
- public Object getWrappedObject() {
- return getChildren().length;
- }
-
- @Override
- public JEAttribute[] getChildren() {
- try {
- return computeChildren();
- } catch (Exception e) {
- return new JEAttribute[] {new Error(this, "", e)};
- }
- }
-
- protected abstract JEAttribute[] computeChildren() throws Exception;
-
- @Override
- public String getLabel() {
- Object[] children= getChildren();
- String count;
- if (children.length == 1 && children[0] instanceof Error) {
- count= Error.ERROR;
- } else {
- count= String.valueOf(children.length);
- }
- return fName + " (" + count + ")";
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementProperty.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementProperty.java
deleted file mode 100644
index 1b5c7cea..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementProperty.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.wst.jsdt.jseview.views;
-
-
-public class JavaElementProperty extends JEAttribute {
-
- private final JEAttribute fParent;
- private final String fName;
- private final String fValue;
- private final Object fValueObject;
-
- public JavaElementProperty(JEAttribute parent, String name) {
- fParent= parent;
- fName= name;
- fValue= null;
- fValueObject= null;
- }
-
- public JavaElementProperty(JEAttribute parent, String name, Object value) {
- fParent= parent;
- fName= name;
- fValueObject= value;
- if (value instanceof String)
- fValue= "\"" + value + "\"";
- else
- fValue= String.valueOf(value);
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- @Override
- public Object getWrappedObject() {
- return fValueObject;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- JavaElementProperty other= (JavaElementProperty) obj;
- if (fParent == null) {
- if (other.fParent != null)
- return false;
- } else if (! fParent.equals(other.fParent)) {
- return false;
- }
-
- if (fName == null) {
- if (other.fName != null)
- return false;
- } else if (! fName.equals(other.fName)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return (fParent != null ? fParent.hashCode() : 0)
- + (fName != null ? fName.hashCode() : 0);
- }
-
- @Override
- public JEAttribute[] getChildren() {
- if (fValue != null)
- return EMPTY;
-
- try {
- computeValue();
- return EMPTY;
- } catch (Exception e) {
- return new Error[]{ new Error(this, "", e) };
- }
- }
-
- @Override
- public String getLabel() {
- String value= fValue;
- if (value == null) {
- try {
- value= String.valueOf(computeValue());
- } catch (Exception e) {
- return Error.ERROR;
- }
- }
-
- if (fName == null)
- return value;
- else
- return fName + ": " + value;
- }
-
- protected Object computeValue() throws Exception {
- return fValue;
- }
-
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementView.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementView.java
deleted file mode 100644
index 29d496ef..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/JavaElementView.java
+++ /dev/null
@@ -1,953 +0,0 @@
-/*******************************************************************************
- * 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.wst.jsdt.jseview.views;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.NotEnabledException;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.core.commands.common.NotDefinedException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-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.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.jface.text.ITextSelection;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchCommandConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ContributionItemFactory;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.keys.IBindingService;
-import org.eclipse.ui.part.DrillDownAdapter;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.IShowInTarget;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-
-import org.eclipse.ui.ide.IDE;
-
-import org.eclipse.wst.jsdt.core.ElementChangedEvent;
-import org.eclipse.wst.jsdt.core.IClassFile;
-import org.eclipse.wst.jsdt.core.ICodeAssist;
-import org.eclipse.wst.jsdt.core.IElementChangedListener;
-import org.eclipse.wst.jsdt.core.IIncludePathEntry;
-import org.eclipse.wst.jsdt.core.IJarEntryResource;
-import org.eclipse.wst.jsdt.core.IJavaScriptElement;
-import org.eclipse.wst.jsdt.core.IJavaScriptModel;
-import org.eclipse.wst.jsdt.core.IJavaScriptProject;
-import org.eclipse.wst.jsdt.core.IJavaScriptUnit;
-import org.eclipse.wst.jsdt.core.ISourceRange;
-import org.eclipse.wst.jsdt.core.ISourceReference;
-import org.eclipse.wst.jsdt.core.IType;
-import org.eclipse.wst.jsdt.core.JavaScriptCore;
-import org.eclipse.wst.jsdt.core.JavaScriptModelException;
-import org.eclipse.wst.jsdt.jseview.EditorUtility;
-import org.eclipse.wst.jsdt.jseview.JEPluginImages;
-import org.eclipse.wst.jsdt.jseview.JEViewPlugin;
-import org.eclipse.wst.jsdt.jseview.properties.ClasspathEntryProperties;
-import org.eclipse.wst.jsdt.jseview.properties.JarEntryResourceProperties;
-import org.eclipse.wst.jsdt.jseview.properties.JavaElementProperties;
-import org.eclipse.wst.jsdt.jseview.properties.MarkerProperties;
-import org.eclipse.wst.jsdt.jseview.properties.ResourceProperties;
-import org.eclipse.wst.jsdt.ui.JavaScriptElementLabelProvider;
-import org.eclipse.wst.jsdt.ui.JavaScriptUI;
-
-
-public class JavaElementView extends ViewPart implements IShowInSource, IShowInTarget {
- TreeViewer fViewer;
- private DrillDownAdapter fDrillDownAdapter;
- JERoot fInput;
-
- private Action fFocusAction;
- private Action fFindTypeAction;
- private Action fResolveTypeAction;
- private Action fCreateFromBindingKeyAction;
- private Action fResetAction;
- private Action fCodeSelectAction;
- private Action fElementAtAction;
- private Action fCreateFromHandleAction;
- private Action fRefreshAction;
- TreeCopyAction fCopyAction;
- private Action fCompareAction;
- private Action fPropertiesAction;
- Action fDoubleClickAction;
-
- private Action fLogDeltasAction;
-
- private PropertySheetPage fPropertySheetPage;
-
- private static class InputDialog extends org.eclipse.jface.dialogs.InputDialog {
- public InputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue, IInputValidator validator) {
- super(parentShell, dialogTitle, dialogMessage, initialValue, validator);
- }
- @Override
- protected boolean isResizable() {
- return true;
- }
- }
- private static class JEViewSelectionProvider implements ISelectionProvider {
- private final TreeViewer fViewer;
- ListenerList fSelectionChangedListeners= new ListenerList();
-
- public JEViewSelectionProvider(TreeViewer viewer) {
- fViewer= viewer;
- fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- fireSelectionChanged();
- }
- });
- }
-
- void fireSelectionChanged() {
- if (fSelectionChangedListeners != null) {
- SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
-
- Object[] listeners= fSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
- listener.selectionChanged(event);
- }
- }
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- fSelectionChangedListeners.add(listener);
- }
-
- public ISelection getSelection() {
- IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection();
- ArrayList<Object> externalSelection= new ArrayList<Object>();
- for (Iterator<?> iter= selection.iterator(); iter.hasNext();) {
- Object element= iter.next();
- if (element instanceof JavaElement) {
- IJavaScriptElement javaElement= ((JavaElement) element).getJavaElement();
- if (javaElement != null && ! (javaElement instanceof IJavaScriptModel)) // various selection listeners assume getJavaProject() is non-null
- externalSelection.add(javaElement);
- } else if (element instanceof JEResource) {
- IResource resource= ((JEResource) element).getResource();
- if (resource != null &&! (resource instanceof IWorkspaceRoot)) // various selection listeners assume getProject() is non-null
- externalSelection.add(resource);
- } else if (element instanceof JEAttribute) {
- Object wrappedObject= ((JEAttribute) element).getWrappedObject();
- if (wrappedObject != null) {
- externalSelection.add(wrappedObject);
- }
- }
- }
- return new StructuredSelection(externalSelection);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- fSelectionChangedListeners.remove(listener);
- }
-
- public void setSelection(ISelection selection) {
- //not supported
- }
- }
-
- public JavaElementView() {
- //
- }
-
- @Override
- public void createPartControl(Composite parent) {
- fViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- fDrillDownAdapter = new DrillDownAdapter(fViewer) {
- @SuppressWarnings("synthetic-access")
- @Override
- protected void updateNavigationButtons() {
- super.updateNavigationButtons();
- if (fViewer.getInput() instanceof JEAttribute && ! fViewer.getInput().equals(fInput)) {
- setContentDescription(((JEAttribute) fViewer.getInput()).getLabel());
- } else {
- setContentDescription("");
- }
-
- }
- };
- fViewer.setContentProvider(new JEViewContentProvider());
- fViewer.setLabelProvider(new JEViewLabelProvider());
- reset();
- makeActions();
- hookContextMenu();
- hookDoubleClickAction();
- getSite().setSelectionProvider(new JEViewSelectionProvider(fViewer));
- fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- fCopyAction.setEnabled(! event.getSelection().isEmpty());
- }
- });
- contributeToActionBars();
- }
-
- void reset() {
- setSingleInput(getJavaScriptModel());
- }
-
- private IJavaScriptModel getJavaScriptModel() {
- return JavaScriptCore.create(JEViewPlugin.getWorkspace().getRoot());
- }
-
- void setSingleInput(Object javaElementOrResource) {
- setInput(Collections.singleton(javaElementOrResource));
- }
-
- void setInput(Collection<?> javaElementsOrResources) {
- fInput= new JERoot(javaElementsOrResources);
- fViewer.setInput(fInput);
- ITreeContentProvider tcp= (ITreeContentProvider) fViewer.getContentProvider();
- Object[] elements= tcp.getElements(fInput);
- if (elements.length > 0) {
- fViewer.setSelection(new StructuredSelection(elements[0]));
- if (elements.length == 1) {
- fViewer.setExpandedState(elements[0], true);
- }
- }
- fDrillDownAdapter.reset();
- }
-
- void setEmptyInput() {
- setInput(Collections.emptySet());
- }
-
- private void hookContextMenu() {
- MenuManager menuMgr = new MenuManager("#PopupMenu");
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- JavaElementView.this.fillContextMenu(manager);
- }
- });
- Menu menu = menuMgr.createContextMenu(fViewer.getControl());
- fViewer.getControl().setMenu(menu);
- getSite().registerContextMenu(menuMgr, fViewer);
- }
-
- private void contributeToActionBars() {
- IActionBars bars = getViewSite().getActionBars();
- fillLocalPullDown(bars.getMenuManager());
- fillLocalToolBar(bars.getToolBarManager());
- bars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
- bars.setGlobalActionHandler(ActionFactory.COPY.getId(), fCopyAction);
- bars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), fPropertiesAction);
- }
-
- private void fillLocalPullDown(IMenuManager manager) {
- manager.add(fCodeSelectAction);
- manager.add(fElementAtAction);
- manager.add(fCreateFromHandleAction);
- manager.add(fResetAction);
- manager.add(fLogDeltasAction);
- manager.add(new Separator());
- manager.add(fRefreshAction);
- }
-
- void fillContextMenu(IMenuManager manager) {
- addFocusActionOrNot(manager);
- manager.add(fResetAction);
- manager.add(fRefreshAction);
- manager.add(new Separator());
-
- if (! getSite().getSelectionProvider().getSelection().isEmpty()) {
- MenuManager showInSubMenu= new MenuManager(getShowInMenuLabel());
- IWorkbenchWindow workbenchWindow= getSite().getWorkbenchWindow();
- showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(workbenchWindow));
- manager.add(showInSubMenu);
- }
- addElementActionsOrNot(manager);
- manager.add(new Separator());
-
- manager.add(fCopyAction);
- manager.add(new Separator());
-
- fDrillDownAdapter.addNavigationActions(manager);
- manager.add(new Separator());
- // Other plug-ins can contribute there actions here
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- manager.add(new Separator());
- addCompareActionOrNot(manager);
- manager.add(fPropertiesAction);
- }
-
- private String getShowInMenuLabel() {
- String keyBinding= null;
-
- IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
- if (bindingService != null)
- keyBinding= bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.NAVIGATE_SHOW_IN_QUICK_MENU);
-
- if (keyBinding == null)
- keyBinding= ""; //$NON-NLS-1$
-
- return "Sho&w In" + '\t' + keyBinding;
- }
-
- private void addFocusActionOrNot(IMenuManager manager) {
- if (fViewer.getSelection() instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection= (IStructuredSelection) fViewer.getSelection();
- if (structuredSelection.size() == 1) {
- Object first= structuredSelection.getFirstElement();
- if (first instanceof JavaElement) {
- String name= ((JavaElement) first).getJavaElement().getElementName();
- fFocusAction.setText("Fo&cus On '" + name + '\'');
- manager.add(fFocusAction);
- }
- }
- }
- }
-
- private void addElementActionsOrNot(IMenuManager manager) {
- if (fViewer.getSelection() instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection= (IStructuredSelection) fViewer.getSelection();
- if (structuredSelection.size() == 1) {
- Object first= structuredSelection.getFirstElement();
- if (first instanceof JavaElement) {
- IJavaScriptElement javaElement= ((JavaElement) first).getJavaElement();
- if (javaElement instanceof IJavaScriptProject) {
- manager.add(fFindTypeAction);
- manager.add(fCreateFromBindingKeyAction);
- }
- if (javaElement instanceof IType) {
- manager.add(fResolveTypeAction);
- }
- }
- }
- }
- }
-
- private void addCompareActionOrNot(IMenuManager manager) {
- if (fViewer.getSelection() instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection= (IStructuredSelection) fViewer.getSelection();
- if (structuredSelection.size() == 2) {
- manager.add(fCompareAction);
- }
- }
- }
-
- private void fillLocalToolBar(IToolBarManager manager) {
- manager.add(fCodeSelectAction);
- manager.add(fElementAtAction);
- manager.add(fResetAction);
- manager.add(fRefreshAction);
- manager.add(new Separator());
- fDrillDownAdapter.addNavigationActions(manager);
- }
-
- private void makeActions() {
- fCodeSelectAction= new Action("Set Input from Editor (&codeSelect)", JEPluginImages.IMG_SET_FOCUS_CODE_SELECT) {
- @Override public void run() {
- IEditorPart editor= getSite().getPage().getActiveEditor();
- if (editor == null) {
- setEmptyInput();
- return;
- }
- IEditorInput input= editor.getEditorInput();
- ISelectionProvider selectionProvider= editor.getSite().getSelectionProvider();
- if (input == null || selectionProvider == null) {
- setEmptyInput();
- return;
- }
- ISelection selection= selectionProvider.getSelection();
- if (! (selection instanceof ITextSelection)) {
- setEmptyInput();
- return;
- }
- IJavaScriptElement javaElement= (IJavaScriptElement) input.getAdapter(IJavaScriptElement.class);
- if (javaElement == null) {
- setEmptyInput();
- return;
- }
-
- IJavaScriptElement[] resolved;
- try {
- resolved= codeResolve(javaElement, (ITextSelection) selection);
- } catch (JavaScriptModelException e) {
- setEmptyInput();
- return;
- }
- if (resolved.length == 0) {
- setEmptyInput();
- return;
- }
-
- setInput(Arrays.asList(resolved));
- }
- };
- fCodeSelectAction.setToolTipText("Set input from current editor's selection (codeSelect)");
-
- fElementAtAction= new Action("Set Input from Editor location (&getElementAt)", JEPluginImages.IMG_SET_FOCUS) {
- @Override public void run() {
- IEditorPart editor= getSite().getPage().getActiveEditor();
- if (editor == null) {
- setEmptyInput();
- return;
- }
- IEditorInput input= editor.getEditorInput();
- ISelectionProvider selectionProvider= editor.getSite().getSelectionProvider();
- if (input == null || selectionProvider == null) {
- setEmptyInput();
- return;
- }
- ISelection selection= selectionProvider.getSelection();
- if (! (selection instanceof ITextSelection)) {
- setEmptyInput();
- return;
- }
- IJavaScriptElement javaElement= (IJavaScriptElement) input.getAdapter(IJavaScriptElement.class);
- if (javaElement == null) {
- setEmptyInput();
- return;
- }
-
- IJavaScriptElement resolved;
- try {
- resolved= getElementAtOffset(javaElement, (ITextSelection) selection);
- } catch (JavaScriptModelException e) {
- setEmptyInput();
- return;
- }
- if (resolved == null) {
- setEmptyInput();
- return;
- }
-
- setSingleInput(resolved);
- }
- };
- fElementAtAction.setToolTipText("Set input from current editor's selection location (getElementAt)");
-
- fCreateFromHandleAction= new Action("Create From &Handle...") {
- @Override public void run() {
- InputDialog dialog= new InputDialog(getSite().getShell(), "Create Java Element From Handle Identifier", "&Handle identifier:", "", null);
- if (dialog.open() != Window.OK)
- return;
- String handleIdentifier= dialog.getValue();
- IJavaScriptElement javaElement= JavaScriptCore.create(handleIdentifier);
- setSingleInput(javaElement);
- }
- };
-
- fFocusAction= new Action() {
- @Override public void run() {
- Object selected= ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
- setSingleInput(((JavaElement) selected).getJavaElement());
- }
- };
- fFocusAction.setToolTipText("Focus on Selection");
-
- fFindTypeAction= new Action() {
- @Override public void run() {
- Object selected= ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
- final IJavaScriptProject project= (IJavaScriptProject) ((JavaElement) selected).getJavaElement();
-
- InputDialog dialog= new InputDialog(getSite().getShell(), "IJavaScriptProject#findType(String fullyQualifiedName, IProgressMonitor pm)", "fullyQualifiedName:", "", null);
- if (dialog.open() != Window.OK)
- return;
- final String fullyQualifiedName= dialog.getValue();
-
- class Runner implements IRunnableWithProgress {
- IType type;
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- type= project.findType(fullyQualifiedName, monitor);
- } catch (JavaScriptModelException e) {
- throw new InvocationTargetException(e);
- }
- }
- }
- Runner runner= new Runner();
- try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runner);
- } catch (InvocationTargetException e) {
- JEViewPlugin.log(e);
- } catch (InterruptedException e) {
- JEViewPlugin.log(e);
- }
- JavaElement element= new JavaElement(fInput, fullyQualifiedName, runner.type);
- fViewer.add(fInput, element);
- fViewer.setSelection(new StructuredSelection(element));
- }
- };
- fFindTypeAction.setText("findType(..)...");
-
- fResolveTypeAction= new Action() {
- @Override public void run() {
- Object selected= ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
- final IType type= (IType) ((JavaElement) selected).getJavaElement();
-
- InputDialog dialog= new InputDialog(getSite().getShell(), "IType#resolveType(String typeName)", "typeName:", "", null);
- if (dialog.open() != Window.OK)
- return;
- final String typeName= dialog.getValue();
-
- JavaElementChildrenProperty element= new JavaElementChildrenProperty(fInput, "'" + type.getFullyQualifiedName() + "'.resolveType(\"" + typeName +"\")") {
- @Override protected JEAttribute[] computeChildren() throws Exception {
- String[][] resolvedTypes= type.resolveType(typeName);
- if (resolvedTypes == null) {
- return new JEAttribute[] { new Null(this, "result") };
- }
- JEAttribute[] resolvedJEAttributes= new JEAttribute[resolvedTypes.length];
- for (int i= 0; i < resolvedTypes.length; i++) {
- String[] resolvedType= resolvedTypes[i];
- resolvedJEAttributes[i]= new JavaElementProperty(this, null, resolvedType[0] + ", " + resolvedType[1]);
- }
- return resolvedJEAttributes;
- }
- };
- fViewer.add(fInput, element);
- fViewer.setSelection(new StructuredSelection(element));
- fViewer.setExpandedState(element, true);
- }
- };
- fResolveTypeAction.setText("resolveType(String)...");
-
- fCreateFromBindingKeyAction= new Action("Create From &Binding Key...") {
- @Override public void run() {
- Object selected= ((IStructuredSelection) fViewer.getSelection()).getFirstElement();
- final IJavaScriptProject project= (IJavaScriptProject) ((JavaElement) selected).getJavaElement();
-
- InputDialog dialog= new InputDialog(getSite().getShell(), "IJavaScriptProject#findElement(String bindingKey, WorkingCopyOwner owner)", "&bindingKey:", "", null);
- if (dialog.open() != Window.OK)
- return;
- final String bindingKey= dialog.getValue();
-
- class Runner implements IRunnableWithProgress {
- IJavaScriptElement element;
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- element= project.findElement(new Path(bindingKey), null);
- } catch (JavaScriptModelException e) {
- throw new InvocationTargetException(e);
- }
- }
- }
- Runner runner= new Runner();
- try {
- PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runner);
- } catch (InvocationTargetException e) {
- JEViewPlugin.log(e);
- } catch (InterruptedException e) {
- JEViewPlugin.log(e);
- }
- JavaElement element= new JavaElement(fInput, bindingKey, runner.element);
- fViewer.add(fInput, element);
- fViewer.setSelection(new StructuredSelection(element));
- }
- };
-
- fResetAction= new Action("&Reset View", getJavaModelImageDescriptor()) {
- @Override public void run() {
- reset();
- }
- };
- fResetAction.setToolTipText("Reset View to JavaModel");
-
- fRefreshAction= new Action("Re&fresh", JEPluginImages.IMG_REFRESH) {
- @Override public void run() {
- BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
- public void run() {
- fViewer.refresh();
- }
- });
- }
- };
- fRefreshAction.setToolTipText("Refresh");
- fRefreshAction.setActionDefinitionId("org.eclipse.ui.file.refresh");
-
- fCopyAction= new TreeCopyAction(new Tree[] {fViewer.getTree()});
-
- fPropertiesAction= new Action("&Properties", JEPluginImages.IMG_PROPERTIES) {
- @Override
- public void run() {
- String viewId = IPageLayout.ID_PROP_SHEET;
- IWorkbenchPage page= getViewSite().getPage();
- IViewPart view;
- try {
- view= page.showView(viewId);
- page.activate(JavaElementView.this);
- page.bringToTop(view);
- } catch (PartInitException e) {
- JEViewPlugin.log("could not find Properties view", e);
- }
- }
- };
- fPropertiesAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_PROPERTIES);
-
- fDoubleClickAction = new Action() {
- private Object fPreviousDouble;
-
- @Override public void run() {
- ISelection selection = fViewer.getSelection();
- Object obj = ((IStructuredSelection)selection).getFirstElement();
-
- boolean isSecondDoubleClick= (obj == fPreviousDouble);
- fPreviousDouble= isSecondDoubleClick ? null : obj;
-
- if (obj instanceof JavaElement) {
- IJavaScriptElement javaElement= ((JavaElement) obj).getJavaElement();
- if (javaElement != null) {
- switch (javaElement.getElementType()) {
- case IJavaScriptElement.JAVASCRIPT_MODEL :
- break;
-
- case IJavaScriptElement.JAVASCRIPT_PROJECT :
- case IJavaScriptElement.PACKAGE_FRAGMENT_ROOT :
- case IJavaScriptElement.PACKAGE_FRAGMENT :
- ICommandService service = (ICommandService) getSite().getService(ICommandService.class);
- Command showInCommand= service.getCommand(IWorkbenchCommandConstants.NAVIGATE_SHOW_IN);
- Map<String, String> params= Collections.singletonMap("org.eclipse.ui.navigate.showIn.targetId", JavaScriptUI.ID_PACKAGES);
- try {
- Object context= ((IHandlerService) getSite().getService(IHandlerService.class)).getCurrentState();
- showInCommand.executeWithChecks(new ExecutionEvent(null, params, null, context));
- } catch (ExecutionException e1) {
- showAndLogError("Could not show element", e1);
- } catch (NotDefinedException e1) {
- showAndLogError("Could not show element", e1);
- } catch (NotEnabledException e1) {
- showAndLogError("Could not show element", e1);
- } catch (NotHandledException e1) {
- showAndLogError("Could not show element", e1);
- }
- break;
-
- default :
- try {
- IEditorPart editorPart= JavaScriptUI.openInEditor(javaElement);
- if (editorPart != null) {
- if (isSecondDoubleClick && javaElement instanceof ISourceReference && editorPart instanceof ITextEditor) {
- ISourceRange sourceRange= ((ISourceReference) javaElement).getSourceRange();
- EditorUtility.selectInEditor((ITextEditor) editorPart, sourceRange.getOffset(), sourceRange.getLength());
- } else {
- JavaScriptUI.revealInEditor(editorPart, javaElement);
- }
- }
- } catch (PartInitException e) {
- showAndLogError("Could not open editor.", e); //$NON-NLS-1$
- } catch (JavaScriptModelException e) {
- showAndLogError("Could not open editor.", e); //$NON-NLS-1$
- }
- }
- }
-
- } else if (obj instanceof Error) {
- Error error= (Error) obj;
- JEViewPlugin.log(error.getException());
-
- } else if (obj instanceof JEMarker) {
- JEMarker marker= (JEMarker) obj;
- try {
- IDE.openEditor(getSite().getPage(), marker.getMarker());
- } catch (PartInitException e) {
- showAndLogError("Could not open editor.", e); //$NON-NLS-1$
- }
- }
- }
- };
-
- fCompareAction= new Action() {
- @Override public void run() {
- Object[] selection= ((IStructuredSelection) fViewer.getSelection()).toArray();
- Object first= ((JEAttribute) selection[0]).getWrappedObject();
- Object second= ((JEAttribute) selection[1]).getWrappedObject();
- boolean identical= first == second;
- boolean equals1= first != null && first.equals(second);
- boolean equals2= second != null && second.equals(first);
- boolean inconsistentEquals= equals1 != equals2;
-
- String msg= "==: " + identical + "\nequals(..): " + (inconsistentEquals ? "INCONSISTENT" : equals1);
- MessageDialog.openInformation(fViewer.getTree().getShell(), "Comparison", msg);
- }
- };
- fCompareAction.setText("C&ompare with Each Other...");
-
-
- fLogDeltasAction= new Action("Log JavaScript element deltas", IAction.AS_CHECK_BOX) {
-
- private IElementChangedListener fListener= new IElementChangedListener() {
- public void elementChanged(ElementChangedEvent event) {
- JEViewPlugin.logMessage(event.getDelta().toString());
- }
- };
-
- @Override public void run() {
- String message;
- if (!isChecked()) {
- JavaScriptCore.removeElementChangedListener(fListener);
- message= "Element listener removed";
- } else {
- JavaScriptCore.addElementChangedListener(fListener);
- message= "Element listener added. Deltas are now written to log.";
- }
- MessageDialog.openInformation(fViewer.getTree().getShell(), "Log Java Element Deltas", message);
- }
- };
-
- }
-
-
- static IJavaScriptElement[] codeResolve(IJavaScriptElement input, ITextSelection selection) throws JavaScriptModelException {
- if (input instanceof ICodeAssist) {
- if (input instanceof IJavaScriptUnit) {
- reconcile((IJavaScriptUnit) input);
- }
- IJavaScriptElement[] elements= ((ICodeAssist)input).codeSelect(selection.getOffset(), selection.getLength());
- if (elements != null && elements.length > 0)
- return elements;
- }
- return new IJavaScriptElement[0];
- }
-
- static IJavaScriptElement getElementAtOffset(IJavaScriptElement input, ITextSelection selection) throws JavaScriptModelException {
- if (input instanceof IJavaScriptUnit) {
- IJavaScriptUnit cunit= (IJavaScriptUnit) input;
- reconcile(cunit);
- IJavaScriptElement ref= cunit.getElementAt(selection.getOffset());
- if (ref == null)
- return input;
- else
- return ref;
- } else if (input instanceof IClassFile) {
- IJavaScriptElement ref= ((IClassFile)input).getElementAt(selection.getOffset());
- if (ref == null)
- return input;
- else
- return ref;
- }
- return input;
- }
-
- static void reconcile(IJavaScriptUnit unit) throws JavaScriptModelException {
- synchronized(unit) {
- unit.reconcile(
- IJavaScriptUnit.NO_AST,
- false /* don't force problem detection */,
- null /* use primary owner */,
- null /* no progress monitor */);
- }
- }
-
- private ImageDescriptor getJavaModelImageDescriptor() {
- JavaScriptElementLabelProvider lp= new JavaScriptElementLabelProvider(JavaScriptElementLabelProvider.SHOW_SMALL_ICONS);
- Image modelImage= lp.getImage(getJavaScriptModel());
- ImageDescriptor modelImageDescriptor= ImageDescriptor.createFromImage(modelImage);
- lp.dispose();
- return modelImageDescriptor;
- }
-
- private void hookDoubleClickAction() {
- fViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- fDoubleClickAction.run();
- }
- });
- }
-
- void showAndLogError(String message, CoreException e) {
- JEViewPlugin.log(message, e);
- ErrorDialog.openError(getSite().getShell(), "JavaElement View", message, e.getStatus()); //$NON-NLS-1$
- }
-
- void showAndLogError(String message, Exception e) {
- IStatus status= new Status(IStatus.ERROR, JEViewPlugin.getPluginId(), 0, message, e);
- JEViewPlugin.log(status);
- ErrorDialog.openError(getSite().getShell(), "JavaElement View", null, status); //$NON-NLS-1$
- }
-
- void showMessage(String message) {
- MessageDialog.openInformation(
- fViewer.getControl().getShell(),
- "JavaElement View",
- message);
- }
-
- /**
- * Passing the focus request to the viewer's control.
- */
- @Override
- public void setFocus() {
- fViewer.getControl().setFocus();
- }
-
- public ShowInContext getShowInContext() {
- return new ShowInContext(null, getSite().getSelectionProvider().getSelection());
- }
-
- public boolean show(ShowInContext context) {
- ISelection selection= context.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection= ((IStructuredSelection) selection);
- if (structuredSelection.size() >= 1) {
- Set<Object> input= new LinkedHashSet<Object>();
- for (Iterator<?> iter = structuredSelection.iterator(); iter.hasNext();) {
- Object item= iter.next();
- if (item instanceof IJavaScriptElement) {
- input.add(item);
- } else if (item instanceof IResource) {
- IJavaScriptElement je= JavaScriptCore.create((IResource) item);
- if (je == null) {
- input.add(item);
- } else {
- input.add(je);
- }
- } else if (item instanceof IJarEntryResource) {
- input.add(item);
- }
- }
- if (input.size() > 0) {
- setInput(input);
- return true;
- }
- }
- }
-
- Object input= context.getInput();
- if (input instanceof IEditorInput) {
- Object elementOfInput= getElementOfInput((IEditorInput)context.getInput());
- if (elementOfInput != null) {
- setSingleInput(elementOfInput);
- return true;
- }
- }
-
- return false;
- }
-
- Object getElementOfInput(IEditorInput input) {
- Object adapted= input.getAdapter(IClassFile.class);
- if (adapted != null) {
- return adapted;
- }
-
- if (input instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)input).getFile();
- IJavaScriptElement javaElement= JavaScriptCore.create(file);
- if (javaElement != null) {
- return javaElement;
- } else {
- return file;
- }
- } else if (input instanceof IStorageEditorInput) {
- try {
- return ((IStorageEditorInput) input).getStorage();
- } catch (CoreException e) {
- return null;
- }
- }
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySheetPage.class) {
- return getPropertySheetPage();
- }
- return super.getAdapter(adapter);
- }
-
- private PropertySheetPage getPropertySheetPage() {
- if (fPropertySheetPage == null) {
- final PropertySheetPage propertySheetPage= new PropertySheetPage();
- propertySheetPage.setPropertySourceProvider(new IPropertySourceProvider() {
- public IPropertySource getPropertySource(Object object) {
- if (object instanceof IJavaScriptElement)
- return new JavaElementProperties((IJavaScriptElement) object);
- else if (object instanceof IResource)
- return new ResourceProperties((IResource) object);
- else if (object instanceof IMarker)
- return new MarkerProperties((IMarker) object);
- else if (object instanceof IJarEntryResource)
- return new JarEntryResourceProperties((IJarEntryResource) object);
-// else if (object instanceof IMemberValuePair)
-// return new MemberValuePairProperties((IMemberValuePair) object);
- else if (object instanceof IIncludePathEntry)
- return new ClasspathEntryProperties((IIncludePathEntry) object);
- else
- return null;
- }
- });
- fPropertySheetPage= propertySheetPage;
- }
- return fPropertySheetPage;
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Mapper.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Mapper.java
deleted file mode 100644
index 7b717e18..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Mapper.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.wst.jsdt.jseview.views;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-public abstract class Mapper<I, O> {
- public abstract O map(I element);
-
- public static <I, O> List<O> build(Collection<? extends I> elements, Mapper<I, O> mapper) {
- ArrayList<O> result = new ArrayList<O>(elements.size());
- for (I element : elements)
- result.add(mapper.map(element));
- return result;
- }
- public List<O> mapToList(Collection<? extends I> elements) {
- ArrayList<O> result = new ArrayList<O>(elements.size());
- for (I element : elements)
- result.add(map(element));
- return result;
- }
-} \ No newline at end of file
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Null.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Null.java
deleted file mode 100644
index caa03c78..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/Null.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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.wst.jsdt.jseview.views;
-
-import org.eclipse.core.runtime.Assert;
-
-
-
-public class Null extends JEAttribute {
-
- private final JEAttribute fParent;
- private final String fName;
-
- public Null(JEAttribute parent, String name) {
- Assert.isNotNull(parent);
- Assert.isNotNull(name);
- fParent= parent;
- fName= name;
- }
-
- @Override
- public JEAttribute getParent() {
- return fParent;
- }
-
- @Override
- public JEAttribute[] getChildren() {
- return EMPTY;
- }
-
- @Override
- public Object getWrappedObject() {
- return null;
- }
-
- @Override
- public String getLabel() {
- return fName + ": null";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || !obj.getClass().equals(getClass())) {
- return false;
- }
-
- Null other= (Null) obj;
- if (! fParent.equals(other.fParent)) {
- return false;
- }
- if (! fName.equals(other.fName)) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return fParent.hashCode() + fName.hashCode();
- }
-}
diff --git a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/TreeCopyAction.java b/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/TreeCopyAction.java
deleted file mode 100644
index 605fa39b..00000000
--- a/development/org.eclipse.wst.jsdt.jseview/src/org/eclipse/wst/jsdt/jseview/views/TreeCopyAction.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * 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
- *******************************************************************************/
-package org.eclipse.wst.jsdt.jseview.views;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-
-import org.eclipse.wst.jsdt.jseview.JEViewPlugin;
-
-
-public class TreeCopyAction extends Action {
-
- private static class TreeObject {
- private final TreeItem fTreeItem;
- private boolean fSelected;
- private final List<TreeObject> fChildren;
- public TreeObject(TreeItem element, boolean selected) {
- fTreeItem= element;
- fSelected= selected;
- fChildren= new ArrayList<TreeObject>();
- }
- public void setSelected() {
- fSelected= true;
- }
- public void addChild(TreeObject child) {
- fChildren.add(child);
- }
- public boolean isSelected() {
- return fSelected;
- }
- public TreeItem getTreeItem() {
- return fTreeItem;
- }
- public List<TreeObject> getChildren() {
- return fChildren;
- }
- @Override
- public String toString() {
- StringBuffer buf= new StringBuffer();
- if (fSelected)
- buf.append("* "); //$NON-NLS-1$
- buf.append(trim(fTreeItem.getText())).append(" ["); //$NON-NLS-1$
- for (int i= 0; i < fChildren.size(); i++) {
- TreeObject child= fChildren.get(i);
- buf.append(trim(child.getTreeItem().getText()));
- if (i > 0)
- buf.append(", "); //$NON-NLS-1$
- }
- return buf.append("]").toString(); //$NON-NLS-1$
- }
- private String trim(String string) {
- if (string.length() > 60)
- return string.substring(0, 60) + "..."; //$NON-NLS-1$
- else
- return string;
- }
- }
-
- private final Tree[] fTrees;
-
- public TreeCopyAction(Tree[] trees) {
- fTrees= trees;
- setText("&Copy"); //$NON-NLS-1$
- setToolTipText("Copy to Clipboard"); //$NON-NLS-1$
- setEnabled(false);
- setImageDescriptor(JEViewPlugin.getDefault().getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY));
- setId(ActionFactory.COPY.getId());
- setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY);
- }
-
- @Override
- public void run() {
- Tree tree= null;
- for (int i= 0; i < fTrees.length; i++) {
- if (fTrees[i].isFocusControl()) {
- tree= fTrees[i];
- break;
- }
- }
- if (tree == null)
- return;
-
- TreeItem[] selection= tree.getSelection();
- if (selection.length == 0)
- return;
-
- Clipboard clipboard= null;
- try {
- clipboard= new Clipboard(tree.getDisplay());
- if (selection.length == 1) {
- clipboard.setContents(new Object[]{selection[0].getText()}, new Transfer[]{TextTransfer.getInstance()});
- } else if (selection.length > 1) {
- copyTree(selection, clipboard);
- }
- } finally {
- if (clipboard != null)
- clipboard.dispose();
- }
- }
-
- private void copyTree(TreeItem[] selection, Clipboard clipboard) {
- HashMap<TreeItem, TreeObject> elementToTreeObj= new HashMap<TreeItem, TreeObject>();
- List<TreeObject> roots= new ArrayList<TreeObject>();
- int indent= Integer.MIN_VALUE;
-
- for (int i= 0; i < selection.length; i++) {
- TreeItem item= selection[i];
- TreeObject treeObj= elementToTreeObj.get(item);
- if (treeObj == null) {
- treeObj= new TreeObject(item, true);
- elementToTreeObj.put(item, treeObj);
- } else {
- treeObj.setSelected();
- continue;
- }
- // walk up to roots:
- int level= 0;
- item= item.getParentItem();
- while (item != null) {
- TreeObject parentTreeObj= elementToTreeObj.get(item);
- if (parentTreeObj == null) {
- parentTreeObj= new TreeObject(item, false);
- elementToTreeObj.put(item, parentTreeObj);
- parentTreeObj.addChild(treeObj);
- treeObj= parentTreeObj;
- item= item.getParentItem();
- level--;
- } else {
- parentTreeObj.addChild(treeObj);
- treeObj= parentTreeObj;
- break;
- }
- }
- if (item == null) {
- roots.add(treeObj);
- indent= Math.max(indent, level);
- }
- }
- elementToTreeObj= null;
- StringBuffer buf= new StringBuffer();
- appendSelectionObjects(buf, indent, roots);
- String result= buf.length() > 0 ? buf.substring(1) : buf.toString();
- clipboard.setContents(new Object[] { result }, new Transfer[] { TextTransfer.getInstance() });
- }
-
- private void appendSelectionObjects(StringBuffer buffer, int indent, List<TreeObject> selObjs) {
- for (Iterator<TreeObject> iter= selObjs.iterator(); iter.hasNext();) {
- TreeObject selObj= iter.next();
- if (selObj.isSelected()) {
- buffer.append('\n');
- for (int d= 0; d < indent; d++)
- buffer.append('\t');
- buffer.append(selObj.getTreeItem().getText());
- }
- appendSelectionObjects(buffer, indent + 1, selObj.getChildren());
- }
- }
-}

Back to the top