use of com.amalto.workbench.providers.XPathTreeContentProvider in project tmdm-studio-se by Talend.
the class XpathSelectDialog method provideViwerContent.
// changeDomTree(
protected void provideViwerContent(XSDSchema xsdSchema, String filter) {
drillDownAdapter = new DrillDownAdapter(domViewer);
domViewer.setLabelProvider(new XSDTreeLabelProvider(selectionFilter));
XPathTreeContentProvider provider = new XPathTreeContentProvider(this.site, xsdSchema, parent, filter);
// filter the entity with the filter text but not the concept name.
// provider.setConceptName(this.conceptName);
domViewer.setContentProvider(provider);
domViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent e) {
StructuredSelection sel = (StructuredSelection) e.getSelection();
xpath = getXpath(sel);
xpathText.setText(xpath);
boolean enable = false;
if (selectionFilter == null) {
enable = xpath.length() > 0;
} else {
enable = xpath.length() > 0 && (selectionFilter.check(sel.getFirstElement()) == FilterResult.ENABLE);
}
getButton(IDialogConstants.OK_ID).setEnabled(enable);
}
});
domViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
domViewer.setSorter(new ViewerSorter() {
@Override
public int category(Object element) {
// SimpleTypeDefinition
if (element instanceof XSDFacet) {
return 100;
}
// unique keys after element declarations and before other keys
if (element instanceof XSDIdentityConstraintDefinition) {
XSDIdentityConstraintDefinition icd = (XSDIdentityConstraintDefinition) element;
if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.UNIQUE_LITERAL)) {
return 300;
} else if (icd.getIdentityConstraintCategory().equals(XSDIdentityConstraintCategory.KEY_LITERAL)) {
return 301;
} else {
return 302;
}
}
return 200;
}
@Override
public int compare(Viewer theViewer, Object e1, Object e2) {
int cat1 = category(e1);
int cat2 = category(e2);
return cat1 - cat2;
}
});
domViewer.setInput(site);
}
Aggregations