Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordacarver2009-10-12 17:47:00 +0000
committerdacarver2009-10-12 17:47:00 +0000
commitd81e27938c92e4bd4d7efc19b16859729e050c03 (patch)
treec638bc0cd510ee12beadb4337f7312b7878e0221 /bundles/org.eclipse.wst.xsl.ui
parentb08520fee900cf720e2ea1f205a85722205de874 (diff)
downloadwebtools.sourceediting.xsl-d81e27938c92e4bd4d7efc19b16859729e050c03.tar.gz
webtools.sourceediting.xsl-d81e27938c92e4bd4d7efc19b16859729e050c03.tar.xz
webtools.sourceediting.xsl-d81e27938c92e4bd4d7efc19b16859729e050c03.zip
[244674]: Added XSL specific awarness to the outline view.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=244674
Diffstat (limited to 'bundles/org.eclipse.wst.xsl.ui')
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/icons/full/alphab_sort_co.gifbin0 -> 153 bytes
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/icons/full/hierarchy.gifbin0 -> 209 bytes
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/icons/full/templatenamed_obj.gifbin0 -> 193 bytes
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/icons/full/xslattribute-set.gifbin0 -> 233 bytes
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/plugin.properties2
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/plugin.xml11
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/XSLWorkbenchAdapter.java98
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/AttributeShowingLabelProvider.java214
-rwxr-xr-xbundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/JFaceNodeAdapter.java78
-rwxr-xr-xbundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/XSLContentOutlineConfiguration.java247
-rwxr-xr-xbundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/registry/AdapterFactoryProviderForXSL.java1
-rwxr-xr-xbundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/util/XSLPluginImages.java3
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/ListWorkbenchAdapter.java (renamed from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/ListWorkbenchAdapter.java)3
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/StylesheetModelView.java (renamed from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/StylesheetView.java)9
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/XSLModelAdapterFactory.java (renamed from bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/XSLModelAdapterFactory.java)2
-rw-r--r--bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/XSLWorkbenchAdapter.java127
16 files changed, 639 insertions, 156 deletions
diff --git a/bundles/org.eclipse.wst.xsl.ui/icons/full/alphab_sort_co.gif b/bundles/org.eclipse.wst.xsl.ui/icons/full/alphab_sort_co.gif
new file mode 100644
index 0000000..6311cc0
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/icons/full/alphab_sort_co.gif
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsl.ui/icons/full/hierarchy.gif b/bundles/org.eclipse.wst.xsl.ui/icons/full/hierarchy.gif
new file mode 100644
index 0000000..7c7dca8
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/icons/full/hierarchy.gif
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsl.ui/icons/full/templatenamed_obj.gif b/bundles/org.eclipse.wst.xsl.ui/icons/full/templatenamed_obj.gif
new file mode 100644
index 0000000..7d24707
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/icons/full/templatenamed_obj.gif
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsl.ui/icons/full/xslattribute-set.gif b/bundles/org.eclipse.wst.xsl.ui/icons/full/xslattribute-set.gif
new file mode 100644
index 0000000..f2e6ec6
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/icons/full/xslattribute-set.gif
Binary files differ
diff --git a/bundles/org.eclipse.wst.xsl.ui/plugin.properties b/bundles/org.eclipse.wst.xsl.ui/plugin.properties
index 92e27c1..2af2e20 100644
--- a/bundles/org.eclipse.wst.xsl.ui/plugin.properties
+++ b/bundles/org.eclipse.wst.xsl.ui/plugin.properties
@@ -27,7 +27,7 @@ commandTooltipNewXMLFile = New XML File
commandTooltipNewDTDFile = New DTD File
commandTooltipNewXSDFile = New XML Schema File
commandTooltipNewXSLFile = New XSL File
-viewNameStylesheet = Stylesheet
+viewNameStylesheet = Stylesheet Model
pageSyntaxColoring = Syntax Coloring
XSL_Property_validation = XSLT Validation
diff --git a/bundles/org.eclipse.wst.xsl.ui/plugin.xml b/bundles/org.eclipse.wst.xsl.ui/plugin.xml
index 37a825a..ba0f525 100644
--- a/bundles/org.eclipse.wst.xsl.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.xsl.ui/plugin.xml
@@ -31,6 +31,10 @@
class="org.eclipse.wst.xsl.ui.internal.StructuredTextViewerConfigurationXSL"
target="org.eclipse.wst.xml.core.xslsource">
</sourceViewerConfiguration>
+ <contentOutlineConfiguration
+ class="org.eclipse.wst.xsl.ui.internal.contentoutline.XSLContentOutlineConfiguration"
+ target="org.eclipse.wst.xml.core.xslsource">
+ </contentOutlineConfiguration>
<doubleClickStrategy
class="org.eclipse.wst.xsl.ui.internal.doubleclick.XSLDoubleClickStrategy"
target="org.eclipse.wst.xsl.XSL_XPATH">
@@ -146,16 +150,17 @@
<extension
point="org.eclipse.ui.views">
<view
- class="org.eclipse.wst.xsl.ui.internal.StylesheetView"
+ category="org.eclipse.wst.xml"
+ class="org.eclipse.wst.xsl.ui.internal.views.stylesheet.StylesheetModelView"
+ icon="icons/full/hierarchy.gif"
id="org.eclipse.wst.xsl.ui.view.outline"
name="%viewNameStylesheet"
- category="org.eclipse.wst.xml"
restorable="true">
</view>
</extension>
<extension point="org.eclipse.core.runtime.adapters">
<factory
- class="org.eclipse.wst.xsl.ui.internal.XSLModelAdapterFactory"
+ class="org.eclipse.wst.xsl.ui.internal.views.stylesheet.XSLModelAdapterFactory"
adaptableType="org.eclipse.wst.xsl.core.model.XSLModelObject">
<adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
</factory>
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/XSLWorkbenchAdapter.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/XSLWorkbenchAdapter.java
deleted file mode 100644
index d11c0ef..0000000
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/XSLWorkbenchAdapter.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.eclipse.wst.xsl.ui.internal;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.xsl.core.model.Import;
-import org.eclipse.wst.xsl.core.model.Include;
-import org.eclipse.wst.xsl.core.model.Stylesheet;
-import org.eclipse.wst.xsl.core.model.Template;
-import org.eclipse.wst.xsl.core.model.Variable;
-import org.eclipse.wst.xsl.core.model.XSLModelObject;
-
-class XSLWorkbenchAdapter implements IWorkbenchAdapter {
- private final Object[] EMPTY = new Object[0];
-
- public Object[] getChildren(Object o) {
- XSLModelObject obj = (XSLModelObject) o;
- switch (obj.getModelType()) {
- case STYLESHEET:
- Stylesheet stylesheet = (Stylesheet) obj;
- return new Object[] {
- new ListWorkbenchAdapter(stylesheet, null, stylesheet
- .getVersion(), "icons/full/xslt_launch.gif"), //$NON-NLS-1$
- new ListWorkbenchAdapter(stylesheet, stylesheet
- .getImports(), "Imports", "icons/full/imports.gif"), //$NON-NLS-1$ //$NON-NLS-2$
- new ListWorkbenchAdapter(stylesheet, stylesheet
- .getIncludes(), "Includes", //$NON-NLS-1$
- "icons/full/imports.gif"), //$NON-NLS-1$
- new ListWorkbenchAdapter(stylesheet, stylesheet
- .getGlobalVariables(), "Variables", null), //$NON-NLS-1$
- new ListWorkbenchAdapter(stylesheet, stylesheet
- .getTemplates(), "Templates", null) }; //$NON-NLS-1$
- }
- return EMPTY;
- }
-
- public ImageDescriptor getImageDescriptor(Object object) {
- XSLModelObject obj = (XSLModelObject) object;
- String path = null;
- switch (obj.getModelType()) {
- case STYLESHEET:
- path = "icons/full/xslt_launch.gif"; //$NON-NLS-1$
- break;
- case IMPORT:
- case INCLUDE:
- path = "icons/full/import.gif"; //$NON-NLS-1$
- break;
- case TEMPLATE:
- path = "icons/full/methdef_obj.gif"; //$NON-NLS-1$
- break;
- case VARIABLE:
- path = "icons/full/field_default_obj.gif"; //$NON-NLS-1$
- break;
- }
- return path == null ? null : AbstractUIPlugin.imageDescriptorFromPlugin(
- XSLUIPlugin.PLUGIN_ID, path);
- }
-
- public String getLabel(Object o) {
- String label = null;
- XSLModelObject obj = (XSLModelObject) o;
- switch (obj.getModelType()) {
- case STYLESHEET:
- Stylesheet stylesheet = (Stylesheet) obj;
- label = stylesheet.getVersion() == null ? "?" : stylesheet //$NON-NLS-1$
- .getVersion();
- break;
- case IMPORT:
- Import imp = (Import) obj;
- label = imp.getHref();
- break;
- case INCLUDE:
- Include inc = (Include) obj;
- label = inc.getHref();
- break;
- case TEMPLATE:
- Template t = (Template) obj;
- StringBuffer sb = new StringBuffer();
- if (t.getName() != null)
- sb.append(t.getName()).append(" "); //$NON-NLS-1$
- if (t.getMatch() != null)
- sb.append(t.getMatch()).append(" "); //$NON-NLS-1$
- if (t.getMode() != null)
- sb.append("(").append(t.getMode()).append(")"); //$NON-NLS-1$//$NON-NLS-2$
- label = sb.toString();
- break;
- case VARIABLE:
- Variable v = (Variable) obj;
- label = v.getName();
- break;
- }
- return label;
- }
-
- public Object getParent(Object o) {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/AttributeShowingLabelProvider.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/AttributeShowingLabelProvider.java
new file mode 100644
index 0000000..8672721
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/AttributeShowingLabelProvider.java
@@ -0,0 +1,214 @@
+package org.eclipse.wst.xsl.ui.internal.contentoutline;
+
+import java.util.List;
+
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
+import org.eclipse.wst.xsl.core.XSLCore;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class AttributeShowingLabelProvider extends JFaceNodeLabelProvider {
+ boolean fShowAttributes = false;
+ static final String ATTR_NAME = "name"; //$NON-NLS-1$
+ static final String ATTR_ID = "id"; //$NON-NLS-1$
+
+ public AttributeShowingLabelProvider(boolean showAttributes) {
+ fShowAttributes = showAttributes;
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ */
+ public String getText(Object o) {
+ StringBuffer text = null;
+ if (o instanceof Node) {
+ Node node = (Node) o;
+ if ((node.getNodeType() == Node.ELEMENT_NODE) && fShowAttributes) {
+ text = new StringBuffer(super.getText(o));
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
+ if (node.hasAttributes()) {
+ Element element = (Element) node;
+ NamedNodeMap attributes = element.getAttributes();
+ Node idTypedAttribute = null;
+ Node requiredAttribute = null;
+ boolean hasId = false;
+ boolean hasName = false;
+ Node shownAttribute = null;
+
+ // try to get content model element
+ // declaration
+ CMElementDeclaration elementDecl = null;
+ ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
+ if (mq != null) {
+ elementDecl = mq.getCMElementDeclaration(element);
+ }
+ // find an attribute of type (or just named)
+ // ID
+ if (elementDecl != null) {
+ int i = 0;
+ while ((i < attributes.getLength()) && (idTypedAttribute == null)) {
+ Node attr = attributes.item(i);
+ String attrName = attr.getNodeName();
+ CMNamedNodeMap attributeDeclarationMap = elementDecl.getAttributes();
+
+ CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributeDeclarationMap);
+ List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent(element, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
+ for (int k = 0; k < nodes.size(); k++) {
+ CMNode cmnode = (CMNode) nodes.get(k);
+ if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
+ allAttributes.put(cmnode);
+ }
+ }
+ attributeDeclarationMap = allAttributes;
+
+ CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributeDeclarationMap.getNamedItem(attrName);
+ if (attrDecl != null) {
+ if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) {
+ idTypedAttribute = attr;
+ }
+ else if ((attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) && (requiredAttribute == null)) {
+ // as a backup, keep tabs on
+ // any required
+ // attributes
+ requiredAttribute = attr;
+ }
+ else {
+ hasId = hasId || attrName.equals(ATTR_ID);
+ hasName = hasName || attrName.equals(ATTR_NAME);
+ }
+ }
+ ++i;
+ }
+ }
+
+ /*
+ * If no suitable attribute was found, try using a
+ * required attribute, if none, then prefer "id" or
+ * "name", otherwise just use first attribute
+ */
+ if (idTypedAttribute != null) {
+ shownAttribute = idTypedAttribute;
+ }
+ else if (requiredAttribute != null) {
+ shownAttribute = requiredAttribute;
+ }
+ else if (hasId) {
+ shownAttribute = attributes.getNamedItem(ATTR_ID);
+ }
+ else if (hasName) {
+ shownAttribute = attributes.getNamedItem(ATTR_NAME);
+ }
+ if (shownAttribute == null) {
+ shownAttribute = attributes.item(0);
+ }
+
+ // display the attribute and value (without quotes)
+ String attributeName = shownAttribute.getNodeName();
+ if ((attributeName != null) && (attributeName.length() > 0)) {
+ text.append(" "); //$NON-NLS-1$
+ text.append(attributeName);
+ String attributeValue = shownAttribute.getNodeValue();
+ if ((attributeValue != null) && (attributeValue.length() > 0)) {
+ text.append("="); //$NON-NLS-1$
+ text.append(StringUtils.strip(attributeValue));
+ }
+ }
+
+// if (XSLCore.XSL_NAMESPACE_URI.equals(node.getNamespaceURI())) {
+// Element el = (Element) node;
+// Attr attr = el.getAttributeNode("mode"); //$NON-NLS-1$
+// if (attr != null) {
+// text.append(" "); //$NON-NLS-1$
+// text.append(attr.getName());
+// text.append("="); //$NON-NLS-1$
+// text.append(StringUtils.strip(attr.getNodeValue()));
+// }
+// }
+ }
+ }
+ else {
+ text = new StringBuffer(super.getText(o));
+ }
+ }
+ else {
+ return super.toString();
+ }
+ return text.toString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ */
+ public String getToolTipText(Object element) {
+ if (element instanceof Node) {
+ switch (((Node) element).getNodeType()) {
+ case Node.COMMENT_NODE :
+ case Node.CDATA_SECTION_NODE :
+ case Node.PROCESSING_INSTRUCTION_NODE :
+ case Node.TEXT_NODE : {
+ String nodeValue = ((Node) element).getNodeValue().trim();
+ return prepareText(nodeValue);
+ }
+ case Node.ELEMENT_NODE : {
+ // show the preceding comment's tooltip information
+ Node previous = ((Node) element).getPreviousSibling();
+ Element elem = (Element) element;
+ if (XSLCore.isXSLNamespace((Node)element)) {
+ if (elem.hasAttribute("mode")) { //$NON-NLS-1$
+ return "Mode: " + elem.getAttribute("mode"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ if (previous != null && previous.getNodeType() == Node.TEXT_NODE)
+ previous = previous.getPreviousSibling();
+ if (previous != null && previous.getNodeType() == Node.COMMENT_NODE)
+ return getToolTipText(previous);
+ }
+ }
+ }
+ return super.getToolTipText(element);
+ }
+
+ /**
+ * Remove leading indentation from each line in the give string.
+ * @param text
+ * @return
+ */
+ private String prepareText(String text) {
+ StringBuffer nodeText = new StringBuffer();
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ if (c != '\r' && c != '\n') {
+ nodeText.append(c);
+ }
+ else if (c == '\r' || c == '\n') {
+ nodeText.append('\n');
+ while (Character.isWhitespace(c) && i < text.length()) {
+ i++;
+ c = text.charAt(i);
+ }
+ nodeText.append(c);
+ }
+ }
+ return nodeText.toString();
+ }
+
+ public void setShowAttributes(boolean fShowAttributes) {
+ this.fShowAttributes = fShowAttributes;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/JFaceNodeAdapter.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/JFaceNodeAdapter.java
index e52ecb0..d099953 100755
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/JFaceNodeAdapter.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/JFaceNodeAdapter.java
@@ -39,17 +39,6 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
final static Class ADAPTER_KEY = IJFaceNodeAdapter.class;
- /**
- * debug .option
- */
- private static final boolean DEBUG = getDebugValue();
-
- private static boolean getDebugValue() {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/outline"); //$NON-NLS-1$
- boolean result = (value != null) && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- return result;
- }
-
JFaceNodeAdapterFactory fAdapterFactory;
RefreshStructureJob fRefreshJob = null;
@@ -58,13 +47,17 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
this.fAdapterFactory = adapterFactory;
}
- protected ImageDescriptor getXSLImage(String name) {
- String path = null;
+ protected ImageDescriptor getXSLImage(Element node) {
+ String name = node.getLocalName();
if (name.equals("import") || name.equals("include")) { //$NON-NLS-1$//$NON-NLS-2$
return XSLPluginImageHelper.getInstance().getImageDescriptor(XSLPluginImages.IMG_ELM_IMPORT_INCLUDE);
}
if (name.equals("template")) { //$NON-NLS-1$
- return XSLPluginImageHelper.getInstance().getImageDescriptor(XSLPluginImages.IMG_ELM_TEMPLATE);
+ if (node.hasAttribute("name")) { //$NON-NLS-1$
+ return XSLPluginImageHelper.getInstance().getImageDescriptor(XSLPluginImages.IMG_ELM_TEMPLATE_NAME);
+ } else {
+ return XSLPluginImageHelper.getInstance().getImageDescriptor(XSLPluginImages.IMG_ELM_TEMPLATE);
+ }
}
if (name.equals("variable") || name.equals("param")) { //$NON-NLS-1$ //$NON-NLS-2$
@@ -83,9 +76,9 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
Node node = (Node) object;
switch (node.getNodeType()) {
case Node.ELEMENT_NODE : {
- if (node.getNamespaceURI().equals(XSLCore.XSL_NAMESPACE_URI)) {
+ if (XSLCore.XSL_NAMESPACE_URI.equals(node.getNamespaceURI())) {
Element elem = (Element) node;
- ImageDescriptor imgDesc = getXSLImage(elem.getLocalName());
+ ImageDescriptor imgDesc = getXSLImage(elem);
if (imgDesc == null) {
image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
} else {
@@ -118,6 +111,7 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION);
break;
}
+ // Should never see COMMENT NODEs.
case Node.COMMENT_NODE : {
image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_COMMENT);
break;
@@ -144,17 +138,12 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
public Object[] getChildren(Object object) {
- // (pa) 20021217
- // cmvc defect 235554
- // performance enhancement: using child.getNextSibling() rather than
- // nodeList(item) for O(n) vs. O(n*n)
- //
ArrayList v = new ArrayList();
if (object instanceof Node) {
Node node = (Node) object;
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
Node n = child;
- if (n.getNodeType() != Node.TEXT_NODE) {
+ if (n.getNodeType() != Node.TEXT_NODE && n.getNodeType() != Node.COMMENT_NODE) {
v.add(n);
}
}
@@ -165,6 +154,8 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
/**
* Returns an enumeration with the elements belonging to the passed
* element. These are the top level items in a list, tree, table, etc...
+ * @param node
+ * @return
*/
public Object[] getElements(Object node) {
return getChildren(node);
@@ -172,6 +163,8 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
/**
* Fetches the label image specific to this object instance.
+ * @param node DOM Node
+ * @return Image for the label.
*/
public Image getLabelImage(Object node) {
Image image = null;
@@ -192,6 +185,7 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
/**
* Fetches the label text specific to this object instance.
+ * @return Node Name for the Label
*/
public String getLabelText(Object node) {
return getNodeName(node);
@@ -199,21 +193,24 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
private String getNodeName(Object object) {
StringBuffer nodeName = new StringBuffer();
- if (object instanceof Node) {
- Node node = (Node) object;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- if (XSLCore.XSL_NAMESPACE_URI.equals(node.getNamespaceURI())) {
- Element elem = (Element) node;
- nodeName.append(elem.getLocalName());
- } else {
- nodeName.append(node.getNodeName());
- }
- } else {
- nodeName.append(node.getNodeName());
- }
+ if (!(object instanceof Node)) {
+ return nodeName.toString();
+ }
+
+ Node node = (Node) object;
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ nodeName.append(node.getNodeName());
if (node.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
nodeName.insert(0, "DOCTYPE:"); //$NON-NLS-1$
}
+ return nodeName.toString();
+ }
+
+ if (XSLCore.XSL_NAMESPACE_URI.equals(node.getNamespaceURI())) {
+ Element elem = (Element) node;
+ nodeName.append(elem.getLocalName());
+ } else {
+ nodeName.append(node.getNodeName());
}
return nodeName.toString();
}
@@ -236,9 +233,6 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
public boolean hasChildren(Object object) {
- // (pa) 20021217
- // cmvc defect 235554 > use child.getNextSibling() instead of
- // nodeList(item) for O(n) vs. O(n*n)
Node node = (Node) object;
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child.getNodeType() != Node.TEXT_NODE) {
@@ -277,19 +271,9 @@ public class JFaceNodeAdapter implements IJFaceNodeAdapter {
while (iterator.hasNext()) {
Object listener = iterator.next();
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90637
- // if (notifier instanceof Node && (listener instanceof
- // StructuredViewer) && (eventType ==
- // INodeNotifier.STRUCTURE_CHANGED || (eventType ==
- // INodeNotifier.CHANGE && changedFeature == null))) {
if ((listener instanceof StructuredViewer) && ((eventType == INodeNotifier.STRUCTURE_CHANGED) || (eventType == INodeNotifier.CONTENT_CHANGED) || (eventType == INodeNotifier.CHANGE))) {
- if (DEBUG) {
- System.out.println("JFaceNodeAdapter notified on event type > " + eventType); //$NON-NLS-1$
- }
- // refresh on structural and "unknown" changes
StructuredViewer structuredViewer = (StructuredViewer) listener;
- // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5230
if (structuredViewer.getControl() != null) {
getRefreshJob().refresh(structuredViewer, (Node) notifier);
}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/XSLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/XSLContentOutlineConfiguration.java
new file mode 100755
index 0000000..e479093
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/contentoutline/XSLContentOutlineConfiguration.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ * IBM Corporation - based on XMLContentOutlineConfiguration initial API and implementation
+ * David Carver (STAR) - initial XSL implementation.
+ *
+ *******************************************************************************/
+package org.eclipse.wst.xsl.ui.internal.contentoutline;
+
+import java.util.List;
+
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.wst.sse.core.utils.StringUtils;
+import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateAction;
+import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateActionContributionItem;
+import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
+import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
+import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
+import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
+import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
+import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
+import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
+import org.eclipse.wst.xsl.ui.internal.contentoutline.JFaceNodeContentProvider;
+import org.eclipse.wst.xsl.ui.internal.contentoutline.JFaceNodeLabelProvider;
+import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
+import org.eclipse.wst.xml.ui.views.contentoutline.AbstractXMLContentOutlineConfiguration;
+import org.eclipse.wst.xml.ui.views.contentoutline.XMLContentOutlineConfiguration;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * More advanced Outline Configuration for XML support. Expects that the viewer's
+ * input will be the DOM Model.
+ *
+ * @see AbstractXMLContentOutlineConfiguration
+ * @since 1.0
+ */
+public class XSLContentOutlineConfiguration extends XMLContentOutlineConfiguration {
+ static final String ATTR_NAME = "name"; //$NON-NLS-1$
+ static final String ATTR_ID = "id"; //$NON-NLS-1$
+
+
+ /**
+ * Toggle action for whether or not to display element's first attribute
+ */
+ private class ToggleShowAttributeAction extends PropertyChangeUpdateAction {
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
+ private TreeViewer fTreeViewer;
+
+ public ToggleShowAttributeAction(IPreferenceStore store, String preference, TreeViewer treeViewer) {
+ super(XMLUIMessages.XMLContentOutlineConfiguration_0, store, preference, true);
+ setToolTipText(getText());
+
+ setImageDescriptor(EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_OBJ_PROP_PS));
+ fTreeViewer = treeViewer;
+ update();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.texteditor.IUpdate#update()
+ */
+ public void update() {
+ super.update();
+ fShowAttributes = isChecked();
+
+ // notify the configuration of the change
+ enableShowAttributes(fShowAttributes, fTreeViewer);
+
+ // refresh the outline view
+ fTreeViewer.refresh(true);
+ }
+ }
+
+ private AttributeShowingLabelProvider fAttributeShowingLabelProvider;
+ private IContentProvider fContentProvider = null;
+
+ boolean fShowAttributes = false;
+
+ /*
+ * Preference key for Show Attributes
+ */
+ private final String OUTLINE_SHOW_ATTRIBUTE_PREF = "outline-show-attribute"; //$NON-NLS-1$
+
+ /**
+ * Create new instance of XMLContentOutlineConfiguration
+ */
+ public XSLContentOutlineConfiguration() {
+ // Must have empty constructor to createExecutableExtension
+ super();
+
+ /**
+ * Set up our preference store here. This is done so that subclasses
+ * aren't required to set their own values, although if they have,
+ * those will be used instead.
+ */
+ IPreferenceStore store = getPreferenceStore();
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_NODE, "1, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.PROCESSING_INSTRUCTION_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.PROCESSING_INSTRUCTION_NODE, "2, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_TYPE_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_TYPE_NODE, "3, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_FRAGMENT_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_FRAGMENT_NODE, "4, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.COMMENT_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.COMMENT_NODE, "5, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ATTRIBUTE_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ATTRIBUTE_NODE, "6, false"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ELEMENT_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ELEMENT_NODE, "7, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_REFERENCE_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_REFERENCE_NODE, "8, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.CDATA_SECTION_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.CDATA_SECTION_NODE, "9, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_NODE, "10, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.NOTATION_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.NOTATION_NODE, "11, true"); //$NON-NLS-1$
+ if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.TEXT_NODE).length() == 0)
+ store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.TEXT_NODE, "12, false"); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#createMenuContributions(org.eclipse.jface.viewers.TreeViewer)
+ */
+ protected IContributionItem[] createMenuContributions(TreeViewer viewer) {
+ IContributionItem[] items;
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
+ IContributionItem showAttributeItem = new PropertyChangeUpdateActionContributionItem(new ToggleShowAttributeAction(getPreferenceStore(), OUTLINE_SHOW_ATTRIBUTE_PREF, viewer));
+
+ items = super.createMenuContributions(viewer);
+ if (items == null) {
+ items = new IContributionItem[]{showAttributeItem};
+ }
+ else {
+ IContributionItem[] combinedItems = new IContributionItem[items.length + 1];
+ System.arraycopy(items, 0, combinedItems, 0, items.length);
+ combinedItems[items.length] = showAttributeItem;
+ items = combinedItems;
+ }
+ return items;
+ }
+
+ /**
+ * Notifies this configuration that the flag that indicates whether or not
+ * to show attribute values in the tree viewer has changed. The tree
+ * viewer is automatically refreshed afterwards to update the labels.
+ *
+ * Clients should not call this method, but rather should react to it.
+ *
+ * @param showAttributes
+ * flag indicating whether or not to show attribute values in
+ * the tree viewer
+ * @param treeViewer
+ * the TreeViewer associated with this configuration
+ */
+ protected void enableShowAttributes(boolean showAttributes, TreeViewer treeViewer) {
+ if (fAttributeShowingLabelProvider != null) {
+ fAttributeShowingLabelProvider.setShowAttributes(showAttributes);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getContentProvider(org.eclipse.jface.viewers.TreeViewer)
+ */
+ public IContentProvider getContentProvider(TreeViewer viewer) {
+ if (fContentProvider == null) {
+ fContentProvider = new JFaceNodeContentProvider();
+ }
+ return fContentProvider;
+ }
+
+ private Object getFilteredNode(Object object) {
+ if (object instanceof Node) {
+ Node node = (Node) object;
+ short nodeType = node.getNodeType();
+ // replace attribute node in selection with its parent
+ if (nodeType == Node.ATTRIBUTE_NODE) {
+ node = ((Attr) node).getOwnerElement();
+ }
+ // anything else not visible, replace with parent node
+ else if (nodeType == Node.TEXT_NODE || nodeType == Node.COMMENT_NODE) {
+ node = node.getParentNode();
+ }
+ return node;
+ }
+ return object;
+ }
+
+ private Object[] getFilteredNodes(Object[] filteredNodes) {
+ for (int i = 0; i < filteredNodes.length; i++) {
+ filteredNodes[i] = getFilteredNode(filteredNodes[i]);
+ }
+ return filteredNodes;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getLabelProvider(org.eclipse.jface.viewers.TreeViewer)
+ */
+ public ILabelProvider getLabelProvider(TreeViewer viewer) {
+ if (fAttributeShowingLabelProvider == null) {
+ fAttributeShowingLabelProvider = new AttributeShowingLabelProvider(fShowAttributes);
+ }
+ return fAttributeShowingLabelProvider;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getSelection(org.eclipse.jface.viewers.TreeViewer,
+ * org.eclipse.jface.viewers.ISelection)
+ */
+ public ISelection getSelection(TreeViewer viewer, ISelection selection) {
+ ISelection filteredSelection = selection;
+ if (selection instanceof IStructuredSelection) {
+ Object[] filteredNodes = getFilteredNodes(((IStructuredSelection) selection).toArray());
+ filteredSelection = new StructuredSelection(filteredNodes);
+ }
+ return filteredSelection;
+ }
+}
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/registry/AdapterFactoryProviderForXSL.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/registry/AdapterFactoryProviderForXSL.java
index 8376222..3084397 100755
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/registry/AdapterFactoryProviderForXSL.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/registry/AdapterFactoryProviderForXSL.java
@@ -21,7 +21,6 @@ import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryProvider;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelhandler.ModelHandlerForXML;
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
import org.eclipse.wst.xml.ui.internal.DOMObserver;
import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/util/XSLPluginImages.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/util/XSLPluginImages.java
index 5dde68c..d53cd22 100755
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/util/XSLPluginImages.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/util/XSLPluginImages.java
@@ -61,6 +61,9 @@ public class XSLPluginImages {
public static final String IMG_ELM_TEMPLATE = "icons/full/package_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_ELM_TEMPLATE_NAME = "icons/full/templatenamed_obj.gif"; //$NON-NLS-1$
+
+
public static final String IMG_ELM_VARIABLE = "icons/full/field_default_obj.gif"; //$NON-NLS-1$
public static final String IMG_ELM_FUNCTION = "icons/full/function.gif"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/ListWorkbenchAdapter.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/ListWorkbenchAdapter.java
index 8b5a7c5..fae334c 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/ListWorkbenchAdapter.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/ListWorkbenchAdapter.java
@@ -8,7 +8,7 @@
* Contributors:
* Doug Satchwell (Chase Technology Ltd) - initial API and implementation
*******************************************************************************/
-package org.eclipse.wst.xsl.ui.internal;
+package org.eclipse.wst.xsl.ui.internal.views.stylesheet;
import java.util.List;
@@ -16,6 +16,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.wst.xsl.core.model.Stylesheet;
+import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin;
public class ListWorkbenchAdapter implements IWorkbenchAdapter
{
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/StylesheetView.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/StylesheetModelView.java
index cbf5762..f3f7409 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/StylesheetView.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/StylesheetModelView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Chase Technology Ltd - http://www.chasetechnology.co.uk
+ * Copyright (c) 2008, 2009 Chase Technology Ltd 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
@@ -7,8 +7,9 @@
*
* Contributors:
* Doug Satchwell (Chase Technology Ltd) - initial API and implementation
+ * David Carver (STAR) - bug 244674 - Enhanced and cleaned up view
*******************************************************************************/
-package org.eclipse.wst.xsl.ui.internal;
+package org.eclipse.wst.xsl.ui.internal.views.stylesheet;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
@@ -39,7 +40,7 @@ import org.eclipse.wst.xsl.core.model.XSLNode;
*
*
*/
-public class StylesheetView extends ViewPart
+public class StylesheetModelView extends ViewPart
{
private IEditorPart activeEditor;
//private boolean isFiringSelection;
@@ -113,7 +114,7 @@ public class StylesheetView extends ViewPart
public void selectionChanged(SelectionChangedEvent event)
{
- if (getSite().getPage().getActivePart() == StylesheetView.this)
+ if (getSite().getPage().getActivePart() == StylesheetModelView.this)
handleTreeSelection((IStructuredSelection)event.getSelection(),false);
}
});
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/XSLModelAdapterFactory.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/XSLModelAdapterFactory.java
index 8436b34..f2ca67f 100644
--- a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/XSLModelAdapterFactory.java
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/XSLModelAdapterFactory.java
@@ -8,7 +8,7 @@
* Contributors:
* Doug Satchwell (Chase Technology Ltd) - initial API and implementation
*******************************************************************************/
-package org.eclipse.wst.xsl.ui.internal;
+package org.eclipse.wst.xsl.ui.internal.views.stylesheet;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.model.IWorkbenchAdapter;
diff --git a/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/XSLWorkbenchAdapter.java b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/XSLWorkbenchAdapter.java
new file mode 100644
index 0000000..0386dfc
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsl.ui/src/org/eclipse/wst/xsl/ui/internal/views/stylesheet/XSLWorkbenchAdapter.java
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Chase Technology Ltd 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:
+ * Doug Satchwell (Chase Technology Ltd) - initial API and implementation
+ * David Carver (STAR) - bug 244674 - Enhanced and cleaned up view
+ *******************************************************************************/
+package org.eclipse.wst.xsl.ui.internal.views.stylesheet;
+
+import java.util.ArrayList;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.wst.xsl.core.model.Import;
+import org.eclipse.wst.xsl.core.model.Include;
+import org.eclipse.wst.xsl.core.model.Stylesheet;
+import org.eclipse.wst.xsl.core.model.Template;
+import org.eclipse.wst.xsl.core.model.Variable;
+import org.eclipse.wst.xsl.core.model.Function;
+import org.eclipse.wst.xsl.core.model.XSLModelObject;
+import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin;
+import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImages;
+
+class XSLWorkbenchAdapter implements IWorkbenchAdapter {
+ private final Object[] EMPTY = new Object[0];
+
+ public Object[] getChildren(Object o) {
+ if (o instanceof XSLModelObject) {
+ XSLModelObject obj = (XSLModelObject) o;
+ switch (obj.getModelType()) {
+ case STYLESHEET:
+ Stylesheet stylesheet = (Stylesheet) obj;
+ ArrayList modelItems = new ArrayList();
+ modelItems.add(new ListWorkbenchAdapter(stylesheet, null, stylesheet.getVersion(), XSLPluginImages.IMG_ELM_STYLESHET));
+ modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getImports(), "Imports", XSLPluginImages.IMG_ELM_IMPORT_INCLUDE)); //$NON-NLS-1$
+ modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getIncludes(), "Includes", XSLPluginImages.IMG_ELM_IMPORT_INCLUDE)); //$NON-NLS-1$
+ modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getGlobalVariables(), "Variables", XSLPluginImages.IMG_ELM_VARIABLE)); //$NON-NLS-1$
+ modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getTemplates(), "Templates", XSLPluginImages.IMG_ELM_TEMPLATE)); //$NON-NLS-1$
+ if (stylesheet.getFunctions().size() > 0) {
+ modelItems.add(new ListWorkbenchAdapter(stylesheet, stylesheet.getTemplates(), "Functions", XSLPluginImages.IMG_ELM_FUNCTION)); //$NON-NLS-1$
+ }
+ return modelItems.toArray();
+ }
+ }
+ return EMPTY;
+ }
+
+ public ImageDescriptor getImageDescriptor(Object object) {
+ XSLModelObject obj = (XSLModelObject) object;
+ String path = null;
+ switch (obj.getModelType()) {
+ case STYLESHEET:
+ path = XSLPluginImages.IMG_ELM_STYLESHET;
+ break;
+ case IMPORT:
+ case INCLUDE:
+ path = XSLPluginImages.IMG_ELM_IMPORT_INCLUDE;
+ break;
+ case TEMPLATE: {
+ Template template = (Template) obj;
+ if (template.getName() != null) {
+ path = XSLPluginImages.IMG_ELM_TEMPLATE_NAME;
+ } else {
+ path = XSLPluginImages.IMG_ELM_TEMPLATE;
+ }
+ break;
+ }
+ case VARIABLE:
+ path = XSLPluginImages.IMG_ELM_VARIABLE;
+ break;
+ case FUNCTION:
+ path = XSLPluginImages.IMG_ELM_FUNCTION;
+ break;
+
+ }
+ return path == null ? null : AbstractUIPlugin.imageDescriptorFromPlugin(
+ XSLUIPlugin.PLUGIN_ID, path);
+ }
+
+ public String getLabel(Object o) {
+ String label = null;
+ XSLModelObject obj = (XSLModelObject) o;
+ switch (obj.getModelType()) {
+ case STYLESHEET:
+ Stylesheet stylesheet = (Stylesheet) obj;
+ label = stylesheet.getVersion() == null ? "?" : stylesheet //$NON-NLS-1$
+ .getVersion();
+ break;
+ case IMPORT:
+ Import imp = (Import) obj;
+ label = imp.getHref();
+ break;
+ case INCLUDE:
+ Include inc = (Include) obj;
+ label = inc.getHref();
+ break;
+ case TEMPLATE:
+ Template t = (Template) obj;
+ StringBuffer sb = new StringBuffer();
+ if (t.getName() != null)
+ sb.append(t.getName()).append(" "); //$NON-NLS-1$
+ if (t.getMatch() != null)
+ sb.append(t.getMatch()).append(" "); //$NON-NLS-1$
+ if (t.getMode() != null)
+ sb.append("(").append(t.getMode()).append(")"); //$NON-NLS-1$//$NON-NLS-2$
+ label = sb.toString();
+ break;
+ case VARIABLE:
+ Variable v = (Variable) obj;
+ label = v.getName();
+ break;
+ case FUNCTION:
+ Function f = (Function) obj;
+ label = f.getName();
+ }
+ return label;
+ }
+
+ public Object getParent(Object o) {
+ return null;
+ }
+}

Back to the top