use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class XSDAnyElementContentsSection method doWidgetSelected.
public void doWidgetSelected(SelectionEvent e) {
XSDConcreteComponent concreteComponent = (XSDConcreteComponent) input;
if (concreteComponent instanceof XSDWildcard) {
XSDWildcard wildcard = (XSDWildcard) concreteComponent;
if (e.widget == namespaceCombo) {
String newValue = namespaceCombo.getText();
boolean removeAttribute = false;
if (newValue.length() == 0) {
removeAttribute = true;
}
// element); //$NON-NLS-1$
if (removeAttribute) {
wildcard.unsetLexicalNamespaceConstraint();
} else {
wildcard.setStringLexicalNamespaceConstraint(newValue);
}
// endRecording(element);
} else if (e.widget == processContentsCombo) {
String newValue = processContentsCombo.getText();
boolean removeAttribute = false;
if (newValue.length() == 0) {
removeAttribute = true;
}
// element); //$NON-NLS-1$
if (removeAttribute) {
wildcard.unsetProcessContents();
} else {
wildcard.setProcessContents(XSDProcessContents.get(processContentsCombo.getItem(processContentsCombo.getSelectionIndex())));
}
// endRecording(element);
}
}
super.doWidgetSelected(e);
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class AbstractSectionDescriptor method appliesTo.
/* (non-Javadoc)
* @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
*/
public boolean appliesTo(IWorkbenchPart part, ISelection selection) {
Object object = null;
if (selection instanceof StructuredSelection) {
StructuredSelection structuredSelection = (StructuredSelection) selection;
object = structuredSelection.getFirstElement();
if (object instanceof XSDConcreteComponent || object instanceof Element) {
return true;
}
}
return false;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class ExtensionsSection method isTreeViewerInputElement.
protected boolean isTreeViewerInputElement(Element element) {
if (input instanceof XSDConcreteComponent) {
XSDConcreteComponent component = (XSDConcreteComponent) input;
Element componentElement = component.getElement();
Node parent = element.getParentNode();
Node grandParent = parent != null ? parent.getParentNode() : null;
return componentElement == element || componentElement == parent || componentElement == grandParent;
}
return false;
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class ExtensionsSection method setInput.
public void setInput(IWorkbenchPart part, ISelection selection) {
super.setInput(part, selection);
if (adapter == null) {
if (selection instanceof StructuredSelection) {
Object obj = ((StructuredSelection) selection).getFirstElement();
if (obj instanceof XSDConcreteComponent) {
Element element = ((XSDConcreteComponent) obj).getElement();
if (element != null) {
adapter = XSDModelAdapter.lookupOrCreateModelAdapter(element.getOwnerDocument());
if (adapter != null) {
ModelReconcileAdapter modelReconcileAdapter = adapter.getModelReconcileAdapter();
if (modelReconcileAdapter != null) {
modelReconcileAdapter.addListener(internalNodeAdapter);
}
}
}
}
}
}
extensionTreeViewer.expandToLevel(2);
}
use of org.eclipse.xsd.XSDConcreteComponent in project webtools.sourceediting by eclipse.
the class AddXSDModelGroupCommand method getOwner.
private XSDConcreteComponent getOwner() {
XSDConcreteComponent owner = null;
if (parent instanceof XSDElementDeclaration) {
XSDElementDeclaration ed = (XSDElementDeclaration) parent;
if (ed.getTypeDefinition() != null) {
if (ed.getAnonymousTypeDefinition() == null) {
ed.setTypeDefinition(null);
XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
ed.setAnonymousTypeDefinition(td);
owner = ed.getTypeDefinition();
} else {
XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
ed.setAnonymousTypeDefinition(td);
owner = td;
}
} else if (ed.getAnonymousTypeDefinition() == null) {
XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
ed.setAnonymousTypeDefinition(td);
owner = td;
} else if (ed.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition) {
owner = ed.getAnonymousTypeDefinition();
} else if (ed.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition) {
XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition();
ed.setAnonymousTypeDefinition(td);
owner = td;
}
} else if (parent instanceof XSDModelGroup) {
newModelGroup = createModelGroup();
((XSDModelGroup) parent).getContents().add(newModelGroup.getContainer());
} else if (parent instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) parent;
owner = parent;
if (ct.getContent() instanceof XSDParticle) {
XSDParticle particle = (XSDParticle) ct.getContent();
if (particle.getContent() instanceof XSDModelGroup) {
owner = null;
newModelGroup = createModelGroup();
XSDModelGroup newParent = (XSDModelGroup) particle.getContent();
newParent.getContents().add(newModelGroup.getContainer());
}
}
} else if (parent instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition modelGroupDefinition = (XSDModelGroupDefinition) parent;
owner = null;
newModelGroup = createModelGroup();
if (modelGroupDefinition.getModelGroup() != null) {
XSDModelGroup newParent = modelGroupDefinition.getModelGroup();
newParent.getContents().add(newModelGroup.getContainer());
} else {
modelGroupDefinition.setModelGroup(newModelGroup);
}
}
return owner;
}
Aggregations