use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDSimpleTypeDefinitionAdapter method getActions.
public String[] getActions(Object object) {
List list = new ArrayList();
list.add(AddXSDEnumerationFacetAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(SetBaseTypeAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(DeleteAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
Object schema = getEditorSchema();
XSDTypeDefinition typeDefinition = getXSDTypeDefinition();
if (typeDefinition.getSchema() == schema) {
XSDConcreteComponent container = typeDefinition.getContainer();
if (container == schema || container instanceof XSDRedefine) {
list.add(SetInputToGraphView.ID);
}
} else {
list.add(OpenInNewEditor.ID);
}
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(ShowPropertiesViewAction.ID);
return (String[]) list.toArray(new String[0]);
}
use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDAttributeGroupDefinitionAdapter method getActions.
public String[] getActions(Object object) {
List list = new ArrayList();
list.add(AddXSDAttributeDeclarationAction.ID);
list.add(AddXSDAnyAttributeAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(DeleteAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
Object schema = getEditorSchema();
XSDAttributeGroupDefinition attributeGroupDefinition = getXSDAttributeGroupDefinition();
if (attributeGroupDefinition.getSchema() == schema) {
XSDConcreteComponent container = attributeGroupDefinition.getContainer();
if (container == schema || container instanceof XSDRedefine) {
list.add(SetInputToGraphView.ID);
}
} else {
list.add(OpenInNewEditor.ID);
}
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(ShowPropertiesViewAction.ID);
return (String[]) list.toArray(new String[0]);
}
use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDModelGroupDefinitionAdapter 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 list = new ArrayList();
XSDModelGroupDefinition modelGroupDefinition = getXSDModelGroupDefinition();
boolean isModelGroupReference = modelGroupDefinition.isModelGroupDefinitionReference();
if (!isModelGroupReference) {
list.add(AddXSDElementAction.ID);
list.add(AddXSDElementAction.REF_ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(AddXSDModelGroupAction.SEQUENCE_ID);
list.add(AddXSDModelGroupAction.CHOICE_ID);
list.add(AddXSDModelGroupAction.ALL_ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
}
list.add(DeleteAction.ID);
if (isModelGroupReference) {
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(BaseSelectionAction.SUBMENU_START_ID + Messages._UI_ACTION_SET_MULTIPLICITY);
list.add(SetMultiplicityAction.REQUIRED_ID);
list.add(SetMultiplicityAction.ZERO_OR_ONE_ID);
list.add(SetMultiplicityAction.ZERO_OR_MORE_ID);
list.add(SetMultiplicityAction.ONE_OR_MORE_ID);
list.add(BaseSelectionAction.SUBMENU_END_ID);
}
list.add(BaseSelectionAction.SEPARATOR_ID);
Object schema = getEditorSchema();
if (modelGroupDefinition.getSchema() == schema) {
XSDConcreteComponent container = modelGroupDefinition.getContainer();
if (container == schema || container instanceof XSDRedefine) {
list.add(SetInputToGraphView.ID);
}
} else {
list.add(OpenInNewEditor.ID);
}
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(ShowPropertiesViewAction.ID);
return (String[]) list.toArray(new String[0]);
}
use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDComplexTypeDefinitionAdapter method getActions.
public String[] getActions(Object object) {
List list = new ArrayList();
Object schema = getEditorSchema();
XSDComplexTypeDefinition complexType = getXSDComplexTypeDefinition();
Object contentType = getContentType();
XSDDerivationMethod derivation = complexType.getDerivationMethod();
if (contentType instanceof XSDSimpleTypeDefinition) {
List fields = getFields();
boolean hasSimpleContentAttributes = false;
for (Iterator iterator = fields.iterator(); iterator.hasNext(); ) {
Object field = iterator.next();
// We have attributes, so we need to add the compartment for housing the attributes
if (field instanceof XSDAttributeDeclarationAdapter) {
hasSimpleContentAttributes = true;
break;
}
}
if (hasSimpleContentAttributes || XSDDerivationMethod.EXTENSION_LITERAL.equals(derivation)) {
list.add(AddXSDAttributeDeclarationAction.ID);
} else if (XSDDerivationMethod.RESTRICTION_LITERAL.equals(derivation)) {
list.add(AddXSDEnumerationFacetAction.ID);
}
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(SetBaseTypeAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(DeleteAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
} else {
list.add(AddXSDElementAction.ID);
list.add(AddXSDElementAction.REF_ID);
list.add(AddXSDAnyElementAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(AddXSDAttributeDeclarationAction.ID);
list.add(AddXSDAttributeDeclarationAction.REF_ID);
list.add(AddXSDAttributeGroupDefinitionAction.REF_ID);
list.add(AddXSDAnyAttributeAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(AddXSDModelGroupAction.SEQUENCE_ID);
list.add(AddXSDModelGroupAction.CHOICE_ID);
list.add(AddXSDModelGroupAction.ALL_ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(DeleteAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(SetBaseTypeAction.ID);
list.add(BaseSelectionAction.SEPARATOR_ID);
}
if (complexType.getSchema() == schema) {
XSDConcreteComponent container = complexType.getContainer();
if (container == schema || container instanceof XSDRedefine) {
list.add(SetInputToGraphView.ID);
}
} else {
list.add(OpenInNewEditor.ID);
}
list.add(BaseSelectionAction.SEPARATOR_ID);
list.add(ShowPropertiesViewAction.ID);
String[] result = new String[list.size()];
list.toArray(result);
return result;
}
use of org.eclipse.xsd.XSDRedefine in project webtools.sourceediting by eclipse.
the class XSDSchemaAdapter method notifyChanged.
public void notifyChanged(final Notification msg) {
class CategoryNotification extends NotificationImpl {
protected Object category;
public CategoryNotification(Object category) {
super(msg.getEventType(), msg.getOldValue(), msg.getNewValue(), msg.getPosition());
this.category = category;
}
public Object getNotifier() {
return category;
}
public Object getFeature() {
return msg.getFeature();
}
}
if (children == null) {
getChildren();
}
Object newValue = msg.getNewValue();
Object oldValue = msg.getOldValue();
// Bug 245480 - Deletion of Include, Import and Redefine is not reflected in the Outline view
// We only want to refresh the Directives folder for any changes to XSDDirectives. The first case covers
// changes to one directive, whereas the missing case as reported in bug 245480 covers changes to a list
// of directives.
boolean updateDirectivesCategory = false;
if (oldValue instanceof XSDSchemaDirective) {
updateDirectivesCategory = true;
} else if (oldValue instanceof Collection) {
Iterator iterator = ((Collection) oldValue).iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof XSDSchemaDirective) {
// if we find at least one directive, then we should refresh the folder
updateDirectivesCategory = true;
break;
}
}
}
if (newValue instanceof XSDInclude || newValue instanceof XSDImport || newValue instanceof XSDRedefine || // handle the case for delete directive
(msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Contents() && updateDirectivesCategory) || // updates to the imports/includes
msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_IncorporatedVersions()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.DIRECTIVES);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
adapter.setChildren(getDirectives(xsdSchema));
adapter.setAllChildren(getDirectives(xsdSchema));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_ElementDeclarations()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.ELEMENTS);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
adapter.setChildren(getGlobalElements(xsdSchema));
adapter.setAllChildren(getGlobalElements(xsdSchema, true));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_AttributeDeclarations() || msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_AttributeGroupDefinitions()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.ATTRIBUTES);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
adapter.setChildren(getAttributeList(xsdSchema));
adapter.setAllChildren(getAttributeList(xsdSchema, true));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_TypeDefinitions()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.TYPES);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
List types = getComplexTypes(xsdSchema);
types.addAll(getSimpleTypes(xsdSchema));
adapter.setChildren(types);
adapter.setAllChildren(getTypes(xsdSchema, true));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_ModelGroupDefinitions()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.GROUPS);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
adapter.setChildren(getGroups(xsdSchema));
adapter.setAllChildren(getGroups(xsdSchema, true));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Annotations()) {
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_SchemaLocation()) {
notifyListeners(msg, null);
return;
}
types = null;
getTypes();
super.notifyChanged(msg);
}
Aggregations