use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class MakeAnonymousTypeGlobalAction method canEnable.
private boolean canEnable(XSDConcreteComponent xsdComponent) {
if (xsdComponent instanceof XSDComplexTypeDefinition) {
fSelectedComponent = (XSDComplexTypeDefinition) xsdComponent;
isComplexType = true;
XSDComplexTypeDefinition typeDef = (XSDComplexTypeDefinition) xsdComponent;
XSDConcreteComponent parent = typeDef.getContainer();
if (parent instanceof XSDElementDeclaration) {
fParentName = ((XSDElementDeclaration) parent).getName();
return true;
}
} else if (xsdComponent instanceof XSDSimpleTypeDefinition) {
fSelectedComponent = (XSDSimpleTypeDefinition) xsdComponent;
isComplexType = false;
XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) xsdComponent;
XSDConcreteComponent parent = typeDef.getContainer();
if (parent instanceof XSDElementDeclaration) {
fParentName = ((XSDElementDeclaration) parent).getName();
return true;
} else if (parent instanceof XSDAttributeDeclaration) {
fParentName = ((XSDAttributeDeclaration) parent).getName();
return true;
}
}
return false;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDBaseAdapter method getGlobalXSDContainer.
protected IADTObject getGlobalXSDContainer(XSDConcreteComponent component) {
XSDConcreteComponent c = component.getContainer();
// We want the top most structural component
while (c != null && !(c.getContainer() instanceof XSDSchema) && !(c instanceof XSDComplexTypeDefinition) && !(c instanceof XSDSimpleTypeDefinition) && !(c instanceof XSDModelGroupDefinition) && !(c instanceof XSDAttributeGroupDefinition)) {
c = c.getContainer();
}
Adapter adapter = XSDAdapterFactory.getInstance().adapt(c);
if (adapter instanceof IADTObject)
return (IADTObject) adapter;
return null;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDBaseAdapter method getContainerType.
/**
* Implements IField getContainerType. Get parent Complex Type containing the field
* @return IComplexType
*/
public IComplexType getContainerType() {
XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent) target;
XSDConcreteComponent parent = null;
XSDComplexTypeDefinition ct = null;
for (parent = xsdConcreteComponent.getContainer(); parent != null; ) {
if (parent instanceof XSDComplexTypeDefinition) {
ct = (XSDComplexTypeDefinition) parent;
break;
}
parent = parent.getContainer();
}
if (ct != null) {
return (IComplexType) XSDAdapterFactory.getInstance().adapt(ct);
}
return null;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDRedefineAdapter method getCategoryChildren.
private List getCategoryChildren(int category) {
List list = new ArrayList();
XSDRedefine redefine = (XSDRedefine) target;
Iterator iterator = redefine.getContents().iterator();
while (iterator.hasNext()) {
XSDRedefineContent redefineContent = (XSDRedefineContent) iterator.next();
if (redefineContent instanceof XSDAttributeGroupDefinition && category == CategoryAdapter.ATTRIBUTES) {
list.add(redefineContent);
} else if (redefineContent instanceof XSDModelGroupDefinition && category == CategoryAdapter.GROUPS) {
list.add(redefineContent);
} else if (redefineContent instanceof XSDComplexTypeDefinition && category == CategoryAdapter.TYPES) {
list.add(redefineContent);
} else if (redefineContent instanceof XSDSimpleTypeDefinition && category == CategoryAdapter.TYPES) {
list.add(redefineContent);
}
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return adapterList;
}
use of org.eclipse.xsd.XSDComplexTypeDefinition in project webtools.sourceediting by eclipse.
the class CreateElementAction method run.
/*
* @see IAction#run()
*/
public void run() {
beginRecording(getDescription());
final Element child = createAndAddNewChildElement();
endRecording();
if (selectionProvider != null) {
final XSDConcreteComponent comp = xsdSchema.getCorrespondingComponent(child);
// selectionProvider.setSelection(new StructuredSelection(comp));
Runnable runnable = new Runnable() {
public void run() {
if (comp instanceof XSDAttributeDeclaration) {
if (((XSDAttributeDeclaration) comp).getContainer() instanceof XSDAttributeUse) {
if (comp.getContainer().getContainer() instanceof XSDAttributeGroupDefinition) {
selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
} else if (comp.getContainer().getContainer() instanceof XSDComplexTypeDefinition) {
if (XSDDOMHelper.inputEquals(child, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true)) {
selectionProvider.setSelection(new StructuredSelection(comp.getContainer()));
} else {
selectionProvider.setSelection(new StructuredSelection(comp));
}
} else {
selectionProvider.setSelection(new StructuredSelection(comp));
}
} else {
selectionProvider.setSelection(new StructuredSelection(comp));
}
} else {
selectionProvider.setSelection(new StructuredSelection(comp));
}
if (comp instanceof XSDNamedComponent) {
if (sourceContext instanceof AbstractEditPartViewer) {
// AbstractEditPartViewer viewer = (AbstractEditPartViewer)sourceContext;
// Object obj = viewer.getSelectedEditParts().get(0);
// if (obj instanceof GraphicalEditPart)
// {
// if (obj instanceof ElementDeclarationEditPart)
// {
// XSDElementDeclaration elem = ((ElementDeclarationEditPart)obj).getXSDElementDeclaration();
// if (!elem.isElementDeclarationReference())
// {
// ((ElementDeclarationEditPart)obj).doEditName();
// }
// }
// else if (obj instanceof ModelGroupDefinitionEditPart)
// {
// XSDModelGroupDefinition group = ((ModelGroupDefinitionEditPart)obj).getXSDModelGroupDefinition();
// if (!group.isModelGroupDefinitionReference())
// {
// ((ModelGroupDefinitionEditPart)obj).doEditName();
// }
// }
// else if (obj instanceof ComplexTypeDefinitionEditPart)
// {
// XSDComplexTypeDefinition ct = ((ComplexTypeDefinitionEditPart)obj).getXSDComplexTypeDefinition();
// if (ct.getName() != null)
// {
// ((ComplexTypeDefinitionEditPart)obj).doEditName();
// }
// }
// else if (obj instanceof TopLevelComponentEditPart)
// {
// ((TopLevelComponentEditPart)obj).doEditName();
// }
// }
}
}
}
};
Display.getDefault().timerExec(50, runnable);
}
}
Aggregations