use of org.eclipse.xsd.XSDNamedComponent in project webtools.sourceediting by eclipse.
the class FindReferencesInProjectAction method run.
public void run() {
String pattern = "";
XSDNamedComponent component = getXSDNamedComponent();
IFile file = getCurrentFile();
if (file != null && component != null) {
QualifiedName metaName = determineMetaName(component);
QualifiedName elementQName = new QualifiedName(component.getTargetNamespace(), component.getName());
IPath fullPath = file.getFullPath();
ProjectSearchScope scope = new ProjectSearchScope(fullPath);
String scopeDescription = "Project";
XSDSearchQuery searchQuery = new XSDSearchQuery(pattern, file, elementQName, metaName, XSDSearchQuery.LIMIT_TO_REFERENCES, scope, scopeDescription);
NewSearchUI.activateSearchResultView();
NewSearchUI.runQueryInBackground(searchQuery);
}
}
use of org.eclipse.xsd.XSDNamedComponent in project tmdm-studio-se by Talend.
the class XpathComposite method getItems.
protected String[] getItems() {
Set<String> entities = section.getEntities();
if (null != entities) {
XSDSchema schema = getDatamodelXSD();
Object[] child = getXSDSchemaChildren(schema);
List<String> items = new LinkedList<String>();
for (Object obj : child) {
if (obj instanceof XSDNamedComponent) {
if (entities.contains(((XSDNamedComponent) obj).getName())) {
XSDComponentChildElementsHolder holder = new XSDComponentChildElementsHolder((XSDNamedComponent) obj);
String[] eles = holder.getAllElements();
if (null == eles) {
continue;
}
for (String ele : eles) {
items.add(ele);
}
}
}
}
return items.toArray(new String[0]);
}
return null;
}
use of org.eclipse.xsd.XSDNamedComponent in project tmdm-studio-se by Talend.
the class XpathComposite method getXSDSchemaChildren.
Object[] getXSDSchemaChildren(XSDSchema schema) {
List<XSDElementDeclaration> declarations = new ArrayList<XSDElementDeclaration>();
EList<XSDElementDeclaration> elementDeclarations = schema.getElementDeclarations();
for (XSDElementDeclaration declaration : elementDeclarations) {
if (declaration.eContainer().equals(schema)) {
declarations.add(declaration);
}
}
Object[] schemaChildren = Util.filterOutDuplicatedElems(declarations.toArray(new XSDNamedComponent[declarations.size()]));
return schemaChildren;
}
use of org.eclipse.xsd.XSDNamedComponent in project tmdm-studio-se by Talend.
the class UtilTest method testFilterOutDuplicatedElems.
@Test
public void testFilterOutDuplicatedElems() {
// $NON-NLS-1$
String simpletypeName = "simpletype";
// $NON-NLS-1$
String complextypeName = "complextype";
// $NON-NLS-1$
String concepName = "concept";
// $NON-NLS-1$
String idconstraintName = "identityconstraint";
// $NON-NLS-1$
String modelgroupName = "modelgroup";
XSDFactory factory = XSDFactory.eINSTANCE;
XSDSimpleTypeDefinition simpleTypeDefinition = factory.createXSDSimpleTypeDefinition();
XSDComplexTypeDefinition complexTypeDefinition = factory.createXSDComplexTypeDefinition();
XSDElementDeclaration elementDeclaration = factory.createXSDElementDeclaration();
XSDIdentityConstraintDefinition identityConstraintDefinition = factory.createXSDIdentityConstraintDefinition();
XSDModelGroupDefinition modelGroupDefinition = factory.createXSDModelGroupDefinition();
simpleTypeDefinition.setName(simpletypeName);
complexTypeDefinition.setName(complextypeName);
elementDeclaration.setName(concepName);
identityConstraintDefinition.setName(idconstraintName);
modelGroupDefinition.setName(modelgroupName);
XSDNamedComponent[] checkedElements = { simpleTypeDefinition, complexTypeDefinition, elementDeclaration, identityConstraintDefinition, modelGroupDefinition };
Object[] duplicatedElems = Util.filterOutDuplicatedElems(checkedElements);
List<XSDNamedComponent> allElements = Arrays.asList(checkedElements);
assertNotNull(duplicatedElems);
assertTrue(checkedElements.length == duplicatedElems.length);
for (int i = 0; i < duplicatedElems.length; i++) {
assertTrue(allElements.contains(duplicatedElems[i]));
}
//
XSDSimpleTypeDefinition simpleTypeDefinition2 = factory.createXSDSimpleTypeDefinition();
XSDComplexTypeDefinition complexTypeDefinition2 = factory.createXSDComplexTypeDefinition();
XSDElementDeclaration elementDeclaration2 = factory.createXSDElementDeclaration();
XSDIdentityConstraintDefinition identityConstraintDefinition2 = factory.createXSDIdentityConstraintDefinition();
XSDModelGroupDefinition modelGroupDefinition2 = factory.createXSDModelGroupDefinition();
simpleTypeDefinition2.setName(simpletypeName);
complexTypeDefinition2.setName(complextypeName);
elementDeclaration2.setName(concepName);
identityConstraintDefinition2.setName(idconstraintName);
modelGroupDefinition2.setName(modelgroupName);
XSDNamedComponent[] checkedElements2 = { simpleTypeDefinition, complexTypeDefinition, elementDeclaration, identityConstraintDefinition, modelGroupDefinition, simpleTypeDefinition2, complexTypeDefinition2, elementDeclaration2, identityConstraintDefinition2, modelGroupDefinition2 };
duplicatedElems = Util.filterOutDuplicatedElems(checkedElements2);
assertNotNull(duplicatedElems);
assertTrue(checkedElements.length == duplicatedElems.length);
for (int i = 0; i < duplicatedElems.length; i++) {
assertTrue(allElements.contains(duplicatedElems[i]));
}
}
use of org.eclipse.xsd.XSDNamedComponent in project webtools.sourceediting by eclipse.
the class BaseFieldEditPart method doEditName.
public void doEditName(boolean addFromDesign) {
if (!addFromDesign)
return;
// removeFeedback();
Runnable runnable = new Runnable() {
public void run() {
Object object = ((XSDBaseAdapter) getModel()).getTarget();
if (object instanceof XSDNamedComponent) {
Point p = getNameLabelFigure().getLocation();
LabelEditManager manager = new LabelEditManager(BaseFieldEditPart.this, new LabelCellEditorLocator(BaseFieldEditPart.this, p));
NameUpdateCommandWrapper wrapper = new NameUpdateCommandWrapper();
adtDirectEditPolicy.setUpdateCommand(wrapper);
manager.show();
}
}
};
Display.getCurrent().asyncExec(runnable);
}
Aggregations