Skip to main content

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

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/annotations/XMLAnnotationsView.java161
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/CMListWorkbenchAdapter.java193
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelAdapterFactory.java31
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelView.java89
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelWorkbenchAdapter.java49
5 files changed, 0 insertions, 523 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/annotations/XMLAnnotationsView.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/annotations/XMLAnnotationsView.java
deleted file mode 100644
index c29b473e1f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/annotations/XMLAnnotationsView.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Standards for Technology in Automotive Retail 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:
- * David Carver (STAR) - initial API and implementation
- * David Carver (Intalio) - generalize the implementation for contribution to eclipse
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.views.annotations;
-
-import org.eclipse.jface.internal.text.html.HTMLTextPresenter;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.part.ViewPart;
-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.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.taginfo.MarkupTagInfoProvider;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.w3c.dom.Node;
-
-/**
- * Provides a view similar to the JavaDoc view that will display any documentation that resides in
- * the content model for an XML document.
- *
- * @author dcarver
- *
- */
-public class XMLAnnotationsView extends ViewPart implements ISelectionListener {
-
- public static final String ID = "org.eclipse.wst.xml.ui.view.annotations.XMLAnnotationsView"; //$NON-NLS-1$
-
- private StyledText styledtext;
-
- private String xmlDoc = XMLUIMessages.Documentation_view_default_msg;
-
- private HTMLTextPresenter presenter;
-
- private final TextPresentation presentation = new TextPresentation();
-
- private IStructuredSelection currentSelection;
- private CMNode cmNode;
-
- public XMLAnnotationsView() {
- }
-
- public void init(IViewSite site) throws PartInitException {
- super.init(site);
- getSite().getPage().addPostSelectionListener(this);
- }
-
- /**
- * Create contents of the view part.
- *
- * @param parent
- */
- public void createPartControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NONE);
- container.setLayout(new FillLayout());
- presenter = new HTMLTextPresenter(false);
- createStyledTextWidget(container);
- doStyledTextInput();
- }
-
- private void createStyledTextWidget(Composite container) {
- styledtext = new StyledText(container, SWT.V_SCROLL | SWT.H_SCROLL);
- styledtext.setBackground(getColor(SWT.COLOR_INFO_BACKGROUND));
- styledtext.setEditable(false);
- styledtext.setBounds(container.getBounds());
- styledtext.addControlListener(new ControlAdapter() {
- /*
- * @see
- * org.eclipse.swt.events.ControlAdapter#controlResized(org.eclipse
- * .swt.events.ControlEvent)
- */
- public void controlResized(ControlEvent e) {
- doStyledTextInput();
- }
- });
- }
-
- private void doStyledTextInput() {
- presentation.clear();
- Rectangle size = styledtext.getClientArea();
- int width = size.width;
- int height = size.height;
- if (width == 0) {
- width = 200;
- }
-
- if (height == 0) {
- height = 400;
- }
-
- String msg = presenter.updatePresentation(styledtext, xmlDoc, presentation, width, height);
- if (msg != null) {
- styledtext.setText(msg);
- TextPresentation.applyTextPresentation(presentation, styledtext);
- }
- }
-
- public void setFocus() {
-
- }
-
-
- public void dispose() {
- styledtext = null;
- getSite().getPage().removePostSelectionListener(this);
- cmNode = null;
- super.dispose();
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-
- IEditorPart edPart = getSite().getPage().getActiveEditor();
- if (part.equals(edPart)) {
- if (selection instanceof IStructuredSelection) {
- currentSelection = (IStructuredSelection) selection;
- if (!selection.isEmpty()
- && (currentSelection.getFirstElement() instanceof Node)) {
- Node node = (Node) currentSelection.getFirstElement();
- ModelQuery mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- if (mq != null) {
- cmNode = mq.getCMNode(node);
- MarkupTagInfoProvider tagInfo = new MarkupTagInfoProvider();
- xmlDoc = tagInfo.getInfo(cmNode);
- }
- else {
- xmlDoc = XMLUIMessages.Documentation_view_default_msg;
- }
- doStyledTextInput();
- }
- }
- }
- }
-
- private Color getColor(int colorID) {
- Display display = Display.getCurrent();
- return display.getSystemColor(colorID);
- }
-
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/CMListWorkbenchAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/CMListWorkbenchAdapter.java
deleted file mode 100644
index 08d4fd27b0..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/CMListWorkbenchAdapter.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.views.contentmodel;
-
-import java.util.ArrayList;
-import java.util.EmptyStackException;
-import java.util.List;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMVisitor;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-public class CMListWorkbenchAdapter extends CMVisitor implements IWorkbenchAdapter {
-
- private CMElementDeclaration fDeclaration;
- private String text;
- private ImageDescriptor image;
- private GroupStack fGroupStack;
- private CMDescriber fRoot;
-
- public CMListWorkbenchAdapter(CMElementDeclaration decl) {
- text = getFormattedLabel(decl.getNodeName(), decl.getMinOccur(), decl.getMaxOccur(), decl.getDataType());
- fDeclaration = decl;
- image = AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, XMLEditorPluginImages.IMG_OBJ_ELEMENT);
-
- fGroupStack = new GroupStack();
- fRoot = new CMDescriber(decl);
- }
-
- public Object[] getChildren(Object o) {
- /* TODO Use the CMElementDeclaration and ModelQuery to get the available children of the root element */
- return fRoot.getChildren(o);
- }
-
- public ImageDescriptor getImageDescriptor(Object object) {
- return image;
- }
-
- public String getLabel(Object o) {
- return text;
- }
-
- public Object getParent(Object o) {
- return fDeclaration;
- }
-
- /**
- * Formats the label for an element declaration. The format will be: <b>name</b> [<i>min</i>..<i>max</i>], where <i>max</i> when unbounded is represented by <b>*</b>
- * @param name The name of the element declaration
- * @param min The minimum number of occurrences of the element
- * @param max The maximum number of occurrences of the element
- * @return The formatted label String
- */
- static String getFormattedLabel(String name, int min, int max, CMDataType dataType) {
- StringBuffer buffer = new StringBuffer(name);
- buffer.append('[');
- buffer.append(min);
- buffer.append(".."); //$NON-NLS-1$
- buffer.append((max >= 0 ? Integer.toString(max) : "*")); //$NON-NLS-1$
- buffer.append(']');
- if (dataType != null) {
- buffer.append(" {"); //$NON-NLS-1$
- buffer.append(dataType.getDataTypeName());
- buffer.append('}');
- }
- return buffer.toString();
- }
-
- /**
- * Workbench adapter that describes its CMNode. It calculates its children lazily using the CMVisitor
- * to identify immediate children (i.e., the content of child nodes is not visited).
- *
- */
- private class CMDescriber extends CMVisitor implements IWorkbenchAdapter {
-
- List fChildren = null;
- ImageDescriptor fImage;
- String label;
- CMNode root;
-
- public CMDescriber(CMNode node) {
- root = node;
- }
-
- public Object[] getChildren(Object o) {
- if (fChildren == null) {
- fChildren = new ArrayList();
- if (root.getNodeType() == CMNode.ELEMENT_DECLARATION) {
- CMElementDeclaration ed = (CMElementDeclaration) root;
- CMNamedNodeMap nodeMap = ed.getAttributes();
- int size = nodeMap.getLength();
- for (int i = 0; i < size; i++) {
- visitCMNode(nodeMap.item(i));
- }
- visitCMNode(ed.getContent());
- }
- }
- return fChildren.toArray();
- }
-
- public ImageDescriptor getImageDescriptor(Object object) {
- return fImage;
- }
-
- public void setImage(String path) {
- fImage = AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, path);
- }
- public String getLabel(Object o) {
- return label;
- }
-
- public Object getParent(Object o) {
- return root;
- }
-
- public void visitCMGroup(CMGroup e) {
- fGroupStack.push(e.getMaxOccur());
- super.visitCMGroup(e);
- fGroupStack.pop();
- }
-
- public void visitCMAttributeDeclaration(CMAttributeDeclaration ad) {
- CMDescriber describer = new CMDescriber(ad);
- describer.label = ad.getNodeName();
- describer.setImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- fChildren.add(describer);
- }
-
- public void visitCMElementDeclaration(CMElementDeclaration ed) {
- CMDescriber describer = new CMDescriber(ed);
-
- // If the parent group stack containing this element declaration is unbounded, the element within is unbounded as well
- describer.label = getFormattedLabel(ed.getNodeName(), ed.getMinOccur(), (!fGroupStack.isEmpty() && fGroupStack.peek() < 0) ? -1 : ed.getMaxOccur(), ed.getDataType());
- describer.setImage(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- fChildren.add(describer);
- }
- }
-
- /**
- * A stack of integers used to determine if an element declaration is unbounded
- *
- */
- private static class GroupStack {
- int[] stack;
- int size;
-
- public GroupStack() {
- stack = new int[5];
- }
-
- public void push(int i) {
- if (size >= stack.length) {
- int[] tmp = stack;
- stack = new int[stack.length * 2];
- System.arraycopy(tmp, 0, stack, 0, tmp.length);
- }
- stack[size++] = i;
- }
-
- public int pop() {
- if (isEmpty())
- throw new EmptyStackException();
- return stack[--size];
- }
-
- public boolean isEmpty() {
- return size == 0;
- }
-
- public int peek() {
- if (isEmpty())
- throw new EmptyStackException();
- return stack[size - 1];
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelAdapterFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelAdapterFactory.java
deleted file mode 100644
index 21dad4efa7..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelAdapterFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Standards for Technology in Automotive Retail 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:
- * David Carver - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.views.contentmodel;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-public class ContentModelAdapterFactory implements IAdapterFactory {
- private static Class[] ADAPTORLIST = new Class[] { IWorkbenchAdapter.class };
- private IWorkbenchAdapter adapter = new ContentModelWorkbenchAdapter();
-
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (IWorkbenchAdapter.class.equals(adapterType))
- return adapter;
- return null;
- }
-
- public Class[] getAdapterList() {
- return ADAPTORLIST;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelView.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelView.java
deleted file mode 100644
index 6391e43e79..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelView.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Standards for Technology in Automotive Retail 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:
- * David Carver - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.views.contentmodel;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.State;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.model.BaseWorkbenchContentProvider;
-import org.eclipse.ui.model.WorkbenchLabelProvider;
-import org.eclipse.ui.part.ViewPart;
-import org.w3c.dom.Element;
-
-
-public class ContentModelView extends ViewPart implements ISelectionListener {
- private TreeViewer tv;
-
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- getSite().getPage().addPostSelectionListener(this);
- }
-
- public void dispose() {
- getSite().getPage().removePostSelectionListener(this);
- super.dispose();
- }
-
- public void createPartControl(Composite parent) {
- Tree tree = new Tree(parent, SWT.NONE);
- tv = new TreeViewer(tree);
- tv.setContentProvider(new BaseWorkbenchContentProvider());
- tv.setLabelProvider(new WorkbenchLabelProvider());
- }
-
- public void setFocus() {
-
- }
-
-
- private IStructuredSelection currentSelection;
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
-
- IEditorPart edPart = getSite().getPage().getActiveEditor();
- if (part.equals(edPart)) {
- if (selection instanceof IStructuredSelection) {
- currentSelection = (IStructuredSelection) selection;
- if (!selection.isEmpty()
- && (currentSelection.getFirstElement() instanceof Element)) {
- if (isLinkedWithEditor() && !currentSelection.getFirstElement().equals(tv.getInput())) {
- tv.setInput(currentSelection.getFirstElement());
- }
- }
- }
- }
-
- }
-
- private boolean isLinkedWithEditor() {
- ICommandService service = (ICommandService) PlatformUI.getWorkbench()
- .getService(ICommandService.class);
- Command command = service.getCommand("org.eclipse.wst.xml.ui.cmnd.contentmodel.sych"); //$NON-NLS-1$
- State state = command.getState("org.eclipse.ui.commands.toggleState"); //$NON-NLS-1$
-
- return ((Boolean) state.getValue()).booleanValue();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelWorkbenchAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelWorkbenchAdapter.java
deleted file mode 100644
index fcec1a6356..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/views/contentmodel/ContentModelWorkbenchAdapter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Standards for Technology in Automotive Retail 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:
- * David Carver - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.views.contentmodel;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-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.modelquery.ModelQueryUtil;
-import org.w3c.dom.Element;
-
-class ContentModelWorkbenchAdapter implements IWorkbenchAdapter {
- private final Object[] EMPTY = new Object[0];
- private Object parent = null;
-
- public Object[] getChildren(Object o) {
- if (o instanceof Element) {
- Element node = (Element) o;
- ModelQuery mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- if (mq != null) {
- CMElementDeclaration decl = mq.getCMElementDeclaration(node);
- CMListWorkbenchAdapter adapter = new CMListWorkbenchAdapter(decl);
- return new Object[] { adapter };
- }
- }
- return EMPTY;
- }
-
- public ImageDescriptor getImageDescriptor(Object object) {
- return null;
- }
-
- public String getLabel(Object o) {
- return null;
- }
-
- public Object getParent(Object o) {
- return parent;
- }
-}

Back to the top