use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class AddXSDAnyElementCommand method execute.
public void execute() {
try {
if (doCreateModelGroupForComplexType) {
Assert.isNotNull(complexType);
beginRecording(complexType.getElement());
createModelGroup();
} else {
beginRecording(parent.getElement());
}
XSDWildcard wildCard = XSDFactory.eINSTANCE.createXSDWildcard();
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
particle.setContent(wildCard);
parent.getContents().add(particle);
addedXSDConcreteComponent = wildCard;
formatChild(parent.getElement());
} finally {
endRecording();
}
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class XSDAnyElementContentsSection method doWidgetSelected.
public void doWidgetSelected(SelectionEvent e) {
XSDConcreteComponent concreteComponent = (XSDConcreteComponent) input;
if (concreteComponent instanceof XSDWildcard) {
XSDWildcard wildcard = (XSDWildcard) concreteComponent;
if (e.widget == namespaceCombo) {
String newValue = namespaceCombo.getText();
boolean removeAttribute = false;
if (newValue.length() == 0) {
removeAttribute = true;
}
// element); //$NON-NLS-1$
if (removeAttribute) {
wildcard.unsetLexicalNamespaceConstraint();
} else {
wildcard.setStringLexicalNamespaceConstraint(newValue);
}
// endRecording(element);
} else if (e.widget == processContentsCombo) {
String newValue = processContentsCombo.getText();
boolean removeAttribute = false;
if (newValue.length() == 0) {
removeAttribute = true;
}
// element); //$NON-NLS-1$
if (removeAttribute) {
wildcard.unsetProcessContents();
} else {
wildcard.setProcessContents(XSDProcessContents.get(processContentsCombo.getItem(processContentsCombo.getSelectionIndex())));
}
// endRecording(element);
}
}
super.doWidgetSelected(e);
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class XSDCommonUIUtils method getInputXSDAnnotation.
public static XSDAnnotation getInputXSDAnnotation(XSDConcreteComponent input, boolean createIfNotExist) {
XSDAnnotation xsdAnnotation = null;
XSDFactory factory = XSDFactory.eINSTANCE;
if (input instanceof XSDAttributeDeclaration) {
XSDAttributeDeclaration xsdComp = (XSDAttributeDeclaration) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDAttributeGroupDefinition) {
XSDAttributeGroupDefinition xsdComp = (XSDAttributeGroupDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdComp = (XSDElementDeclaration) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDNotationDeclaration) {
XSDNotationDeclaration xsdComp = (XSDNotationDeclaration) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDXPathDefinition) {
XSDXPathDefinition xsdComp = (XSDXPathDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDModelGroup) {
XSDModelGroup xsdComp = (XSDModelGroup) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition xsdComp = (XSDModelGroupDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDIdentityConstraintDefinition) {
XSDIdentityConstraintDefinition xsdComp = (XSDIdentityConstraintDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDWildcard) {
XSDWildcard xsdComp = (XSDWildcard) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDSchema) {
XSDSchema xsdComp = (XSDSchema) input;
List list = xsdComp.getAnnotations();
if (list.size() > 0) {
xsdAnnotation = (XSDAnnotation) list.get(0);
} else {
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
if (xsdComp.getContents() != null) {
xsdComp.getContents().add(0, xsdAnnotation);
}
}
}
return xsdAnnotation;
} else if (input instanceof XSDFacet) {
XSDFacet xsdComp = (XSDFacet) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDTypeDefinition) {
XSDTypeDefinition xsdComp = (XSDTypeDefinition) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDInclude) {
XSDInclude xsdComp = (XSDInclude) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDImport) {
XSDImport xsdComp = (XSDImport) input;
xsdAnnotation = xsdComp.getAnnotation();
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
xsdComp.setAnnotation(xsdAnnotation);
}
} else if (input instanceof XSDRedefine) {
XSDRedefine xsdComp = (XSDRedefine) input;
List contents = xsdComp.getContents();
for (int i = 0; i < contents.size(); i++) {
Object content = contents.get(i);
if (content instanceof XSDAnnotation) {
xsdAnnotation = (XSDAnnotation) content;
break;
}
}
if (createIfNotExist && xsdAnnotation == null) {
xsdAnnotation = factory.createXSDAnnotation();
contents.add(0, xsdAnnotation);
}
return xsdAnnotation;
} else if (input instanceof XSDAnnotation) {
xsdAnnotation = (XSDAnnotation) input;
}
if (createIfNotExist) {
formatAnnotation(xsdAnnotation);
}
return xsdAnnotation;
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class XSDWildcardAdapter method getText.
public String getText() {
XSDWildcard xsdWildcard = (XSDWildcard) target;
StringBuffer result = new StringBuffer();
Element element = xsdWildcard.getElement();
if (element != null) {
result.append(element.getNodeName());
boolean hasMinOccurs = element.hasAttribute(XSDConstants.MINOCCURS_ATTRIBUTE);
boolean hasMaxOccurs = element.hasAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE);
if (hasMinOccurs || hasMaxOccurs) {
// $NON-NLS-1$
result.append(" [");
if (hasMinOccurs) {
int min = ((XSDParticle) xsdWildcard.getContainer()).getMinOccurs();
if (min == XSDParticle.UNBOUNDED) {
// $NON-NLS-1$
result.append("*");
} else {
result.append(String.valueOf(min));
}
} else // print default
{
int min = ((XSDParticle) xsdWildcard.getContainer()).getMinOccurs();
result.append(String.valueOf(min));
}
if (hasMaxOccurs) {
int max = ((XSDParticle) xsdWildcard.getContainer()).getMaxOccurs();
// $NON-NLS-1$
result.append("..");
if (max == XSDParticle.UNBOUNDED) {
// $NON-NLS-1$
result.append("*");
} else {
result.append(String.valueOf(max));
}
} else // print default
{
// $NON-NLS-1$
result.append("..");
int max = ((XSDParticle) xsdWildcard.getContainer()).getMaxOccurs();
result.append(String.valueOf(max));
}
// $NON-NLS-1$
result.append("]");
}
}
return result.toString();
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class XSDAttributeDragAndDropCommand method doDrop.
protected void doDrop(List siblings, GraphicalEditPart movingEditPart) {
commonSetup(siblings, movingEditPart);
if ((previousRefComponent instanceof XSDAttributeDeclaration || previousRefComponent instanceof XSDWildcard) && (nextRefComponent instanceof XSDAttributeDeclaration || nextRefComponent instanceof XSDWildcard)) {
XSDConcreteComponent parent = previousRefComponent.getContainer().getContainer();
if (closerSibling == BELOW_IS_CLOSER) {
parent = nextRefComponent.getContainer().getContainer();
}
action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
} else if (previousRefComponent == null && (nextRefComponent instanceof XSDAttributeDeclaration || nextRefComponent instanceof XSDWildcard)) {
XSDConcreteComponent parent = nextRefComponent.getContainer().getContainer();
if (closerSibling == ABOVE_IS_CLOSER) {
if (leftSiblingEditPart == null) {
action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
} else if (parentEditPart != null) {
action = new MoveXSDAttributeAction(parentEditPart.getXSDConcreteComponent(), xsdComponentToDrag, previousRefComponent, nextRefComponent);
}
} else {
action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
}
} else if (previousRefComponent instanceof XSDAttributeDeclaration && nextRefComponent == null) {
XSDConcreteComponent parent = previousRefComponent.getContainer().getContainer();
if (closerSibling == ABOVE_IS_CLOSER) {
action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
} else {
if (rightSiblingEditPart == null) {
action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
} else {
action = new MoveXSDAttributeAction(parent, xsdComponentToDrag, previousRefComponent, nextRefComponent);
}
}
}
if (action != null)
canExecute = action.canMove();
}
Aggregations