use of org.eclipse.xsd.XSDConcreteComponent 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.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class InternalXSDMultiPageEditor method createNavigationLocation.
public INavigationLocation createNavigationLocation() {
if (getActivePage() == DESIGN_PAGE_INDEX) {
try {
RootEditPart rootEditPart = graphicalViewer.getRootEditPart();
EditPart editPart = rootEditPart.getContents();
if (editPart instanceof RootContentEditPart) {
RootContentEditPart rootContentEditPart = (RootContentEditPart) editPart;
Object input = rootContentEditPart.getInput();
if (input instanceof Adapter) {
XSDConcreteComponent concreteComponent = (XSDConcreteComponent) ((Adapter) input).getTarget();
Object object = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getAdapter(ProductCustomizationProvider.class);
if (object instanceof ProductCustomizationProvider) {
ProductCustomizationProvider productCustomizationProvider = (ProductCustomizationProvider) object;
if (productCustomizationProvider != null) {
return productCustomizationProvider.getNavigationLocation(this, concreteComponent, rootContentEditPart);
}
}
return new DesignViewNavigationLocation(this, concreteComponent);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
} else {
return new MultiPageEditorTextSelectionNavigationLocation(getTextEditor(), true);
}
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDAttributeReferenceEditManager method modifyComponentReference.
public void modifyComponentReference(Object referencingObject, ComponentSpecification referencedComponent) {
XSDAttributeDeclaration concreteComponent = null;
if (referencingObject instanceof Adapter) {
Adapter adapter = (Adapter) referencingObject;
if (adapter.getTarget() instanceof XSDAttributeDeclaration) {
concreteComponent = (XSDAttributeDeclaration) adapter.getTarget();
}
} else if (referencingObject instanceof XSDConcreteComponent) {
concreteComponent = (XSDAttributeDeclaration) referencingObject;
}
if (concreteComponent != null) {
if (referencedComponent.isNew()) {
XSDAttributeDeclaration attributeDec = null;
if (referencedComponent.getMetaName() == IXSDSearchConstants.ATTRIBUTE_META_NAME) {
AddXSDAttributeDeclarationCommand command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, concreteComponent.getSchema());
command.setNameToAdd(referencedComponent.getName());
command.execute();
attributeDec = (XSDAttributeDeclaration) command.getAddedComponent();
}
if (attributeDec != null) {
Command command = new UpdateAttributeReferenceCommand(Messages._UI_ACTION_UPDATE_ATTRIBUTE_REFERENCE, concreteComponent, attributeDec);
command.execute();
}
XSDDirectivesManager.removeUnusedXSDImports(concreteComponent.getSchema());
} else {
Command command = new UpdateAttributeReferenceAndManagerDirectivesCommand(concreteComponent, referencedComponent.getName(), referencedComponent.getQualifier(), referencedComponent.getFile());
command.setLabel(Messages._UI_ACTION_UPDATE_ATTRIBUTE_REFERENCE);
command.execute();
}
}
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDModelReconcileAdapter method handleNodeChanged.
protected void handleNodeChanged(Node node) {
try {
if (!shouldReconcileModelFor(node)) {
return;
}
} catch (Exception e) {
}
if (node instanceof Element) {
Element element = (Element) node;
if (delayedReconciler.shouldDelay(schema)) {
delayedReconciler.elementChanged(element, schema);
} else {
XSDConcreteComponent concreteComponent = schema.getCorrespondingComponent(node);
concreteComponent.elementChanged(element);
}
} else if (node instanceof Document) {
// The document changed so we may need to fix up the
// definition's root element
Document document = (Document) node;
Element schemaElement = document.getDocumentElement();
if (schemaElement != null && schemaElement != schema.getElement()) {
//
if (schemaElement.getLocalName().equals(XSDConstants.SCHEMA_ELEMENT_TAG)) {
// System.out.println("****** Setting new schema");
schema.setElement(schemaElement);
}
} else if (schemaElement != null) {
// handle the case where the definition element's content has changed
// TODO (cs) do we really need to handle this case?
schema.elementChanged(schemaElement);
} else if (schemaElement == null) {
// otherwise the statements below don't get run
try {
schema.getContents().clear();
} catch (NullPointerException e) {
// workaround
}
// See comment above for https://bugs.eclipse.org/bugs/show_bug.cgi?id=203291
try {
schema.getIncorporatedVersions().clear();
} catch (Exception e) {
}
try {
schema.getElementDeclarations().clear();
} catch (Exception e) {
}
try {
schema.getTypeDefinitions().clear();
} catch (Exception e) {
}
try {
schema.getAttributeDeclarations().clear();
} catch (Exception e) {
}
try {
schema.getModelGroupDefinitions().clear();
} catch (Exception e) {
}
try {
schema.getAttributeGroupDefinitions().clear();
} catch (Exception e) {
}
try {
schema.setTargetNamespace(null);
} catch (Exception e) {
}
try {
schema.reset();
} catch (Exception e) {
}
schema.setElement(null);
}
}
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDElementDragAndDropCommand method getElement.
/*
* (non-Javadoc)
* @see org.eclipse.wst.xsd.ui.internal.commands.BaseDragAndDropCommand#getElement()
*/
protected Element getElement() {
XSDElementDeclarationAdapter adapter = (XSDElementDeclarationAdapter) itemToDrag.getModel();
XSDElementDeclaration target = (XSDElementDeclaration) adapter.getTarget();
XSDConcreteComponent parent = (XSDConcreteComponent) target.eContainer();
return parent.getElement();
}
Aggregations