use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDModelGroupDefinitionAdapter method getTopContainer.
public IADTObject getTopContainer() {
XSDModelGroupDefinition group = getXSDModelGroupDefinition();
XSDConcreteComponent container = group.getContainer();
if (container instanceof XSDSchema || container instanceof XSDRedefine)
return this;
else
return getGlobalXSDContainer(group);
}
use of org.eclipse.xsd.XSDConcreteComponent 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);
}
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDHyperlinkTargetLocator method caseXSDElementDeclaration.
/*
* (non-Javadoc)
*
* @see org.eclipse.xsd.util.XSDSwitch#caseXSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration)
*/
public Object caseXSDElementDeclaration(XSDElementDeclaration elementDeclaration) {
XSDConcreteComponent target = null;
if (elementDeclaration.isElementDeclarationReference()) {
target = elementDeclaration.getResolvedElementDeclaration();
} else {
XSDConcreteComponent typeDefinition = null;
if (elementDeclaration.getAnonymousTypeDefinition() == null) {
typeDefinition = elementDeclaration.getTypeDefinition();
}
XSDConcreteComponent substitutionGroupAffiliation = elementDeclaration.getSubstitutionGroupAffiliation();
if (typeDefinition != null && substitutionGroupAffiliation != null) {
if (XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE.equals(attributeName)) {
target = substitutionGroupAffiliation;
} else {
target = typeDefinition;
}
} else {
target = typeDefinition != null ? typeDefinition : substitutionGroupAffiliation;
}
if (isFromSchemaForSchema(target)) {
target = null;
}
}
return target;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDHyperlinkTargetLocator method caseXSDTypeDefinition.
/*
* (non-Javadoc)
*
* @see org.eclipse.xsd.util.XSDSwitch#caseXSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)
*/
public Object caseXSDTypeDefinition(XSDTypeDefinition typeDefinition) {
XSDConcreteComponent target = null;
XSDTypeDefinition baseType = typeDefinition.getBaseType();
if (baseType != null) {
target = baseType;
}
if (isFromSchemaForSchema(target)) {
target = null;
}
return target;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDHyperlinkTargetLocator method caseXSDSimpleTypeDefinition.
public Object caseXSDSimpleTypeDefinition(XSDSimpleTypeDefinition typeDefinition) {
XSDConcreteComponent target = null;
// Simple types can be one of: atomic, list or union.
XSDVariety variety = typeDefinition.getVariety();
int varietyType = variety.getValue();
switch(varietyType) {
case XSDVariety.ATOMIC:
{
target = typeDefinition.getBaseTypeDefinition();
}
break;
case XSDVariety.LIST:
{
target = typeDefinition.getItemTypeDefinition();
}
break;
case XSDVariety.UNION:
{
List memberTypes = typeDefinition.getMemberTypeDefinitions();
if (memberTypes != null && memberTypes.size() > 0) {
// ISSUE: What if there are more than one type?
// This could be a case for multiple hyperlinks at the same
// location.
target = (XSDConcreteComponent) memberTypes.get(0);
}
}
break;
}
if (isFromSchemaForSchema(target)) {
target = null;
}
return target;
}
Aggregations