use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDTypesSearchListProvider method populateComponentList.
public void populateComponentList(IComponentList list, SearchScope scope, IProgressMonitor pm) {
// first we add the 'built in' types
//
XSDSchema schemaForSchema = XSDSchemaImpl.getSchemaForSchema(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001);
for (Iterator i = schemaForSchema.getSimpleTypeIdMap().values().iterator(); i.hasNext(); ) {
XSDTypeDefinition td = (XSDTypeDefinition) i.next();
if (builtInFilter == null || !builtInFilter.shouldFilterOut(td)) {
list.add(td);
}
}
// now we traverse the types already defined within the visible schemas
// we do this in addition to the component search since this should execute
// very quickly and there's a good chance the user wants to select a time
// that's
// already imported/included
// TODO (cs) ensure we don't add duplicates when we proceed to use the
// search list
//
List visitedSchemas = new ArrayList();
for (int i = 0; i < schemas.length; i++) {
XSDSchema schema = schemas[i];
QualifiedName kind = showComplexTypes ? IXSDSearchConstants.TYPE_META_NAME : IXSDSearchConstants.SIMPLE_TYPE_META_NAME;
ComponentCollectingXSDVisitor visitor = new ComponentCollectingXSDVisitor(list, kind);
visitor.visitSchema(schema, true);
visitedSchemas.addAll(visitor.getVisitedSchemas());
}
//
if (scope != null) {
populateComponentListUsingSearch(list, scope, pm, createFileMap(visitedSchemas));
}
}
use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class XSDHyperlinkTargetLocator method caseXSDTypeDefinition.
/*
* (non-Javadoc)
*
* @see org.eclipse.xsd.util.XSDSwitch#caseXSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)
*/
public Object caseXSDTypeDefinition(XSDTypeDefinition typeDefinition) {
XSDConcreteComponent target = null;
XSDTypeDefinition baseType = typeDefinition.getBaseType();
if (baseType != null) {
target = baseType;
}
if (isFromSchemaForSchema(target)) {
target = null;
}
return target;
}
use of org.eclipse.xsd.XSDTypeDefinition in project webtools.sourceediting by eclipse.
the class MakeAnonymousTypeGlobalCommand method run.
public void run() {
XSDConcreteComponent model = getModelObject();
XSDConcreteComponent parent = model.getContainer();
XSDTypeDefinition globalTypeDef = null;
if (model instanceof XSDComplexTypeDefinition) {
if (parent instanceof XSDElementDeclaration) {
// clone typedef with it's content and set it global
globalTypeDef = (XSDComplexTypeDefinition) model.cloneConcreteComponent(true, false);
globalTypeDef.setName(fNewName);
parent.getSchema().getContents().add(globalTypeDef);
((XSDElementDeclaration) parent).setTypeDefinition(globalTypeDef);
}
} else if (model instanceof XSDSimpleTypeDefinition) {
XSDSimpleTypeDefinition typeDef = (XSDSimpleTypeDefinition) model;
if (parent instanceof XSDElementDeclaration) {
// clone typedef with it's content and set it global
globalTypeDef = (XSDSimpleTypeDefinition) typeDef.cloneConcreteComponent(true, false);
globalTypeDef.setName(fNewName);
parent.getSchema().getContents().add(globalTypeDef);
((XSDElementDeclaration) parent).setTypeDefinition(globalTypeDef);
formatChild(globalTypeDef.getElement());
} else if (parent instanceof XSDAttributeDeclaration) {
// clone typedef with it's content and set it global
globalTypeDef = (XSDSimpleTypeDefinition) typeDef.cloneConcreteComponent(true, false);
globalTypeDef.setName(fNewName);
parent.getSchema().getContents().add(globalTypeDef);
((XSDAttributeDeclaration) parent).setTypeDefinition((XSDSimpleTypeDefinition) globalTypeDef);
}
}
formatChild(globalTypeDef.getElement());
}
use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.
the class ComplexTypeConfigComposite method refresh.
private void refresh() {
XSDTypeDefinition selectedExtends = getExtends();
radGroupAll.setEnabled(!isExtendsSelected());
radGroupSequence.setEnabled(!isExtendsSelected());
radGroupChoice.setEnabled(!isExtendsSelected());
if (!getDefaultExtends().equals(selectedExtends) && selectedExtends instanceof XSDComplexTypeDefinition && !Util.isAllComplexType((XSDComplexTypeDefinition) selectedExtends)) {
radGroupAll.setSelection(false);
radGroupSequence.setSelection(Util.isSequenceComplexType((XSDComplexTypeDefinition) selectedExtends));
radGroupChoice.setSelection(Util.isChoiceComplexType((XSDComplexTypeDefinition) selectedExtends));
}
comboExtends.getCombo().setEnabled(!isGroupAll());
}
use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.
the class ComplexTypeInputDialog method modifyText.
public void modifyText(ModifyEvent e) {
getButton(IDialogConstants.OK_ID).setEnabled(true);
// $NON-NLS-1$
conceptPanel.setMessage("");
String type = conceptPanel.getText();
if (// $NON-NLS-1$
Pattern.compile("^\\s+\\w+\\s*").matcher(type).matches() || type.trim().replaceAll("\\s", "").length() != type.trim().length()) {
// $NON-NLS-1$//$NON-NLS-2$
conceptPanel.setMessage(Messages._NameWithEmptyCharacters);
getButton(IDialogConstants.OK_ID).setEnabled(false);
return;
}
type = type.trim();
if (!XSDUtil.isValidatedXSDName(type)) {
conceptPanel.setMessage(Messages.InvalidName_Message);
getButton(IDialogConstants.OK_ID).setEnabled(false);
return;
}
for (XSDTypeDefinition specType : xsdSchema.getTypeDefinitions()) {
String typeToCompare = specType.getName();
// $NON-NLS-1$
int delimiter = type.indexOf(" : ");
if (delimiter != -1) {
type = type.substring(0, delimiter);
}
if (typeToCompare.equals(type)) {
if (caller instanceof XSDNewComplexTypeDefinition) {
conceptPanel.setMessage(Messages._SameTypeNameExists);
getButton(IDialogConstants.OK_ID).setEnabled(false);
} else if (caller instanceof XSDChangeToComplexTypeAction && specType instanceof XSDSimpleTypeDefinition) {
conceptPanel.setMessage(Messages._SameTypeNameExists);
getButton(IDialogConstants.OK_ID).setEnabled(false);
}
break;
}
}
}
Aggregations