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/views')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/AbstractXMLContentOutlineConfiguration.java342
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java411
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java282
3 files changed, 0 insertions, 1035 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/AbstractXMLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/AbstractXMLContentOutlineConfiguration.java
deleted file mode 100644
index 00b2cf507b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/AbstractXMLContentOutlineConfiguration.java
+++ /dev/null
@@ -1,342 +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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.views.contentoutline;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.IReleasable;
-import org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeContentProvider;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
-import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager;
-import org.eclipse.wst.xml.ui.internal.dnd.DragNodeCommand;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/**
- * Basic Outline Configuration for generic XML support. Expects that the viewer's
- * input will be the DOM Model, and provides basic label and content providers.
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration
- * @since 3.1
- */
-public abstract class AbstractXMLContentOutlineConfiguration extends ContentOutlineConfiguration {
- private class ActionManagerMenuListener implements IMenuListener, IReleasable {
- private XMLNodeActionManager fActionManager;
- private TreeViewer fTreeViewer;
-
- public ActionManagerMenuListener(TreeViewer viewer) {
- fTreeViewer = viewer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- public void menuAboutToShow(IMenuManager manager) {
- if (fActionManager == null) {
- fActionManager = createNodeActionManager(fTreeViewer);
- }
- if (fActionManager != null) {
- fActionManager.fillContextMenu(manager, fTreeViewer.getSelection());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.internal.IReleasable#release()
- */
- public void release() {
- fTreeViewer = null;
- if (fActionManager != null) {
- fActionManager.setModel(null);
- }
- }
- }
-
- private static class StatusLineLabelProvider extends JFaceNodeLabelProvider {
- public StatusLineLabelProvider() {
- super();
- }
-
- public String getText(Object element) {
- if (element == null)
- return null;
-
- if (!(element instanceof Node)) {
- return super.getText(element);
- }
-
- StringBuffer s = new StringBuffer();
- Node node = (Node) element;
- while (node != null) {
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- s.insert(0, super.getText(node));
- }
-
- if (node.getNodeType() == Node.ATTRIBUTE_NODE)
- node = ((Attr) node).getOwnerElement();
- else
- node = node.getParentNode();
-
- if (node != null && node.getNodeType() != Node.DOCUMENT_NODE) {
- s.insert(0, IPath.SEPARATOR);
- }
- }
- return s.toString();
- }
- }
-
- private IContentProvider fContentProvider = null;
-
- private ActionManagerMenuListener fContextMenuFiller = null;
-
- private ILabelProvider fLabelProvider = null;
-
- boolean fShowAttributes = false;
-
- private ILabelProvider fSimpleLabelProvider;
- private TransferDragSourceListener[] fTransferDragSourceListeners;
-
- private TransferDropTargetListener[] fTransferDropTargetListeners;
-
- /**
- * Create new instance of XMLContentOutlineConfiguration
- */
- public AbstractXMLContentOutlineConfiguration() {
- // Must have empty constructor to createExecutableExtension
- super();
- }
-
- /**
- * Returns the NodeActionManager to use for the given treeViewer.
- * <p>
- * Not API. May be removed in the future.
- * </p>
- *
- * @param treeViewer
- * the TreeViewer associated with this configuration
- * @return a node action manager for use with this tree viewer
- */
- protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer) {
- return new XMLNodeActionManager((IStructuredModel) treeViewer.getInput(), treeViewer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getContentProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public IContentProvider getContentProvider(TreeViewer viewer) {
- if (fContentProvider == null) {
- fContentProvider = new JFaceNodeContentProvider();
- }
- return fContentProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getLabelProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public ILabelProvider getLabelProvider(TreeViewer viewer) {
- if (fLabelProvider == null) {
- fLabelProvider = new JFaceNodeLabelProvider();
- }
- return fLabelProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getMenuListener(org.eclipse.jface.viewers.TreeViewer)
- */
- public IMenuListener getMenuListener(TreeViewer viewer) {
- if (fContextMenuFiller == null) {
- fContextMenuFiller = new ActionManagerMenuListener(viewer);
- }
- return fContextMenuFiller;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getPreferenceStore()
- */
- protected IPreferenceStore getPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- public ILabelProvider getStatusLineLabelProvider(TreeViewer treeViewer) {
- if (fSimpleLabelProvider == null) {
- fSimpleLabelProvider = new StatusLineLabelProvider();
- }
- return fSimpleLabelProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getTransferDragSourceListeners(org.eclipse.jface.viewers.TreeViewer)
- */
- public TransferDragSourceListener[] getTransferDragSourceListeners(final TreeViewer treeViewer) {
- if (fTransferDragSourceListeners == null) {
- fTransferDragSourceListeners = new TransferDragSourceListener[]{new TransferDragSourceListener() {
-
- public void dragFinished(DragSourceEvent event) {
- LocalSelectionTransfer.getTransfer().setSelection(null);
- }
-
- public void dragSetData(DragSourceEvent event) {
- }
-
- public void dragStart(DragSourceEvent event) {
- LocalSelectionTransfer.getTransfer().setSelection(treeViewer.getSelection());
- }
-
- public Transfer getTransfer() {
- return LocalSelectionTransfer.getTransfer();
- }
- }};
- }
-
- return fTransferDragSourceListeners;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getTransferDropTargetListeners(org.eclipse.jface.viewers.TreeViewer)
- */
- public TransferDropTargetListener[] getTransferDropTargetListeners(final TreeViewer treeViewer) {
- if (fTransferDropTargetListeners == null) {
- fTransferDropTargetListeners = new TransferDropTargetListener[]{new TransferDropTargetListener() {
- public void dragEnter(DropTargetEvent event) {
- }
-
- public void dragLeave(DropTargetEvent event) {
- }
-
- public void dragOperationChanged(DropTargetEvent event) {
- }
-
- public void dragOver(DropTargetEvent event) {
- event.feedback = DND.FEEDBACK_SELECT;
- float feedbackFloat = getHeightInItem(event);
- if (feedbackFloat > 0.75) {
- event.feedback = DND.FEEDBACK_INSERT_AFTER;
- }
- else if (feedbackFloat < 0.25) {
- event.feedback = DND.FEEDBACK_INSERT_BEFORE;
- }
- event.feedback |= DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
- }
-
- public void drop(DropTargetEvent event) {
- if (event.operations != DND.DROP_NONE && LocalSelectionTransfer.getTransfer().getSelection() != null && !LocalSelectionTransfer.getTransfer().getSelection().isEmpty()) {
- IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
- if (selection != null && !selection.isEmpty() && event.item != null && event.item.getData() != null) {
- /*
- * the command uses these numbers instead of the
- * feedback constants (even though it converts in
- * the other direction as well)
- */
- float feedbackFloat = getHeightInItem(event);
-
- final DragNodeCommand command = new DragNodeCommand(event.item.getData(), feedbackFloat, event.operations, event.detail, selection.toList(), treeViewer);
- if (command != null && command.canExecute()) {
- SafeRunnable.run(new SafeRunnable() {
- public void run() throws Exception {
- command.execute();
- }
- });
- }
- }
- }
- }
-
- public void dropAccept(DropTargetEvent event) {
- }
-
- private float getHeightInItem(DropTargetEvent event) {
- if (event.item == null)
- return .5f;
- if (event.item instanceof TreeItem) {
- TreeItem treeItem = (TreeItem) event.item;
- Control control = treeItem.getParent();
- Point point = control.toControl(new Point(event.x, event.y));
- Rectangle bounds = treeItem.getBounds();
- return (float) (point.y - bounds.y) / (float) bounds.height;
- }
- else if (event.item instanceof TableItem) {
- TableItem tableItem = (TableItem) event.item;
- Control control = tableItem.getParent();
- Point point = control.toControl(new Point(event.x, event.y));
- Rectangle bounds = tableItem.getBounds(0);
- return (float) (point.y - bounds.y) / (float) bounds.height;
- }
- else {
- return 0.0F;
- }
- }
-
- public Transfer getTransfer() {
- return LocalSelectionTransfer.getTransfer();
- }
-
- public boolean isEnabled(DropTargetEvent event) {
- return getTransfer().isSupportedType(event.currentDataType);
- }
- }};
- }
- return fTransferDropTargetListeners;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#unconfigure(org.eclipse.jface.viewers.TreeViewer)
- */
- public void unconfigure(TreeViewer viewer) {
- super.unconfigure(viewer);
- fTransferDragSourceListeners = null;
- fTransferDropTargetListeners = null;
- if (fContextMenuFiller != null) {
- fContextMenuFiller.release();
- fContextMenuFiller = null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java
deleted file mode 100644
index ec3f156834..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java
+++ /dev/null
@@ -1,411 +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.views.contentoutline;
-
-import java.util.List;
-
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateAction;
-import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateActionContributionItem;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeContentProvider;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * More advanced Outline Configuration for XML support. Expects that the viewer's
- * input will be the DOM Model.
- *
- * @see AbstractXMLContentOutlineConfiguration
- * @since 1.0
- */
-public class XMLContentOutlineConfiguration extends AbstractXMLContentOutlineConfiguration {
- static final String ATTR_NAME = "name";
- static final String ATTR_ID = "id";
-
- private class AttributeShowingLabelProvider extends JFaceNodeLabelProvider {
- public boolean isLabelProperty(Object element, String property) {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object o) {
- StringBuffer text = null;
- if (o instanceof Node) {
- Node node = (Node) o;
- if ((node.getNodeType() == Node.ELEMENT_NODE) && fShowAttributes) {
- text = new StringBuffer(super.getText(o));
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
- if (node.hasAttributes()) {
- Element element = (Element) node;
- NamedNodeMap attributes = element.getAttributes();
- Node idTypedAttribute = null;
- Node requiredAttribute = null;
- boolean hasId = false;
- boolean hasName = false;
- Node shownAttribute = null;
-
- // try to get content model element
- // declaration
- CMElementDeclaration elementDecl = null;
- ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- if (mq != null) {
- elementDecl = mq.getCMElementDeclaration(element);
- }
- // find an attribute of type (or just named)
- // ID
- if (elementDecl != null) {
- int i = 0;
- while ((i < attributes.getLength()) && (idTypedAttribute == null)) {
- Node attr = attributes.item(i);
- String attrName = attr.getNodeName();
- CMNamedNodeMap attributeDeclarationMap = elementDecl.getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributeDeclarationMap);
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent(element, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attributeDeclarationMap = allAttributes;
-
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributeDeclarationMap.getNamedItem(attrName);
- if (attrDecl != null) {
- if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) {
- idTypedAttribute = attr;
- }
- else if ((attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) && (requiredAttribute == null)) {
- // as a backup, keep tabs on
- // any required
- // attributes
- requiredAttribute = attr;
- }
- else {
- hasId = hasId || attrName.equals(ATTR_ID);
- hasName = hasName || attrName.equals(ATTR_NAME);
- }
- }
- ++i;
- }
- }
-
- /*
- * If no suitable attribute was found, try using a
- * required attribute, if none, then prefer "id" or
- * "name", otherwise just use first attribute
- */
- if (idTypedAttribute != null) {
- shownAttribute = idTypedAttribute;
- }
- else if (requiredAttribute != null) {
- shownAttribute = requiredAttribute;
- }
- else if (hasId) {
- shownAttribute = attributes.getNamedItem(ATTR_ID);
- }
- else if (hasName) {
- shownAttribute = attributes.getNamedItem(ATTR_NAME);
- }
- if (shownAttribute == null) {
- shownAttribute = attributes.item(0);
- }
-
- // display the attribute and value (without quotes)
- String attributeName = shownAttribute.getNodeName();
- if ((attributeName != null) && (attributeName.length() > 0)) {
- text.append(" "); //$NON-NLS-1$
- text.append(attributeName);
- String attributeValue = shownAttribute.getNodeValue();
- if ((attributeValue != null) && (attributeValue.length() > 0)) {
- text.append("="); //$NON-NLS-1$
- text.append(StringUtils.strip(attributeValue));
- }
- }
- }
- }
- else {
- text = new StringBuffer(super.getText(o));
- }
- }
- else {
- return super.toString();
- }
- return text.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
- */
- public String getToolTipText(Object element) {
- if (element instanceof Node) {
- switch (((Node) element).getNodeType()) {
- case Node.COMMENT_NODE :
- case Node.CDATA_SECTION_NODE :
- case Node.PROCESSING_INSTRUCTION_NODE :
- case Node.TEXT_NODE : {
- String nodeValue = ((Node) element).getNodeValue().trim();
- return prepareText(nodeValue);
- }
- case Node.ELEMENT_NODE : {
- // show the preceding comment's tooltip information
- Node previous = ((Node) element).getPreviousSibling();
- if (previous != null && previous.getNodeType() == Node.TEXT_NODE)
- previous = previous.getPreviousSibling();
- if (previous != null && previous.getNodeType() == Node.COMMENT_NODE)
- return getToolTipText(previous);
- }
- }
- }
- return super.getToolTipText(element);
- }
-
- /**
- * Remove leading indentation from each line in the give string.
- * @param text
- * @return
- */
- private String prepareText(String text) {
- StringBuffer nodeText = new StringBuffer();
- for (int i = 0; i < text.length(); i++) {
- char c = text.charAt(i);
- if (c != '\r' && c != '\n') {
- nodeText.append(c);
- }
- else if (c == '\r' || c == '\n') {
- nodeText.append('\n');
- while (Character.isWhitespace(c) && i < text.length()) {
- i++;
- c = text.charAt(i);
- }
- nodeText.append(c);
- }
- }
- return nodeText.toString();
- }
- }
-
- /**
- * Toggle action for whether or not to display element's first attribute
- */
- private class ToggleShowAttributeAction extends PropertyChangeUpdateAction {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
- private TreeViewer fTreeViewer;
-
- public ToggleShowAttributeAction(IPreferenceStore store, String preference, TreeViewer treeViewer) {
- super(XMLUIMessages.XMLContentOutlineConfiguration_0, store, preference, true);
- setToolTipText(getText());
- // images needed
- // setDisabledImageDescriptor(SYNCED_D);
- // (nsd) temporarily re-use Properties view image
- setImageDescriptor(EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_OBJ_PROP_PS));
- fTreeViewer = treeViewer;
- update();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
- fShowAttributes = isChecked();
-
- // notify the configuration of the change
- enableShowAttributes(fShowAttributes, fTreeViewer);
-
- // refresh the outline view
- fTreeViewer.refresh(true);
- }
- }
-
- private ILabelProvider fAttributeShowingLabelProvider;
- private IContentProvider fContentProvider = null;
-
- boolean fShowAttributes = false;
-
- /*
- * Preference key for Show Attributes
- */
- private final String OUTLINE_SHOW_ATTRIBUTE_PREF = "outline-show-attribute"; //$NON-NLS-1$
-
- /**
- * Create new instance of XMLContentOutlineConfiguration
- */
- public XMLContentOutlineConfiguration() {
- // Must have empty constructor to createExecutableExtension
- super();
-
- /**
- * Set up our preference store here. This is done so that subclasses
- * aren't required to set their own values, although if they have,
- * those will be used instead.
- */
- IPreferenceStore store = getPreferenceStore();
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_NODE, "1, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.PROCESSING_INSTRUCTION_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.PROCESSING_INSTRUCTION_NODE, "2, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_TYPE_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_TYPE_NODE, "3, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_FRAGMENT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_FRAGMENT_NODE, "4, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.COMMENT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.COMMENT_NODE, "5, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ATTRIBUTE_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ATTRIBUTE_NODE, "6, false");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ELEMENT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ELEMENT_NODE, "7, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_REFERENCE_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_REFERENCE_NODE, "8, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.CDATA_SECTION_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.CDATA_SECTION_NODE, "9, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_NODE, "10, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.NOTATION_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.NOTATION_NODE, "11, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.TEXT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.TEXT_NODE, "12, false");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#createMenuContributions(org.eclipse.jface.viewers.TreeViewer)
- */
- protected IContributionItem[] createMenuContributions(TreeViewer viewer) {
- IContributionItem[] items;
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
- IContributionItem showAttributeItem = new PropertyChangeUpdateActionContributionItem(new ToggleShowAttributeAction(getPreferenceStore(), OUTLINE_SHOW_ATTRIBUTE_PREF, viewer));
-
- items = super.createMenuContributions(viewer);
- if (items == null) {
- items = new IContributionItem[]{showAttributeItem};
- }
- else {
- IContributionItem[] combinedItems = new IContributionItem[items.length + 1];
- System.arraycopy(items, 0, combinedItems, 0, items.length);
- combinedItems[items.length] = showAttributeItem;
- items = combinedItems;
- }
- return items;
- }
-
- /**
- * Notifies this configuration that the flag that indicates whether or not
- * to show attribute values in the tree viewer has changed. The tree
- * viewer is automatically refreshed afterwards to update the labels.
- *
- * Clients should not call this method, but rather should react to it.
- *
- * @param showAttributes
- * flag indicating whether or not to show attribute values in
- * the tree viewer
- * @param treeViewer
- * the TreeViewer associated with this configuration
- */
- protected void enableShowAttributes(boolean showAttributes, TreeViewer treeViewer) {
- // nothing by default
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getContentProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public IContentProvider getContentProvider(TreeViewer viewer) {
- if (fContentProvider == null) {
- fContentProvider = new JFaceNodeContentProvider();
- }
- return fContentProvider;
- }
-
- private Object getFilteredNode(Object object) {
- if (object instanceof Node) {
- Node node = (Node) object;
- short nodeType = node.getNodeType();
- // replace attribute node in selection with its parent
- if (nodeType == Node.ATTRIBUTE_NODE) {
- node = ((Attr) node).getOwnerElement();
- }
- // anything else not visible, replace with parent node
- else if (nodeType == Node.TEXT_NODE) {
- node = node.getParentNode();
- }
- return node;
- }
- return object;
- }
-
- private Object[] getFilteredNodes(Object[] filteredNodes) {
- for (int i = 0; i < filteredNodes.length; i++) {
- filteredNodes[i] = getFilteredNode(filteredNodes[i]);
- }
- return filteredNodes;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getLabelProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public ILabelProvider getLabelProvider(TreeViewer viewer) {
- if (fAttributeShowingLabelProvider == null) {
- fAttributeShowingLabelProvider = new AttributeShowingLabelProvider();
- }
- return fAttributeShowingLabelProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getSelection(org.eclipse.jface.viewers.TreeViewer,
- * org.eclipse.jface.viewers.ISelection)
- */
- public ISelection getSelection(TreeViewer viewer, ISelection selection) {
- ISelection filteredSelection = selection;
- if (selection instanceof IStructuredSelection) {
- Object[] filteredNodes = getFilteredNodes(((IStructuredSelection) selection).toArray());
- filteredSelection = new StructuredSelection(filteredNodes);
- }
- return filteredSelection;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java
deleted file mode 100644
index a4f3a4e164..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java
+++ /dev/null
@@ -1,282 +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
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.views.properties;
-
-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.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.progress.UIJob;
-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.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration;
-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.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.properties.XMLPropertySource;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Configuration for property sheet page which shows XML content.
- *
- * @see org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration
- * @since 1.0
- */
-public class XMLPropertySheetConfiguration extends PropertySheetConfiguration {
- private class CMDocumentManagerListenerImpl implements CMDocumentManagerListener {
- 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)) {
- refreshPages();
- }
- }
-
- public void propertyChanged(CMDocumentManager cmDocumentManager, String propertyName) {
- if (cmDocumentManager.getPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD)) {
- refreshPages();
- }
- }
-
- private void refreshPages() {
- getPropertiesRefreshJob().addPropertySheetPage(fPropertySheetPage);
- getPropertiesRefreshJob().schedule(PropertiesRefreshJob.UPDATE_DELAY);
- }
- }
-
- private class PropertiesRefreshJob extends UIJob {
- public static final int UPDATE_DELAY = 200;
-
- Set propertySheetPages = null;
-
- public PropertiesRefreshJob() {
- super(XMLUIMessages.JFaceNodeAdapter_1);
- setSystem(true);
- setPriority(Job.SHORT);
- propertySheetPages = new HashSet(1);
- }
-
- void addPropertySheetPage(IPropertySheetPage page) {
- if (page != null && propertySheetPages != null) {
- propertySheetPages.add(page);
- schedule(UPDATE_DELAY);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#canceling()
- */
- protected void canceling() {
- propertySheetPages.clear();
- super.canceling();
- }
-
- public IStatus runInUIThread(IProgressMonitor monitor) {
- Object[] pages = propertySheetPages.toArray();
- propertySheetPages.clear();
-
- for (int i = 0; i < pages.length; i++) {
- PropertySheetPage page = (PropertySheetPage) pages[i];
- if ((page != null) && (page.getControl() != null) && !page.getControl().isDisposed()) {
- page.refresh();
- }
- }
-
- return Status.OK_STATUS;
- }
- }
-
- private class XMLPropertySheetRefreshAdapter implements INodeAdapter {
- public boolean isAdapterForType(Object type) {
- return false;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- if (fPropertySheetPage != null) {
- getPropertiesRefreshJob().addPropertySheetPage(fPropertySheetPage);
- }
- }
- }
-
- private class XMLPropertySourceProvider implements IPropertySourceProvider {
- private IPropertySource fPropertySource = null;
- private INodeNotifier fSource = null;
-
- public IPropertySource getPropertySource(Object object) {
- if ((fSource != null) && object.equals(fSource)) {
- return fPropertySource;
- }
-
- if (object instanceof IDOMNode) {
- fSource = (INodeNotifier) object;
- fPropertySource = (IPropertySource) fSource.getAdapterFor(IPropertySource.class);
- if (fPropertySource == null) {
- fPropertySource = new XMLPropertySource((INodeNotifier) object) {
- public void setPropertyValue(Object nameObject, Object value) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=218979
- for (int i = 0; i < fSelectedNotifiers.length; i++) {
- fSelectedNotifiers[i].removeAdapter(fRefreshAdapter);
- }
- super.setPropertyValue(nameObject, value);
- for (int i = 0; i < fSelectedNotifiers.length; i++) {
- fSelectedNotifiers[i].addAdapter(fRefreshAdapter);
- }
- }
- };
- }
- }
- else {
- fSource = null;
- fPropertySource = null;
- }
- return fPropertySource;
- }
- }
-
- private CMDocumentManagerListenerImpl fCMDocumentManagerListener = new CMDocumentManagerListenerImpl();
- private PropertiesRefreshJob fPropertiesRefreshJob = null;
- IPropertySheetPage fPropertySheetPage = null;
- private IPropertySourceProvider fPropertySourceProvider = null;
- private INodeAdapter fRefreshAdapter = new XMLPropertySheetRefreshAdapter();
- private CMDocumentManager[] fSelectedCMDocumentManagers = new CMDocumentManager[0];
- private INodeNotifier[] fSelectedNotifiers = new INodeNotifier[0];
-
-
- /**
- * Create new instance of XMLPropertySheetConfiguration
- */
- public XMLPropertySheetConfiguration() {
- // Must have empty constructor to createExecutableExtension
- super();
- }
-
- public ISelection getInputSelection(IWorkbenchPart selectingPart, ISelection selection) {
- if (fSelectedNotifiers != null) {
- for (int i = 0; i < fSelectedNotifiers.length; i++) {
- fSelectedNotifiers[i].removeAdapter(fRefreshAdapter);
- }
- fSelectedNotifiers = null;
- }
- for (int i = 0; i < fSelectedCMDocumentManagers.length; i++) {
- fSelectedCMDocumentManagers[i].removeListener(fCMDocumentManagerListener);
- }
-
- ISelection preferredSelection = selection;
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSel = (IStructuredSelection) selection;
-
- /*
- * On Attr nodes, select the owner Element. On Text nodes, select
- * the parent Element.
- */
- Object[] selectedObjects = new Object[structuredSel.size()];
- System.arraycopy(structuredSel.toArray(), 0, selectedObjects, 0, selectedObjects.length);
- for (int i = 0; i < selectedObjects.length; i++) {
- Object inode = selectedObjects[i];
- if (inode instanceof Node) {
- Node node = (Node) inode;
- // replace Attribute Node with its owner
- Node parentNode = node.getParentNode();
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- Element ownerElement = ((Attr) node).getOwnerElement();
- selectedObjects[i] = ownerElement;
- }
- // replace Text Node with its parent
- else if (((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.CDATA_SECTION_NODE)) && (parentNode != null)) {
- selectedObjects[i] = parentNode;
- }
- }
- }
-
- if (selectedObjects.length > 0) {
- Set managers = new HashSet(1);
- Set selectedNotifiers = new HashSet(1);
-
- for (int i = 0; i < selectedObjects.length; i++) {
- if (selectedObjects[i] instanceof Node) {
- ModelQuery query = ModelQueryUtil.getModelQuery(((Node) selectedObjects[i]).getOwnerDocument());
- if (query != null) {
- CMDocumentManager mgr = query.getCMDocumentManager();
- if (mgr != null) {
- managers.add(mgr);
- mgr.addListener(fCMDocumentManagerListener);
- }
- }
- }
- /*
- * Add UI refresh adapters and remember notifiers for
- * later removal
- */
- if (selectedObjects[i] instanceof INodeNotifier) {
- selectedNotifiers.add(selectedObjects[i]);
- ((INodeNotifier) selectedObjects[i]).addAdapter(fRefreshAdapter);
- }
- }
- fSelectedCMDocumentManagers = (CMDocumentManager[]) managers.toArray(new CMDocumentManager[managers.size()]);
- fSelectedNotifiers = (INodeNotifier[]) selectedNotifiers.toArray(new INodeNotifier[selectedNotifiers.size()]);
- }
-
-
- preferredSelection = new StructuredSelection(selectedObjects);
- }
- return preferredSelection;
- }
-
- PropertiesRefreshJob getPropertiesRefreshJob() {
- if (fPropertiesRefreshJob == null) {
- fPropertiesRefreshJob = new PropertiesRefreshJob();
- }
- return fPropertiesRefreshJob;
- }
-
- public IPropertySourceProvider getPropertySourceProvider(IPropertySheetPage page) {
- if (fPropertySourceProvider == null) {
- fPropertySheetPage = page;
- fPropertySourceProvider = new XMLPropertySourceProvider();
- }
- return fPropertySourceProvider;
- }
-
-
- public void unconfigure() {
- super.unconfigure();
- for (int i = 0; i < fSelectedCMDocumentManagers.length; i++) {
- fSelectedCMDocumentManagers[i].removeListener(fCMDocumentManagerListener);
- }
- if(fPropertiesRefreshJob != null) {
- fPropertiesRefreshJob.cancel();
- fPropertiesRefreshJob.propertySheetPages = null;
- }
- fPropertySheetPage = null;
- }
-}

Back to the top