use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDModelGroupAdapter method getActions.
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IActionProvider#getActions(java.lang.Object)
*/
public String[] getActions(Object object) {
Collection actionIDs = new ArrayList();
actionIDs.add(AddXSDElementAction.ID);
actionIDs.add(AddXSDElementAction.REF_ID);
actionIDs.add(AddXSDAnyElementAction.ID);
// Add Element Ref
actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
actionIDs.add(AddXSDModelGroupAction.SEQUENCE_ID);
actionIDs.add(AddXSDModelGroupAction.CHOICE_ID);
actionIDs.add(AddXSDModelGroupAction.ALL_ID);
actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
actionIDs.add(AddXSDModelGroupDefinitionAction.MODELGROUPDEFINITIONREF_ID);
// actionIDs.add(AddFieldAction.ID);
actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
// Add Any
actionIDs.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_MULTIPLICITY);
actionIDs.add(SetMultiplicityAction.REQUIRED_ID);
actionIDs.add(SetMultiplicityAction.ZERO_OR_ONE_ID);
actionIDs.add(SetMultiplicityAction.ZERO_OR_MORE_ID);
actionIDs.add(SetMultiplicityAction.ONE_OR_MORE_ID);
actionIDs.add(BaseSelectionAction.SUBMENU_END_ID);
if (!(getParent(target) instanceof XSDModelGroupDefinition)) {
actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
actionIDs.add(DeleteAction.ID);
}
actionIDs.add(BaseSelectionAction.SEPARATOR_ID);
actionIDs.add(ShowPropertiesViewAction.ID);
return (String[]) actionIDs.toArray(new String[0]);
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDSchemaAdapter method getGroups.
public List getGroups(XSDSchema schema, boolean showFromIncludes) {
List groups = schema.getModelGroupDefinitions();
List list = new ArrayList();
for (Iterator i = groups.iterator(); i.hasNext(); ) {
XSDModelGroupDefinition group = (XSDModelGroupDefinition) i.next();
if (shouldShowComponent(group, schema, showFromIncludes)) {
list.add(group);
}
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return adapterList;
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class XSDVisitorForFields method visitModelGroupDefinition.
public void visitModelGroupDefinition(XSDModelGroupDefinition modelGroupDef) {
// listen to definition in case it changes
XSDModelGroupDefinition resolvedModelGroupDef = modelGroupDef.getResolvedModelGroupDefinition();
if (visitedGroups.contains(resolvedModelGroupDef.getModelGroup()))
return;
if (modelGroupDef.isModelGroupDefinitionReference()) {
// if it's a reference we need to listen to the reference incase it changes
if (!thingsWeNeedToListenTo.contains(modelGroupDef))
thingsWeNeedToListenTo.add(modelGroupDef);
}
super.visitModelGroupDefinition(modelGroupDef);
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class AddXSDModelGroupAction method run.
public void run() {
Object selection = ((IStructuredSelection) getSelection()).getFirstElement();
if (selection instanceof XSDBaseAdapter) {
XSDConcreteComponent xsdComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget();
AddXSDModelGroupCommand command = null;
if (xsdComponent instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) xsdComponent;
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdElementDeclaration, xsdCompositor);
getCommandStack().execute(command);
} else if (xsdComponent instanceof XSDModelGroup) {
XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdComponent;
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdModelGroup, xsdCompositor);
getCommandStack().execute(command);
} else if (xsdComponent instanceof XSDComplexTypeDefinition || xsdComponent instanceof XSDModelGroupDefinition) {
command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdComponent, xsdCompositor);
getCommandStack().execute(command);
}
if (command != null) {
Adapter adapter = XSDAdapterFactory.getInstance().adapt(command.getAddedComponent());
if (adapter != null)
provider.setSelection(new StructuredSelection(adapter));
}
}
}
use of org.eclipse.xsd.XSDModelGroupDefinition in project webtools.sourceediting by eclipse.
the class AddXSDElementCommand method createXSDElementDeclaration.
protected XSDParticle createXSDElementDeclaration() {
// $NON-NLS-1$
XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string");
XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration();
XSDConcreteComponent comp = xsdModelGroup.getContainer();
ArrayList usedAttributeNames = new ArrayList();
XSDCommonUIUtils.resetVisitedGroupsStack();
usedAttributeNames.addAll(XSDCommonUIUtils.getChildElements(xsdModelGroup));
while (comp != null) {
if (comp instanceof XSDModelGroupDefinition) {
usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDModelGroupDefinition) comp));
break;
} else if (comp instanceof XSDComplexTypeDefinition) {
usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDComplexTypeDefinition) comp));
usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes((XSDComplexTypeDefinition) comp));
break;
}
comp = comp.getContainer();
}
element.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "NewElement" : nameToAdd, // $NON-NLS-1$
usedAttributeNames));
element.setTypeDefinition(type);
XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle();
particle.setContent(element);
addedXSDConcreteComponent = element;
return particle;
}
Aggregations