Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornitind2005-04-13 19:12:49 +0000
committernitind2005-04-13 19:12:49 +0000
commit292ded1b4de2f6030e4038b92a37ea5914d3ea7d (patch)
tree44e67d379b97f7e2b353212e4103815636679fec /bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline
parent20cb84d3fe65f82e36498d9946b3b951273a4a4d (diff)
downloadwebtools.sourceediting-20050413_1525.tar.gz
webtools.sourceediting-20050413_1525.tar.xz
webtools.sourceediting-20050413_1525.zip
This commit was manufactured by cvs2svn to create tag 'v20050413_1525'.v20050413_1525
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/BufferedOutlineUpdater.java63
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java344
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java136
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshOutlineJob.java189
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshPropertySheetJob.java62
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java52
8 files changed, 0 insertions, 1054 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/BufferedOutlineUpdater.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/BufferedOutlineUpdater.java
deleted file mode 100644
index d9670cac1b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/BufferedOutlineUpdater.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.w3c.dom.Node;
-
-
-/**
- * Can handle multiple subsequent calls to processNode(..) by buffering them
- * w/ a RefreshOutlineJob. Only one refresh is performed (on the UI Thread) on the
- * minimal affected area of the tree at the end of the batch of updates (after
- * the last update is processed).
- *
- * @author pavery
- */
-public class BufferedOutlineUpdater {
-
- private RefreshOutlineJob fRefreshJob = null;
- private StructuredViewer fViewer = null;
-
- /**
- * @param structuredViewer
- * the viewer we are updating
- * @param node
- * the specific node that changed
- */
- public void processNode(final StructuredViewer structuredViewer, Node node) {
-
- // refresh on structural and "unknown" changes
- // it would be nice to not refresh the viewer if it's not visible
- // but only refresh when it's brought back to the front
- if (structuredViewer.getControl() != null) {
- if(getViewer() == null)
- setViewer(structuredViewer);
- getRefreshJob().refresh(node);
- }
- }
-
- private RefreshOutlineJob getRefreshJob() {
- if(fRefreshJob == null)
- fRefreshJob = new RefreshOutlineJob(getViewer());
- return fRefreshJob;
- }
-
- private StructuredViewer getViewer() {
- return fViewer;
- }
-
- private void setViewer(StructuredViewer viewer) {
- fViewer = viewer;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java
deleted file mode 100644
index c3615de782..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapterFactory;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManagerListener;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.w3c.dom.Node;
-
-/**
- * Adapts a DOM node to a JFace viewer.
- */
-public class JFaceNodeAdapter implements IJFaceNodeAdapter {
-
- public class CMDocumentManagerListenerImpl implements CMDocumentManagerListener {
-
- List beingRefreshed = Collections.synchronizedList(new ArrayList());
-
- public void cacheCleared(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache cache) {
-
- }
-
- public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) {
-
- if (newStatus == CMDocumentCache.STATUS_LOADED || newStatus == CMDocumentCache.STATUS_ERROR) {
- refreshViewers();
- }
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- public void propertyChanged(CMDocumentManager cmDocumentManager, String propertyName) {
-
- if (cmDocumentManager.getPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD)) {
- refreshViewers();
- }
- }
-
- protected void refreshViewers() {
-
- // we're counting on getListers returning a "copy" of the
- // listeners, so we'll be thread safe.
- Collection listeners = ((IJFaceNodeAdapterFactory) adapterFactory).getListeners();
- Iterator iterator = listeners.iterator();
- while (iterator.hasNext()) {
- Object listener = iterator.next();
- // now that we use aynchExec, we ourselves have to gaurd
- // against
- // agains adding some refreshes when its already being
- // refreshed.
- if (listener instanceof PropertySheetPage && (!beingRefreshed.contains(listener))) {
- final PropertySheetPage propertySheetPage = (PropertySheetPage) listener;
- beingRefreshed.add(propertySheetPage);
- getDisplay().asyncExec(new Runnable() {
-
- public void run() {
-
- if (getDisplay().isDisposed()) {
- return;
- }
- if (propertySheetPage.getControl() != null && !propertySheetPage.getControl().isDisposed()) {
- propertySheetPage.refresh();
- beingRefreshed.remove(propertySheetPage);
- }
- }
- });
- }
- }
- }
- }
-
- final static Class ADAPTER_KEY = IJFaceNodeAdapter.class;
-
- // for debugging
- private static final boolean DEBUG;
- static {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/outline"); //$NON-NLS-1$
- DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
-
- protected INodeAdapterFactory adapterFactory;
- protected CMDocumentManagerListener cmDocumentManagerListener;
- private BufferedOutlineUpdater fUpdater = null;
-
- public JFaceNodeAdapter(INodeAdapterFactory adapterFactory) {
-
- super();
- this.adapterFactory = adapterFactory;
- }
-
- protected Image createImage(Object object) {
-
- Image image = null;
- Node node = (Node) object;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- break;
- }
- case Node.ATTRIBUTE_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- break;
- }
- case Node.TEXT_NODE : { // actually, TEXT should never be seen in
- // the tree
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_CDATASECTION);
- break;
- }
- case Node.ENTITY_REFERENCE_NODE :
- case Node.ENTITY_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ENTITY);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION);
- break;
- }
- case Node.COMMENT_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_COMMENT);
- break;
- }
- case Node.DOCUMENT_TYPE_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_DOCTYPE);
- break;
- }
- case Node.NOTATION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_NOTATION);
- break;
- }
- default : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- break;
- }
- }
- return image;
- }
-
- protected Image createXMLImageDescriptor(String imageResourceName) {
- return XMLEditorPluginImageHelper.getInstance().getImage(imageResourceName);
- }
-
- public Object[] getChildren(Object object) {
-
- // (pa) 20021217
- // cmvc defect 235554
- // performance enhancement: using child.getNextSibling() rather than
- // nodeList(item) for O(n) vs. O(n*n)
- //
- Node node = (Node) object;
- ArrayList v = new ArrayList(node.getChildNodes().getLength());
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- Node n = child;
- if (n.getNodeType() != Node.TEXT_NODE)
- v.add(n);
- }
- return v.toArray();
- }
-
- /**
- * Returns a CMDocumentManagerListener that can update JFace views when
- * notified of CMDocumentManager events
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManagerListener getCMDocumentManagerListener() {
-
- if (cmDocumentManagerListener == null)
- cmDocumentManagerListener = new CMDocumentManagerListenerImpl();
- return cmDocumentManagerListener;
- }
-
- Display getDisplay() {
-
- // Note: the workbench should always have a display
- // (unless running headless), whereas Display.getCurrent()
- // only returns the display if the currently executing thread
- // has one.
- if (PlatformUI.isWorkbenchRunning())
- return PlatformUI.getWorkbench().getDisplay();
- else
- return null;
- }
-
- /**
- * Returns an enumeration with the elements belonging to the passed
- * element. These are the top level items in a list, tree, table, etc...
- */
- public Object[] getElements(Object node) {
-
- return getChildren(node);
- }
-
- /**
- * Fetches the label image specific to this object instance.
- */
- public Image getLabelImage(Object node) {
-
- Image image = CMImageUtil.getImage(CMImageUtil.getDeclaration((Node) node));
- if (image == null && JFaceResources.getImageRegistry() != null) {
- ImageRegistry imageRegistry = JFaceResources.getImageRegistry();
- String nodeName = getNodeName(node);
- image = imageRegistry.get(nodeName);
- if (image == null) {
- image = createImage(node);
- if (image != null)
- imageRegistry.put(nodeName, image);
- }
- }
- return image;
- }
-
- /**
- * Fetches the label text specific to this object instance.
- */
- public String getLabelText(Object node) {
-
- return getNodeName(node);
- }
-
- private String getNodeName(Object object) {
-
- Node node = (Node) object;
- String nodeName = node.getNodeName();
- if (node.getNodeType() == Node.DOCUMENT_TYPE_NODE)
- nodeName = "DOCTYPE:" + nodeName; //$NON-NLS-1$
- return nodeName;
- }
-
- private BufferedOutlineUpdater getOutlineUpdater() {
- if (fUpdater == null)
- fUpdater = new BufferedOutlineUpdater();
- return fUpdater;
- }
-
- public Object getParent(Object object) {
-
- Node node = (Node) object;
- return node.getParentNode();
- }
-
- public boolean hasChildren(Object object) {
-
- // (pa) 20021217
- // cmvc defect 235554 > use child.getNextSibling() instead of
- // nodeList(item) for O(n) vs. O(n*n)
- Node node = (Node) object;
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.TEXT_NODE)
- return true;
- }
- return false;
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
-
- return type.equals(ADAPTER_KEY);
- }
-
- /**
- * Called by the object being adapter (the notifier) when something has
- * changed.
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
-
- // future_TODO: the 'uijobs' used in this method were added to solve
- // threading problems when the dom
- // is updated in the background while the editor is open. They may be
- // a bit overkill and not that useful.
- // (That is, may be be worthy of job manager management). If they are
- // found to be important enough to leave in,
- // there's probably some optimization that can be done.
- Collection listeners = ((JFaceNodeAdapterFactory) adapterFactory).getListeners();
- Iterator iterator = listeners.iterator();
-
- while (iterator.hasNext()) {
- Object listener = iterator.next();
- if (notifier instanceof Node && (listener instanceof StructuredViewer) && (eventType == INodeNotifier.STRUCTURE_CHANGED || (eventType == INodeNotifier.CHANGE && changedFeature == null))) {
-
- if (DEBUG)
- System.out.println("JFaceNodeAdapter notified on event type > " + eventType); //$NON-NLS-1$
-
- // refresh on structural and "unknown" changes
- StructuredViewer structuredViewer = (StructuredViewer) listener;
- // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5230
- if (structuredViewer.getControl() != null /*
- * &&
- * structuredViewer.getControl().isVisible()
- */)
- getOutlineUpdater().processNode(structuredViewer, (Node) notifier);
- } else if ((listener instanceof PropertySheetPage) && ((eventType == INodeNotifier.CHANGE) || (eventType == INodeNotifier.STRUCTURE_CHANGED))) {
- PropertySheetPage propertySheetPage = (PropertySheetPage) listener;
- if (propertySheetPage.getControl() != null /*
- * &&
- * !propertySheetPage.getControl().isDisposed()
- */) {
- RefreshPropertySheetJob refreshPropertySheetJob = new RefreshPropertySheetJob(getDisplay(), XMLUIMessages.JFaceNodeAdapter_1, propertySheetPage); //$NON-NLS-1$
- refreshPropertySheetJob.schedule();
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java
deleted file mode 100644
index d2ac99a98f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.wst.sse.core.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapterFactory;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-
-
-/**
- * An adapter factory to create JFaceNodeAdapters. Use this adapter factory
- * with a JFaceAdapterContentProvider to display DOM nodes in a tree.
- */
-public class JFaceNodeAdapterFactory extends AbstractAdapterFactory implements IJFaceNodeAdapterFactory {
- protected CMDocumentManager cmDocumentManager;
- /**
- * This keeps track of all the listeners.
- */
- protected ArrayList fListeners = new ArrayList();
-
- protected INodeAdapter singletonAdapter;
-
- public JFaceNodeAdapterFactory() {
- this(IJFaceNodeAdapter.class, true);
- }
-
- public JFaceNodeAdapterFactory(Object adapterKey, boolean registerAdapters) {
- super(adapterKey, registerAdapters);
- }
-
- public synchronized void addListener(Object listener) {
- fListeners.add(listener);
- }
-
- public INodeAdapterFactory copy() {
-
- return new JFaceNodeAdapterFactory(this.adapterKey, this.shouldRegisterAdapter);
- }
-
- /**
- * Create a new JFace adapter for the DOM node passed in
- */
- protected INodeAdapter createAdapter(INodeNotifier node) {
- if (singletonAdapter == null) {
- // create the JFaceNodeAdapter
- singletonAdapter = new JFaceNodeAdapter(this);
- initAdapter(singletonAdapter, node);
- }
- return singletonAdapter;
- }
-
- /**
- * returns "copy" so no one can modify our list. Its is a shallow copy.
- */
- public synchronized Collection getListeners() {
- return (Collection) fListeners.clone();
- }
-
- protected void initAdapter(INodeAdapter adapter, INodeNotifier node) {
- // register for CMDocumentManager events
- if (((JFaceNodeAdapter) adapter).getCMDocumentManagerListener() != null) {
- ModelQueryAdapter mqadapter = (ModelQueryAdapter) node.getAdapterFor(ModelQueryAdapter.class);
- if (mqadapter != null) {
- ModelQuery mquery = mqadapter.getModelQuery();
- if (mquery != null && mquery.getCMDocumentManager() != null) {
- cmDocumentManager = mquery.getCMDocumentManager();
- cmDocumentManager.addListener(((JFaceNodeAdapter) adapter).getCMDocumentManagerListener());
- }
- }
- }
- }
-
- public void release() {
- // deregister from CMDocumentManager events
- if (cmDocumentManager != null && singletonAdapter != null && ((JFaceNodeAdapter) singletonAdapter).getCMDocumentManagerListener() != null) {
- cmDocumentManager.removeListener(((JFaceNodeAdapter) singletonAdapter).getCMDocumentManagerListener());
- }
- }
-
- public synchronized void removeListener(Object listener) {
- fListeners.remove(listener);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java
deleted file mode 100644
index 67a7161f7e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.xml.core.document.IDOMModel;
-
-
-/**
- * An ITreeContentProvider for a TreeViewers used to display DOM nodes. This
- * content provider takes an adapter factory to create JFace adapters for the
- * nodes in the tree.
- */
-public class JFaceNodeContentProvider implements ITreeContentProvider {
- protected INodeAdapterFactory adapterFactory;
-
- public JFaceNodeContentProvider(INodeAdapterFactory jfaceAdapterFactory) {
- super();
- this.adapterFactory = jfaceAdapterFactory;
- }
-
- /**
- * The visual part that is using this content provider is about to be
- * disposed. Deallocate all allocated SWT resources.
- */
- public void dispose() {
- }
-
- /**
- * Returns the JFace adapter for the specified object.
- *
- * @return com.ibm.sed.view.tree.DOMJFaceAdapter The JFace adapter
- * @param adaptable
- * java.lang.Object The object to get the adapter for
- */
- protected IJFaceNodeAdapter getAdapter(Object adaptable) {
- if (adaptable instanceof INodeNotifier) {
- INodeAdapter adapter = adapterFactory.adapt((INodeNotifier) adaptable);
- if (adapter instanceof IJFaceNodeAdapter)
- return (IJFaceNodeAdapter) adapter;
- }
- return null;
- }
-
- public Object[] getChildren(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null)
- return adapter.getChildren(object);
-
- return new Object[0];
- }
-
- public Object[] getElements(Object object) {
- // The root is usually an instance of an XMLStructuredModel in
- // which case we want to extract the document.
- Object topNode = object;
- if (object instanceof IDOMModel)
- topNode = ((IDOMModel) object).getDocument();
-
- IJFaceNodeAdapter adapter = getAdapter(topNode);
-
- if (adapter != null)
- return adapter.getElements(topNode);
-
- return new Object[0];
- }
-
- public Object getParent(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null)
- return adapter.getParent(object);
-
- return null;
- }
-
- public boolean hasChildren(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null)
- return adapter.hasChildren(object);
-
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java
deleted file mode 100644
index 5bcca4c6d4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-
-
-/**
- * A class that uses a JFaceNodeAdapterFactory to provide adapters to provide
- * the labels and images for DOM nodes.
- */
-public class JFaceNodeLabelProvider implements ILabelProvider {
-
- protected INodeAdapterFactory adapterFactory;
-
- /**
- * JFaceNodeLabelProvider constructor comment.
- */
- public JFaceNodeLabelProvider(INodeAdapterFactory adapterFactory) {
- super();
- this.adapterFactory = adapterFactory;
- }
-
- /**
- * Adds a listener to the label provider. A label provider should inform
- * its listener about state changes that enforces rendering of the visual
- * part that uses this label provider.
- */
- public void addListener(ILabelProviderListener listener) {
- // The label provider state never changes so we do not have
- // to implement this method.
- }
-
- /**
- * The visual part that is using this label provider is about to be
- * disposed. Deallocate all allocated SWT resources.
- */
- public void dispose() {
- // Nothing to dispose
- }
-
- /**
- * Returns the JFace adapter for the specified object.
- *
- * @return com.ibm.sed.view.tree.DOMJFaceAdapter The JFace adapter
- * @param adaptable
- * java.lang.Object The object to get the adapter for
- */
- protected IJFaceNodeAdapter getAdapter(Object adaptable) {
- return (IJFaceNodeAdapter) adapterFactory.adapt((INodeNotifier) adaptable);
- }
-
- /**
- * Returns the image for the label of the given element, for use in the
- * given viewer.
- *
- * @param element
- * The element for which to provide the label image. Element
- * can be <code>null</code> indicating no input object is set
- * to the viewer.
- */
- public Image getImage(Object element) {
- return getAdapter(element).getLabelImage(element);
- }
-
- /**
- * Returns the text for the label of the given element, for use in the
- * given viewer.
- *
- * @param element
- * The element for which to provide the label text. Element can
- * be <code>null</code> indicating no input object is set to
- * the viewer.
- */
- public java.lang.String getText(Object element) {
- // This was returning null, on occasion ... probably should not be,
- // but
- // took the quick and easy way out for now. (dmw 3/8/01)
- String result = getAdapter(element).getLabelText(element);
- if (result == null)
- result = "";//$NON-NLS-1$
- return result;
- }
-
- /**
- * Checks whether this label provider is affected by the given domain
- * event.
- */
- public boolean isAffected(Object dummy) {//DomainEvent event) {
- //return event.isModifier(DomainEvent.NON_STRUCTURE_CHANGE);
- return true;
-
- }
-
- /**
- * Returns whether the label would be affected by a change to the given
- * property of the given element. This can be used to optimize a
- * non-structural viewer update. If the property mentioned in the update
- * does not affect the label, then the viewer need not update the label.
- *
- * @param element
- * the element
- * @param property
- * the property
- * @return <code>true</code> if the label would be affected, and
- * <code>false</code> if it would be unaffected
- */
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /**
- * Removes a listener from the label provider.
- */
- public void removeListener(ILabelProviderListener listener) {
- // The label provider state never changes so we do not have
- // to implement this method.
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshOutlineJob.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshOutlineJob.java
deleted file mode 100644
index da47a04fef..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshOutlineJob.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * This job holds a queue of updates (affected nodes) for the outline.
- * When a new request comes in, the current run is canceled, the new
- * request is added to the queue, then the job is re-scheduled.
- *
- * @author pavery
- */
-public class RefreshOutlineJob extends Job {
-
- private static final long UPDATE_DELAY = 200;
- /** List of refresh requests (Nodes)*/
- private final List fRequests;
- /** the tree viewer */
- private final StructuredViewer fViewer;
- /** debug flag */
- private static final boolean DEBUG;
- static {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/outline"); //$NON-NLS-1$
- DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
-
- public RefreshOutlineJob(StructuredViewer viewer) {
- super(XMLUIMessages.refreshoutline_0); //$NON-NLS-1$
- setPriority(Job.LONG);
- setSystem(true);
- fRequests = new ArrayList(1);
- fViewer = viewer;
- }
- private synchronized void addRequest(Node node) {
-
- // if we already have a request which contains the new request,
- // discare the new request
- int size = fRequests.size();
- for (int i=0; i<size; i++) {
- if(contains((Node)fRequests.get(i), node))
- return;
- }
- // if new request is contains any existing requests,
- // remove those
- for (Iterator it = fRequests.iterator(); it.hasNext();) {
- if(contains(node, (Node)it.next()))
- it.remove();
- }
- fRequests.add(node);
- }
- /**
- * This method also synchronized because it accesses the fRequests queue
- * @return an array of the currently requested Nodes to refresh
- */
- private synchronized Node[] getRequests() {
-
- Node[] toRefresh = (Node[]) fRequests.toArray(new Node[fRequests.size()]);
- fRequests.clear();
- return toRefresh;
- }
-
- /**
- * Invoke a refresh on the viewer on the given node.
- * @param node
- */
- public void refresh(Node node) {
-
- if (node == null)
- return;
-
- cancel();
- addRequest(node);
- schedule(UPDATE_DELAY);
- }
-
- /**
- * @return if the root is parent of possible, return true, otherwise
- * return false
- */
- private boolean contains(Node root, Node possible) {
-
- if (DEBUG) {
- System.out.println("=============================================================================================================="); //$NON-NLS-1$
- System.out.println("recursive call w/ root: " + root.getNodeName() + " and possible: " + possible); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("--------------------------------------------------------------------------------------------------------------"); //$NON-NLS-1$
- }
-
- // the following checks are important
- // #document node will break the algorithm otherwise
-
- // can't contain the parent if it's null
- if (root == null) {
- if (DEBUG) System.out.println("returning false: root is null"); //$NON-NLS-1$
- return false;
- }
- // nothing can be parent of Document node
- if (possible instanceof Document) {
- if (DEBUG) System.out.println("returning false: possible is Document node"); //$NON-NLS-1$
- return false;
- }
- // document contains everything
- if(root instanceof Document) {
- if (DEBUG) System.out.println("returning true: root is Document node"); //$NON-NLS-1$
- return true;
- }
-
- // depth first
- Node current = root;
- // loop siblings
- while (current != null) {
- if (DEBUG) System.out.println(" -> iterating sibling (" + current.getNodeName() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- // found it
- if (possible.equals(current)) {
- if (DEBUG) System.out.println(" !!! found: " + possible.getNodeName() + " in subtree for: " + root.getNodeName()); //$NON-NLS-1$ //$NON-NLS-2$
- return true;
- }
- // drop one level deeper if necessary
- if (current.getFirstChild() != null) {
- return contains(current.getFirstChild(), possible);
- }
- current = current.getNextSibling();
- }
- // never found it
- return false;
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- Node[] toRefresh = getRequests();
- for (int i = 0; i < toRefresh.length; i++) {
- if (monitor.isCanceled())
- throw new OperationCanceledException();
- doRefresh(toRefresh[i]);
- }
- }
- finally {
- monitor.done();
- }
- return status;
- }
-
- /**
- * Refresh must be on UI thread because it's on a SWT widget.
- * @param node
- */
- private void doRefresh(final Node node) {
- final Display display = PlatformUI.getWorkbench().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
-
- if(DEBUG)
- System.out.println("refresh on: [" +node.getNodeName()+ "]"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if(node instanceof Document)
- fViewer.refresh();
- else
- fViewer.refresh(node);
- }
- });
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshPropertySheetJob.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshPropertySheetJob.java
deleted file mode 100644
index d6aabb5676..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshPropertySheetJob.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-
-
-public class RefreshPropertySheetJob extends UIJob {
-
-
- private PropertySheetPage fPropertySheetPage;
-
- /**
- * @param jobDisplay
- * @param name
- */
- public RefreshPropertySheetJob(Display jobDisplay, String name, PropertySheetPage propertySheetPage) {
- super(jobDisplay, name);
- setPriority(Job.SHORT);
- fPropertySheetPage = propertySheetPage;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor monitor) {
- IStatus result = Status.OK_STATUS;
- try {
- Control control = fPropertySheetPage.getControl();
- // we should have check before even scheduling this, but even if
- // ok then, need to check again, right before executing.
- if (control != null && !control.isDisposed()) {
- fPropertySheetPage.refresh();
- }
- } catch (Exception e) {
- result = errorStatus(e);
- } finally {
- monitor.done();
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java
deleted file mode 100644
index 9626c19b57..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
-import org.eclipse.wst.xml.ui.actions.AbstractNodeActionManager;
-import org.w3c.dom.Node;
-
-
-public class XMLNodeActionManager extends AbstractNodeActionManager {
- public XMLNodeActionManager(IStructuredModel model, Viewer viewer) {
- super(model, ModelQueryUtil.getModelQuery(model), viewer);
- }
-
- public void reformat(Node newElement, boolean deep) {
- try {
- // tell the model that we are about to make a big model change
- model.aboutToChangeModel();
-
- // format selected node
- IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
- formatProcessor.formatNode(newElement);
- } finally {
- // tell the model that we are done with the big model change
- model.changedModel();
- }
- }
-
- public void setModel(IStructuredModel newModel) {
- model = newModel;
- setModelQuery(ModelQueryUtil.getModelQuery(newModel));
- }
-
- protected void setModelQuery(ModelQuery newModelQuery) {
- modelQuery = newModelQuery;
- }
-}

Back to the top