use of org.eclipse.xsd.XSDModelGroup in project webtools.sourceediting by eclipse.
the class XSDModelGroupAdapter method getText.
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement#getText()
*/
public String getText() {
XSDModelGroup xsdModelGroup = getXSDModelGroup();
StringBuffer result = new StringBuffer();
String name = xsdModelGroup.getCompositor().getName();
if (name != null) {
result.append(name);
}
Element element = xsdModelGroup.getElement();
if (element != null) {
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) xsdModelGroup.getContainer()).getMinOccurs();
if (min == XSDParticle.UNBOUNDED) {
// $NON-NLS-1$
result.append("*");
} else {
result.append(String.valueOf(min));
}
} else // print default
{
int min = ((XSDParticle) xsdModelGroup.getContainer()).getMinOccurs();
result.append(String.valueOf(min));
}
if (hasMaxOccurs) {
int max = ((XSDParticle) xsdModelGroup.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) xsdModelGroup.getContainer()).getMaxOccurs();
result.append(String.valueOf(max));
}
// $NON-NLS-1$
result.append("]");
}
}
return result.toString();
}
use of org.eclipse.xsd.XSDModelGroup in project webtools.sourceediting by eclipse.
the class XSDModelGroupAdapter method getChildren.
public ITreeElement[] getChildren() {
XSDModelGroup xsdModelGroup = getXSDModelGroup();
List list = new ArrayList();
for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext(); ) {
Object object = i.next();
XSDParticleContent particle = ((XSDParticle) object).getContent();
if (particle instanceof XSDElementDeclaration) {
list.add(particle);
} else if (particle instanceof XSDWildcard) {
list.add(particle);
} else if (particle instanceof XSDModelGroup) {
list.add(particle);
} else if (particle instanceof XSDModelGroupDefinition) {
// list.add(((XSDModelGroupDefinition)particle).getResolvedModelGroupDefinition());
list.add(particle);
}
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
use of org.eclipse.xsd.XSDModelGroup in project webtools.sourceediting by eclipse.
the class XSDElementDragAndDropCommand method doDrop.
protected void doDrop(List siblings, GraphicalEditPart movingEditPart) {
commonSetup(siblings, movingEditPart);
// Can common this code up with XSDAttributeDragAndDropCommand...
if ((previousRefComponent instanceof XSDElementDeclaration || previousRefComponent instanceof XSDWildcard) && (nextRefComponent instanceof XSDElementDeclaration || nextRefComponent instanceof XSDWildcard)) {
XSDModelGroup modelGroup = (XSDModelGroup) previousRefComponent.getContainer().getContainer();
if (parentEditPart != null)
modelGroup = ((ModelGroupEditPart) parentEditPart).getXSDModelGroup();
action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
} else if (previousRefComponent == null && (nextRefComponent instanceof XSDElementDeclaration || nextRefComponent instanceof XSDWildcard)) {
if (closerSibling == ABOVE_IS_CLOSER) {
if (leftSiblingEditPart == null) {
action = new MoveXSDElementAction(topMostGroup.getXSDModelGroup(), xsdComponentToDrag, null, null, false);
} else if (parentEditPart != null) {
action = new MoveXSDElementAction(((ModelGroupEditPart) parentEditPart).getXSDModelGroup(), xsdComponentToDrag, previousRefComponent, nextRefComponent);
}
} else {
XSDModelGroup modelGroup = (XSDModelGroup) nextRefComponent.getContainer().getContainer();
action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
}
} else if ((previousRefComponent instanceof XSDElementDeclaration || previousRefComponent instanceof XSDWildcard) && nextRefComponent == null) {
XSDModelGroup modelGroup = (XSDModelGroup) previousRefComponent.getContainer().getContainer();
if (parentEditPart != null)
modelGroup = ((ModelGroupEditPart) parentEditPart).getXSDModelGroup();
if (closerSibling == ABOVE_IS_CLOSER) {
action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
} else {
if (rightSiblingEditPart == null) {
action = new MoveXSDElementAction(topMostGroup.getXSDModelGroup(), xsdComponentToDrag, null, null, true);
} else {
action = new MoveXSDElementAction(modelGroup, xsdComponentToDrag, previousRefComponent, nextRefComponent);
}
}
}
if (action != null)
canExecute = action.canMove();
}
use of org.eclipse.xsd.XSDModelGroup in project webtools.sourceediting by eclipse.
the class ModelGroupDefinitionReferenceEditPart method getModelChildren.
protected List getModelChildren() {
List list = new ArrayList();
XSDModelGroupDefinitionAdapter adapter = (XSDModelGroupDefinitionAdapter) getModel();
XSDModelGroupDefinition groupDef = ((XSDModelGroupDefinition) adapter.getTarget());
XSDModelGroupDefinition resolvedGroupDef = groupDef.getResolvedModelGroupDefinition();
XSDModelGroup xsdModelGroup = resolvedGroupDef.getModelGroup();
ArrayList listOfVisibleGroupRefs = new ArrayList();
for (EditPart ep = getParent(); ep != null; ) {
Object object = ep.getModel();
if (object instanceof XSDModelGroupDefinitionAdapter) {
Object model = ((XSDModelGroupDefinitionAdapter) object).getTarget();
if (model instanceof XSDModelGroupDefinition) {
listOfVisibleGroupRefs.add(((XSDModelGroupDefinition) model).getResolvedModelGroupDefinition());
}
}
ep = ep.getParent();
}
boolean isCyclic = (listOfVisibleGroupRefs.contains(resolvedGroupDef));
if (xsdModelGroup != null && !isCyclic)
list.add(XSDAdapterFactory.getInstance().adapt(xsdModelGroup));
if (isCyclic)
list.add(new TargetConnectionSpaceFiller(null));
return list;
}
use of org.eclipse.xsd.XSDModelGroup in project webtools.sourceediting by eclipse.
the class XSDModelGroupSection method refresh.
public void refresh() {
super.refresh();
if (isReadOnly) {
composite.setEnabled(false);
} else {
composite.setEnabled(true);
}
setListenerEnabled(false);
if (input != null) {
if (input instanceof XSDModelGroup) {
XSDModelGroup particle = (XSDModelGroup) input;
String modelType = particle.getCompositor().getName();
modelGroupCombo.setText(modelType);
minCombo.setEnabled(!(particle.eContainer() instanceof XSDModelGroupDefinition));
maxCombo.setEnabled(!(particle.eContainer() instanceof XSDModelGroupDefinition));
}
}
refreshMinMax();
setListenerEnabled(true);
}
Aggregations