use of org.eclipse.jface.viewers.ViewerFilter 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.eclipse.jface.viewers.ViewerFilter in project tdi-studio-se by Talend.
the class JavaScdDialog method createScdContents.
/**
* DOC hcw Comment method "createContents".
*
* @param composite
*/
@Override
Control createScdContents(Composite parent) {
SashForm sashForm = new SashForm(parent, SWT.VERTICAL | SWT.SMOOTH);
GridDataFactory.fillDefaults().grab(true, true).applyTo(sashForm);
sashForm.setLayout(new GridLayout(1, true));
sashForm.SASH_WIDTH = 1;
Composite sashPart1 = new Composite(sashForm, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).spacing(20, 10).applyTo(sashPart1);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sashPart1);
Composite filterUnusedComposite = new Composite(sashPart1, SWT.NONE);
GridLayoutFactory.swtDefaults().margins(0, 0).spacing(0, 0).applyTo(filterUnusedComposite);
GridDataFactory.fillDefaults().span(1, 2).grab(true, true).applyTo(filterUnusedComposite);
ViewerFilter filter = createFilter(filterUnusedComposite);
unusedFields = new FieldSection(filterUnusedComposite, scdManager, false, false);
unusedFields.setTitle(Messages.getString("JavaScdDialog.unUsed"), //$NON-NLS-1$
SWTResourceManager.getColor(//$NON-NLS-1$
198, //$NON-NLS-1$
195, 198));
unusedFields.setTableInput(scdManager.getUnusedFields());
unusedFields.getTableViewer().addFilter(filter);
unusedFields.setSortable(true);
GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(unusedFields.getControl());
//$NON-NLS-1$
addContextHelp(unusedFields.getTableViewer().getTable(), "org.talend.designer.scd.unused");
type0Fields = new FieldSection(sashPart1, scdManager, false, false);
type0Fields.setTitle(Messages.getString("JavaScdDialog.type0Field"), //$NON-NLS-1$
SWTResourceManager.getColor(//$NON-NLS-1$
255, 146, 0));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(type0Fields.getControl());
GridData fieldsData = new GridData(GridData.FILL_BOTH);
fieldsData.heightHint = 100;
type0Fields.getControl().setLayoutData(fieldsData);
type0Fields.setTableInput(scdManager.getType0Table());
//$NON-NLS-1$
addContextHelp(type0Fields.getTableViewer().getTable(), "org.talend.designer.scd.type0");
type1Fields = new FieldSection(sashPart1, scdManager, false, false, ScdParameterConstants.DROP_COPY_TYPE1FIELDS);
type1Fields.setTitle(Messages.getString("JavaScdDialog.type1Field"), //$NON-NLS-1$
SWTResourceManager.getColor(//$NON-NLS-1$
255, 203, 0));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(type1Fields.getControl());
type1Fields.getControl().setLayoutData(fieldsData);
type1Fields.setTableInput(scdManager.getType1Table());
//$NON-NLS-1$
addContextHelp(type1Fields.getTableViewer().getTable(), "org.talend.designer.scd.type1");
Composite sashPart2 = new Composite(sashForm, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).spacing(20, 10).applyTo(sashPart2);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sashPart2);
sourceKeys = new FieldSection(sashPart2, scdManager, false, false, ScdParameterConstants.DROP_COPY_SOURCEKEYS);
sourceKeys.setTitle(Messages.getString("JavaScdDialog.sourceKey"), //$NON-NLS-1$
SWTResourceManager.getColor(//$NON-NLS-1$
156, //$NON-NLS-1$
0, 255));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sourceKeys.getControl());
sourceKeys.setTableInput(scdManager.getSourceKeys());
//$NON-NLS-1$
addContextHelp(sourceKeys.getTableViewer().getTable(), "org.talend.designer.scd.sourceKey");
type2Fields = new Type2Section(sashPart2, scdManager, ScdParameterConstants.DROP_COPY_TYPE2FIELDS);
type2Fields.setTitle(Messages.getString("JavaScdDialog.type2Field"), //$NON-NLS-1$
SWTResourceManager.getColor(//$NON-NLS-1$
255, 255, 0));
GridDataFactory.swtDefaults().span(1, 2).align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(type2Fields.getControl());
type2Fields.setTableInput(scdManager.getType2Table());
if (scdManager.getVersionData() != null) {
type2Fields.setVersionInput(scdManager.getVersionData());
} else {
type2Fields.setVersionInput(new Versioning());
}
//$NON-NLS-1$
addContextHelp(type2Fields.getTableViewer().getTable(), "org.talend.designer.scd.type2");
surrogateKeys = new SurrogateSection(sashPart2, scdManager);
surrogateKeys.setTitle(Messages.getString("JavaScdDialog.surrogateKey"), //$NON-NLS-1$
SWTResourceManager.getColor(214, 40, 255));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(surrogateKeys.getControl());
surrogateKeys.setTableInput(scdManager.getSurrogateKeys());
surrogateKeys.addContextHelp(this);
Composite sashPart3 = new Composite(sashForm, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).spacing(20, 10).applyTo(sashPart3);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(sashPart3);
Label placeHolder = new Label(sashPart3, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(placeHolder);
type3Fields = new Type3Section(sashPart3, scdManager);
type3Fields.setTitle(Messages.getString("JavaScdDialog.type3Key"), //$NON-NLS-1$
SWTResourceManager.getColor(//$NON-NLS-1$
24, 182, 255));
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(type3Fields.getControl());
type3Fields.setTableInput(scdManager.getType3Table());
//$NON-NLS-1$
addContextHelp(type3Fields.getTable(), "org.talend.designer.scd.type3");
scdManager.setUnusedFieldsSource(unusedFields);
ScdSection[] sections = { surrogateKeys, sourceKeys, type0Fields, type1Fields, type2Fields, type3Fields };
for (ScdSection scd : sections) {
scdManager.addUnusedFieldsTarget(scd);
}
sashForm.setSashWidth(3);
// the following codes are used to adjust the heights
int totalHeight = getDialogSize().y;
sashForm.setWeights(new int[] { totalHeight / 4, totalHeight / 2, totalHeight / 4 });
return sashForm;
}
use of org.eclipse.jface.viewers.ViewerFilter 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.eclipse.jface.viewers.ViewerFilter 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.eclipse.jface.viewers.ViewerFilter in project tdi-studio-se by Talend.
the class ExtendedNodeReviewDialog method createDialogArea.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
//$NON-NLS-1$
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "before createDialogArea...");
GridData data = (GridData) container.getLayoutData();
data.minimumHeight = 400;
data.heightHint = 400;
data.minimumWidth = 500;
data.widthHint = 500;
container.setLayoutData(data);
textFilter = new ViewerTextFilter();
createFilterField(container);
treeViewer = provider.createViewer(container);
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
getButton(IDialogConstants.OK_ID).setEnabled(isValidSelection(event));
}
});
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
if (getButton(IDialogConstants.OK_ID).isEnabled()) {
okPressed();
}
}
});
treeViewer.addFilter(textFilter);
treeViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return filterByType(viewer, parentElement, element);
}
});
return container;
}
Aggregations