use of org.talend.core.ui.advanced.composite.FilteredCheckboxTree in project tdi-studio-se by Talend.
the class ExportItemWizardPage method createTreeViewer.
private void createTreeViewer(Composite itemComposite) {
filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI) {
@Override
protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
RepoCommonViewerProvider provider = RepoCommonViewerProvider.CHECKBOX;
if (baseViewId != null) {
provider.setViewId(baseViewId);
}
CheckboxTreeViewer viwer = (CheckboxTreeViewer) provider.createViewer(parent);
// FIXME this is temp fix for 5.4.2
INavigatorContentService navigatorContentService = ((INavigatorContentServiceProvider) viwer).getNavigatorContentService();
if (navigatorContentService != null) {
IExtensionStateModel findStateModel = navigatorContentService.findStateModel(//$NON-NLS-1$
"com.oaklandsw.transform.navigatorContent");
if (findStateModel != null) {
//$NON-NLS-1$
findStateModel.setBooleanProperty("org.talend.repository.ui.actions.importexport", true);
}
}
return viwer;
}
@Override
protected void refreshCompleted() {
getViewer().expandToLevel(3);
restoreCheckedElements();
}
@Override
protected boolean isNodeCollectable(TreeItem item) {
Object obj = item.getData();
if (obj instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) obj;
if (node.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
return true;
}
}
return false;
}
};
filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
boolean select = true;
if (element instanceof RepositoryNode) {
select = selectRepositoryNode(viewer, (RepositoryNode) element);
}
if (select) {
for (IRepositoryReviewFilter nodeHandler : RepositoryContentManager.getRepositoryReviewFilters()) {
//$NON-NLS-1$
boolean exportFilter = nodeHandler.filter(viewer, parentElement, element, "repository_review");
if (!exportFilter) {
return exportFilter;
}
}
}
return select;
}
});
}
use of org.talend.core.ui.advanced.composite.FilteredCheckboxTree in project tdi-studio-se by Talend.
the class ImportItemWizardPage method createTreeViewer.
private TreeViewer createTreeViewer(Composite listComposite) {
filteredCheckboxTree = new FilteredCheckboxTree(listComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
CheckboxTreeViewer viewer = filteredCheckboxTree.getViewer();
viewer.setContentProvider(new ITreeContentProvider() {
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IContainerNode) {
return ((IContainerNode) parentElement).getChildren().toArray();
}
return null;
}
@Override
public Object[] getElements(Object inputElement) {
// return getValidItems();
return repositoryUtil.getTreeViewInput().toArray();
}
@Override
public boolean hasChildren(Object element) {
if (element instanceof IContainerNode) {
return ((IContainerNode) element).hasChildren();
}
return false;
}
@Override
public Object getParent(Object element) {
return null;
}
@Override
public void dispose() {
}
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
});
viewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
if (element instanceof IContainerNode) {
if (element instanceof ProjectNode) {
Project project = ((ProjectNode) element).getProject();
return ProjectManager.getProjectDisplayLabel(project);
}
return ((IContainerNode) element).getLabel();
} else if (element instanceof ItemRecord) {
return ((ItemRecord) element).getLabel();
}
return super.getText(element);
}
@Override
public Image getImage(Object element) {
if (element instanceof IContainerNode) {
return ((IContainerNode) element).getImage();
} else if (element instanceof ItemRecord) {
return ((ItemRecord) element).getImage();
}
return super.getImage(element);
}
});
viewer.setSorter(TreeBuilder.createSorter());
viewer.setInput(this);
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
filteredCheckboxTree.calculateCheckedLeafNodes();
updateFinishStatus();
}
});
filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return selectRepositoryNode(viewer, element);
}
});
return viewer;
}
use of org.talend.core.ui.advanced.composite.FilteredCheckboxTree in project tdi-studio-se by Talend.
the class UseDynamicJobSelectionDialog method createTreeViewer.
private void createTreeViewer(Composite itemComposite) {
filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI) {
@Override
protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
return (CheckboxTreeViewer) RepoCommonViewerProvider.CHECKBOX.createViewer(parent);
}
@Override
protected void refreshCompleted() {
restoreCheckedElements();
}
};
CheckboxTreeViewer viewer = filteredCheckboxTree.getViewer();
viewer.setComparer(new IElementComparer() {
private String getElementUniqueString(Object element) {
if (element instanceof RepositoryNode && getSupportType() != null && getSupportType().equals(((RepositoryNode) element).getContentType())) {
final RepositoryNode node = (RepositoryNode) element;
StringBuffer sb = new StringBuffer();
boolean validElem = false;
ENodeType type = node.getType();
if (ENodeType.REPOSITORY_ELEMENT.equals(type)) {
sb.append(node.getId());
validElem = true;
} else if (ENodeType.SIMPLE_FOLDER.equals(type)) {
final IRepositoryViewObject object = node.getObject();
// path
if (object instanceof Folder) {
sb.append(((Folder) object).getPath());
sb.append('/');
}
sb.append(node.getLabel());
validElem = true;
}
if (validElem) {
sb.append('|');
// add project
if (node.getRoot() != null && node.getRoot().getProject() != null) {
sb.append(node.getRoot().getProject().getTechnicalLabel());
}
sb.append('|');
sb.append(node.getContentType().getType());
sb.append('|');
sb.append(type);
return sb.toString();
}
}
return null;
}
@Override
public int hashCode(Object element) {
final String elementUniqueString = getElementUniqueString(element);
if (elementUniqueString != null) {
return elementUniqueString.hashCode();
}
return element.hashCode();
}
@Override
public boolean equals(Object a, Object b) {
String aStr = getElementUniqueString(a);
String bStr = getElementUniqueString(b);
return aStr != null && bStr != null ? aStr.equals(bStr) : a.equals(b);
}
});
viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
RepositoryNode node = (RepositoryNode) element;
return filterRepositoryNode(node);
}
});
}
use of org.talend.core.ui.advanced.composite.FilteredCheckboxTree in project tdi-studio-se by Talend.
the class ExportTreeViewer method createTreeViewer.
private void createTreeViewer(Composite itemComposite) {
filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI) {
@Override
protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
RepositoryViewerProvider provider = new RepositoryViewerProvider() {
@Override
protected ERepositoryObjectType getCheckingType() {
return ExportTreeViewer.this.getCheckingType();
}
};
return (CheckboxTreeViewer) provider.createViewer(parent);
}
@Override
protected void refreshCompleted() {
getViewer().expandToLevel(3);
restoreCheckedElements();
}
@Override
protected boolean isNodeCollectable(TreeItem item) {
Object obj = item.getData();
if (obj instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) obj;
if (node.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
return true;
}
}
return false;
}
};
getExportItemsTreeViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
RepositoryNode node = (RepositoryNode) element;
return filterRepositoryNode(node);
}
});
}
Aggregations