use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class ModelGroupEditPart method getModelChildren.
protected List getModelChildren() {
// XSDModelGroupAdapter modelGroupAdapter = (XSDModelGroupAdapter)getModel();
// ArrayList ch = new ArrayList();
// ITreeElement [] tree = modelGroupAdapter.getChildren();
// int length = tree.length;
// for (int i = 0; i < length; i++)
// {
// ch.add(tree[i]);
// }
List list = new ArrayList();
XSDModelGroup xsdModelGroup = getXSDModelGroup();
for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext(); ) {
XSDParticle next = (XSDParticle) i.next();
if (next.getContent() instanceof XSDElementDeclaration) {
XSDElementDeclaration elementDeclaration = (XSDElementDeclaration) next.getContent();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(elementDeclaration);
list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) adapter));
}
if (next.getContent() instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition def = (XSDModelGroupDefinition) next.getContent();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(def);
list.add(adapter);
} else if (next.getTerm() instanceof XSDModelGroup) {
XSDModelGroup modelGroup = (XSDModelGroup) next.getTerm();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(modelGroup);
list.add(adapter);
} else if (next.getTerm() instanceof XSDWildcard) {
XSDWildcard wildCard = (XSDWildcard) next.getTerm();
Adapter adapter = XSDAdapterFactory.getInstance().adapt(wildCard);
list.add(new TargetConnectionSpaceFiller((XSDBaseAdapter) adapter));
}
}
if (list.size() == 0)
list.add(new TargetConnectionSpaceFiller(null));
return list;
// return ch;
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class KeyboardDragImpl method performKeyboardDrag.
public void performKeyboardDrag(GraphicalEditPart movingElement, int direction) {
KeyBoardAccessibilityEditPolicy policy = (KeyBoardAccessibilityEditPolicy) movingElement.getEditPolicy(KeyBoardAccessibilityEditPolicy.KEY);
EditPart rightElement = policy.getRelativeEditPart(movingElement, direction);
policy = (KeyBoardAccessibilityEditPolicy) rightElement.getEditPolicy(KeyBoardAccessibilityEditPolicy.KEY);
EditPart leftElement = (policy != null) ? policy.getRelativeEditPart(rightElement, direction) : null;
// TODO: add support for extenders
if (!(movingElement instanceof XSDBaseFieldEditPart))
return;
XSDBaseFieldEditPart movingField = (XSDBaseFieldEditPart) movingElement;
XSDBaseFieldEditPart leftField = (XSDBaseFieldEditPart) leftElement;
XSDBaseFieldEditPart rightField = (XSDBaseFieldEditPart) rightElement;
Object movingObject = movingField.getModel();
BaseDragAndDropCommand command = null;
if (movingObject instanceof XSDElementDeclarationAdapter || movingObject instanceof XSDWildcard) {
command = new XSDElementDragAndDropCommand(movingField, leftField, rightField, direction);
} else if (movingObject instanceof XSDAttributeDeclarationAdapter) {
command = new XSDAttributeDragAndDropCommand(movingField, leftField, rightField, direction);
}
if (command != null && command.canExecute()) {
command.execute();
// This is to reselect the moved item
try {
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor != null && editor.getAdapter(ISelectionProvider.class) != null) {
ISelectionProvider provider = (ISelectionProvider) editor.getAdapter(ISelectionProvider.class);
if (provider != null) {
provider.setSelection(new StructuredSelection(movingElement.getModel()));
}
}
} catch (Exception e) {
}
}
}
use of org.eclipse.xsd.XSDWildcard in project tmdm-studio-se by Talend.
the class XSDTreeLabelProvider method getImage.
@Override
public Image getImage(Object obj) {
if (obj instanceof XSDElementDeclaration) {
// top declaration
XSDElementDeclaration decl = (XSDElementDeclaration) obj;
// check if concept or "just" element
boolean isConcept = false;
EList l = decl.getIdentityConstraintDefinitions();
for (Iterator iter = l.iterator(); iter.hasNext(); ) {
XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) iter.next();
if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
isConcept = true;
break;
}
}
// display approprite image
if (isConcept) {
return ImageCache.getCreatedImage(EImage.CONCEPT.getPath());
} else {
return ImageCache.getCreatedImage(EImage.ELEMENT_ONLY.getPath());
/*
* if (decl.getTypeDefinition() instanceof XSDComplexTypeDefinition) return
* PlatformUI.getWorkbench().getSharedImages().getCreatedImage(ISharedImages.IMG_OBJ_FOLDER); else
* return ImageCache.getCreatedImage( "icons/elements_obj_+.gif");
*/
}
}
if (obj instanceof XSDParticle) {
XSDParticle xsdParticle = (XSDParticle) obj;
XSDTerm xsdTerm = xsdParticle.getTerm();
if (xsdTerm instanceof XSDElementDeclaration) {
// get Type of Parent Group
List<Object> realKeyInfos = Util.getRealKeyInfos(entity, xsdParticle);
if (realKeyInfos != null && realKeyInfos.size() > 0) {
return ImageCache.getCreatedImage(EImage.PRIMARYKEY.getPath());
}
if (XSDUtil.hasFKInfo((XSDElementDeclaration) xsdTerm)) {
return ImageCache.getCreatedImage(EImage.FK_OBJ.getPath());
}
XSDConcreteComponent xsdConcreteComponent = xsdParticle.getContainer();
if (xsdConcreteComponent instanceof XSDModelGroup) {
return ImageCache.getCreatedImage(EImage.SCHEMAELEMENT.getPath());
}
/*
* if(((XSDElementDeclaration) xsdTerm).getAnonymousTypeDefinition() instanceof
* XSDComplexTypeDefinition) return ImageCache.getCreatedImage( EImage.COMPLEXTYPE.getPath()); else
* return ImageCache.getCreatedImage( EImage.SIMPLETYPE.getPath());
*/
} else if (xsdTerm instanceof XSDModelGroup) {
int type = ((XSDModelGroup) xsdTerm).getCompositor().getValue();
switch(type) {
case XSDCompositor.ALL:
return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
case XSDCompositor.CHOICE:
return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
case XSDCompositor.SEQUENCE:
return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
}
} else if (xsdTerm instanceof XSDWildcard) {
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/wildcard.gif");
} else {
log.info(Messages.bind(Messages.XSDTreeLabelProvider_27, xsdTerm.getClass().getName()));
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/error.gif");
}
}
if (obj instanceof XSDSimpleTypeDefinition) {
return ImageCache.getCreatedImage(EImage.SIMPLETYPE.getPath());
}
if (obj instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition) obj;
XSDComplexTypeContent ctc = ctd.getContent();
if (ctc instanceof XSDParticle) {
if (((XSDParticle) ctc).getTerm() instanceof XSDModelGroup) {
int type = ((XSDModelGroup) ((XSDParticle) ctc).getTerm()).getCompositor().getValue();
switch(type) {
case XSDCompositor.ALL:
return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
case XSDCompositor.CHOICE:
return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
case XSDCompositor.SEQUENCE:
return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
}
}
} else {
// simple Type!!!
log.info(Messages.bind(Messages.XSDTreeLabelProvider_28, ctc.getClass().getName()));
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/error.gif");
}
}
if (obj instanceof XSDModelGroup) {
int type = ((XSDModelGroup) obj).getCompositor().getValue();
switch(type) {
case XSDCompositor.ALL:
return ImageCache.getCreatedImage(EImage.COMPLEX_ALL.getPath());
case XSDCompositor.CHOICE:
return ImageCache.getCreatedImage(EImage.COMPLEX_CHOICE.getPath());
case XSDCompositor.SEQUENCE:
return ImageCache.getCreatedImage(EImage.COMPLEX_SEQUENCE.getPath());
}
}
if (obj instanceof XSDFacet) {
return ImageCache.getCreatedImage(EImage.FACET.getPath());
}
if (obj instanceof XSDIdentityConstraintDefinition) {
XSDIdentityConstraintDefinition identity = (XSDIdentityConstraintDefinition) obj;
if (identity.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
return ImageCache.getCreatedImage(EImage.KEYS.getPath());
}
return ImageCache.getCreatedImage(EImage.PRIMARYKEY.getPath());
}
if (obj instanceof XSDXPathDefinition) {
XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
if (xpath.getVariety().equals(XSDXPathVariety.FIELD_LITERAL)) {
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/field.gif");
}
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/selector.gif");
}
if (obj instanceof XSDAttributeGroupDefinition) {
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/attribute_group.gif");
}
if (obj instanceof XSDAttributeUse) {
XSDAttributeUse att = (XSDAttributeUse) obj;
if ("xmlns".equals(att.getAttributeDeclaration().getTargetNamespace())) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
}
if (att.getUse().equals(XSDAttributeUseCategory.REQUIRED_LITERAL)) {
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/attribute_mandatory.gif");
} else {
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/attribute.gif");
}
}
if (obj instanceof XSDAttributeDeclaration) {
XSDAttributeDeclaration attributeDec = (XSDAttributeDeclaration) obj;
if (// $NON-NLS-1$
"xmlns".equals(attributeDec.getTargetNamespace())) {
return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
} else {
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/attribute.gif");
}
}
if (obj instanceof XSDAnnotation) {
return ImageCache.getCreatedImage(EImage.ANNOTATION.getPath());
}
if (obj instanceof Element) {
try {
Element e = (Element) obj;
if (e.getLocalName().equals("documentation")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
} else if (e.getLocalName().equals("appinfo")) {
// $NON-NLS-1$
// $NON-NLS-1$
String source = e.getAttribute("source");
if (source != null) {
if (source.startsWith("X_Label_")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.LABEL.getPath());
} else if (source.equals("X_ForeignKey")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.FK_OBJ.getPath());
} else if (source.equals("X_Visible_Rule")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
} else if (source.equals("X_Default_Value_Rule")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
} else if (source.equals("X_ForeignKeyInfo")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
} else if (source.equals("X_ForeignKeyInfoFormat")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
// fix bug 0013194 by rhou.
} else if (source.equals("X_FKIntegrity")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
} else if (source.equals("X_FKIntegrity_Override")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
} else if (source.equals("X_Retrieve_FKinfos")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.KEYINFO.getPath());
} else if (source.equals("X_SourceSystem")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.SOURCESYSTEM.getPath());
} else if (source.equals("X_TargetSystem")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.TARGETSYSTEM.getPath());
} else if (source.startsWith("X_Description_")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
} else if (source.equals("X_Write")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
} else if (source.equals("X_Deny_Create")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
} else if (source.equals("X_Deny_LogicalDelete")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
} else if (source.equals("X_Deny_PhysicalDelete")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
} else if (source.equals("X_Lookup_Field")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.BROWSE.getPath());
} else if (source.equals("X_Hide")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.SECURITYANNOTATION.getPath());
} else if (source.equals("X_Schematron")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.ROUTINE.getPath());
} else if (source.equals("X_Workflow")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.WORKFLOW_PROCESS.getPath());
} else if (source.equals("X_AutoExpand")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.DEFAULT.getPath());
}
if (source.equals("X_ForeignKey_Filter")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.FILTER_PS.getPath());
} else if (source.startsWith("X_Display_Format_")) {
// $NON-NLS-1$
return ImageCache.getCreatedImage(EImage.THIN_MIN_VIEW.getPath());
} else {
return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
}
} else {
return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
}
} else {
return ImageCache.getCreatedImage(EImage.DOCUMENTATION.getPath());
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
// $NON-NLS-1$
return ImageCache.getCreatedImage("icons/small_warn.gif");
// return PlatformUI.getWorkbench().getSharedImages().getCreatedImage(ISharedImages.IMG_OBJ_ELEMENT);
}
use of org.eclipse.xsd.XSDWildcard in project tmdm-studio-se by Talend.
the class TypesContentProvider method getXSDParticleChildren.
private Object[] getXSDParticleChildren(XSDParticle particle) {
// System.out.println("getXSDParticleChildren() CLASS "+particle.getClass().getName());
// System.out.println("getXSDParticleChildren() TERM "+particle.getTerm().getClass().getName()+": "+particle.getTerm());
XSDTerm term = particle.getTerm();
if (term instanceof XSDElementDeclaration) {
XSDTypeDefinition typeDef = ((XSDElementDeclaration) term).getTypeDefinition();
if (typeDef == null)
// elements with not type declaration (allowed)
return new Object[0];
ArrayList<Object> list = new ArrayList<Object>();
if (typeDef instanceof XSDComplexTypeDefinition) {
list.addAll(getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) typeDef));
} else {
list.add(typeDef);
}
list.addAll(((XSDElementDeclaration) term).getIdentityConstraintDefinitions());
XSDAnnotation annotation = ((XSDElementDeclaration) term).getAnnotation();
if (filter != null && !filter.isAll()) {
} else {
if (annotation != null) {
list.add(annotation);
}
}
return list.toArray(new Object[list.size()]);
}
if (term instanceof XSDModelGroup) {
// a ModelGroup skip it and get children directtly
EList list = ((XSDModelGroup) term).getContents();
return list.toArray(new XSDParticle[list.size()]);
}
if (term instanceof XSDWildcard) {
}
return new Object[] {};
}
use of org.eclipse.xsd.XSDWildcard in project tmdm-studio-se by Talend.
the class XSDGenerateHTML method printParticle.
/**
* Print a particle with markup for the document.
*
* @param xsdParticle a particle.
* @param rootElementDeclarationMarkup the markup.
*/
public void printParticle(XSDParticle xsdParticle, String rootElementDeclarationMarkup) {
int minOccurs = xsdParticle.getMinOccurs();
int maxOccurs = xsdParticle.getMaxOccurs();
XSDTerm xsdTerm = xsdParticle.getTerm();
if (xsdTerm instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) xsdTerm;
String elementDeclarationName = xsdElementDeclaration.getName();
String elementDeclarationMarkup = null;
if (rootElementDeclarationMarkup == null) {
elementDeclarationMarkup = getElementDeclarationMarkup(elementDeclarationName);
}
if (elementDeclarationMarkup != null) {
// $NON-NLS-1$
System.out.print("<span class='");
System.out.print(elementDeclarationMarkup);
// $NON-NLS-1$
System.out.print("'>");
}
// $NON-NLS-1$ //$NON-NLS-2$
System.out.print("<a href='#" + getLocalAnchor(xsdElementDeclaration) + "'>");
System.out.print(elementDeclarationName.charAt(0));
// $NON-NLS-1$
System.out.print("</a>");
System.out.print(elementDeclarationName.substring(1));
if (elementDeclarationMarkup != null) {
// $NON-NLS-1$
System.out.print("</span>");
}
if (minOccurs == 0) {
if (maxOccurs == 1) {
// $NON-NLS-1$
System.out.print("?");
} else {
// $NON-NLS-1$
System.out.print("*");
}
} else if (maxOccurs == -1) {
// $NON-NLS-1$
System.out.print("+");
}
} else if (xsdTerm instanceof XSDModelGroup) {
XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdTerm;
List particles = xsdModelGroup.getParticles();
boolean isRedundant = particles.size() == 1 && minOccurs == 1 && maxOccurs == 1 && ((XSDParticle) particles.get(0)).getTerm() instanceof XSDModelGroup;
if (!isRedundant) {
// ) //$NON-NLS-1$
System.out.print("(");
}
String separator = // $NON-NLS-1$
XSDCompositor.CHOICE_LITERAL == xsdModelGroup.getCompositor() ? // $NON-NLS-1$
" | " : // $NON-NLS-1$ //$NON-NLS-2$
XSDCompositor.SEQUENCE_LITERAL == xsdModelGroup.getCompositor() ? ", " : " & ";
for (Iterator i = xsdModelGroup.getParticles().iterator(); i.hasNext(); ) {
XSDParticle childParticle = (XSDParticle) i.next();
printParticle(childParticle, rootElementDeclarationMarkup);
if (i.hasNext()) {
System.out.print(separator);
}
}
if (!isRedundant) {
// (
// $NON-NLS-1$
System.out.print(")");
if (minOccurs == 0) {
if (maxOccurs == 1) {
// $NON-NLS-1$
System.out.print("?");
} else {
// $NON-NLS-1$
System.out.print("*");
}
} else if (maxOccurs == -1) {
// $NON-NLS-1$
System.out.print("+");
}
}
} else if (xsdTerm instanceof XSDWildcard) {
// $NON-NLS-1$
System.out.print("<em>{any}</em>");
}
}
Aggregations