use of com.amalto.workbench.providers.ServerTreeContentProvider in project tmdm-studio-se by Talend.
the class DataModelSelectDialog method changeToResource.
private void changeToResource() {
TreeParent parent = null;
// Modified by hbhong,to fix bug 21784
TreeObject[] children = treeParent.getChildren();
for (TreeObject element : children) {
parent = (TreeParent) element;
if (parent.getType() == TreeObject.DATA_MODEL) {
break;
}
}
// The ending| bug:21784
contentProvider = new ServerTreeContentProvider(site, parent);
setTreeContentProvider(contentProvider);
domViewer.setLabelProvider(new ServerTreeLabelProvider());
domViewer.setSorter(new ViewerSorter() {
@Override
public int category(Object element) {
if (element instanceof TreeParent) {
TreeParent category = (TreeParent) element;
if (category.getType() == TreeObject.CATEGORY_FOLDER) {
return -1;
}
}
return 0;
}
});
domViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent e) {
StructuredSelection sel = (StructuredSelection) e.getSelection();
List<String> xpathList = new ArrayList<String>();
Object[] selections = sel.toArray();
for (Object obj : selections) {
TreeObject treeObj = (TreeObject) obj;
if (treeObj != null && treeObj.getType() == TreeObject.DATA_MODEL) {
xpathList.add(treeObj.getDisplayName());
}
}
xpaths = xpathList.toArray(new String[0]);
if (getButton(IDialogConstants.OK_ID) != null) {
getButton(IDialogConstants.OK_ID).setEnabled(xpathList.size() > 0);
}
}
});
domViewer.setInput(site);
}
Aggregations