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:
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/JFaceNodeAdapter.java257
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java183
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java120
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java81
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java368
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java53
6 files changed, 0 insertions, 1062 deletions
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 0ea3570340..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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
- * 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.Iterator;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-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 {
-
- final static Class ADAPTER_KEY = IJFaceNodeAdapter.class;
-
- /**
- * debug .option
- */
- private static final boolean DEBUG = getDebugValue();
-
- private static boolean getDebugValue() {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/outline"); //$NON-NLS-1$
- boolean result = (value != null) && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- return result;
- }
-
- JFaceNodeAdapterFactory fAdapterFactory;
- RefreshStructureJob fRefreshJob = null;
-
- public JFaceNodeAdapter(JFaceNodeAdapterFactory adapterFactory) {
- super();
- this.fAdapterFactory = 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_TXTEXT);
- 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_TXTEXT);
- 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)
- //
- ArrayList v = new ArrayList();
- if (object instanceof Node) {
- Node node = (Node) object;
- 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 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 = null;
- if (node instanceof Node) {
- // check for an image from the content model
- image = CMImageUtil.getImage(CMImageUtil.getDeclaration((Node) node));
- if (image == null) {
- /*
- * Create/get image based on Node type. Images are cached
- * transparently in this class, subclasses must do this for
- * themselves if they're going to return their own results.
- */
- image = createImage(node);
- }
- }
- return image;
- }
-
- /**
- * Fetches the label text specific to this object instance.
- */
- public String getLabelText(Object node) {
- return getNodeName(node);
- }
-
- private String getNodeName(Object object) {
- StringBuffer nodeName = new StringBuffer();
- if (object instanceof Node) {
- Node node = (Node) object;
- nodeName.append(node.getNodeName());
-
- if (node.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- nodeName.insert(0, "DOCTYPE:"); //$NON-NLS-1$
- }
-
- }
- return nodeName.toString();
- }
-
-
- public Object getParent(Object object) {
- if (object instanceof Node) {
- Node node = (Node) object;
- return node.getParentNode();
- }
- return null;
- }
-
- private synchronized RefreshStructureJob getRefreshJob() {
- if (fRefreshJob == null) {
- fRefreshJob = new RefreshStructureJob();
- }
- return fRefreshJob;
- }
-
-
- 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) {
- if (type == null) {
- return false;
- }
- 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.
- if (notifier instanceof Node) {
- Collection listeners = fAdapterFactory.getListeners();
- Iterator iterator = listeners.iterator();
-
- while (iterator.hasNext()) {
- Object listener = iterator.next();
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90637
- // if (notifier instanceof Node && (listener instanceof
- // StructuredViewer) && (eventType ==
- // INodeNotifier.STRUCTURE_CHANGED || (eventType ==
- // INodeNotifier.CHANGE && changedFeature == null))) {
- if ((listener instanceof StructuredViewer) && ((eventType == INodeNotifier.STRUCTURE_CHANGED) || (eventType == INodeNotifier.CONTENT_CHANGED) || (eventType == INodeNotifier.CHANGE))) {
- 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) {
- getRefreshJob().refresh(structuredViewer, (Node) notifier);
- }
- }
- }
- }
- }
-}
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 3943403b34..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * 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.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.util.Assert;
-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.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-
-/**
- * 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 {
- public class CMDocumentManagerListenerImpl implements CMDocumentManagerListener {
- private static final int UPDATE_DELAY = 200;
-
- public void cacheCleared(CMDocumentCache cache) {
- // nothing to do
- }
-
- public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) {
- if ((newStatus == CMDocumentCache.STATUS_LOADED) || (newStatus == CMDocumentCache.STATUS_ERROR)) {
- refreshViewers();
- }
- }
-
- public void propertyChanged(CMDocumentManager cmDocumentManager, String propertyName) {
- if (cmDocumentManager.getPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD)) {
- refreshViewers();
- }
- }
-
- private void refreshViewers() {
- Object[] listeners = getListeners().toArray();
- for (int i = 0; i < listeners.length; i++) {
- if (listeners[i] instanceof StructuredViewer) {
- final StructuredViewer viewer = (StructuredViewer) listeners[i];
- Job refresh = new UIJob(XMLUIMessages.refreshoutline_0) {
- public IStatus runInUIThread(IProgressMonitor monitor) {
- Control refreshControl = viewer.getControl();
- if ((refreshControl != null) && !refreshControl.isDisposed()) {
- viewer.refresh(true);
- }
- return Status.OK_STATUS;
- }
- };
- refresh.setSystem(true);
- refresh.setPriority(Job.SHORT);
- refresh.schedule(UPDATE_DELAY);
- }
- else if (listeners[i] instanceof Viewer) {
- final Viewer viewer = (Viewer) listeners[i];
- Job refresh = new UIJob(XMLUIMessages.refreshoutline_0) {
- public IStatus runInUIThread(IProgressMonitor monitor) {
- Control refreshControl = viewer.getControl();
- if ((refreshControl != null) && !refreshControl.isDisposed()) {
- viewer.refresh();
- }
- return Status.OK_STATUS;
- }
- };
- refresh.setSystem(true);
- refresh.setPriority(Job.SHORT);
- refresh.schedule(UPDATE_DELAY);
- }
- }
- }
- }
-
- private CMDocumentManager cmDocumentManager;
- private CMDocumentManagerListenerImpl fCMDocumentManagerListener = null;
- /**
- * This keeps track of all the listeners.
- */
- private Set fListeners = new HashSet();
-
- 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(getAdapterKey(), isShouldRegisterAdapter());
- }
-
- /**
- * 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. It is a shallow copy.
- */
- public synchronized Collection getListeners() {
- return new ArrayList(fListeners);
- }
-
- protected void initAdapter(INodeAdapter adapter, INodeNotifier node) {
- Assert.isTrue(cmDocumentManager == null);
- Assert.isTrue(fCMDocumentManagerListener == null);
-
- // register for CMDocumentManager events
- ModelQueryAdapter mqadapter = (ModelQueryAdapter) node.getAdapterFor(ModelQueryAdapter.class);
- if (mqadapter != null) {
- ModelQuery mquery = mqadapter.getModelQuery();
- if ((mquery != null) && (mquery.getCMDocumentManager() != null)) {
- cmDocumentManager = mquery.getCMDocumentManager();
- fCMDocumentManagerListener = new CMDocumentManagerListenerImpl();
- cmDocumentManager.addListener(fCMDocumentManagerListener);
- }
- }
- }
-
- public void release() {
- // deregister from CMDocumentManager events
- if ((cmDocumentManager != null) && (fCMDocumentManagerListener != null)) {
- cmDocumentManager.removeListener(fCMDocumentManagerListener);
- }
- fListeners.clear();
- if (singletonAdapter != null && singletonAdapter instanceof JFaceNodeAdapter) {
- RefreshStructureJob refreshJob = ((JFaceNodeAdapter) singletonAdapter).fRefreshJob;
- if (refreshJob != null) {
- refreshJob.cancel();
- }
- }
- }
-
- 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 f3c5452f80..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * 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.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-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.provisional.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 {
-
- public JFaceNodeContentProvider() {
- super();
- }
-
- /**
- * 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.
- *
- * @param adaptable
- * java.lang.Object The object to get the adapter for
- */
- protected IJFaceNodeAdapter getAdapter(Object adaptable) {
- if (adaptable instanceof INodeNotifier) {
- INodeAdapter adapter = ((INodeNotifier) adaptable).getAdapterFor(IJFaceNodeAdapter.class);
- 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) {
- if ((oldInput != null) && (oldInput instanceof IStructuredModel)) {
- IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IStructuredModel) oldInput).getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class);
- if (factory != null) {
- factory.removeListener(viewer);
- }
- }
- if ((newInput != null) && (newInput instanceof IStructuredModel)) {
- IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IStructuredModel) newInput).getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class);
- if (factory != null) {
- factory.addListener(viewer);
- }
- }
- }
-}
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 6168ddebcf..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-
-/**
- * A (column) label provider backed by JFaceNodeAdapters.
- */
-public class JFaceNodeLabelProvider extends ColumnLabelProvider {
- /**
- * JFaceNodeLabelProvider constructor comment.
- */
- public JFaceNodeLabelProvider() {
- super();
- }
-
- /**
- * Returns the JFace adapter for the specified object.
- *
- * @param adaptable
- * java.lang.Object The object to get the adapter for
- */
- protected IJFaceNodeAdapter getAdapter(Object adaptable) {
- if (adaptable instanceof INodeNotifier) {
- INodeAdapter adapter = ((INodeNotifier) adaptable).getAdapterFor(IJFaceNodeAdapter.class);
- if (adapter instanceof IJFaceNodeAdapter) {
- return (IJFaceNodeAdapter) adapter;
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- IJFaceNodeAdapter adapter = getAdapter(element);
- if (adapter != null)
- return adapter.getLabelImage(element);
- return super.getImage(element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- IJFaceNodeAdapter adapter = getAdapter(element);
- if (adapter != null)
- return adapter.getLabelText(element);
- return super.getText(element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object,
- * java.lang.String)
- */
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java
deleted file mode 100644
index 55c93901e5..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-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 multiple structured
- * viewers. When a new request comes in, the current run is cancelled, the new
- * request is added to the queue, then the job is re-scheduled. Support for
- * multiple structured viewers is required because refresh updates are usually
- * triggered by model changes, and the model may be visible in more than one
- * viewer.
- *
- * @author pavery
- */
-class RefreshStructureJob extends Job {
-
- /** debug flag */
- static final boolean DEBUG;
- private static final long UPDATE_DELAY = 300;
- static {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/refreshStructure"); //$NON-NLS-1$
- DEBUG = (value != null) && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
- /** List of refresh requests (Nodes) */
- private final List fRefreshes;
- /** List of update requests (Nodes) */
- private final List fUpdates;
- /** List of update requests (Nodes) */
- private final List fUpdateProperties;
- /** the structured viewers */
- Set fRefreshViewers = new HashSet(3);
- Set fUpdateViewers = new HashSet(3);
-
- public RefreshStructureJob() {
- super(XMLUIMessages.refreshoutline_0);
- setPriority(Job.LONG);
- setSystem(true);
- fRefreshes = new ArrayList(5);
- fUpdates = new ArrayList(5);
- fUpdateProperties = new ArrayList(5);
- }
-
- private synchronized void addUpdateRequest(Node newNodeRequest, String[] updateProperties) {
- /*
- * If we get to here, either from existing request list being zero
- * length, or no exisitng requests "matched" new request, then add the
- * new request.
- */
- fUpdates.add(newNodeRequest);
- fUpdateProperties.add(updateProperties);
- }
-
- private synchronized void addUpdateViewer(StructuredViewer viewer) {
- fUpdateViewers.add(viewer);
- }
-
- private synchronized void addRefreshRequest(Node newNodeRequest) {
- /*
- * note: the caller must NOT pass in null node request (which, since
- * private method, we do not need to gaurd against here, as long as we
- * gaurd against it in calling method.
- */
- int size = fRefreshes.size();
- for (int i = 0; i < size; i++) {
- Node existingNodeRequest = (Node) fRefreshes.get(i);
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=157427 If we
- * already have a request which equals the new request, discard
- * the new request
- */
- if (existingNodeRequest.equals(newNodeRequest)) {
- return;
- }
- /*
- * If we already have a request which contains the new request,
- * discard the new request
- */
- if (contains(existingNodeRequest, newNodeRequest)) {
- return;
- }
- /*
- * If new request contains any existing requests, replace it with
- * new request. ISSUE: technically, we should replace ALL
- * contained, existing requests (such as if many siblings already
- * que'd up when their common parent is then requested, but, I'm
- * not sure if that occurs much, in practice, or if there's an
- * algorithm to quickly find them all. Actually, I guess we could
- * just go through the _rest_ of the list (i+1 to size) and remove
- * any that are contained by new request ... in future :) .
- */
- if (contains(newNodeRequest, existingNodeRequest)) {
- fRefreshes.set(i, newNodeRequest);
- return;
- }
- }
- /*
- * If we get to here, either from existing request list being zero
- * length, or no exisitng requests "matched" new request, then add the
- * new request.
- */
- fRefreshes.add(newNodeRequest);
- }
-
- private synchronized void addRefreshViewer(StructuredViewer viewer) {
- fRefreshViewers.add(viewer);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#canceling()
- */
- protected void canceling() {
- fUpdates.clear();
- fUpdateViewers.clear();
- super.canceling();
- }
-
- /**
- * Simple hierarchical containment relationship. Note, this method returns
- * "false" if the two nodes are equal!
- *
- * @param root
- * @param possible
- * @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 child 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;
- }
-
- // check parentage
- Node current = possible;
- // loop parents
- while ((current != null) && (current.getNodeType() != Node.DOCUMENT_NODE)) {
- // found it
- if (root.equals(current)) {
- if (DEBUG) {
- System.out.println(" !!! found: " + possible.getNodeName() + " in subelement of: " + root.getNodeName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return true;
- }
- current = current.getParentNode();
- }
- // never found it
- return false;
- }
-
- /**
- * Refresh must be on UI thread because it's on a SWT widget.
- *
- * @param node
- */
- private void doRefresh(final Node node, final StructuredViewer[] viewers) {
- 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$
- }
-
- for (int i = 0; i < viewers.length; i++) {
- if (!viewers[i].getControl().isDisposed()) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- viewers[i].refresh(true);
- }
- else {
- viewers[i].refresh(node, true);
- }
- }
- else {
- if (DEBUG) {
- System.out.println(" !!! skipped refreshing disposed viewer: " + viewers[i]); //$NON-NLS-1$
- }
- }
- }
- }
- });
- }
-
- /**
- * Update must be on UI thread because it's on a SWT widget.
- *
- * @param node
- */
- private void doUpdate(final StructuredViewer[] viewers, final Node node, final String[] properties) {
- 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$
- }
-
- for (int i = 0; i < viewers.length; i++) {
- if (!viewers[i].getControl().isDisposed()) {
- viewers[i].update(node, properties);
- }
- else {
- if (DEBUG) {
- System.out.println(" !!! skipped refreshing disposed viewer: " + viewers[i]); //$NON-NLS-1$
- }
- }
- }
- }
- });
- }
-
- /**
- * This method also synchronized because it accesses the fRefreshes queue
- * and fRefreshViewers list
- *
- * @return an array containing and array of the currently requested Nodes
- * to refresh and the viewers in which to refresh them
- */
- private synchronized Object[] getRefreshRequests() {
- Node[] toRefresh = (Node[]) fRefreshes.toArray(new Node[fRefreshes.size()]);
- fRefreshes.clear();
-
- StructuredViewer[] viewers = (StructuredViewer[]) fRefreshViewers.toArray(new StructuredViewer[fRefreshViewers.size()]);
- fRefreshViewers.clear();
-
- return new Object[]{toRefresh, viewers};
- }
-
- /**
- * This method also synchronized because it accesses the fUpdates queue
- * and fUpdateViewers list
- *
- * @return an array containing and array of the currently requested Nodes
- * to refresh and the viewers in which to refresh them
- */
- private synchronized Object[] getUpdateRequests() {
- Node[] toUpdate = (Node[]) fUpdates.toArray(new Node[fUpdates.size()]);
- fUpdates.clear();
-
- StructuredViewer[] viewers = (StructuredViewer[]) fUpdateViewers.toArray(new StructuredViewer[fUpdateViewers.size()]);
- fUpdateViewers.clear();
-
- String[][] properties = (String[][]) fUpdateProperties.toArray(new String[fUpdateProperties.size()][]);
- fUpdateProperties.clear();
-
- return new Object[]{toUpdate, viewers, properties};
- }
-
- /**
- * Invoke a refresh on the viewer on the given node.
- *
- * @param node
- */
- public void refresh(StructuredViewer viewer, Node node) {
- if (node == null) {
- return;
- }
-
- addRefreshViewer(viewer);
- addRefreshRequest(node);
- schedule(UPDATE_DELAY);
- }
-
- /**
- * Invoke a refresh on the viewer on the given node.
- *
- * @param node
- */
- public void update(StructuredViewer viewer, Node node, String[] properties) {
- if (node == null) {
- return;
- }
-
- addUpdateViewer(viewer);
- addUpdateRequest(node, properties);
- schedule(UPDATE_DELAY);
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- performUpdates();
-
- performRefreshes(monitor);
- }
- finally {
- monitor.done();
- }
- return status;
- }
-
- private void performRefreshes(IProgressMonitor monitor) {
- // Retrieve BOTH viewers and Nodes on one block
- Object[] requests = getRefreshRequests();
- Node[] nodes = (Node[]) requests[0];
- StructuredViewer[] viewers = (StructuredViewer[]) requests[1];
-
- for (int i = 0; i < nodes.length; i++) {
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- doRefresh(nodes[i], viewers);
- }
- }
-
- private void performUpdates() {
- // Retrieve BOTH viewers and Nodes on one block
- Object[] requests = getUpdateRequests();
- Node[] nodes = (Node[]) requests[0];
- StructuredViewer[] viewers = (StructuredViewer[]) requests[1];
- String[][] properties = (String[][]) requests[2];
-
- for (int i = 0; i < nodes.length; i++) {
- doUpdate(viewers, nodes[i], properties[i]);
- }
- }
-
-}
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 f858071966..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * 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.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-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.internal.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
- fModel.aboutToChangeModel();
-
- // format selected node
- IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
- formatProcessor.formatNode(newElement);
- }
- finally {
- // tell the model that we are done with the big model change
- fModel.changedModel();
- }
- }
-
- public void setModel(IStructuredModel newModel) {
- fModel = newModel;
- setModelQuery(ModelQueryUtil.getModelQuery(newModel));
- }
-
- protected void setModelQuery(ModelQuery newModelQuery) {
- modelQuery = newModelQuery;
- }
-}

Back to the top