[299595] Improves the extensibility of XSD editor to add figure
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaAdapter.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaAdapter.java
index db29fe9..d6f82bf 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaAdapter.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/adapters/XSDSchemaAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
+ * Copyright (c) 2001, 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
@@ -38,6 +38,7 @@
import org.eclipse.xsd.XSDImport;
import org.eclipse.xsd.XSDInclude;
import org.eclipse.xsd.XSDModelGroupDefinition;
+import org.eclipse.xsd.XSDNamedComponent;
import org.eclipse.xsd.XSDPackage;
import org.eclipse.xsd.XSDRedefine;
import org.eclipse.xsd.XSDSchema;
@@ -343,7 +344,7 @@
for (Iterator i = elements.iterator(); i.hasNext();)
{
XSDElementDeclaration elem = (XSDElementDeclaration) i.next();
- if (isSameNamespace(elem.getTargetNamespace(),schema.getTargetNamespace()) && (elem.getRootContainer() == schema || showFromIncludes))
+ if (shouldShowComponent(elem, schema, showFromIncludes))
{
list.add(elem);
}
@@ -372,7 +373,7 @@
if (td instanceof XSDComplexTypeDefinition)
{
XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) td;
- if (isSameNamespace(ct.getTargetNamespace(),schema.getTargetNamespace()) && (ct.getRootContainer() == schema || showFromIncludes))
+ if (shouldShowComponent(ct, schema, showFromIncludes))
{
list.add(ct);
}
@@ -401,7 +402,7 @@
for (Iterator i = xsdSchema.getAttributeGroupDefinitions().iterator(); i.hasNext();)
{
XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) i.next();
- if (isSameNamespace(attrGroup.getTargetNamespace(), xsdSchema.getTargetNamespace()) && (attrGroup.getRootContainer() == xsdSchema || showFromIncludes))
+ if (shouldShowComponent(attrGroup, xsdSchema, showFromIncludes))
{
attributeGroupList.add(attrGroup);
}
@@ -470,7 +471,7 @@
if (td instanceof XSDSimpleTypeDefinition)
{
XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) td;
- if (isSameNamespace(st.getTargetNamespace(),schema.getTargetNamespace()) && (st.getRootContainer() == schema || showFromIncludes))
+ if (shouldShowComponent(st, schema, showFromIncludes))
{
list.add(st);
}
@@ -493,7 +494,7 @@
for (Iterator i = groups.iterator(); i.hasNext();)
{
XSDModelGroupDefinition group = (XSDModelGroupDefinition) i.next();
- if (isSameNamespace(group.getTargetNamespace(),schema.getTargetNamespace()) && (group.getRootContainer() == schema || showFromIncludes))
+ if (shouldShowComponent(group, schema, showFromIncludes))
{
list.add(group);
}
@@ -528,4 +529,9 @@
{
return XSDEditorPlugin.getXSDImage("icons/XSDFile.gif"); //$NON-NLS-1$
}
+
+ protected boolean shouldShowComponent(XSDNamedComponent component, XSDSchema schema, boolean showFromIncludes)
+ {
+ return isSameNamespace(component.getTargetNamespace(), schema.getTargetNamespace()) && (component.getRootContainer() == schema || showFromIncludes);
+ }
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/CategoryEditPart.java b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/CategoryEditPart.java
index d8da401..bc8008e 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/CategoryEditPart.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt-xsd/org/eclipse/wst/xsd/ui/internal/design/editparts/CategoryEditPart.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
+ * Copyright (c) 2001, 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
@@ -41,7 +41,7 @@
public class CategoryEditPart extends BaseEditPart
{
protected SelectionHandlesEditPolicyImpl selectionHandlesEditPolicy;
- Figure outerPane;
+ protected Figure outerPane;
HeadingFigure headingFigure;
protected ScrollPane scrollpane;
protected int minimumHeight = 400;
@@ -56,10 +56,7 @@
outerPane = new Figure();
outerPane.setBorder(new RoundedLineBorder(1, 6));
- headingFigure = new HeadingFigure();
- outerPane.add(headingFigure);
- headingFigure.getLabel().setText(((CategoryAdapter) getModel()).getText());
- headingFigure.getLabel().setIcon(((CategoryAdapter) getModel()).getImage());
+ createHeadingFigure();
int minHeight = SWT.DEFAULT;
switch (getType())
@@ -145,6 +142,14 @@
return outerPane;
}
+ protected void createHeadingFigure()
+ {
+ headingFigure = new HeadingFigure();
+ outerPane.add(headingFigure);
+ headingFigure.getLabel().setText(((CategoryAdapter) getModel()).getText());
+ headingFigure.getLabel().setIcon(((CategoryAdapter) getModel()).getImage());
+ }
+
public void refreshVisuals()
{
super.refreshVisuals();
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ADTContentOutlinePage.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ADTContentOutlinePage.java
index f1102d7..48fb01e 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ADTContentOutlinePage.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ADTContentOutlinePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
+ * Copyright (c) 2001, 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
@@ -279,7 +279,8 @@
}
else
{
- getTreeViewer().setSelection(new StructuredSelection(structuredSelection.getFirstElement()), true);
+ if(structuredSelection.getFirstElement() !=null)
+ getTreeViewer().setSelection(new StructuredSelection(structuredSelection.getFirstElement()), true);
}
}
}