use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDCommonUIUtils method getModelGroup.
public static XSDModelGroup getModelGroup(XSDComplexTypeDefinition cType) {
XSDParticle particle = cType.getComplexType();
if (particle == null || particle.eContainer() != cType)
return null;
Object particleContent = particle.getContent();
XSDModelGroup group = null;
if (particleContent instanceof XSDModelGroupDefinition)
group = ((XSDModelGroupDefinition) particleContent).getResolvedModelGroupDefinition().getModelGroup();
else if (particleContent instanceof XSDModelGroup)
group = (XSDModelGroup) particleContent;
if (group == null)
return null;
if (group.getContents().isEmpty() || group.eResource() != cType.eResource()) {
XSDComplexTypeContent content = cType.getContent();
if (content instanceof XSDParticle)
group = (XSDModelGroup) ((XSDParticle) content).getContent();
}
return group;
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDModelGroupDefinitionSection method setInput.
public void setInput(IWorkbenchPart part, ISelection selection) {
super.setInput(part, selection);
init();
relayout();
if (isReference) {
TypesHelper helper = new TypesHelper(xsdSchema);
List items = new ArrayList();
items = helper.getModelGroups();
if (input instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition group = (XSDModelGroupDefinition) input;
XSDConcreteComponent parent = group.getContainer();
while (parent != null) {
if (parent instanceof XSDModelGroupDefinition) {
items.remove(((XSDModelGroupDefinition) parent).getQName());
break;
}
parent = parent.getContainer();
}
}
// $NON-NLS-1$
items.add(0, "");
componentNameCombo.setItems((String[]) items.toArray(new String[0]));
}
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDModelGroupDefinitionSection method doWidgetSelected.
public void doWidgetSelected(SelectionEvent e) {
if (e.widget == componentNameCombo) {
String newValue = componentNameCombo.getText();
if (input instanceof XSDNamedComponent) {
XSDNamedComponent namedComponent = (XSDNamedComponent) input;
Element element = namedComponent.getElement();
if (namedComponent instanceof XSDModelGroupDefinition) {
element.setAttribute(XSDConstants.REF_ATTRIBUTE, newValue);
XSDDirectivesManager.removeUnusedXSDImports(namedComponent.getSchema());
}
}
}
super.doWidgetSelected(e);
}
Aggregations