use of org.eclipse.xsd.impl.XSDModelGroupImpl in project tmdm-studio-se by Talend.
the class Util method doChangeElementTypeToSequence.
private static IStatus doChangeElementTypeToSequence(XSDComplexTypeDefinition compx, int maxOccurs) {
XSDParticleImpl partCnt = (XSDParticleImpl) compx.getContent();
XSDModelGroupImpl mdlGrp = (XSDModelGroupImpl) partCnt.getTerm();
if ((maxOccurs > 1 || maxOccurs == -1) && mdlGrp.getCompositor() != XSDCompositor.SEQUENCE_LITERAL) {
// change the parent element to xsd:sequence
if (!MessageDialog.openConfirm(null, Messages.Util_32, Messages.Util_33)) {
return Status.CANCEL_STATUS;
}
mdlGrp.setCompositor(XSDCompositor.SEQUENCE_LITERAL);
compx.updateElement();
}
return Status.OK_STATUS;
}
use of org.eclipse.xsd.impl.XSDModelGroupImpl in project tmdm-studio-se by Talend.
the class ConceptComposite method updateElementGroup.
private void updateElementGroup(XSDComplexTypeDefinition type) {
if (type != null) {
XSDParticleImpl partCnt = (XSDParticleImpl) type.getContent();
if (partCnt != null) {
XSDModelGroupImpl mdlGrp = (XSDModelGroupImpl) partCnt.getTerm();
XSDCompositor typeComposite = mdlGrp.getCompositor();
if (typeComposite.equals(XSDCompositor.SEQUENCE_LITERAL)) {
setSequence();
} else if (typeComposite.equals(XSDCompositor.ALL_LITERAL)) {
setAll();
} else if (typeComposite.equals(XSDCompositor.CHOICE_LITERAL)) {
setChoice();
}
enableRadioButtons(false);
}
}
}
use of org.eclipse.xsd.impl.XSDModelGroupImpl in project webtools.sourceediting by eclipse.
the class AddXSDElementAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
selection = ((XSDBaseAdapter) selection).getTarget();
}
AddXSDElementCommand command = null;
if (selection instanceof XSDComplexTypeDefinition) {
command = new AddXSDElementCommand(getText(), (XSDComplexTypeDefinition) selection);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (selection instanceof XSDModelGroupDefinition) {
command = new AddXSDElementCommand(getText(), (XSDModelGroupDefinition) selection);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (selection instanceof XSDSchema) {
command = new AddXSDElementCommand(getText(), (XSDSchema) selection);
getCommandStack().execute(command);
} else if (selection instanceof XSDModelGroup) {
XSDModelGroup modelGroup = (XSDModelGroup) selection;
XSDConcreteComponent component = modelGroup.getContainer();
XSDComplexTypeDefinition ct = null;
while (component != null) {
if (component instanceof XSDComplexTypeDefinition) {
ct = (XSDComplexTypeDefinition) component;
break;
}
component = component.getContainer();
}
if (ct != null) {
command = new AddXSDElementCommand(getText(), (XSDModelGroup) selection, ct);
} else {
command = new AddXSDElementCommand(getText(), (XSDModelGroup) selection);
}
command.setReference(isReference);
getCommandStack().execute(command);
} else if (selection instanceof XSDElementDeclaration || selection instanceof XSDAttributeUse) {
XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent) selection;
XSDConcreteComponent parent = null;
XSDComplexTypeDefinition ct = null;
XSDModelGroupDefinition group = null;
XSDModelGroupImpl ctGroup = null;
for (parent = xsdConcreteComponent.getContainer(); parent != null; ) {
if (parent instanceof XSDComplexTypeDefinition) {
ct = (XSDComplexTypeDefinition) parent;
break;
} else if (parent instanceof XSDModelGroupDefinition) {
group = (XSDModelGroupDefinition) parent;
break;
} else if (parent instanceof XSDModelGroupImpl) {
ctGroup = (XSDModelGroupImpl) parent;
break;
}
parent = parent.getContainer();
}
if (ct != null) {
command = new AddXSDElementCommand(getText(), ct);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (ctGroup != null) {
XSDElementDeclaration sel = (XSDElementDeclaration) selection;
int index = ctGroup.getContents().indexOf(sel.eContainer());
command = new AddXSDElementCommand(getText(), ctGroup, getId(), index);
command.setReference(isReference);
getCommandStack().execute(command);
} else if (group != null) {
command = new AddXSDElementCommand(getText(), group);
command.setReference(isReference);
getCommandStack().execute(command);
}
}
if (command != null) {
addedComponent = command.getAddedComponent();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent);
selectAddedComponent(adapter);
}
}
Aggregations