use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDComplexTypeSection method fillTypesCombo.
private void fillTypesCombo() {
baseTypeCombo.removeAll();
baseTypeCombo.add(Messages._UI_COMBO_BROWSE);
baseTypeCombo.add(Messages._UI_COMBO_NEW);
// Add the current Type of this attribute if needed
XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input;
XSDTypeDefinition baseType = complexType.getBaseType();
if (baseType != null && baseType.getQName() != null) {
// no prefix
String currentTypeName = baseType.getQName(xsdSchema);
if (currentTypeName != null && !currentTypeName.equals("anyType"))
baseTypeCombo.add(currentTypeName);
}
}
use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDComplexTypeSection method refresh.
/*
* @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
*/
public void refresh() {
super.refresh();
if (Display.getCurrent() == null)
return;
setListenerEnabled(false);
showLink(!hideHyperLink);
try {
// $NON-NLS-1$
nameText.setText("");
// $NON-NLS-1$
baseTypeCombo.setText("");
fillTypesCombo();
if (input instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input;
String name = complexType.getName();
if (name == null)
// $NON-NLS-1$
name = "";
// $NON-NLS-1$
boolean isAnonymousType = name.equals("") ? true : false;
if (isAnonymousType) {
// $NON-NLS-1$
nameText.setText("**anonymous**");
nameText.setEditable(false);
} else {
nameText.setText(name);
nameText.setEditable(true);
}
XSDTypeDefinition baseTypeDefinition = complexType.getBaseTypeDefinition();
// $NON-NLS-1$
String baseType = "";
if (baseTypeDefinition != null) {
baseType = baseTypeDefinition.getName();
if (baseType == null) {
// $NON-NLS-1$
baseType = "";
} else if (baseType.equals("anyType")) {
// $NON-NLS-1$
baseType = "";
}
}
baseTypeCombo.setText(baseType);
// $NON-NLS-1$
derivedByCombo.setText("");
int derivationMethod = complexType.getDerivationMethod().getValue();
XSDDOMHelper domHelper = new XSDDOMHelper();
if (domHelper.getDerivedByElementFromComplexType(complexType.getElement()) != null) {
if (derivationMethod == XSDDerivationMethod.EXTENSION) {
derivedByCombo.setText(XSDConstants.EXTENSION_ELEMENT_TAG);
} else if (derivationMethod == XSDDerivationMethod.RESTRICTION) {
derivedByCombo.setText(XSDConstants.RESTRICTION_ELEMENT_TAG);
}
}
}
} finally {
setListenerEnabled(true);
}
}
use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDElementDeclarationSection method refresh.
/*
* @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh()
*/
public void refresh() {
setListenerEnabled(false);
super.refresh();
XSDElementDeclaration xsdElementDeclaration = ((XSDElementDeclaration) input).getResolvedElementDeclaration();
// refresh name
// $NON-NLS-1$
nameText.setText("");
// $NON-NLS-1$
typeCombo.setText("");
String name = xsdElementDeclaration.getName();
if (name != null) {
nameText.setText(name);
}
if (isElementReference) {
refreshRefCombo();
}
// refresh type
if (input != null) {
if (input instanceof XSDElementDeclaration) {
boolean isAnonymous = xsdElementDeclaration.getAnonymousTypeDefinition() != null;
// XSDTypeDefinition typeDef = XSDUtils.getResolvedType(xsdElementDeclaration);
XSDTypeDefinition typeDef = xsdElementDeclaration.getResolvedElementDeclaration().getTypeDefinition();
if (typeDef != null)
typeName = typeDef.getQName(xsdSchema);
if (typeName == null) {
// $NON-NLS-1$
typeName = "";
}
fillTypesCombo();
if (isAnonymous) {
typeCombo.setText("**Anonymous**");
typeName = "**Anonymous**";
} else {
if (typeDefinition != null) {
typeCombo.setText(typeName);
} else {
// $NON-NLS-1$
typeCombo.setText(Messages.UI_NO_TYPE);
}
}
maxCombo.setEnabled(!xsdElementDeclaration.isGlobal() || isElementReference);
minCombo.setEnabled(!xsdElementDeclaration.isGlobal() || isElementReference);
}
}
// refresh min max
refreshMinMax();
setListenerEnabled(true);
}
use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDSimpleTypeSection method fillTypesCombo.
private void fillTypesCombo() {
typesCombo.removeAll();
IEditorPart editor = getActiveEditor();
ComponentReferenceEditManager manager = (ComponentReferenceEditManager) editor.getAdapter(XSDTypeReferenceEditManager.class);
if (manager != null) {
ComponentSpecification[] items = manager.getQuickPicks();
typesCombo.add(Messages._UI_COMBO_BROWSE);
typesCombo.add(Messages._UI_COMBO_NEW);
for (int i = 0; i < items.length; i++) {
typesCombo.add(items[i].getName());
}
// Add the current Type of this attribute if needed
XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) input;
XSDTypeDefinition baseType = simpleType.getBaseType();
if (baseType != null && baseType.getQName() != null) {
// no prefix
String currentTypeName = baseType.getQName(xsdSchema);
ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager);
if (// not in quickPick
ret == null && currentTypeName != null) {
typesCombo.add(currentTypeName);
}
}
}
}
use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class AddXSDAttributeGroupDefinitionCommand method walkUpInheritance.
private void walkUpInheritance(XSDComplexTypeDefinition ct) {
updateNames(ct);
XSDTypeDefinition typeDef = ct.getBaseTypeDefinition();
if (ct != ct.getRootType()) {
if (typeDef instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition ct2 = (XSDComplexTypeDefinition) typeDef;
walkUpInheritance(ct2);
}
}
}
Aggregations