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 ow by vtst.
the class LessProjectPropertyPage method createContents.
@Override
protected Control createContents(Composite parent) {
Composite composite = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH);
Label label = SWTFactory.createLabel(composite, messages.getString("LessProjectPropertyPage_includePaths"), 1);
label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
includePaths.createContents(IContainer.class, composite);
label = SWTFactory.createLabel(composite, messages.getString("LessProjectPropertyPage_roots"), 1);
label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
roots.createContents(IFile.class, composite);
final IContentType lessContentType = Platform.getContentTypeManager().getContentType(LessRuntimeModule.CONTENT_TYPE_ID);
final IProject project = this.getProject();
roots.setAddFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parent, Object element) {
if (element instanceof IProject)
return project.equals(element);
else if (element instanceof IContainer)
return true;
else if (element instanceof IFile) {
IFile file = (IFile) element;
try {
if (file.getContentDescription() == null)
return false;
IContentType fileContentType = file.getContentDescription().getContentType();
if (fileContentType != null && fileContentType.isKindOf(lessContentType))
return true;
} catch (CoreException e) {
}
}
return false;
}
});
try {
includePaths.setCurrentValue(ResourceListProperty.<IContainer>get(IContainer.class, getProject(), new QualifiedName(LessProjectProperty.QUALIFIER, LessProjectProperty.INCLUDE_PATHS)));
roots.setCurrentValue(ResourceListProperty.<IFile>get(IFile.class, getProject(), new QualifiedName(LessProjectProperty.QUALIFIER, LessProjectProperty.ROOTS)));
} catch (CoreException e) {
this.setErrorMessage(e.getMessage());
}
return composite;
}
use of org.eclipse.jface.viewers.ViewerFilter in project bndtools by bndtools.
the class LocalRepositorySelectionPage method createControl.
public void createControl(Composite parent) {
setTitle("Select Local Repository");
setMessage("Bundle will be imported into the selected repository.");
Table table = new Table(parent, SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
final TableViewer viewer = new TableViewer(table);
viewer.setContentProvider(new RepositoryTreeContentProvider());
viewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
viewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return (element instanceof RepositoryPlugin) && ((RepositoryPlugin) element).canWrite();
}
} });
try {
Workspace workspace = Central.getWorkspace();
viewer.setInput(workspace);
if (selectedRepository != null)
viewer.setSelection(new StructuredSelection(selectedRepository));
validate(workspace);
} catch (Exception e) {
logger.logError("Error querying local repositories", e);
setErrorMessage("Error querying local repositories, see log for details.");
}
// LISTENERS
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
}
});
viewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent evt) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
setSelectedRepository((RepositoryPlugin) selection.getFirstElement());
IWizardPage nextPage = getNextPage();
if (nextPage != null)
getContainer().showPage(nextPage);
}
});
setControl(table);
}
use of org.eclipse.jface.viewers.ViewerFilter in project bndtools by bndtools.
the class MapValuesContentProvider method createAvailableBundlesPanel.
Control createAvailableBundlesPanel(Composite parent) {
Composite panel = new Composite(parent, SWT.NONE);
new Label(panel, SWT.NONE).setText("Available Bundles:");
selectionSearchTxt = new Text(panel, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL);
selectionSearchTxt.setMessage("filter bundle name");
final Tree availableTree = new Tree(panel, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
availableViewer = new TreeViewer(availableTree);
availableViewer.setLabelProvider(new RepositoryTreeLabelProvider(false));
availableViewer.setContentProvider(new RepositoryTreeContentProvider());
availableViewer.setAutoExpandLevel(2);
availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
// Load data
try {
refreshBundleList();
} catch (Exception e) {
setErrorMessage("Error querying repositories: " + e.getMessage());
logger.logError("Error querying repository configuration.", e);
}
// Listeners
selectionSearchTxt.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ARROW_DOWN)
availableTree.setFocus();
}
});
selectionSearchTxt.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
availableViewer.setFilters(new ViewerFilter[] { alreadySelectedFilter });
}
});
availableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
// Enable add button when a bundle or bundle version is selected on
// the left
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) availableViewer.getSelection();
for (Iterator<?> iter = sel.iterator(); iter.hasNext(); ) {
Object element = iter.next();
if (element instanceof RepositoryBundle || element instanceof RepositoryBundleVersion || element instanceof ProjectBundle) {
addButton.setEnabled(true);
return;
}
}
addButton.setEnabled(false);
}
});
availableViewer.addOpenListener(new IOpenListener() {
@Override
public void open(OpenEvent event) {
doAdd();
}
});
GridLayout layout;
GridData gd;
layout = new GridLayout(1, false);
panel.setLayout(layout);
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
selectionSearchTxt.setLayoutData(gd);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.heightHint = 300;
gd.widthHint = 250;
availableTree.setLayoutData(gd);
return panel;
}
use of org.eclipse.jface.viewers.ViewerFilter in project dbeaver by serge-rider.
the class AttributeEditPage method createPageContents.
@Override
protected Control createPageContents(Composite parent) {
Composite propsGroup = new Composite(parent, SWT.NONE);
propsGroup.setLayout(new GridLayout(2, false));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
propsGroup.setLayoutData(gd);
//$NON-NLS-2$
final Text nameText = UIUtils.createLabelText(propsGroup, "Name", attribute.getName());
nameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (attribute instanceof DBPNamedObject2) {
((DBPNamedObject2) attribute).setName(nameText.getText());
}
}
});
UIUtils.createControlLabel(propsGroup, "Properties").setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
final PropertyTreeViewer propertyViewer = new PropertyTreeViewer(propsGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
propertyViewer.getControl().setLayoutData(gd);
propertyViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return true;
}
});
PropertySourceAbstract pc = new PropertySourceEditable(commandContext, attribute, attribute) {
@Override
public void setPropertyValue(@Nullable DBRProgressMonitor monitor, Object editableValue, ObjectPropertyDescriptor prop, Object newValue) throws IllegalArgumentException {
super.setPropertyValue(monitor, editableValue, prop, newValue);
/*
if (prop.getId().equals("dataType")) {
newValue = getPropertyValue(monitor, editableValue, prop);
if (newValue instanceof DBSDataType) {
DBPPropertyDescriptor lengthProp = getProperty("maxLength");
if (lengthProp instanceof ObjectPropertyDescriptor) {
DBPDataKind dataKind = ((DBSDataType) newValue).getDataKind();
if (dataKind == DBPDataKind.STRING) {
setPropertyValue(monitor, editableValue, (ObjectPropertyDescriptor) lengthProp, 100);
} else {
setPropertyValue(monitor, editableValue, (ObjectPropertyDescriptor) lengthProp, null);
}
propertyViewer.update(lengthProp, null);
}
}
}
*/
}
};
pc.collectProperties();
for (DBPPropertyDescriptor prop : pc.getProperties()) {
if (prop instanceof ObjectPropertyDescriptor) {
if (((ObjectPropertyDescriptor) prop).isEditPossible() && !((ObjectPropertyDescriptor) prop).isNameProperty()) {
continue;
}
}
pc.removeProperty(prop);
}
propertyViewer.loadProperties(pc);
return propsGroup;
}
Aggregations