use of org.eclipse.wst.xsd.ui.internal.adapters.XSDModelGroupAdapter 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.wst.xsd.ui.internal.adapters.XSDModelGroupAdapter in project webtools.sourceediting by eclipse.
the class ModelGroupEditPart method refreshVisuals.
protected void refreshVisuals() {
boolean isReadOnly = false;
GenericGroupFigure modelGroupFigure = (GenericGroupFigure) getFigure();
XSDModelGroupAdapter adapter = (XSDModelGroupAdapter) getModel();
isReadOnly = adapter.isReadOnly();
String nodeName = "";
Image image;
switch(getXSDModelGroup().getCompositor().getValue()) {
case XSDCompositor.ALL:
{
image = isReadOnly ? ModelGroupFigure.ALL_ICON_DISABLED_IMAGE : ModelGroupFigure.ALL_ICON_IMAGE;
modelGroupFigure.getIconFigure().image = XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent) adapter.getTarget(), image, isReadOnly);
nodeName = XSDConstants.ALL_ELEMENT_TAG;
break;
}
case XSDCompositor.CHOICE:
{
image = isReadOnly ? ModelGroupFigure.CHOICE_ICON_DISABLED_IMAGE : ModelGroupFigure.CHOICE_ICON_IMAGE;
modelGroupFigure.getIconFigure().image = XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent) adapter.getTarget(), image, isReadOnly);
nodeName = XSDConstants.CHOICE_ELEMENT_TAG;
break;
}
case XSDCompositor.SEQUENCE:
{
image = isReadOnly ? ModelGroupFigure.SEQUENCE_ICON_DISABLED_IMAGE : ModelGroupFigure.SEQUENCE_ICON_IMAGE;
modelGroupFigure.getIconFigure().image = XSDCommonUIUtils.getUpdatedImage((XSDConcreteComponent) adapter.getTarget(), image, isReadOnly);
nodeName = XSDConstants.SEQUENCE_ELEMENT_TAG;
break;
}
}
// String occurenceDescription = adapter.getNameAnnotationToolTipString();
// modelGroupFigure.getIconFigure().setToolTip(occurenceDescription);
// TODO: commmon this up with XSDParticleAdapter's code
// -2 means the user didn't specify (so the default is 1)
int minOccurs = adapter.getMinOccurs();
int maxOccurs = adapter.getMaxOccurs();
// $NON-NLS-1$
String occurenceDescription = "";
if (minOccurs == -3 && maxOccurs == -3) {
occurenceDescription = nodeName;
modelGroupFigure.setText(null);
} else if (minOccurs == 0 && (maxOccurs == -2 || maxOccurs == 1)) {
// $NON-NLS-1$
occurenceDescription = nodeName + " [0..1]";
modelGroupFigure.setText("0..1");
} else if ((minOccurs == 1 && maxOccurs == 1) || (minOccurs == -2 && maxOccurs == 1) || (minOccurs == 1 && maxOccurs == -2)) {
// $NON-NLS-1$
occurenceDescription = nodeName + " [1..1]";
modelGroupFigure.setText("1..1");
} else if (minOccurs == -2 && maxOccurs == -2) {
occurenceDescription = nodeName;
modelGroupFigure.setText(null);
} else {
if (maxOccurs == -2)
maxOccurs = 1;
// $NON-NLS-1$ //$NON-NLS-2$
String maxSymbol = maxOccurs == -1 ? "*" : "" + maxOccurs;
// $NON-NLS-1$ //$NON-NLS-2$
String minSymbol = minOccurs == -2 ? "1" : "" + minOccurs;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
occurenceDescription = nodeName + " [" + minSymbol + ".." + maxSymbol + "]";
modelGroupFigure.setText(minSymbol + ".." + maxSymbol);
}
modelGroupFigure.getIconFigure().setToolTipText(occurenceDescription);
modelGroupFigure.getIconFigure().repaint();
refreshConnection();
}
Aggregations