Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/DOMPropertyDescriptorFactory.java135
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewer.java25
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewerActionBarContributor.java21
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java228
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourcePageActionContributor.java62
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java459
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeExtension.java557
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java66
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorActionDefinitionIds.java33
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorMessages.java51
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginHOLD_OLD.java53
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImageHelper.java157
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImages.java27
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorResources.properties30
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorActionBarContributor.java93
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java938
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java319
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeContentProvider.java320
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeHelpContextIds.java31
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreePropertyDescriptorFactory.java118
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java334
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java170
22 files changed, 0 insertions, 4227 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/DOMPropertyDescriptorFactory.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/DOMPropertyDescriptorFactory.java
deleted file mode 100644
index 5bebb72cca..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/DOMPropertyDescriptorFactory.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-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.properties.EnumeratedStringPropertyDescriptor;
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-
-public class DOMPropertyDescriptorFactory {
-
- protected static final String HACK = "hack"; //$NON-NLS-1$
-
- public DOMPropertyDescriptorFactory() {
- }
-
- public IPropertyDescriptor createAttributePropertyDescriptor(Attr attr) {
- IPropertyDescriptor result = null;
-
- String attributeName = attr.getName();
-
- ModelQuery mq = ModelQueryUtil.getModelQuery(attr.getOwnerDocument());
-
- if (mq != null) {
- CMAttributeDeclaration ad = mq.getCMAttributeDeclaration(attr);
- if (ad != null) {
- String[] valuesArray = mq.getPossibleDataTypeValues(attr.getOwnerElement(), ad);
- if ((valuesArray != null) && (valuesArray.length > 0)) {
- result = new EnumeratedStringPropertyDescriptor(attributeName, attributeName, valuesArray);
- }
- }
- }
-
- if (result == null) {
- result = createDefaultPropertyDescriptor(attributeName);
- }
- return result;
- }
-
- public IPropertyDescriptor createCDATASectionPropertyDescriptor(CDATASection cdataSection) {
- return createDefaultPropertyDescriptor(HACK);
- }
-
- public IPropertyDescriptor createCommentPropertyDescriptor(Comment comment) {
- return createDefaultPropertyDescriptor(HACK);
- }
-
- protected IPropertyDescriptor createDefaultPropertyDescriptor(String attributeName) {
- TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attributeName, attributeName);
- return descriptor;
- }
-
- public IPropertyDescriptor createDocumentTypePropertyDescriptor(DocumentType documentType) {
- return null; // new TextPropertyDescriptor(HACK, HACK);
- }
-
- public IPropertyDescriptor createElementPropertyDescriptor(Element element) {
- return createDefaultPropertyDescriptor(HACK);
- }
-
- public IPropertyDescriptor createEntityReferencePropertyDescriptor(EntityReference entityReference) {
- return createDefaultPropertyDescriptor(HACK);
- }
-
- public IPropertyDescriptor createProcessingInstructionPropertyDescriptor(ProcessingInstruction pi) {
- return createDefaultPropertyDescriptor(HACK);
- }
-
- public IPropertyDescriptor createPropertyDescriptor(Object object) {
- IPropertyDescriptor result = null;
- if (object instanceof Node) {
- Node node = (Node) object;
- int nodeType = node.getNodeType();
- switch (nodeType) {
- case Node.ATTRIBUTE_NODE : {
- result = createAttributePropertyDescriptor((Attr) node);
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- result = createCDATASectionPropertyDescriptor((CDATASection) node);
- break;
- }
- case Node.COMMENT_NODE : {
- result = createCommentPropertyDescriptor((Comment) node);
- break;
- }
- case Node.DOCUMENT_TYPE_NODE : {
- result = createDocumentTypePropertyDescriptor((DocumentType) node);
- break;
- }
- case Node.ELEMENT_NODE : {
- result = createElementPropertyDescriptor((Element) node);
- break;
- }
- case Node.ENTITY_REFERENCE_NODE : {
- result = createEntityReferencePropertyDescriptor((EntityReference) node);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- result = createProcessingInstructionPropertyDescriptor((ProcessingInstruction) node);
- break;
- }
- case Node.TEXT_NODE : {
- result = createTextPropertyDescriptor((Text) node);
- break;
- }
- }
- }
- return result;
- }
-
- public IPropertyDescriptor createTextPropertyDescriptor(Text text) {
- return createDefaultPropertyDescriptor(HACK);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewer.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewer.java
deleted file mode 100644
index f1be97fd80..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.widgets.Control;
-
-public interface IDesignViewer {
- public Control getControl();
-
- String getTitle();
-
- void setDocument(IDocument document);
-
- ISelectionProvider getSelectionProvider();
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewerActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewerActionBarContributor.java
deleted file mode 100644
index 411a3f9178..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/IDesignViewerActionBarContributor.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor;
-
-
-public interface IDesignViewerActionBarContributor extends ISourceViewerActionBarContributor {
- public void initViewerSpecificContributions(IActionBars bars);
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java
deleted file mode 100644
index 5e9ffccd60..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourceEditorActionBarContributor.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
-import org.eclipse.ui.part.MultiPageEditorPart;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.ExtendedEditorActionBuilder;
-import org.eclipse.wst.sse.ui.internal.IExtendedContributor;
-import org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor;
-
-
-public class SourceEditorActionBarContributor extends MultiPageEditorActionBarContributor implements IExtendedContributor {
-
- protected IEditorActionBarContributor designViewerActionBarContributor = null;
- protected IEditorActionBarContributor sourceViewerActionContributor = null;
- protected MultiPageEditorPart multiPageEditor = null;
-
- // EditorExtension
- private static final String EDITOR_ID = "org.eclipse.wst.xml.ui.XMLMultiPageEditorPart"; //$NON-NLS-1$
- private IExtendedContributor extendedContributor;
-
- public SourceEditorActionBarContributor() {
- super();
-
- sourceViewerActionContributor = new SourcePageActionContributor();
-
- // Read action extensions.
- ExtendedEditorActionBuilder builder = new ExtendedEditorActionBuilder();
- extendedContributor = builder.readActionExtensions(EDITOR_ID);
- }
-
- public void init(IActionBars actionBars) {
- super.init(actionBars);
-
- if (actionBars != null) {
- initDesignViewerActionBarContributor(actionBars);
- initSourceViewerActionContributor(actionBars);
- }
- }
-
- protected void initDesignViewerActionBarContributor(IActionBars actionBars) {
- if (designViewerActionBarContributor != null) {
- designViewerActionBarContributor.init(actionBars, getPage());
- }
- }
-
- protected void initSourceViewerActionContributor(IActionBars actionBars) {
- if (sourceViewerActionContributor != null) {
- sourceViewerActionContributor.init(actionBars, getPage());
- }
- }
-
- public void dispose() {
- super.dispose();
-
- if (designViewerActionBarContributor != null) {
- designViewerActionBarContributor.dispose();
- }
-
- if (sourceViewerActionContributor != null) {
- sourceViewerActionContributor.dispose();
- }
-
- if (extendedContributor != null) {
- extendedContributor.dispose();
- }
- }
-
- /**
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(IMenuManager)
- */
- public final void contributeToMenu(IMenuManager menu) {
- super.contributeToMenu(menu);
-
- //addToMenu(menu);
-
- if (extendedContributor != null) {
- extendedContributor.contributeToMenu(menu);
- }
- }
-
- protected void addToMenu(IMenuManager menu) {
- }
-
- /**
- * @see IExtendedContributor#contributeToPopupMenu(IMenuManager)
- */
- public final void contributeToPopupMenu(IMenuManager menu) {
-
- addToPopupMenu(menu);
-
- if (extendedContributor != null) {
- extendedContributor.contributeToPopupMenu(menu);
- }
- }
-
- protected void addToPopupMenu(IMenuManager menu) {
- }
-
- /**
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(IToolBarManager)
- */
- public final void contributeToToolBar(IToolBarManager toolBarManager) {
- super.contributeToToolBar(toolBarManager);
-
- addToToolBar(toolBarManager);
-
- if (extendedContributor != null) {
- extendedContributor.contributeToToolBar(toolBarManager);
- }
- }
-
- protected void addToToolBar(IToolBarManager toolBarManager) {
- }
-
- /**
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToStatusLine(IStatusLineManager)
- */
- public final void contributeToStatusLine(IStatusLineManager manager) {
- super.contributeToStatusLine(manager);
-
- addToStatusLine(manager);
-
- if (extendedContributor != null) {
- extendedContributor.contributeToStatusLine(manager);
- }
- }
-
- protected void addToStatusLine(IStatusLineManager manager) {
- }
-
- /**
- * @see IExtendedContributor#updateToolbarActions()
- */
- public void updateToolbarActions() {
- if (extendedContributor != null) {
- extendedContributor.updateToolbarActions();
- }
- }
-
- public void setActiveEditor(IEditorPart targetEditor) {
- // save multiPageEditor before calling
- // super.setActiveEditor(targetEditor)
- // super.setActiveEditor will call setActivePage(IEditorPart
- // activeEditor)
- // multiPageEditor is needed in setActivePage(IEditorPart
- // activeEditor)
- if (targetEditor instanceof MultiPageEditorPart) {
- multiPageEditor = (MultiPageEditorPart) targetEditor;
- }
-
- super.setActiveEditor(targetEditor);
-
- updateToolbarActions();
-
- if (extendedContributor != null) {
- extendedContributor.setActiveEditor(targetEditor);
- }
- }
-
- public void setActivePage(IEditorPart activeEditor) {
- // This contributor is designed for StructuredTextMultiPageEditorPart.
- // To safe-guard this from problems caused by unexpected usage by
- // other editors, the following
- // check is added.
- if (multiPageEditor != null) {
- if ((activeEditor != null) && (activeEditor instanceof StructuredTextEditor)) {
- activateSourcePage(activeEditor);
- }
- else {
- activateDesignPage(activeEditor);
- }
- }
-
- updateToolbarActions();
-
- IActionBars actionBars = getActionBars();
- if (actionBars != null) {
- // update menu bar and tool bar
- actionBars.updateActionBars();
- }
- }
-
- protected void activateDesignPage(IEditorPart activeEditor) {
- if ((designViewerActionBarContributor != null) && (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor)) {
- designViewerActionBarContributor.setActiveEditor(multiPageEditor);
- }
-
- if ((sourceViewerActionContributor != null) && (sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)) {
- // if design page is not really an IEditorPart, activeEditor ==
- // null, so pass in multiPageEditor instead (d282414)
- if (activeEditor == null) {
- sourceViewerActionContributor.setActiveEditor(multiPageEditor);
- }
- else {
- sourceViewerActionContributor.setActiveEditor(activeEditor);
- }
- ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(false);
- }
- }
-
- protected void activateSourcePage(IEditorPart activeEditor) {
- if ((designViewerActionBarContributor != null) && (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor)) {
- designViewerActionBarContributor.setActiveEditor(multiPageEditor);
- }
-
- if ((sourceViewerActionContributor != null) && (sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)) {
- sourceViewerActionContributor.setActiveEditor(activeEditor);
- ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(true);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourcePageActionContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourcePageActionContributor.java
deleted file mode 100644
index bd1e251276..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/SourcePageActionContributor.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.wst.xml.ui.internal.actions.ActionContributorXML;
-
-
-/**
- * SourcePageActionContributor
- *
- * This class is for multi page editor's source page contributor.
- *
- * Use XMLEditorActionContributor for single page editor.
- */
-public class SourcePageActionContributor extends ActionContributorXML {
-
- private IActionBars fBars;
-
- /**
- * This method calls:
- * <ul>
- * <li><code>contributeToMenu</code> with <code>bars</code>' menu
- * manager</li>
- * <li><code>contributeToToolBar</code> with <code>bars</code>' tool
- * bar manager</li>
- * <li><code>contributeToStatusLine</code> with <code>bars</code>'
- * status line manager</li>
- * </ul>
- * The given action bars are also remembered and made accessible via
- * <code>getActionBars</code>.
- *
- * @param bars
- * the action bars
- *
- */
- public void init(IActionBars bars) {
- fBars = bars;
- contributeToMenu(bars.getMenuManager());
- contributeToToolBar(bars.getToolBarManager());
- contributeToStatusLine(bars.getStatusLineManager());
- }
-
- /**
- * Returns this contributor's action bars.
- *
- * @return the action bars
- */
- public IActionBars getActionBars() {
- return fBars;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java
deleted file mode 100644
index 11a4dd61df..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeContentHelper.java
+++ /dev/null
@@ -1,459 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004-2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMWriter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Attr;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-
-/**
- * This performs the work of taking a DOM tree and converting it to a
- * displayable 'UI' tree.
- *
- * For example : - white space text nodes are ommited from the 'UI' tree -
- * adjacent Text and EntityReference nodes are combined into a single 'UI'
- * node - Elements with 'text only' children are diplayed without children
- *
- */
-public class TreeContentHelper {
-
- public static final int HIDE_WHITE_SPACE_TEXT_NODES = 8;
- public static final int COMBINE_ADJACENT_TEXT_AND_ENTITY_REFERENCES = 16;
- public static final int HIDE_ELEMENT_CHILD_TEXT_NODES = 32;
-
- protected int style = HIDE_WHITE_SPACE_TEXT_NODES | COMBINE_ADJACENT_TEXT_AND_ENTITY_REFERENCES | HIDE_ELEMENT_CHILD_TEXT_NODES;
-
- /**
- *
- */
- public boolean hasStyleFlag(int flag) {
- return (style & flag) != 0;
- }
-
- /**
- *
- */
- public Object[] getChildren(Object element) {
- Object[] result = null;
-
- if (element instanceof Node) {
- Node node = (Node) element;
- List list = new ArrayList();
- boolean textContentOnly = true;
-
- NamedNodeMap map = node.getAttributes();
- if (map != null) {
- int length = map.getLength();
- for (int i = 0; i < length; i++) {
- list.add(map.item(i));
- textContentOnly = false;
- }
- }
-
- Node prevIncludedNode = null;
- for (Node childNode = node.getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) {
- int childNodeType = childNode.getNodeType();
- boolean includeNode = true;
-
- if (includeNode && hasStyleFlag(HIDE_WHITE_SPACE_TEXT_NODES)) {
- if (isIgnorableText(childNode)) {
- // filter out the ignorable text node
- includeNode = false;
- }
- }
-
- if (includeNode && hasStyleFlag(COMBINE_ADJACENT_TEXT_AND_ENTITY_REFERENCES)) {
- if (isTextOrEntityReferenceNode(childNode) && (prevIncludedNode != null) && isTextOrEntityReferenceNode(prevIncludedNode)) {
- // we only show the first of a list of adjacent text
- // or entity reference node in the tree
- // so we filter out this subsequent one
- includeNode = false;
- }
- }
-
- if (hasStyleFlag(HIDE_ELEMENT_CHILD_TEXT_NODES)) {
- if ((childNodeType != Node.TEXT_NODE) && (childNodeType != Node.ENTITY_REFERENCE_NODE)) {
- textContentOnly = false;
- }
- }
-
- if (includeNode) {
- list.add(childNode);
- prevIncludedNode = childNode;
- }
- }
-
- if (hasStyleFlag(HIDE_ELEMENT_CHILD_TEXT_NODES) && textContentOnly) {
- result = new Object[0];
- }
- else {
- result = list.toArray();
- }
- }
- return result;
- }
-
- /**
- *
- */
- protected boolean isTextOrEntityReferenceNode(Node node) {
- return (node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.ENTITY_REFERENCE_NODE);
- }
-
- /**
- *
- */
- public boolean isIgnorableText(Node node) {
- boolean result = false;
- if (node.getNodeType() == Node.TEXT_NODE) {
- String data = ((Text) node).getData();
- result = ((data == null) || (data.trim().length() == 0));
- }
- return result;
- }
-
- /**
- *
- */
- public boolean isCombinedTextNode(Node node) {
- boolean result = false;
- if (node.getNodeType() == Node.TEXT_NODE) {
- Node nextNode = node.getNextSibling();
- if (nextNode != null) {
- if (nextNode.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
- result = true;
- }
- }
- }
- else if (node.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
- result = true;
- }
- return result;
- }
-
- /**
- *
- */
- public List getCombinedTextNodeList(Node theNode) {
- List list = new Vector();
- boolean prevIsEntity = false;
- for (Node node = theNode; node != null; node = node.getNextSibling()) {
- int nodeType = node.getNodeType();
- if (nodeType == Node.ENTITY_REFERENCE_NODE) {
- prevIsEntity = true;
- list.add(node);
- }
- else if ((nodeType == Node.TEXT_NODE) && (prevIsEntity || (node == theNode))) {
- prevIsEntity = false;
- list.add(node);
- }
- else {
- break;
- }
- }
- return list;
- }
-
- public String getElementTextValue(Element element) {
- List list = _getElementTextContent(element);
- return list != null ? getValueForTextContent(list) : null;
- }
-
- public void setElementTextValue(Element element, String value) {
- setElementNodeValue(element, value);
- }
-
- private List _getElementTextContent(Element element) {
- List result = null;
-
- for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) {
- if ((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.ENTITY_REFERENCE_NODE)) {
- if (result == null) {
- result = new Vector();
- }
- result.add(node);
- }
- else {
- result = null;
- break;
- }
- }
- return result;
- }
-
- /**
- * If the element is has 'text only' content this method will return the
- * list of elements that compose the text only content
- */
- public List getElementTextContent(Element element) {
- List result = null;
- if (!element.hasAttributes()) {
- result = _getElementTextContent(element);
- }
- return result;
- }
-
-
- /**
- *
- */
- public String getNodeValue(Node node) {
- String result = null;
- int nodeType = node.getNodeType();
- switch (nodeType) {
- case Node.ATTRIBUTE_NODE : {
- result = ((Attr) node).getValue();
- break;
- }
- case Node.CDATA_SECTION_NODE :
- // drop thru
- case Node.COMMENT_NODE : {
- result = ((CharacterData) node).getData();
- break;
- }
- case Node.DOCUMENT_TYPE_NODE : {
- result = getDocumentTypeValue((DocumentType) node);
- break;
- }
- case Node.ELEMENT_NODE : {
- result = getElementNodeValue((Element) node);
- break;
- }
- case Node.ENTITY_REFERENCE_NODE :
- // drop thru
- case Node.TEXT_NODE : {
- result = getTextNodeValue(node);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- result = ((ProcessingInstruction) node).getData();
- break;
- }
- }
- return result;
- }
-
- /**
- *
- */
- public void setNodeValue(Node node, String value) {
- int nodeType = node.getNodeType();
- try {
- switch (nodeType) {
- case Node.ATTRIBUTE_NODE : {
- ((Attr) node).setValue(value);
- break;
- }
- case Node.CDATA_SECTION_NODE :
- // drop thru
- case Node.COMMENT_NODE : {
- ((CharacterData) node).setData(value);
- break;
- }
- case Node.ELEMENT_NODE : {
- setElementNodeValue((Element) node, value);
- break;
- }
- case Node.ENTITY_REFERENCE_NODE :
- // drop thru
- case Node.TEXT_NODE : {
- setTextNodeValue(node, value);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- ((ProcessingInstruction) node).setData(value);
- break;
- }
- }
- }
- catch (DOMException e) {
- Display d = getDisplay();
- if (d != null) {
- d.beep();
- }
- }
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
-
- /**
- *
- */
- protected String getDocumentTypeValue(DocumentType documentType) {
- return DOMWriter.getDocumentTypeData(documentType);
- }
-
- /**
- *
- */
- protected String getElementNodeValue(Element element) {
- String result = null;
- List list = getElementTextContent(element);
- if (list != null) {
- result = getValueForTextContent(list);
- }
- return result;
- }
-
- /**
- *
- */
- protected void setElementNodeValue(Element element, String value) {
- List list = getElementTextContent(element);
- if (list != null) {
- setValueForTextContent(list, value);
- }
- else {
- Document document = element.getOwnerDocument();
- Text text = document.createTextNode(value);
- element.appendChild(text);
- }
- }
-
- /**
- *
- */
- protected String getTextNodeValue(Node node) {
- String result = null;
- List list = null;
- if (isCombinedTextNode(node)) {
- list = getCombinedTextNodeList(node);
- }
- else {
- list = new Vector();
- list.add(node);
- }
- result = getValueForTextContent(list);
- return result;
- }
-
- /**
- *
- */
- protected void setTextNodeValue(Node node, String value) {
- List list = null;
- if (isCombinedTextNode(node)) {
- list = getCombinedTextNodeList(node);
- }
- else {
- list = new Vector();
- list.add(node);
- }
- setValueForTextContent(list, value);
- }
-
- public Text getEffectiveTextNodeForCombinedNodeList(List list) {
- Text result = null;
- for (Iterator i = list.iterator(); i.hasNext();) {
- Node node = (Node) i.next();
- if (node.getNodeType() == Node.TEXT_NODE) {
- result = (Text) node;
- break;
- }
- }
- return result;
- }
-
- /**
- *
- */
- protected String getValueForTextContent(List list) {
- String result = null;
- if (list.size() > 0) {
- IDOMNode first = (IDOMNode) list.get(0);
- IDOMNode last = (IDOMNode) list.get(list.size() - 1);
- IDOMModel model = first.getModel();
- int start = first.getStartOffset();
- int end = last.getEndOffset();
- try {
- result = model.getStructuredDocument().get(start, end - start);
- }
- catch (Exception e) {
- }
- }
-
- // we trim the content so that it looks nice when viewed
- // we need to be carfull to preserve the 'trimmed' text when the value
- // is set (see setValueForTextContent)
- if (result != null) {
- result = result.trim();
- }
- return result;
- }
-
- /**
- *
- */
- protected void setValueForTextContent(List list, String value) {
- // String oldValue = getValueForTextContent();
- // we worry about preserving trimmed text
- if (list.size() > 0) {
- IDOMNode first = (IDOMNode) list.get(0);
- IDOMNode last = (IDOMNode) list.get(list.size() - 1);
- int start = first.getStartOffset();
- int end = last.getEndOffset();
- first.getModel().getStructuredDocument().replaceText(this, start, end - start, value);
- }
- }
-
- /**
- *
- */
- public boolean isEditable(Node node) {
- int nodeType = node.getNodeType();
- boolean result = false;
- switch (nodeType) {
- case Node.ATTRIBUTE_NODE :
- // drop thru
- case Node.CDATA_SECTION_NODE :
- // drop thru
- case Node.COMMENT_NODE :
- // drop thru
- case Node.ENTITY_REFERENCE_NODE :
- // drop thru
- case Node.TEXT_NODE :
- // drop thru
- case Node.PROCESSING_INSTRUCTION_NODE : {
- result = true;
- break;
- }
- case Node.ELEMENT_NODE : {
- result = (getElementTextContent((Element) node) != null) || (node.getChildNodes().getLength() == 0);
- break;
- }
- }
- return result;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeExtension.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeExtension.java
deleted file mode 100644
index c9832cc8ef..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/TreeExtension.java
+++ /dev/null
@@ -1,557 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ICellEditorListener;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.PlatformUI;
-
-
-public class TreeExtension implements PaintListener {
-
- protected Tree fTree;
- protected EditManager editManager;
- protected String[] fColumnProperties;
- protected ICellModifier cellModifier;
- protected int columnPosition = 300;
- protected int columnHitWidth = 5;
- protected Color tableLineColor;
- protected int controlWidth;
- protected DelayedDrawTimer delayedDrawTimer;
- private boolean fisUnsupportedInput = false;
-
- public TreeExtension(Tree tree) {
- this.fTree = tree;
- InternalMouseListener listener = new InternalMouseListener();
- tree.addMouseMoveListener(listener);
- tree.addMouseListener(listener);
- tree.addPaintListener(this);
- editManager = new EditManager(tree);
- delayedDrawTimer = new DelayedDrawTimer(tree);
-
- tableLineColor = tree.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
- }
-
- public void dispose() {
- tableLineColor.dispose();
- }
-
- public void setCellModifier(ICellModifier modifier) {
- cellModifier = modifier;
- }
-
- public void resetCachedData() {
- // todo: sure seems we should reset something?
- }
-
- public ICellModifier getCellModifier() {
- return cellModifier;
- }
-
- public List getItemList() {
- List list = new Vector();
- getItemListHelper(fTree.getItems(), list);
- return list;
- }
-
- protected void getItemListHelper(TreeItem[] items, List list) {
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
- list.add(item);
- getItemListHelper(item.getItems(), list);
- }
- }
-
- protected TreeItem getTreeItemOnRow(int px, int py) {
- TreeItem result = null;
- List list = getItemList();
- for (Iterator i = list.iterator(); i.hasNext();) {
- TreeItem item = (TreeItem) i.next();
- Rectangle r = item.getBounds();
- if ((r != null) && (px >= r.x) && (py >= r.y) && (py <= r.y + r.height)) {
- result = item;
- }
- }
- return result;
- }
-
- protected class InternalMouseListener extends MouseAdapter implements MouseMoveListener {
- protected int columnDragged = -1;
- protected boolean isDown = false;
- protected int prevX = -1;
- protected Cursor cursor = null;
-
- public void mouseMove(MouseEvent e) {
- if ((e.x > columnPosition - columnHitWidth) && (e.x < columnPosition + columnHitWidth)) {
- if (cursor == null) {
- cursor = new Cursor(fTree.getDisplay(), SWT.CURSOR_SIZEWE);
- fTree.setCursor(cursor);
- }
- }
- else {
- if (cursor != null) {
- fTree.setCursor(null);
- cursor.dispose();
- cursor = null;
- }
- }
-
- if (columnDragged != -1) {
- // using the delay timer will make redraws less flickery
- if (e.x > 20) {
- columnPosition = e.x;
- delayedDrawTimer.reset(20);
- }
- }
- }
-
- public void mouseDown(MouseEvent e) {
- // here we handle the column resizing by detect if the user has
- // click on a column separator
- //
- columnDragged = -1;
- editManager.deactivateCellEditor();
-
- if ((e.x > columnPosition - columnHitWidth) && (e.x < columnPosition + columnHitWidth)) {
- columnDragged = 0;
- }
-
- // here we handle selecting tree items when any thing on the 'row'
- // is clicked
- //
- TreeItem item = fTree.getItem(new Point(e.x, e.y));
- if (item == null) {
- item = getTreeItemOnRow(e.x, e.y);
- if (item != null) {
- TreeItem[] items = new TreeItem[1];
- items[0] = item;
- fTree.setSelection(items);
- }
- }
- }
-
- public void mouseUp(MouseEvent e) {
- columnDragged = -1;
- }
- }
-
- public String[] getColumnProperties() {
- return fColumnProperties;
- }
-
- public void setColumnProperties(String[] columnProperties) {
- this.fColumnProperties = columnProperties;
- }
-
- public void paintControl(PaintEvent event) {
- GC gc = event.gc;
- Rectangle treeBounds = fTree.getBounds();
-
- controlWidth = treeBounds.width;
- Color bg = fTree.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- Color bg2 = fTree.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
-
- gc.setBackground(bg2);
-
- // // This next part causes problems on LINUX, so let's not do it
- // there
- // if (B2BHacks.IS_UNIX == false) {
- // TreeItem[] selectedItems = tree.getSelection();
- // if (selectedItems.length > 0) {
- // for (int i = 0; i < selectedItems.length; i++) {
- // TreeItem item = selectedItems[i];
- // Rectangle bounds = item.getBounds();
- // if (bounds != null) {
- // gc.fillRectangle(bounds.x + bounds.width, bounds.y, controlWidth,
- // bounds.height);
- // }
- // }
- // }
- // }
- //
- if (!fisUnsupportedInput) {
- TreeItem[] items = fTree.getItems();
- if (items.length > 0) {
- gc.setForeground(tableLineColor);
- gc.setBackground(bg);
-
- gc.fillRectangle(columnPosition, treeBounds.x, treeBounds.width, treeBounds.height);
-
- Rectangle itemBounds = items[0].getBounds();
- int height = computeTreeItemHeight();
-
- if (itemBounds != null) {
- /*
- * Bounds will be for the first item, which will either be
- * visible at the top of the Tree, or scrolled off with
- * negative values
- */
- int startY = itemBounds.y;
-
- /* Only draw lines within the Tree boundaries */
- for (int i = startY; i < treeBounds.height; i += height) {
- if (i >= treeBounds.y) {
- gc.drawLine(0, i, treeBounds.width, i);
- }
- }
- }
- gc.drawLine(columnPosition, 0, columnPosition, treeBounds.height);
- paintItems(gc, items, treeBounds);
-
- }
- else {
- addEmptyTreeMessage(gc);
- }
- }
- else {
- addUnableToPopulateTreeMessage(gc);
- }
- }
-
- protected int computeTreeItemHeight() {
- int result = -1;
-
- /*
- * On GTK tree.getItemHeight() seems to lie to us. It reports that the
- * tree item occupies a few pixles less vertical space than it should
- * (possibly because of the image height vs. the text height?). This
- * foils our code that draws the 'row' lines since we assume that
- * lines should be drawn at 'itemHeight' increments. Don't trust
- * getItemHeight() to compute the increment... instead compute the
- * value based on distance between two TreeItems, and then use the
- * larger value.
- *
- * This strategy only works on trees where the items are of even
- * height, however bug
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=117201 indicates that
- * this is no longer promised, at least on win32 and likely on other
- * platforms soon.
- */
- if (fTree.getItemCount() > 0) {
- TreeItem[] items = fTree.getItems();
- Rectangle itemBounds = items[0].getBounds();
-
- if (items[0].getExpanded()) {
- TreeItem[] children = items[0].getItems();
- if (children.length > 0) {
- result = children[0].getBounds().y - itemBounds.y;
- }
- }
- else if (items.length > 1) {
- result = items[1].getBounds().y - itemBounds.y;
- }
- }
-
- result = Math.max(fTree.getItemHeight(), result);
- return result;
- }
-
- protected void addEmptyTreeMessage(GC gc) {
- // nothing to add here
- }
-
- private void addUnableToPopulateTreeMessage(GC gc) {
- // here we print a message when the document cannot be displayed just
- // to give the
- // user a visual cue
- // so that they know how to proceed to edit the blank view
- gc.setForeground(fTree.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- gc.setBackground(fTree.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- gc.drawString(XMLEditorMessages.TreeExtension_0, 10, 10);
- }
-
- void setIsUnsupportedInput(boolean isUnsupported) {
- fisUnsupportedInput = isUnsupported;
- }
-
- public void paintItems(GC gc, TreeItem[] items, Rectangle treeBounds) {
- if (items != null) {
- for (int i = 0; i < items.length; i++) {
- TreeItem item = items[i];
- if (item != null) {
- Rectangle bounds = item.getBounds();
- if (bounds != null) {
- if (treeBounds.intersects(bounds)) {
- paintItem(gc, item, bounds);
- }
- }
-
- // defect 241039
- //
- if (item.getExpanded()) {
- paintItems(gc, item.getItems(), treeBounds);
- }
- }
- }
- }
- }
-
- protected void paintItem(GC gc, TreeItem item, Rectangle bounds) {
- // nothing to paint
- }
-
- public interface ICellEditorProvider {
- CellEditor getCellEditor(Object o, int col);
- }
-
- /**
- * This class is used to improve drawing during a column resize.
- */
- public class DelayedDrawTimer implements Runnable {
- protected Control control;
-
- public DelayedDrawTimer(Control control1) {
- this.control = control1;
- }
-
- public void reset(int milliseconds) {
- getDisplay().timerExec(milliseconds, this);
- }
-
- public void run() {
- control.redraw();
- }
- }
-
- Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- /**
- * EditManager
- */
- public class EditManager {
- protected Tree fTree1;
- protected Control cellEditorHolder;
- protected CellEditorState cellEditorState;
-
- public EditManager(Tree tree) {
- this.fTree1 = tree;
- this.cellEditorHolder = new Composite(tree, SWT.NONE);
-
- final Tree theTree = tree;
-
- MouseAdapter theMouseAdapter = new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- deactivateCellEditor();
-
- if (e.x > columnPosition + columnHitWidth) {
- TreeItem[] items = theTree.getSelection();
- // No edit if more than one row is selected.
- if (items.length == 1) {
- Rectangle bounds = items[0].getBounds();
- if ((bounds != null) && (e.y >= bounds.y) && (e.y <= bounds.y + bounds.height)) {
- int columnToEdit = 1;
- activateCellEditor(items[0], columnToEdit);
- }
- }
- }
- }
- };
-
- SelectionListener selectionListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- applyCellEditorValue();
- }
-
- public void widgetSelected(SelectionEvent e) {
- applyCellEditorValue();
- }
- };
-
- KeyListener keyListener = new KeyAdapter() {
- public void keyPressed(KeyEvent e) {
- if (e.character == SWT.CR) {
- deactivateCellEditor();
- TreeItem[] items = theTree.getSelection();
- if (items.length == 1) {
- activateCellEditor(items[0], 1);
- }
- }
- }
- };
-
- tree.addMouseListener(theMouseAdapter);
- tree.addKeyListener(keyListener);
- ScrollBar hBar = tree.getHorizontalBar();
- if (hBar != null) {
- hBar.addSelectionListener(selectionListener);
- }
- ScrollBar vBar = tree.getVerticalBar();
- if (vBar != null) {
- vBar.addSelectionListener(selectionListener);
- }
- }
-
- public boolean isCellEditorActive() {
- return cellEditorState != null;
- }
-
- public void applyCellEditorValue() {
- if ((cellEditorState != null) && (cellModifier != null)) {
- TreeItem treeItem = cellEditorState.fTreeItem;
-
- // The area below the cell editor needs to be explicity
- // repainted on Linux
- //
- // Rectangle r = B2BHacks.IS_UNIX ? treeItem.getBounds() :
- // null;
-
- Object value = cellEditorState.fCellEditor.getValue();
- String property = cellEditorState.fProperty;
-
- deactivateCellEditor();
-
- cellModifier.modify(treeItem, property, value);
-
- // if (r != null) {
- // tree.redraw(r.x, r.y, tree.getBounds().width, r.height,
- // false);
- // }
- }
- }
-
- public void deactivateCellEditor() {
- // Clean up any previous editor control
- if (cellEditorState != null) {
- cellEditorState.deactivate();
- cellEditorState = null;
- }
- }
-
- public void activateCellEditor(TreeItem treeItem, int column) {
- if (cellModifier instanceof ICellEditorProvider) {
- ICellEditorProvider cellEditorProvider = (ICellEditorProvider) cellModifier;
- Object data = treeItem.getData();
- if (fColumnProperties.length > column) {
- String property = fColumnProperties[column];
- if (cellModifier.canModify(data, property)) {
- CellEditor newCellEditor = cellEditorProvider.getCellEditor(data, column);
- if (newCellEditor != null) {
- // The control that will be the editor must be a
- // child of the columnPosition
- Control control = newCellEditor.getControl();
- if (control != null) {
- cellEditorState = new CellEditorState(newCellEditor, control, treeItem, column, property);
- cellEditorState.activate();
- }
- }
- }
- }
- }
- }
-
- /**
- * this class holds the state that is need on a per cell editor
- * invocation basis
- */
- public class CellEditorState implements ICellEditorListener, FocusListener {
- public CellEditor fCellEditor;
- public Control fControl;
- public TreeItem fTreeItem;
- public int fColumnNumber;
- public String fProperty;
-
- public CellEditorState(CellEditor cellEditor, Control control, TreeItem treeItem, int columnNumber, String property) {
- this.fCellEditor = cellEditor;
- this.fControl = control;
- this.fTreeItem = treeItem;
- this.fColumnNumber = columnNumber;
- this.fProperty = property;
- }
-
- public void activate() {
- Object element = fTreeItem.getData();
- String value = cellModifier.getValue(element, fProperty).toString();
- if (fControl instanceof Text) {
- Text text = (Text) fControl;
- int requiredSize = value.length() + 100;
- if (text.getTextLimit() < requiredSize) {
- text.setTextLimit(requiredSize);
- }
- }
- Rectangle r = fTreeItem.getBounds();
- if (r != null) {
- fControl.setBounds(columnPosition + 5, r.y + 1, fTree1.getClientArea().width - (columnPosition + 5), r.height - 1);
- fControl.setVisible(true);
- fCellEditor.setValue(value);
- fCellEditor.addListener(this);
- fCellEditor.setFocus();
- fControl.addFocusListener(this);
- }
- }
-
- public void deactivate() {
- fCellEditor.removeListener(this);
- fControl.removeFocusListener(this);
- fCellEditor.deactivate();
- fTree1.forceFocus();
- }
-
- // ICellEditorListener methods
- //
- public void applyEditorValue() {
- applyCellEditorValue();
- }
-
- public void cancelEditor() {
- deactivateCellEditor();
- }
-
- public void editorValueChanged(boolean oldValidState, boolean newValidState) {
- // nothing, for now
- }
-
- // FocusListener methods
- //
- public void focusGained(FocusEvent e) {
- // do nothing
- }
-
- public void focusLost(FocusEvent e) {
- applyCellEditorValue();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java
deleted file mode 100644
index 02fd23cb5f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/ViewerExpandCollapseAction.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.AbstractTreeViewer;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class ViewerExpandCollapseAction extends Action {
-
- protected boolean isExpandAction;
- protected AbstractTreeViewer viewer = null;
-
- public ViewerExpandCollapseAction(boolean isExpandAction) {
- this.isExpandAction = isExpandAction;
- if (isExpandAction) {
- ImageDescriptor e_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_ETOOL_EXPANDALL);
- ImageDescriptor d_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_DTOOL_EXPANDALL);
-
- setImageDescriptor(e_imageDescriptor);
- setDisabledImageDescriptor(d_imageDescriptor);
- setToolTipText(XMLUIMessages._UI_INFO_EXPAND_ALL);
- }
- else {
- ImageDescriptor e_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_ETOOL_COLLAPSEALL);
- ImageDescriptor d_imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_DTOOL_COLLAPSEALL);
-
- setImageDescriptor(e_imageDescriptor);
- setDisabledImageDescriptor(d_imageDescriptor);
- setToolTipText(XMLUIMessages._UI_INFO_COLLAPSE_ALL);
- }
- }
-
- public void setViewer(AbstractTreeViewer viewer) {
- this.viewer = viewer;
- }
-
- public void run() {
- if (viewer != null) {
- // temporarily set the visibility to false
- // this has a HUGE performance benefit
- boolean isVisible = viewer.getControl().getVisible();
- viewer.getControl().setVisible(false);
-
- if (isExpandAction) {
- viewer.expandAll();
- }
- else {
- viewer.collapseAll();
- }
-
- // restore the previous visibility state
- //
- viewer.getControl().setVisible(isVisible);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorActionDefinitionIds.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorActionDefinitionIds.java
deleted file mode 100644
index 1d380cfb8b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorActionDefinitionIds.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-
-
-/**
- * Defines the definitions ids for the XML editor actions.
- *
- * @deprecated Use org.eclipse.wst.sse.ui.edit.util.ActionDefinitionIds
- * instead
- */
-public interface XMLEditorActionDefinitionIds {
- public final static String CLEANUP_DOCUMENT = "org.eclipse.wst.sse.ui.edit.ui.cleanup.document";//$NON-NLS-1$
- public final static String FORMAT_DOCUMENT = "org.eclipse.wst.sse.ui.edit.ui.format.document";//$NON-NLS-1$
- public final static String FORMAT_ACTIVE_ELEMENTS = "org.eclipse.wst.sse.ui.edit.ui.format.active.elements";//$NON-NLS-1$
- public final static String OPEN_FILE = "org.eclipse.wst.sse.ui.edit.ui.open.file.from.source";//$NON-NLS-1$
- // public final static String INFORMATION =
- // "org.eclipse.wst.sse.ui.edit.ui.show.tooltip.information";//$NON-NLS-1$
- public final static String INFORMATION = "org.eclipse.jdt.ui.edit.text.java.show.javadoc";//$NON-NLS-1$
- public final static String ADD_BREAKPOINTS = "org.eclipse.wst.sse.ui.edit.ui.add.breakpoints";//$NON-NLS-1$
- public final static String MANAGE_BREAKPOINTS = "org.eclipse.wst.sse.ui.edit.ui.manage.breakpoints";//$NON-NLS-1$
- public final static String ENABLE_BREAKPOINTS = "org.eclipse.wst.sse.ui.edit.ui.enable.breakpoints";//$NON-NLS-1$
- public final static String DISABLE_BREAKPOINTS = "org.eclipse.wst.sse.ui.edit.ui.disable.breakpoints";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorMessages.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorMessages.java
deleted file mode 100644
index c0471bf318..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorMessages.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 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 - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Strings used by XML Editor
- *
- * @plannedfor 1.0
- */
-public class XMLEditorMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.wst.xml.ui.internal.tabletree.XMLEditorResources";//$NON-NLS-1$
-
- public static String XMLTableTreeViewer_0;
- public static String XMLMultiPageEditorPart_0;
- public static String XMLTreeExtension_0;
- public static String XMLTreeExtension_1;
- public static String XMLTreeExtension_3;
- public static String XMLTreeExtension_4;
- public static String XMLTableTreeActionBarContributor_0;
- public static String XMLTableTreeActionBarContributor_1;
- public static String XMLTableTreeActionBarContributor_2;
- public static String XMLTableTreeActionBarContributor_3;
- public static String XMLTableTreeActionBarContributor_4;
- public static String XMLTableTreeActionBarContributor_5;
- public static String XMLTableTreeActionBarContributor_6;
- public static String XMLTableTreeActionBarContributor_7;
- public static String XMLTableTreeActionBarContributor_8;
- public static String An_error_has_occurred_when1_ERROR_;
- public static String Resource__does_not_exist;
- public static String Editor_could_not_be_open;
- public static String TreeExtension_0;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, XMLEditorMessages.class);
- }
-
- private XMLEditorMessages() {
- // cannot create new instance
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginHOLD_OLD.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginHOLD_OLD.java
deleted file mode 100644
index fd3acc0163..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginHOLD_OLD.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry;
-import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryImpl;
-
-/**
- * @deprecated This plugin has combined with the org.eclipse.wst.xml.ui
- * plugin. Use XMLUIPlugin instead.
- */
-public class XMLEditorPluginHOLD_OLD extends AbstractUIPlugin {
-
- public final static String PLUGIN_ID = "org.eclipse.wst.xml.ui.internal.XMLEditorPluginHOLD_OLD"; //$NON-NLS-1$
- protected static XMLEditorPluginHOLD_OLD instance = null;
-
- /**
- * XMLUIPlugin constructor comment.
- */
- public XMLEditorPluginHOLD_OLD() {
- super();
- instance = this;
-
- // reference the preference store so
- // initializeDefaultPreferences(IPreferenceStore preferenceStore) is
- // called
- getPreferenceStore();
- }
-
- public static XMLEditorPluginHOLD_OLD getDefault() {
- return instance;
- }
-
- public synchronized static XMLEditorPluginHOLD_OLD getInstance() {
- return instance;
- }
-
- public AdapterFactoryRegistry getAdapterFactoryRegistry() {
- return AdapterFactoryRegistryImpl.getInstance();
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImageHelper.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImageHelper.java
deleted file mode 100644
index b0d11df890..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImageHelper.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-/**
- * Helper class to handle images provided by this plug-in.
- *
- * NOTE: For internal use only. For images used externally, please use the
- * Shared***ImageHelper class instead.
- *
- * @author amywu
- */
-public class XMLEditorPluginImageHelper {
- private final String PLUGINID = XMLUIPlugin.ID;
- private static XMLEditorPluginImageHelper instance = null;
-
- // save a descriptor for each image
- private HashMap fImageDescRegistry = null;
-
- /**
- * Gets the instance.
- *
- * @return Returns a XMLEditorPluginImageHelper
- */
- public synchronized static XMLEditorPluginImageHelper getInstance() {
- if (instance == null) {
- instance = new XMLEditorPluginImageHelper();
- }
- return instance;
- }
-
- /**
- * Retrieves the image associated with resource from the image registry.
- * If the image cannot be retrieved, attempt to find and load the image at
- * the location specified in resource.
- *
- * @param resource
- * the image to retrieve
- * @return Image the image associated with resource or null if one could
- * not be found
- */
- public Image getImage(String resource) {
- Image image = getImageRegistry().get(resource);
- if (image == null) {
- // create an image
- image = createImage(resource);
- }
- return image;
- }
-
- /**
- * Retrieves the image descriptor associated with resource from the image
- * descriptor registry. If the image descriptor cannot be retrieved,
- * attempt to find and load the image descriptor at the location specified
- * in resource.
- *
- * @param resource
- * the image descriptor to retrieve
- * @return ImageDescriptor the image descriptor assocated with resource or
- * the default "missing" image descriptor if one could not be
- * found
- */
- public ImageDescriptor getImageDescriptor(String resource) {
- ImageDescriptor imageDescriptor = null;
- Object o = getImageDescriptorRegistry().get(resource);
- if (o == null) {
- // create a descriptor
- imageDescriptor = createImageDescriptor(resource);
- }
- else {
- imageDescriptor = (ImageDescriptor) o;
- }
- return imageDescriptor;
- }
-
- /**
- * Returns the image descriptor registry for this plugin.
- *
- * @return HashMap - image descriptor registry for this plugin
- */
- private HashMap getImageDescriptorRegistry() {
- if (fImageDescRegistry == null) {
- fImageDescRegistry = new HashMap();
- }
- return fImageDescRegistry;
- }
-
- /**
- * Returns the image registry for this plugin.
- *
- * @return ImageRegistry - image registry for this plugin
- */
- private ImageRegistry getImageRegistry() {
- return JFaceResources.getImageRegistry();
- }
-
- /**
- * Creates an image from the given resource and adds the image to the
- * image registry.
- *
- * @param resource
- * @return Image
- */
- private Image createImage(String resource) {
- ImageDescriptor desc = getImageDescriptor(resource);
- Image image = null;
-
- if (desc != null) {
- image = desc.createImage();
- // dont add the missing image descriptor image to the image
- // registry
- if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) {
- getImageRegistry().put(resource, image);
- }
- }
- return image;
- }
-
- /**
- * Creates an image descriptor from the given imageFilePath and adds the
- * image descriptor to the image descriptor registry. If an image
- * descriptor could not be created, the default "missing" image descriptor
- * is returned but not added to the image descriptor registry.
- *
- * @param imageFilePath
- * @return ImageDescriptor image descriptor for imageFilePath or default
- * "missing" image descriptor if resource could not be found
- */
- private ImageDescriptor createImageDescriptor(String imageFilePath) {
- ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath);
- if (imageDescriptor != null) {
- getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
- }
- else {
- imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
- }
-
- return imageDescriptor;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImages.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImages.java
deleted file mode 100644
index a35f00f4cc..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorPluginImages.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-/**
- * Bundle of most images used by the XML Editor plug-in.
- */
-public class XMLEditorPluginImages {
- public static final String IMG_DTOOL_COLLAPSE = "icons/full/dtool16/collapse.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_COLLAPSE = "icons/full/etool16/collapse.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_COLLAPSEALL = "icons/full/dtool16/collapse_all.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_COLLAPSEALL = "icons/full/etool16/collapse_all.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_EXPAND = "icons/full/dtool16/expand.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_EXPAND = "icons/full/etool16/expand.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_EXPANDALL = "icons/full/dtool16/expand_all.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_EXPANDALL = "icons/full/etool16/expand_all.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_NEW_XML = "icons/full/dtool16/new_xml.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_NEW_XML = "icons/full/etool16/new_xml.gif"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorResources.properties b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorResources.properties
deleted file mode 100644
index 2fc1735baf..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLEditorResources.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-###############################################################################
-# Copyright (c) 2004, 2005 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-XMLTableTreeViewer_0=Design
-XMLMultiPageEditorPart_0=Source
-XMLTreeExtension_0=Structure
-XMLTreeExtension_1=Value
-XMLTreeExtension_3=The document is empty.
-XMLTreeExtension_4=Right mouse click here to insert content.
-XMLTableTreeActionBarContributor_0=&XML
-XMLTableTreeActionBarContributor_1=&Expand All
-XMLTableTreeActionBarContributor_2=&Collapse All
-XMLTableTreeActionBarContributor_3=Turn Grammar Constraints Off
-XMLTableTreeActionBarContributor_4=&Turn Grammar Constraints Off
-XMLTableTreeActionBarContributor_5=Turn Grammar Constraints On
-XMLTableTreeActionBarContributor_6=&Turn Grammar Constraints On
-XMLTableTreeActionBarContributor_7=Reload Dependencies
-XMLTableTreeActionBarContributor_8=&Reload Dependencies
-##
-An_error_has_occurred_when1_ERROR_=An error has occurred when initializing the input for the the editor's source page.
-Resource__does_not_exist=Resource {0} does not exist.
-Editor_could_not_be_open=Editor could not be open on {0}
-TreeExtension_0=Cannot display document contents.
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorActionBarContributor.java
deleted file mode 100644
index 7d4ee4b629..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorActionBarContributor.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor;
-
-
-public class XMLMultiPageEditorActionBarContributor extends SourceEditorActionBarContributor {
-
- private boolean needsMultiInit = true;
-
- public XMLMultiPageEditorActionBarContributor() {
- super();
- }
-
- protected void initDesignViewerActionBarContributor(IActionBars actionBars) {
- super.initDesignViewerActionBarContributor(actionBars);
-
- if (designViewerActionBarContributor != null) {
- if (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor) {
- ((IDesignViewerActionBarContributor) designViewerActionBarContributor).initViewerSpecificContributions(actionBars);
- }
- }
- }
-
- protected void activateDesignPage(IEditorPart activeEditor) {
- if ((sourceViewerActionContributor != null) && (sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)) {
- // if design page is not really an IEditorPart, activeEditor ==
- // null, so pass in multiPageEditor instead (d282414)
- if (activeEditor == null) {
- sourceViewerActionContributor.setActiveEditor(multiPageEditor);
- }
- else {
- sourceViewerActionContributor.setActiveEditor(activeEditor);
- }
- ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(false);
- }
-
- if ((designViewerActionBarContributor != null) && (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor)) {
- designViewerActionBarContributor.setActiveEditor(multiPageEditor);
- ((IDesignViewerActionBarContributor) designViewerActionBarContributor).setViewerSpecificContributionsEnabled(true);
- }
- }
-
- protected void activateSourcePage(IEditorPart activeEditor) {
- if ((designViewerActionBarContributor != null) && (designViewerActionBarContributor instanceof IDesignViewerActionBarContributor)) {
- designViewerActionBarContributor.setActiveEditor(multiPageEditor);
- ((IDesignViewerActionBarContributor) designViewerActionBarContributor).setViewerSpecificContributionsEnabled(false);
- }
-
- if ((sourceViewerActionContributor != null) && (sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)) {
- sourceViewerActionContributor.setActiveEditor(activeEditor);
- ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(true);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorActionBarContributor#init(org.eclipse.ui.IActionBars)
- */
- public void init(IActionBars actionBars) {
- super.init(actionBars);
- needsMultiInit = true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
- */
- public void setActiveEditor(IEditorPart targetEditor) {
- if (needsMultiInit) {
- designViewerActionBarContributor = new XMLTableTreeActionBarContributor();
- initDesignViewerActionBarContributor(getActionBars());
- needsMultiInit = false;
- }
- super.setActiveEditor(targetEditor);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java
deleted file mode 100644
index 0cb4194e7f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLMultiPageEditorPart.java
+++ /dev/null
@@ -1,938 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and
- * is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- ****************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.ide.IGotoMarker;
-import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
-import org.eclipse.ui.part.MultiPageEditorPart;
-import org.eclipse.ui.part.MultiPageEditorSite;
-import org.eclipse.ui.part.MultiPageSelectionProvider;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.IXMLPreferenceNames;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-public class XMLMultiPageEditorPart extends MultiPageEditorPart {
-
- /**
- * Internal part activation listener, copied from AbstractTextEditor
- */
- class ActivationListener implements IPartListener, IWindowListener {
-
- /** Cache of the active workbench part. */
- private IWorkbenchPart fActivePart;
- /** Indicates whether activation handling is currently be done. */
- private boolean fIsHandlingActivation = false;
- /**
- * The part service.
- *
- * @since 3.1
- */
- private IPartService fPartService;
-
- /**
- * Creates this activation listener.
- *
- * @param partService
- * the part service on which to add the part listener
- * @since 3.1
- */
- public ActivationListener(IPartService partService) {
- fPartService = partService;
- fPartService.addPartListener(this);
- PlatformUI.getWorkbench().addWindowListener(this);
- }
-
- /**
- * Disposes this activation listener.
- *
- * @since 3.1
- */
- public void dispose() {
- fPartService.removePartListener(this);
- PlatformUI.getWorkbench().removeWindowListener(this);
- fPartService = null;
- }
-
- /*
- * @see IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
- */
- public void partActivated(IWorkbenchPart part) {
- fActivePart = part;
- handleActivation();
- }
-
- /*
- * @see IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
- */
- public void partBroughtToTop(IWorkbenchPart part) {
- // do nothing
- }
-
- /*
- * @see IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
- */
- public void partClosed(IWorkbenchPart part) {
- // do nothing
- }
-
- /*
- * @see IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart)
- */
- public void partDeactivated(IWorkbenchPart part) {
- fActivePart = null;
- }
-
- /*
- * @see IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
- */
- public void partOpened(IWorkbenchPart part) {
- // do nothing
- }
-
- /**
- * Handles the activation triggering a element state check in the
- * editor.
- */
- void handleActivation() {
- if (fIsHandlingActivation || (getTextEditor() == null)) {
- return;
- }
-
- if (fActivePart == XMLMultiPageEditorPart.this) {
- fIsHandlingActivation = true;
- try {
- getTextEditor().safelySanityCheckState(getEditorInput());
- }
- finally {
- fIsHandlingActivation = false;
- }
- }
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
- * @since 3.1
- */
- public void windowActivated(IWorkbenchWindow window) {
- if (window == getEditorSite().getWorkbenchWindow()) {
- /*
- * Workaround for problem described in
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11731 Will be
- * removed when SWT has solved the problem.
- */
- window.getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- handleActivation();
- }
- });
- }
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
- * @since 3.1
- */
- public void windowDeactivated(IWorkbenchWindow window) {
- // do nothing
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
- * @since 3.1
- */
- public void windowClosed(IWorkbenchWindow window) {
- // do nothing
- }
-
- /*
- * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
- * @since 3.1
- */
- public void windowOpened(IWorkbenchWindow window) {
- // do nothing
- }
- }
-
- /**
- * Listens for selection from the source page, applying it to the design
- * viewer.
- */
- private class TextEditorPostSelectionAdapter extends UIJob implements ISelectionChangedListener {
- boolean forcePostSelection = false;
- ISelection selection = null;
-
- public TextEditorPostSelectionAdapter() {
- super(getTitle());
- setUser(true);
- }
-
- public IStatus runInUIThread(IProgressMonitor monitor) {
- if (selection != null) {
- fDesignViewer.getSelectionProvider().setSelection(selection);
- }
- return Status.OK_STATUS;
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- if ((fDesignViewer != null) && ((getActivePage() != fDesignPageIndex) || !XMLMultiPageEditorPart.this.equals(getSite().getPage().getActivePart()))) {
- if (forcePostSelection) {
- selection = event.getSelection();
- schedule(200);
- }
- else {
- fDesignViewer.getSelectionProvider().setSelection(event.getSelection());
- }
- }
- }
- }
-
- private class PageInitializationData {
- IConfigurationElement fElement;
- String fPropertyName;
- Object fData;
-
- PageInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
- super();
- fElement = cfig;
- fPropertyName = propertyName;
- fData = data;
- }
- void sendInitializationData(IExecutableExtension executableExtension) {
- try {
- executableExtension.setInitializationData(fElement, fPropertyName, fData);
- } catch (CoreException e) {
- Logger.logException(e);
- }
- }
- }
-
- /**
- * Internal IPropertyListener
- */
- class PropertyListener implements IPropertyListener {
- public void propertyChanged(Object source, int propId) {
- switch (propId) {
- // had to implement input changed "listener" so that
- // StructuredTextEditor could tell it containing editor that
- // the input has change, when a 'resource moved' event is
- // found.
- case IEditorPart.PROP_INPUT : {
- if (source == getTextEditor() && fDesignViewer instanceof XMLTableTreeViewer) {
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- try {
- if (model instanceof IDOMModel) {
- IDOMDocument modelDocument = ((IDOMModel)model).getDocument();
- Object designInput = ((XMLTableTreeViewer)fDesignViewer).getInput();
- if (modelDocument != designInput)
- setInput(getTextEditor().getEditorInput());
- }
- } finally {
- if (model != null)
- model.releaseFromRead();
- }
- }
- }
- case IEditorPart.PROP_DIRTY : {
- if (source == getTextEditor()) {
- if (getTextEditor().getEditorInput() != getEditorInput()) {
- setInput(getTextEditor().getEditorInput());
- /*
- * title should always change when input changes.
- * create runnable for following post call
- */
- Runnable runnable = new Runnable() {
- public void run() {
- _firePropertyChange(IWorkbenchPart.PROP_TITLE);
- }
- };
- /*
- * Update is just to post things on the display
- * queue (thread). We have to do this to get the
- * dirty property to get updated after other
- * things on the queue are executed.
- */
- ((Control) getTextEditor().getAdapter(Control.class)).getDisplay().asyncExec(runnable);
- }
- }
- break;
- }
- case IWorkbenchPart.PROP_TITLE : {
- // update the input if the title is changed
- if (source == getTextEditor()) {
- if (getTextEditor().getEditorInput() != getEditorInput()) {
- setInput(getTextEditor().getEditorInput());
- }
- }
- break;
- }
- default : {
- // propagate changes. Is this needed? Answer: Yes.
- if (source == getTextEditor()) {
- _firePropertyChange(propId);
- }
- break;
- }
- }
-
- }
- }
-
- class TextInputListener implements ITextInputListener {
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- // do nothing
- }
-
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if ((fDesignViewer != null) && (newInput != null)) {
- fDesignViewer.setDocument(newInput);
- }
- }
- }
-
- class StatusLineLabelProvider extends JFaceNodeLabelProvider {
- public StatusLineLabelProvider() {
- }
-
- public String getText(Object element) {
- if (element == null)
- return null;
-
- Node node = (Node) element;
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- return getText(((Attr) node).getOwnerElement());
- }
-
- StringBuffer s = new StringBuffer();
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- while (node != null && node instanceof INodeNotifier) {
- INodeNotifier notifier = (INodeNotifier) node;
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- IJFaceNodeAdapter adapter = (IJFaceNodeAdapter) notifier.getAdapterFor(IJFaceNodeAdapter.class);
- if (adapter != null) {
- s.insert(0, adapter.getLabelText(node));
- }
- }
- node = node.getParentNode();
- if (node != null && node.getNodeType() != Node.DOCUMENT_NODE)
- s.insert(0, IPath.SEPARATOR);
- }
- }
- return s.toString();
- }
-
- public Image getImage(Object element) {
- if (element == null)
- return null;
-
- Node node = (Node) element;
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- return getImage(((Attr) node).getOwnerElement());
- }
- return super.getImage(element);
- }
- }
-
- /** The design page index. */
- private int fDesignPageIndex;
-
- /** The design viewer */
- IDesignViewer fDesignViewer;
-
- private ActivationListener fActivationListener;
-
- IPropertyListener fPropertyListener = null;
-
- /** The source page index. */
- int fSourcePageIndex;
-
- /** The text editor. */
- private StructuredTextEditor fTextEditor;
-
- private TextEditorPostSelectionAdapter fTextEditorSelectionListener;
-
- private ILabelProvider fStatusLineLabelProvider;
-
- private PageInitializationData fPageInitializer;
-
- /**
- * StructuredTextMultiPageEditorPart constructor comment.
- */
- public XMLMultiPageEditorPart() {
- super();
- fStatusLineLabelProvider = new StatusLineLabelProvider();
- }
-
- /*
- * This method is just to make firePropertyChanged accessible from some
- * (anonomous) inner classes.
- */
- void _firePropertyChange(int property) {
- super.firePropertyChange(property);
- }
-
- /**
- * Adds the source page of the multi-page editor.
- */
- private void addSourcePage() throws PartInitException {
- fSourcePageIndex = addPage(fTextEditor, getEditorInput());
- setPageText(fSourcePageIndex, XMLEditorMessages.XMLMultiPageEditorPart_0);
-
- firePropertyChange(PROP_TITLE);
-
- // Changes to the Text Viewer's document instance should also
- // force an
- // input refresh
- fTextEditor.getTextViewer().addTextInputListener(new TextInputListener());
- }
-
- /**
- * Connects the design viewer with the viewer selection manager. Should be
- * done after createSourcePage() is done because we need to get the
- * ViewerSelectionManager from the TextEditor. setModel is also done here
- * because getModel() needs to reference the TextEditor.
- */
- private void connectDesignPage() {
- if (fDesignViewer != null) {
- fDesignViewer.setDocument(getDocument());
- }
-
- /*
- * Connect selection from the Design page to the selection provider
- * for the XMLMultiPageEditorPart so that selection changes in the
- * Design page will propogate across the workbench
- */
- if (fDesignViewer.getSelectionProvider() instanceof IPostSelectionProvider) {
- ((IPostSelectionProvider) fDesignViewer.getSelectionProvider()).addPostSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ((MultiPageSelectionProvider) getSite().getSelectionProvider()).firePostSelectionChanged(event);
- }
- });
- }
- fDesignViewer.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ((MultiPageSelectionProvider) getSite().getSelectionProvider()).fireSelectionChanged(event);
- }
- });
-
- /*
- * Connect selection from the Design page to the selection provider of
- * the Source page so that selection in the Design page will drive
- * selection in the Source page. Prefer post selection.
- */
- if (fDesignViewer.getSelectionProvider() instanceof IPostSelectionProvider) {
- ((IPostSelectionProvider) fDesignViewer.getSelectionProvider()).addPostSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(final SelectionChangedEvent event) {
- /*
- * Only force selection update if source page is not
- * active
- */
- if (getActivePage() != fSourcePageIndex) {
- getTextEditor().getSelectionProvider().setSelection(event.getSelection());
- }
- }
- });
- }
- else {
- fDesignViewer.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- /*
- * Only force selection update if source page is not
- * active
- */
- if (getActivePage() != fSourcePageIndex) {
- getTextEditor().getSelectionProvider().setSelection(event.getSelection());
- }
- /* Bug 210481 - Removed call to updateStatusLine because this is already
- * handled by the selection in the source page */
- }
- });
- }
-
- /*
- * Handle double-click in the Design page by selecting the
- * corresponding amount of text in the Source page.
- */
- fDesignViewer.getControl().addListener(SWT.MouseDoubleClick, new Listener() {
- public void handleEvent(Event event) {
- ISelection selection = fDesignViewer.getSelectionProvider().getSelection();
- int start = -1;
- int length = -1;
- if (selection instanceof IStructuredSelection) {
- /*
- * selection goes from the start of the first object to
- * the end of the last
- */
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- Object o = structuredSelection.getFirstElement();
- Object o2 = null;
- if (structuredSelection.size() > 1) {
- o2 = structuredSelection.toArray()[structuredSelection.size() - 1];
- }
- else {
- o2 = o;
- }
- if (o instanceof IndexedRegion) {
- start = ((IndexedRegion) o).getStartOffset();
- length = ((IndexedRegion) o2).getEndOffset() - start;
- }
- else if (o2 instanceof ITextRegion) {
- start = ((ITextRegion) o).getStart();
- length = ((ITextRegion) o2).getEnd() - start;
- }
- }
- else if (selection instanceof ITextSelection) {
- start = ((ITextSelection) selection).getOffset();
- length = ((ITextSelection) selection).getLength();
- }
- if ((start > -1) && (length > -1)) {
- getTextEditor().selectAndReveal(start, length);
- }
- }
- });
-
- /*
- * Connect selection from the Source page to the selection provider of
- * the Design page so that selection in the Source page will drive
- * selection in the Design page. Prefer post selection.
- */
- ISelectionProvider provider = getTextEditor().getSelectionProvider();
- if (fTextEditorSelectionListener == null) {
- fTextEditorSelectionListener = new TextEditorPostSelectionAdapter();
- }
- if (provider instanceof IPostSelectionProvider) {
- fTextEditorSelectionListener.forcePostSelection = false;
- ((IPostSelectionProvider) provider).addPostSelectionChangedListener(fTextEditorSelectionListener);
- }
- else {
- fTextEditorSelectionListener.forcePostSelection = true;
- provider.addSelectionChangedListener(fTextEditorSelectionListener);
- }
- }
-
- /**
- * Create and Add the Design Page using a registered factory
- *
- */
- private void createAndAddDesignPage() {
- IDesignViewer designViewer = createDesignPage();
-
- fDesignViewer = designViewer;
- // note: By adding the design page as a Control instead of an
- // IEditorPart, page switches will indicate
- // a "null" active editor when the design page is made active
- fDesignPageIndex = addPage(designViewer.getControl());
- setPageText(fDesignPageIndex, designViewer.getTitle());
- }
-
- protected IDesignViewer createDesignPage() {
- XMLTableTreeViewer tableTreeViewer = new XMLTableTreeViewer(getContainer());
- // Set the default infopop for XML design viewer.
- XMLUIPlugin.getInstance().getWorkbench().getHelpSystem().setHelp(tableTreeViewer.getControl(), XMLTableTreeHelpContextIds.XML_DESIGN_VIEW_HELPID);
- return tableTreeViewer;
- }
-
- /**
- * Creates the pages of this multi-page editor.
- * <p>
- * Subclasses of <code>MultiPageEditor</code> must implement this
- * method.
- * </p>
- */
- protected void createPages() {
- try {
- // source page MUST be created before design page, now
- createSourcePage();
-
- createAndAddDesignPage();
- addSourcePage();
- connectDesignPage();
-
- // set the active editor in the action bar contributor first
- // before setactivepage calls action bar contributor's
- // setactivepage (bug141013 - remove when bug151488 is fixed)
- IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor();
- if (contributor instanceof MultiPageEditorActionBarContributor) {
- ((MultiPageEditorActionBarContributor) contributor).setActiveEditor(this);
- }
-
- int activePageIndex = getPreferenceStore().getInt(IXMLPreferenceNames.LAST_ACTIVE_PAGE);
- if ((activePageIndex >= 0) && (activePageIndex < getPageCount())) {
- setActivePage(activePageIndex);
- }
- else {
- setActivePage(fSourcePageIndex);
- }
- }
- catch (PartInitException e) {
- Logger.logException(e);
- throw new RuntimeException(e);
- }
- }
-
- /**
- * @see org.eclipse.ui.part.MultiPageEditorPart#createSite(org.eclipse.ui.IEditorPart)
- */
- protected IEditorSite createSite(IEditorPart editor) {
- IEditorSite site = null;
- if (editor == fTextEditor) {
- site = new MultiPageEditorSite(this, editor) {
- /**
- * @see org.eclipse.ui.part.MultiPageEditorSite#getActionBarContributor()
- */
- public IEditorActionBarContributor getActionBarContributor() {
- IEditorActionBarContributor contributor = super.getActionBarContributor();
- IEditorActionBarContributor multiContributor = XMLMultiPageEditorPart.this.getEditorSite().getActionBarContributor();
- if (multiContributor instanceof XMLMultiPageEditorActionBarContributor) {
- contributor = ((XMLMultiPageEditorActionBarContributor) multiContributor).sourceViewerActionContributor;
- }
- return contributor;
- }
-
- public String getId() {
- // sets this id so nested editor is considered xml source
- // page
- return ContentTypeIdForXML.ContentTypeID_XML + ".source"; //$NON-NLS-1$;
- }
- };
- }
- else {
- site = super.createSite(editor);
- }
- return site;
- }
-
- /**
- * Creates the source page of the multi-page editor.
- */
- protected void createSourcePage() throws PartInitException {
- fTextEditor = createTextEditor();
- fTextEditor.setEditorPart(this);
-
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=134301 - XML editor
- * does not remember font settings
- *
- * @see
- * org.eclipse.ui.texteditor.AbstractTextEditor#getSymbolicFontName()
- */
- fPageInitializer.sendInitializationData(fTextEditor);
-
- if (fPropertyListener == null) {
- fPropertyListener = new PropertyListener();
- }
- fTextEditor.addPropertyListener(fPropertyListener);
- }
-
- /**
- * Method createTextEditor.
- *
- * @return StructuredTextEditor
- */
- private StructuredTextEditor createTextEditor() {
- return new StructuredTextEditor();
- }
-
- private void disconnectDesignPage() {
- if (fDesignViewer != null) {
- fDesignViewer.setDocument(null);
- }
- }
-
- public void dispose() {
- Logger.trace("Source Editor", "XMLMultiPageEditorPart::dispose entry"); //$NON-NLS-1$ //$NON-NLS-2$
-
- disconnectDesignPage();
-
- if (fActivationListener != null) {
- fActivationListener.dispose();
- fActivationListener = null;
- }
-
- if ((fTextEditor != null) && (fPropertyListener != null)) {
- fTextEditor.removePropertyListener(fPropertyListener);
- }
-
- // moved to last when added window ... seems like
- // we'd be in danger of losing some data, like site,
- // or something.
- super.dispose();
-
- Logger.trace("Source Editor", "StructuredTextMultiPageEditorPart::dispose exit"); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void doSave(IProgressMonitor monitor) {
- fTextEditor.doSave(monitor);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.ISaveablePart#doSaveAs()
- */
- public void doSaveAs() {
- fTextEditor.doSaveAs();
- /*
- * Update the design viewer since the editor input would have changed
- * to the new file.
- */
- if (fDesignViewer != null) {
- fDesignViewer.setDocument(getDocument());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class key) {
- Object result = null;
-
- // we extend superclass, not override it, so allow it first
- // chance to satisfy request.
- result = super.getAdapter(key);
-
- if (result == null) {
- if (key == IDesignViewer.class) {
- result = fDesignViewer;
-
- }
- else if (key.equals(IGotoMarker.class)) {
- result = new IGotoMarker() {
- public void gotoMarker(IMarker marker) {
- XMLMultiPageEditorPart.this.gotoMarker(marker);
- }
- };
- }
- else {
- /*
- * DMW: I'm bullet-proofing this because its been reported (on
- * very early versions) a null pointer sometimes happens here
- * on startup, when an editor has been left open when
- * workbench shutdown.
- */
- if (fTextEditor != null) {
- result = fTextEditor.getAdapter(key);
- }
- }
- }
- return result;
- }
-
- private IDocument getDocument() {
- IDocument document = null;
- if (fTextEditor != null) {
- document = fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput());
- }
- return document;
- }
-
- private IPreferenceStore getPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- StructuredTextEditor getTextEditor() {
- return fTextEditor;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchPart#getTitle()
- */
- public String getTitle() {
- String title = null;
- if (getTextEditor() == null) {
- if (getEditorInput() != null) {
- title = getEditorInput().getName();
- }
- }
- else {
- title = getTextEditor().getTitle();
- }
- if (title == null) {
- title = getPartName();
- }
- return title;
- }
-
- void gotoMarker(IMarker marker) {
- setActivePage(fSourcePageIndex);
- IDE.gotoMarker(fTextEditor, marker);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
- * org.eclipse.ui.IEditorInput)
- */
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- try {
- super.init(site, input);
- // we want to listen for our own activation
- fActivationListener = new ActivationListener(site.getWorkbenchWindow().getPartService());
- }
- catch (Exception e) {
- Logger.logException("exception initializing " + getClass().getName(), e); //$NON-NLS-1$
- }
- setPartName(input.getName());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
- */
- public boolean isSaveAsAllowed() {
- return (fTextEditor != null) && fTextEditor.isSaveAsAllowed();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded()
- */
- public boolean isSaveOnCloseNeeded() {
- // overriding super class since it does a lowly isDirty!
- if (fTextEditor != null) {
- return fTextEditor.isSaveOnCloseNeeded();
- }
- return isDirty();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.MultiPageEditorPart#pageChange(int)
- */
- protected void pageChange(int newPageIndex) {
- super.pageChange(newPageIndex);
- saveLastActivePageIndex(newPageIndex);
-
- if (newPageIndex == fDesignPageIndex) {
- // design page isn't an IEditorPart, therefore we have to send
- // selection changes ourselves
- ISelectionProvider selectionProvider = fDesignViewer.getSelectionProvider();
- if (selectionProvider != null) {
- SelectionChangedEvent event = new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection());
- ((MultiPageSelectionProvider) getSite().getSelectionProvider()).fireSelectionChanged(event);
- ((MultiPageSelectionProvider) getSite().getSelectionProvider()).firePostSelectionChanged(event);
- }
- }
- }
-
- private void saveLastActivePageIndex(int newPageIndex) {
- // save the last active page index to preference manager
- getPreferenceStore().setValue(IXMLPreferenceNames.LAST_ACTIVE_PAGE, newPageIndex);
- }
-
- public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
- super.setInitializationData(cfig, propertyName, data);
- fPageInitializer = new PageInitializationData(cfig, propertyName, data);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
- */
- protected void setInput(IEditorInput input) {
- /*
- * If driven from the Source page, it's "model" may not be up to date
- * with (or even exist for) the input just yet. Later notification
- * from the TextViewer could set us straight, although it's not
- * guaranteed to happen after the model has been created.
- */
- super.setInput(input);
- if (fDesignViewer != null) {
- fDesignViewer.setDocument(getDocument());
- }
- setPartName(input.getName());
- }
-
- void updateStatusLine(ISelection selection) {
- IStatusLineManager statusLineManager = getEditorSite().getActionBars().getStatusLineManager();
- if (fStatusLineLabelProvider != null && statusLineManager != null) {
- String text = null;
- Image image = null;
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Object firstElement = ((IStructuredSelection) selection).getFirstElement();
- if (firstElement != null) {
- text = fStatusLineLabelProvider.getText(firstElement);
- image = fStatusLineLabelProvider.getImage((firstElement));
- }
- }
- if (image == null) {
- statusLineManager.setMessage(text);
- }
- else {
- statusLineManager.setMessage(image, text);
- }
- }
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java
deleted file mode 100644
index 9da1fef334..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeActionBarContributor.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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
- * David Carver - bug 212330 - migrate to org.eclipse.ui.menus extension point
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.IMenuManager;
-//import org.eclipse.jface.action.IToolBarManager;
-//import org.eclipse.jface.action.MenuManager;
-//import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-//import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
-import org.w3c.dom.Document;
-
-/**
- *
- */
-public class XMLTableTreeActionBarContributor implements IDesignViewerActionBarContributor {
-
- protected IEditorPart editorPart;
- protected final static String DESIGN_VIEWER_SEPARATOR_1_ID = "sed.tabletree.separator.1"; //$NON-NLS-1$
- protected final static String DESIGN_VIEWER_SEPARATOR_2_ID = "sed.tabletree.separator.2"; //$NON-NLS-1$
- protected final static String VALIDATE_XML_ID = "sed.tabletree.validateXML"; //$NON-NLS-1$
- protected final static String RELOAD_GRAMMAR_ID = "sed.tabletree.reloadGrammar"; //$NON-NLS-1$
- protected final static String TOGGLE_EDIT_MODE_ID = "sed.tabletree.toggleEditMode"; //$NON-NLS-1$
- protected final static String EXPAND_ALL_ID = "sed.tabletree.expandAll"; //$NON-NLS-1$
- protected final static String COLLAPSE_ALL_ID = "sed.tabletree.collapseAll"; //$NON-NLS-1$
-
- protected ToggleEditModeAction toggleAction;
- protected ReloadGrammarAction reloadGrammarAction;
- // protected ValidateXMLAction validateXMLAction;
- protected ViewerExpandCollapseAction expandAction;
- protected ViewerExpandCollapseAction collapseAction;
- protected ViewerExpandCollapseAction xmlMenuExpandAction;
- protected ViewerExpandCollapseAction xmlMenuCollapseAction;
-
- public XMLTableTreeActionBarContributor() {
- }
-
- protected void removeContributions(IContributionManager manager) {
-/* try {
- doRemove(manager, DESIGN_VIEWER_SEPARATOR_1_ID);
- doRemove(manager, DESIGN_VIEWER_SEPARATOR_2_ID);
- doRemove(manager, VALIDATE_XML_ID);
- doRemove(manager, RELOAD_GRAMMAR_ID);
- doRemove(manager, TOGGLE_EDIT_MODE_ID);
- doRemove(manager, EXPAND_ALL_ID);
- doRemove(manager, COLLAPSE_ALL_ID);
- }
- catch (Exception e) {
- }
-*/
- }
-
- protected void doRemove(IContributionManager manager, String id) {
-/* try {
- if (manager.find(id) != null) {
- manager.remove(id);
- }
- }
- catch (Exception e) {
- }
-*/ }
-
- public void init(IActionBars bars, IWorkbenchPage page) {
- init(bars);
- }
-
- public void init(IActionBars bars) {
-// IToolBarManager tbm = bars.getToolBarManager();
-
-/* IMenuManager xmlMenu = bars.getMenuManager().findMenuUsingPath("org.eclipse.core.runtime.xml.design.xmlmenu"); //$NON-NLS-1$
-
- if (xmlMenu == null) {
- xmlMenu = new MenuManager(XMLEditorMessages.XMLTableTreeActionBarContributor_0, "org.eclipse.core.runtime.xml.design.xmlmenu"); //$NON-NLS-1$
- // For RCP usage
- if (bars.getMenuManager().find(IWorkbenchActionConstants.M_WINDOW) != null) {
- bars.getMenuManager().insertBefore(IWorkbenchActionConstants.M_WINDOW, xmlMenu);
- }
- }
- else {
- removeContributions(xmlMenu);
- }
-
- tbm.add(new Separator("DESIGN_VIEWER_SEPARATOR_1_ID")); //$NON-NLS-1$
-*/
- // ToggleEditModeAction
- //
-/* toggleAction = new ToggleEditModeAction();
- toggleAction.setId(TOGGLE_EDIT_MODE_ID);
- xmlMenu.add(toggleAction);
- tbm.add(toggleAction);
-*/
- // ReloadGrammarAction
- //
-/* reloadGrammarAction = new ReloadGrammarAction();
- reloadGrammarAction.setId(RELOAD_GRAMMAR_ID);
- tbm.add(reloadGrammarAction);
- xmlMenu.add(reloadGrammarAction);
-
- xmlMenu.add(new Separator());
-*/
- // ExpandCollapseAction
- //
-/* xmlMenuExpandAction = new ViewerExpandCollapseAction(true);
- xmlMenuExpandAction.setId(EXPAND_ALL_ID);
- xmlMenuExpandAction.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_1);
- xmlMenu.add(xmlMenuExpandAction);
-
- xmlMenuCollapseAction = new ViewerExpandCollapseAction(false);
- xmlMenuCollapseAction.setId(COLLAPSE_ALL_ID);
- xmlMenuCollapseAction.setId(EXPAND_ALL_ID);
- xmlMenuCollapseAction.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_2);
- xmlMenu.add(xmlMenuCollapseAction);
-*/
- }
-
- protected void addActionWithId(IMenuManager menuManager, Action action, String id) {
- action.setId(id);
- menuManager.add(action);
- }
-
- public void initViewerSpecificContributions(IActionBars bars) {
-/* IToolBarManager tbm = bars.getToolBarManager();
- tbm.add(new Separator(DESIGN_VIEWER_SEPARATOR_2_ID));
-
- expandAction = new ViewerExpandCollapseAction(true);
- expandAction.setId(EXPAND_ALL_ID);
- tbm.add(expandAction);
-
- collapseAction = new ViewerExpandCollapseAction(false);
- collapseAction.setId(COLLAPSE_ALL_ID);
- tbm.add(collapseAction);
-*/
- }
-
- public void setViewerSpecificContributionsEnabled(boolean enabled) {
-/* if (expandAction != null) {
- expandAction.setEnabled(enabled);
- xmlMenuExpandAction.setEnabled(enabled);
- }
-
- if (collapseAction != null) {
- collapseAction.setEnabled(enabled);
- xmlMenuCollapseAction.setEnabled(enabled);
- }
-*/
- }
-
- public void setActiveEditor(IEditorPart targetEditor) {
- editorPart = targetEditor;
-
-// IStructuredModel model = getModelForEditorPart(targetEditor);
-/* reloadGrammarAction.setModel(model);
- toggleAction.setModelQuery(ModelQueryUtil.getModelQuery(model));
-
- XMLTableTreeViewer tableTreeViewer = getTableTreeViewerForEditorPart(editorPart);
- if (tableTreeViewer != null) {
- expandAction.setViewer(tableTreeViewer);
- collapseAction.setViewer(tableTreeViewer);
-
- xmlMenuExpandAction.setViewer(tableTreeViewer);
- xmlMenuCollapseAction.setViewer(tableTreeViewer);
- }
-*/
- if (editorPart instanceof XMLMultiPageEditorPart) {
- IWorkbenchPartSite site = editorPart.getSite();
- if (site instanceof IEditorSite) {
- ITextEditor textEditor = ((XMLMultiPageEditorPart) editorPart).getTextEditor();
- IActionBars actionBars = ((IEditorSite) site).getActionBars();
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, getAction(textEditor, ITextEditorActionConstants.UNDO));
- actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, getAction(textEditor, ITextEditorActionConstants.REDO));
- }
- }
-
- // TODO... uncomment this and investigate NPE
- //
- // add the cut/copy/paste for text fields
- // ActionHandlerPlugin.connectPart(editorPart);
- }
-
- protected final IAction getAction(ITextEditor editor, String actionId) {
- return (editor == null ? null : editor.getAction(actionId));
- }
-
- protected IStructuredModel getModelForEditorPart(IEditorPart targetEditor) {
- IStructuredModel result = null;
- if (editorPart instanceof XMLMultiPageEditorPart) {
- StructuredTextEditor textEditor = ((XMLMultiPageEditorPart) targetEditor).getTextEditor();
- result = (textEditor != null) ? textEditor.getModel() : null;
- }
- return result;
- }
-
- protected XMLTableTreeViewer getTableTreeViewerForEditorPart(IEditorPart targetEditor) {
- XMLTableTreeViewer result = null;
- Object object = targetEditor.getAdapter(IDesignViewer.class);
- if (object instanceof XMLTableTreeViewer) {
- result = (XMLTableTreeViewer) object;
- }
- return result;
- }
-
- /**
- *
- */
- public class ToggleEditModeAction extends Action {
- protected ImageDescriptor onImage = SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_CONSTRAINON);
- protected ImageDescriptor offImage = SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_CONSTRAINOFF);
- protected ModelQuery modelQuery;
-
- public ToggleEditModeAction() {
- setAppearanceForEditMode(ModelQuery.EDIT_MODE_CONSTRAINED_STRICT);
- }
-
- public void run() {
- if (modelQuery != null) {
- int newState = getNextState(modelQuery.getEditMode());
- modelQuery.setEditMode(newState);
- setAppearanceForEditMode(newState);
- }
- }
-
- public void setModelQuery(ModelQuery newModelQuery) {
- modelQuery = newModelQuery;
- if (modelQuery != null) {
- setAppearanceForEditMode(modelQuery.getEditMode());
- }
- }
-
- public void setAppearanceForEditMode(int editMode) {
- if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) {
- setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_3);
- setText(XMLEditorMessages.XMLTableTreeActionBarContributor_4);
- setImageDescriptor(onImage);
- }
- else {
- setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_5);
- setText(XMLEditorMessages.XMLTableTreeActionBarContributor_6);
- setImageDescriptor(offImage);
- }
- }
-
- public int getNextState(int editMode) {
- int result = -1;
- if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) {
- result = ModelQuery.EDIT_MODE_UNCONSTRAINED;
- }
- else {
- result = ModelQuery.EDIT_MODE_CONSTRAINED_STRICT;
- }
- return result;
- }
- }
-
- /**
- *
- */
- public class ReloadGrammarAction extends Action {
- protected IStructuredModel model;
-
- public ReloadGrammarAction() {
- setDisabledImageDescriptor(SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_DTOOL_RLDGRMR));
- setImageDescriptor(SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_RLDGRMR));
- setToolTipText(XMLEditorMessages.XMLTableTreeActionBarContributor_7);
- setText(XMLEditorMessages.XMLTableTreeActionBarContributor_8);
- }
-
- public void setModel(IStructuredModel newModel) {
- this.model = newModel;
- }
-
- public void run() {
- if (model != null) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(model);
- Document document = ((IDOMModel) model).getDocument();
- if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) {
- modelQuery.getCMDocumentManager().getCMDocumentCache().clear();
- // TODO... need to figure out how to access the
- // DOMObserver via ModelQuery
- // ...why?
- CMDocumentLoader loader = new InferredGrammarBuildingCMDocumentLoader(document, modelQuery);
- loader.loadCMDocuments();
- }
- }
- }
- }
-
- /**
- * @see org.eclipse.ui.IEditorActionBarContributor#dispose()
- */
- public void dispose() {
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeContentProvider.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeContentProvider.java
deleted file mode 100644
index c713320815..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeContentProvider.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-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.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.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-
-public class XMLTableTreeContentProvider implements ITreeContentProvider, ITableLabelProvider, ILabelProvider, CMDocumentManagerListener {
-
- protected CMDocumentManager documentManager;
-
- StructuredViewer fViewer = null;
-
- private TreeContentHelper treeContentHelper = new TreeContentHelper();
-
- public XMLTableTreeContentProvider() {
- super();
- }
-
- //
- // ILabelProvider stuff
- //
- public void addListener(ILabelProviderListener listener) {
- // since we always return 'false' for "isLabelProperty",
- // not need to listen. Maybe that should change some day?
- }
-
- // CMDocumentManagerListener
- //
- public void cacheCleared(CMDocumentCache cache) {
- doDelayedRefreshForViewers();
- }
-
- public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) {
- if ((newStatus == CMDocumentCache.STATUS_LOADED) || (newStatus == CMDocumentCache.STATUS_ERROR)) {
- doDelayedRefreshForViewers();
- }
- }
-
- public void dispose() {
- }
-
- private void doDelayedRefreshForViewers() {
- if ((fViewer != null) && !fViewer.getControl().isDisposed()) {
- fViewer.getControl().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if ((fViewer != null) && !fViewer.getControl().isDisposed()) {
- fViewer.refresh(true);
- }
- }
- });
- }
- }
-
- public Object[] getChildren(Object element) {
- if (element instanceof INodeNotifier) {
- ((INodeNotifier) element).getAdapterFor(IJFaceNodeAdapter.class);
- }
- return treeContentHelper.getChildren(element);
- }
-
- public Image getColumnImage(Object object, int columnIndex) {
- return (columnIndex == 0) ? getImage(object) : null;
- }
-
- //
- // ITableLabelProvider stuff
- //
- public String getColumnText(Object object, int column) {
- String result = null;
- if (column == 0) {
- result = getText(object);
- }
- else if ((column == 1) && (object instanceof Node)) {
- result = treeContentHelper.getNodeValue((Node) object);
- }
- return result != null ? result : ""; //$NON-NLS-1$
- }
-
- public Object[] getElements(Object element) {
- return getChildren(element);
- }
-
- public Image getImage(Object object) {
- if (object instanceof INodeNotifier) {
- ((INodeNotifier) object).getAdapterFor(IJFaceNodeAdapter.class);
- }
-
- Image image = null;
- if (object instanceof Node) {
- Node node = (Node) object;
- switch (node.getNodeType()) {
- case Node.ATTRIBUTE_NODE : {
- image = SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ATTRIBUTE);
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- image = SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_CDATASECTION);
- break;
- }
- case Node.COMMENT_NODE : {
- image = SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_COMMENT);
- break;
- }
- case Node.DOCUMENT_TYPE_NODE : {
- image = SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_DOCTYPE);
- break;
- }
- case Node.ELEMENT_NODE : {
- image = SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ELEMENT);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- image = SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_PROCESSINGINSTRUCTION);
- break;
- }
- case Node.TEXT_NODE : {
- image = SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_TXTEXT);
- break;
- }
- case Node.ENTITY_REFERENCE_NODE : {
- image = SharedXMLEditorPluginImageHelper.getImage(SharedXMLEditorPluginImageHelper.IMG_OBJ_ENTITY_REFERENCE);
- break;
- }
- }
-
- // if (image != null) {
- // Image markerOverlayImage =
- // overlayIconManager.getOverlayImageForObject(node);
- // if (markerOverlayImage != null) {
- // image = imageFactory.createCompositeImage(image,
- // markerOverlayImage, ImageFactory.BOTTOM_LEFT);
- // }
- // }
- }
- return image;
- }
-
- public Object getParent(Object o) {
- if (o instanceof INodeNotifier) {
- ((INodeNotifier) o).getAdapterFor(IJFaceNodeAdapter.class);
- }
-
- Object result = null;
- if (o instanceof Node) {
- Node node = (Node) o;
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- result = ((Attr) node).getOwnerElement();
- }
- else {
- result = node.getParentNode();
- }
- }
- return result;
- }
-
- public Element getRootElement(Document document) {
- Element rootElement = null;
-
- for (Node childNode = document.getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) {
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- rootElement = (Element) childNode;
- break;
- }
- }
- return rootElement;
- }
-
- public String getText(Object object) {
- if (object instanceof INodeNotifier) {
- ((INodeNotifier) object).getAdapterFor(IJFaceNodeAdapter.class);
- }
-
- String result = null;
- if (object instanceof Node) {
- Node node = (Node) object;
- switch (node.getNodeType()) {
- case Node.ATTRIBUTE_NODE : {
- result = node.getNodeName();
- break;
- }
- case Node.DOCUMENT_TYPE_NODE : {
- result = "DOCTYPE"; //$NON-NLS-1$
- break;
- }
- case Node.ELEMENT_NODE : {
- result = node.getNodeName();
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- result = ((ProcessingInstruction) node).getTarget();
- break;
- }
- }
- }
- return result != null ? result : ""; //$NON-NLS-1$
- }
-
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // remove our listeners to the old state
- if (oldInput != null) {
- Document domDoc = (Document) oldInput;
- ModelQuery mq = ModelQueryUtil.getModelQuery(domDoc);
- if (mq != null) {
- documentManager = mq.getCMDocumentManager();
- if (documentManager != null) {
- documentManager.removeListener(this);
- }
- }
- }
-
- if ((oldInput != null) && (oldInput instanceof IDOMNode)) {
- IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IDOMNode) oldInput).getModel().getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class);
- if (factory != null) {
- factory.removeListener(viewer);
- }
- }
-
- if (viewer instanceof StructuredViewer) {
- fViewer = null;
- }
- else {
- fViewer = (StructuredViewer) viewer;
- }
-
- if ((newInput != null) && (newInput instanceof IDOMNode)) {
- IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IDOMNode) newInput).getModel().getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class);
- if (factory != null) {
- factory.addListener(viewer);
- }
- }
-
- if (newInput != null) {
- Document domDoc = (Document) newInput;
- ModelQuery mq = ModelQueryUtil.getModelQuery(domDoc);
-
- if (mq != null) {
- documentManager = mq.getCMDocumentManager();
- if (documentManager != null) {
- documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_ASYNC_LOAD, true);
- documentManager.addListener(this);
- }
- }
- }
- }
-
- public boolean isDeleted(Object element) {
- return element != null;
- }
-
- // the following methods handle filtering aspects of the viewer
- //
- //
- public boolean isIgnorableText(Node node) {
- boolean result = false;
- try {
- if (node.getNodeType() == Node.TEXT_NODE) {
- String data = ((Text) node).getData();
- result = ((data == null) || (data.trim().length() == 0));
- }
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- return result;
- }
-
- public boolean isLabelProperty(Object object, String property) {
- return false;
- }
-
- public void propertyChanged(CMDocumentManager cmDocumentManager, String propertyName) {
- if (cmDocumentManager.getPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD)) {
- doDelayedRefreshForViewers();
- }
- }
-
- public void removeListener(ILabelProviderListener listener) {
- // since we always return 'false' for "isLabelProperty",
- // not need to listen. Maybe that should change some day?
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeHelpContextIds.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeHelpContextIds.java
deleted file mode 100644
index 60bc4df222..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeHelpContextIds.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-
-
-/**
- * Help context ids for the TableTree view.
- * <p>
- * This interface contains constants only; it is not intended to be
- * implemented or extended.
- * </p>
- *
- */
-public interface XMLTableTreeHelpContextIds {
- // org.eclipse.wst.xml.ui.
- public static final String PREFIX = XMLUIPlugin.ID + "."; //$NON-NLS-1$
-
- // XML Design View
- public static final String XML_DESIGN_VIEW_HELPID = PREFIX + "xmlm3000"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreePropertyDescriptorFactory.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreePropertyDescriptorFactory.java
deleted file mode 100644
index b929b4cf32..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreePropertyDescriptorFactory.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import java.util.List;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-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.properties.EnumeratedStringPropertyDescriptor;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-
-public class XMLTableTreePropertyDescriptorFactory extends DOMPropertyDescriptorFactory {
-
- protected TreeContentHelper treeContentHelper = new TreeContentHelper();
-
- public XMLTableTreePropertyDescriptorFactory() {
- super();
- }
-
- protected IPropertyDescriptor createPropertyDescriptorHelper(String name, Element element, CMNode cmNode) {
- IPropertyDescriptor result = null;
-
- ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- String[] valuesArray = null;
- if (mq != null) {
- valuesArray = mq.getPossibleDataTypeValues(element, cmNode);
- }
- if ((valuesArray != null) && (valuesArray.length > 0)) {
- result = new EnumeratedStringPropertyDescriptor(name, name, valuesArray);
- }
- else {
- result = createDefaultPropertyDescriptor(name);
- }
-
- return result;
- }
-
- public IPropertyDescriptor createTextPropertyDescriptor(Text text) {
- IPropertyDescriptor result = null;
- Node parentNode = text.getParentNode();
- if ((parentNode != null) && (parentNode.getNodeType() == Node.ELEMENT_NODE)) {
- Element parentElement = (Element) parentNode;
- ModelQuery mq = ModelQueryUtil.getModelQuery(text.getOwnerDocument());
- CMElementDeclaration ed = null;
- if (mq != null) {
- ed = mq.getCMElementDeclaration(parentElement);
- }
- if (ed != null) {
- result = createPropertyDescriptorHelper(HACK, parentElement, ed);
- }
- else {
- result = createDefaultPropertyDescriptor(parentElement.getNodeName());
- }
- }
-
- if (result == null) {
- result = new TextPropertyDescriptor(HACK, HACK);
- }
-
- return result;
- }
-
- public IPropertyDescriptor createAttributePropertyDescriptor(Attr attr) {
- IPropertyDescriptor result = null;
-
- String attributeName = attr.getName();
- ModelQuery mq = ModelQueryUtil.getModelQuery(attr.getOwnerDocument());
-
- CMAttributeDeclaration ad = null;
- if (mq != null) {
- ad = mq.getCMAttributeDeclaration(attr);
- }
- if (ad != null) {
- result = createPropertyDescriptorHelper(attributeName, attr.getOwnerElement(), ad);
- }
-
- if (result == null) {
- result = new TextPropertyDescriptor(attributeName, attributeName);
- }
-
- return result;
- }
-
- public IPropertyDescriptor createElementPropertyDescriptor(Element element) {
- IPropertyDescriptor result = null;
- List list = treeContentHelper.getElementTextContent(element);
- if (list != null) {
- Text text = treeContentHelper.getEffectiveTextNodeForCombinedNodeList(list);
- if (text != null) {
- result = createTextPropertyDescriptor(text);
- }
- }
-
- if (result == null) {
- result = new TextPropertyDescriptor(HACK, HACK);
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java
deleted file mode 100644
index 331f2d6b4c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTableTreeViewer.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and
- * is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- ****************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSource;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DragSourceListener;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.DropTargetListener;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.actions.NodeAction;
-import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager;
-import org.eclipse.wst.xml.ui.internal.dnd.DragNodeCommand;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-public class XMLTableTreeViewer extends TreeViewer implements IDesignViewer {
-
- class NodeActionMenuListener implements IMenuListener {
- public void menuAboutToShow(IMenuManager menuManager) {
- // used to disable NodeSelection listening while running
- // NodeAction
- XMLNodeActionManager nodeActionManager = new XMLNodeActionManager(((IDOMDocument) getInput()).getModel(), XMLTableTreeViewer.this) {
- public void beginNodeAction(NodeAction action) {
- super.beginNodeAction(action);
- }
-
- public void endNodeAction(NodeAction action) {
- super.endNodeAction(action);
- }
- };
- nodeActionManager.fillContextMenu(menuManager, getSelection());
- }
- }
-
- private class SelectionProvider implements IPostSelectionProvider {
-
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
- XMLTableTreeViewer.this.addPostSelectionChangedListener(listener);
- }
-
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
- XMLTableTreeViewer.this.removePostSelectionChangedListener(listener);
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- XMLTableTreeViewer.this.addSelectionChangedListener(listener);
- }
-
- public ISelection getSelection() {
- return XMLTableTreeViewer.this.getSelection();
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- XMLTableTreeViewer.this.removeSelectionChangedListener(listener);
- }
-
- public void setSelection(ISelection selection) {
- boolean selectionSet = false;
- if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- if (selection instanceof ITextSelection) {
- ITextSelection textSelection = (ITextSelection) selection;
-
- if (structuredSelection.size() == 1) {
- if (structuredSelection.getFirstElement() instanceof IDOMNode) {
- IDOMNode domNode = (IDOMNode) structuredSelection.getFirstElement();
- IStructuredDocumentRegion startStructuredDocumentRegion = domNode.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- ITextRegion matchingRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(textSelection.getOffset());
- int allowedIterations = 40;
- while (matchingRegion != null && !matchingRegion.getType().equals(DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) && allowedIterations > 0) {
- matchingRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(startStructuredDocumentRegion.getStartOffset(matchingRegion) - 1);
- allowedIterations--;
- }
- if (matchingRegion != null && matchingRegion.getType().equals(DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) {
- String attrName = startStructuredDocumentRegion.getText(matchingRegion);
- NamedNodeMap attributes = domNode.getAttributes();
- if (attributes != null && attrName.length() > 0) {
- Node attr = attributes.getNamedItem(attrName);
- if (attr != null) {
- selectionSet = true;
- XMLTableTreeViewer.this.setSelection(new StructuredSelection(attr));
- }
- }
- }
- }
- }
- }
- }
- }
- if (!selectionSet) {
- XMLTableTreeViewer.this.setSelection(selection);
- }
- }
- }
-
- protected CellEditor cellEditor;
-
- protected XMLTreeExtension treeExtension;
-
- private ISelectionProvider fSelectionProvider = new SelectionProvider();
-
- public XMLTableTreeViewer(Composite parent) {
- super(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
-
- // set up providers
- this.treeExtension = new XMLTreeExtension(getTree());
-
- XMLTableTreeContentProvider provider = new XMLTableTreeContentProvider();
- setContentProvider(provider);
- setLabelProvider(provider);
-
- createContextMenu();
-
- DragSource dragSource = new DragSource(getControl(), DND.DROP_COPY | DND.DROP_MOVE);
- dragSource.addDragListener(createDragSourceListener());
- dragSource.setTransfer(new Transfer[] {LocalSelectionTransfer.getTransfer()});
- DropTarget dropTarget = new DropTarget(getControl(), DND.DROP_COPY | DND.DROP_MOVE);
- dropTarget.addDropListener(createDropTargetListener());
- dropTarget.setTransfer(new Transfer[] {LocalSelectionTransfer.getTransfer()});
- }
-
- /**
- * This creates a context menu for the viewer and adds a listener as well
- * registering the menu for extension.
- */
- protected void createContextMenu() {
- MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
- contextMenu.add(new Separator("additions")); //$NON-NLS-1$
- contextMenu.setRemoveAllWhenShown(true);
- contextMenu.addMenuListener(new NodeActionMenuListener());
- Menu menu = contextMenu.createContextMenu(getControl());
- getControl().setMenu(menu);
- }
-
- private DragSourceListener createDragSourceListener() {
- return new DragSourceListener() {
- public void dragFinished(DragSourceEvent event) {
- LocalSelectionTransfer.getTransfer().setSelection(null);
- }
-
- public void dragSetData(DragSourceEvent event) {
- }
-
- public void dragStart(DragSourceEvent event) {
- LocalSelectionTransfer.getTransfer().setSelection(getSelection());
- }
- };
- }
-
- private DropTargetListener createDropTargetListener() {
- return new DropTargetListener() {
- public void dragEnter(DropTargetEvent event) {
- }
-
- public void dragLeave(DropTargetEvent event) {
- }
-
- public void dragOperationChanged(DropTargetEvent event) {
- }
-
- public void drop(DropTargetEvent event) {
- if (event.operations != DND.DROP_NONE && LocalSelectionTransfer.getTransfer().getSelection() instanceof IStructuredSelection) {
- dragOver(event);
- 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(), XMLTableTreeViewer.this);
- if (command != null && command.canExecute()) {
- SafeRunnable.run(new SafeRunnable() {
- public void run() throws Exception {
- command.execute();
- }
- });
- }
- }
- }
- }
-
- public void dropAccept(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;
- }
-
- 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;
- }
- }
- };
- }
-
- protected void doRefresh(Object o, boolean fromDelayed) {
- treeExtension.resetCachedData();
- super.refresh(o);
- }
-
- public ISelectionProvider getSelectionProvider() {
- return fSelectionProvider;
- }
-
- public String getTitle() {
- return XMLEditorMessages.XMLTableTreeViewer_0;
- }
-
- protected void handleDispose(DisposeEvent event) {
- super.handleDispose(event);
- treeExtension.dispose();
- setDocument(null);
- }
-
- public void refresh() {
- treeExtension.resetCachedData();
- super.refresh();
- }
-
- public void refresh(Object o) {
- treeExtension.resetCachedData();
- super.refresh(o);
- }
-
- public void refresh(boolean updateLabels) {
- treeExtension.resetCachedData();
- super.refresh(updateLabels);
- getControl().redraw();
- }
-
- public void refresh(Object element, boolean updateLabels) {
- treeExtension.resetCachedData();
- super.refresh(element, updateLabels);
- getControl().redraw();
- }
-
- public void setDocument(IDocument document) {
- /*
- * let the text editor to be the one that manages the model's lifetime
- */
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
-
- if ((model != null) && (model instanceof IDOMModel)) {
- Document domDoc = null;
- domDoc = ((IDOMModel) model).getDocument();
- setInput(domDoc);
- treeExtension.setIsUnsupportedInput(false);
- }
- else {
- treeExtension.setIsUnsupportedInput(true);
- }
- }
- finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
-
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java b/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java
deleted file mode 100644
index dfcfc5a13a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src-multipage/org/eclipse/wst/xml/ui/internal/tabletree/XMLTreeExtension.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.tabletree;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ICellModifier;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class XMLTreeExtension extends TreeExtension {
-
- public final static String STRUCTURE_PROPERTY = XMLEditorMessages.XMLTreeExtension_0;
- public final static String VALUE_PROPERTY = XMLEditorMessages.XMLTreeExtension_1;
-
- protected Composite control;
- protected MyCellModifier modifier;
- protected XMLTableTreePropertyDescriptorFactory propertyDescriptorFactory;
- protected CMDescriptionBuilder decriptionBuilder = new CMDescriptionBuilder();
- protected TreeContentHelper treeContentHelper = new TreeContentHelper();
-
- protected Color f1, f2, b1, b2;
- protected boolean cachedDataIsValid = true;
-
- public XMLTreeExtension(Tree tree) {
- super(tree);
- control = tree;
- modifier = new MyCellModifier();
- setCellModifier(modifier);
- String[] properties = {STRUCTURE_PROPERTY, VALUE_PROPERTY};
- setColumnProperties(properties);
-
- /* https://bugs.eclipse.org/bugs/show_bug.cgi?id=185851 - Used to be hardcoded as COLOR_BLACK */
- f1 = tree.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- Color background = tree.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
-
- int r = Math.abs(background.getRed() - 125);
- int g = Math.abs(background.getGreen() - 85);
- int b = Math.abs(background.getBlue() - 105);
-
- f2 = new Color(tree.getDisplay(), r, g, b);
- b1 = tree.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
- b2 = background;
-
- propertyDescriptorFactory = new XMLTableTreePropertyDescriptorFactory();
- }
-
- public void dispose() {
- super.dispose();
- f2.dispose();
- }
-
- public void resetCachedData() {
- cachedDataIsValid = false;
- }
-
- public void paintItems(GC gc, TreeItem[] items, Rectangle treeBounds) {
- super.paintItems(gc, items, treeBounds);
- cachedDataIsValid = true;
- }
-
- protected Object[] computeTreeExtensionData(Object object) {
- Color color = f1;
- String string = ""; //$NON-NLS-1$
- if (string.length() == 0) {
- string = (String) modifier.getValue(object, VALUE_PROPERTY);
- color = f1;
- }
- if ((string.length() == 0) && (object instanceof Element)) {
- string = getElementValueHelper((Element) object);
- color = f2;
- }
- Object[] data = new Object[2];
- data[0] = string;
- data[1] = color;
- return data;
- }
-
- protected void paintItem(GC gc, TreeItem item, Rectangle bounds) {
- super.paintItem(gc, item, bounds);
- Object[] data = computeTreeExtensionData(item.getData());
- if ((data != null) && (data.length == 2)) {
- gc.setClipping(columnPosition, bounds.y + 1, controlWidth, bounds.height);
- gc.setForeground((Color) data[1]);
- gc.drawString((String) data[0], columnPosition + 5, bounds.y + 1);
- gc.setClipping((Rectangle) null);
- }
- }
-
- protected void addEmptyTreeMessage(GC gc) {
- // here we print a message when the document is empty just to give the
- // user a visual cue
- // so that they know how to proceed to edit the blank view
- gc.setForeground(fTree.getDisplay().getSystemColor(SWT.COLOR_BLACK));
- gc.setBackground(fTree.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- gc.drawString(XMLEditorMessages.XMLTreeExtension_3, 10, 10);
- gc.drawString(XMLEditorMessages.XMLTreeExtension_4, 10, 10 + gc.getFontMetrics().getHeight());
- }
-
- public String getElementValueHelper(Element element) {
- String result = null;
-
- ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- if ((result == null) && (mq != null)) {
- CMElementDeclaration ed = mq.getCMElementDeclaration(element);
- if ((ed != null) && !Boolean.TRUE.equals(ed.getProperty("isInferred"))) { //$NON-NLS-1$
- result = decriptionBuilder.buildDescription(ed);
- }
- }
- return result != null ? result : ""; //$NON-NLS-1$
- }
-
- /**
- *
- */
- public class MyCellModifier implements ICellModifier, TreeExtension.ICellEditorProvider {
- public boolean canModify(Object element, String property) {
- boolean result = false;
- if (element instanceof Node) {
- Node node = (Node) element;
- result = (property == VALUE_PROPERTY) && treeContentHelper.isEditable(node);
- }
- return result;
- }
-
- public Object getValue(Object object, String property) {
- String result = null;
- if (object instanceof Node) {
- result = treeContentHelper.getNodeValue((Node) object);
- }
- return (result != null) ? result : ""; //$NON-NLS-1$
- }
-
- public void modify(Object element, String property, Object value) {
- // enableNodeSelectionListener(false);
- Item item = (Item) element;
- String oldValue = treeContentHelper.getNodeValue((Node) item.getData());
- String newValue = value.toString();
- if ((newValue != null) && !newValue.equals(oldValue)) {
- treeContentHelper.setNodeValue((Node) item.getData(), value.toString());
- }
- // enableNodeSelectionListener(true);
- }
-
- public CellEditor getCellEditor(Object o, int col) {
- IPropertyDescriptor pd = propertyDescriptorFactory.createPropertyDescriptor(o);
- return pd != null ? pd.createPropertyEditor(control) : null;
- }
- }
-}

Back to the top