use of org.eclipse.jface.viewers.ViewerFilter in project tdi-studio-se by Talend.
the class PerlScdDialog method createScdContents.
/**
* DOC hcw Comment method "createContents".
*
* @param composite
*/
@Override
Control createScdContents(Composite parent) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(true).spacing(20, 10).applyTo(composite);
GridDataFactory.fillDefaults().applyTo(composite);
Composite filterUnusedComposite = new Composite(composite, SWT.NONE);
GridLayoutFactory.swtDefaults().margins(0, 0).spacing(0, 0).applyTo(filterUnusedComposite);
GridDataFactory.swtDefaults().grab(true, true).applyTo(filterUnusedComposite);
ViewerFilter filter = createFilter(filterUnusedComposite);
unusedFields = new FieldSection(filterUnusedComposite, scdManager, false, false);
//$NON-NLS-1$
unusedFields.setTitle("Unused", SWTResourceManager.getColor(198, 195, 198));
unusedFields.setTableInput(scdManager.getUnusedFields());
unusedFields.getTableViewer().addFilter(filter);
GridDataFactory.swtDefaults().grab(true, true).applyTo(unusedFields.getControl());
//$NON-NLS-1$
addContextHelp(unusedFields.getTableViewer().getTable(), "org.talend.designer.scd.unused");
type1Fields = new FieldSection(composite, scdManager, false, false);
//$NON-NLS-1$
type1Fields.setTitle("Type 1 fields", SWTResourceManager.getColor(255, 203, 0));
GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(type1Fields.getControl());
type1Fields.setTableInput(scdManager.getType1Table());
//$NON-NLS-1$
addContextHelp(type1Fields.getTableViewer().getTable(), "org.talend.designer.scd.type1");
sourceKeys = new FieldSection(composite, scdManager, false, false);
//$NON-NLS-1$
sourceKeys.setTitle(Messages.getString("PerlScdDialog.sourceKey"), SWTResourceManager.getColor(156, 0, 255));
GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(sourceKeys.getControl());
sourceKeys.setTableInput(scdManager.getSourceKeys());
//$NON-NLS-1$
addContextHelp(sourceKeys.getTableViewer().getTable(), "org.talend.designer.scd.sourceKey");
type2Fields = new Type2Section(composite, scdManager);
//$NON-NLS-1$
type2Fields.setTitle(Messages.getString("PerlScdDialog.typeField"), SWTResourceManager.getColor(255, 255, 0));
GridDataFactory.swtDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(type2Fields.getControl());
type2Fields.setTableInput(scdManager.getType2Table());
type2Fields.setSupportCreationType(false);
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");
scdManager.setUnusedFieldsSource(unusedFields);
ScdSection[] sections = { sourceKeys, type1Fields, type2Fields };
for (ScdSection scd : sections) {
scdManager.addUnusedFieldsTarget(scd);
}
return composite;
}
use of org.eclipse.jface.viewers.ViewerFilter in project tdi-studio-se by Talend.
the class DatabaseTypeFilter method createDialogArea.
protected Control createDialogArea(Composite parent, String specifiedPId) {
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);
createFilterField(container);
Composite viewContainer = new Composite(container, SWT.BORDER);
viewContainer.setLayout(new GridLayout());
viewContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
repositoryTreeViewer = RepoCommonViewerProvider.NORMAL.createViewer(viewContainer, specifiedPId);
//$NON-NLS-1$
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed createViewer");
repositoryTreeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
addFilter(textFilter);
if (dbSupportFilter != null) {
addFilter(dbSupportFilter);
}
if (additionalFilters != null) {
addFilter(additionalFilters);
}
ViewerFilter filter = typeProcessor.makeFilter();
addFilter(filter);
//$NON-NLS-1$
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finshed add Filters");
//$NON-NLS-1$
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "set input");
repositoryTreeViewer.expandToLevel(2);
//$NON-NLS-1$
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "expandAll");
final Label label = new Label(container, SWT.NONE);
//$NON-NLS-1$
label.setText(Messages.getString("RepositoryReviewDialog.label"));
label.setForeground(new Color(null, 250, 0, 0));
label.setVisible(false);
// see feature 0003664: tRunJob: When opening the tree dialog to select the job target, it could be useful to
// open it on previous selected job if exists
selectNode();
//$NON-NLS-1$
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "selectNode");
repositoryTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
boolean highlightOKButton = isSelectionValid(event);
getButton(IDialogConstants.OK_ID).setEnabled(highlightOKButton);
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection != null && !selection.isEmpty()) {
RepositoryNode node = (RepositoryNode) selection.getFirstElement();
if (!highlightOKButton && node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObjectType().equals(ERepositoryObjectType.METADATA_VALIDATION_RULES)) {
label.setVisible(true);
} else {
label.setVisible(false);
}
}
}
});
repositoryTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
if (getButton(IDialogConstants.OK_ID).isEnabled()) {
okPressed();
}
}
});
//$NON-NLS-1$
TimeMeasure.step(RepositoryReviewDialog.class.getSimpleName(), "finished createDialogArea...");
TimeMeasure.end(RepositoryReviewDialog.class.getSimpleName());
TimeMeasure.display = false;
TimeMeasure.displaySteps = false;
TimeMeasure.measureActive = false;
return container;
}
use of org.eclipse.jface.viewers.ViewerFilter in project dbeaver by serge-rider.
the class CheckboxTreeManager method collectChildren.
private boolean collectChildren(DBRProgressMonitor monitor, final Object element, List<DBNDatabaseNode> targetChildren, List<DBNDatabaseNode> targetContainers, boolean onlyChecked) throws DBException {
if (element instanceof DBNDatabaseNode) {
for (ViewerFilter filter : filters) {
if (!filter.select(viewer, ((DBNDatabaseNode) element).getParentNode(), element)) {
return false;
}
}
boolean isChecked = ArrayUtils.contains(checkedElements, element);
for (Class<?> type : targetTypes) {
if (type.isInstance(((DBNDatabaseNode) element).getObject())) {
if (!onlyChecked || isChecked) {
targetChildren.add((DBNDatabaseNode) element);
}
return true;
}
}
((DBNDatabaseNode) element).initializeNode(monitor, null);
DBNDatabaseNode[] children = ((DBNDatabaseNode) element).getChildren(monitor);
if (!ArrayUtils.isEmpty(children)) {
boolean foundChild = false;
for (DBNDatabaseNode child : children) {
if (collectChildren(monitor, child, targetChildren, targetContainers, onlyChecked)) {
foundChild = true;
}
}
if (foundChild) {
if (!onlyChecked || isChecked) {
targetContainers.add((DBNDatabaseNode) element);
}
}
return foundChild;
}
}
return false;
}
use of org.eclipse.jface.viewers.ViewerFilter in project translationstudio8 by heartsome.
the class ElementTreeSelectionDialog method evaluateIfTreeEmpty.
private boolean evaluateIfTreeEmpty(Object input) {
Object[] elements = fContentProvider.getElements(input);
if (elements.length > 0) {
if (fFilters != null) {
for (int i = 0; i < fFilters.size(); i++) {
ViewerFilter curr = (ViewerFilter) fFilters.get(i);
elements = curr.filter(fViewer, input, elements);
}
}
}
return elements.length == 0;
}
use of org.eclipse.jface.viewers.ViewerFilter in project translationstudio8 by heartsome.
the class WorkingSetActionProvider method setWorkingSetFilter.
private void setWorkingSetFilter(IWorkingSet workingSet, boolean firstTime) {
ResourceWorkingSetFilter workingSetFilter = null;
ViewerFilter[] filters = viewer.getFilters();
for (int i = 0; i < filters.length; i++) {
if (filters[i] instanceof ResourceWorkingSetFilter) {
workingSetFilter = (ResourceWorkingSetFilter) filters[i];
break;
}
}
if (workingSetFilter == null) {
if (firstTime) {
filterService.addActiveFilterIds(new String[] { WORKING_SET_FILTER_ID });
filterService.updateViewer();
setWorkingSetFilter(workingSet, !FIRST_TIME);
return;
}
WorkbenchNavigatorPlugin.log(//$NON-NLS-1$
"Required filter " + WORKING_SET_FILTER_ID + //$NON-NLS-1$
" is not present. Working set support will not function correctly.", //$NON-NLS-1$
new Status(IStatus.ERROR, WorkbenchNavigatorPlugin.PLUGIN_ID, ""));
return;
}
workingSetFilter.setWorkingSet(emptyWorkingSet ? null : workingSet);
}
Aggregations