use of org.eclipse.jface.viewers.ViewerFilter in project linuxtools by eclipse.
the class DockerImagesView method showAllImages.
/**
* Activates {@link HideDanglingImagesFilter} and
* {@link HideIntermediateImagesFilter} if the given {@code enabled}
* argument is <code>false</code>, deactivates the filter otherwise.
*
* @param enabled
* the argument to enable/disable the filter.
*/
public void showAllImages(boolean enabled) {
if (!enabled) {
this.viewer.addFilter(hideDanglingImagesFilter);
this.viewer.addFilter(hideIntermediateImagesFilter);
} else {
final List<ViewerFilter> filters = new ArrayList<>(Arrays.asList(this.viewer.getFilters()));
// filters
for (Iterator<ViewerFilter> iterator = filters.iterator(); iterator.hasNext(); ) {
ViewerFilter viewerFilter = iterator.next();
if (viewerFilter.equals(hideDanglingImagesFilter) || viewerFilter.equals(hideIntermediateImagesFilter)) {
iterator.remove();
}
}
this.viewer.setFilters(filters.toArray(new ViewerFilter[0]));
}
// Save enablement across sessions using a preference variable.
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
preferences.putBoolean(SHOW_ALL_IMAGES_PREFERENCE, enabled);
refreshViewTitle();
}
use of org.eclipse.jface.viewers.ViewerFilter in project knime-core by knime.
the class WorkflowSelectionDialog method createDialogArea.
/**
* {@inheritDoc}
*/
@Override
protected Control createDialogArea(final Composite parent) {
// a tree viewer to select a workflow group or workflow
Group overall = new Group(parent, SWT.SHADOW_ETCHED_IN);
overall.setText("Export selection:");
overall.setLayout(new GridLayout(1, false));
GridData shellLayout = new GridData(GridData.FILL_BOTH);
shellLayout.widthHint = 300;
shellLayout.heightHint = 350;
overall.setLayoutData(shellLayout);
GridData fillBoth = new GridData(GridData.FILL_BOTH);
m_viewer = new TreeViewer(overall, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
m_viewer.getTree().setLayoutData(fillBoth);
m_viewer.setLabelProvider(new KnimeResourceLabelProviderWithRoot());
m_viewer.setContentProvider(new KnimeResourceContentProviderWithRoot());
m_viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
if (element instanceof IWorkspaceRoot) {
return true;
}
IResource resource = null;
if (element instanceof NodeContainer) {
ProjectWorkflowMap.findProjectFor(((NodeContainer) element).getID());
} else if (element instanceof IResource) {
resource = (IResource) element;
}
if (KnimeResourceUtil.isWorkflow(resource)) {
return true;
}
if (KnimeResourceUtil.isWorkflowGroup(resource)) {
return true;
}
return false;
}
});
m_viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
m_viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
m_selectedObjs = (IStructuredSelection) m_viewer.getSelection();
}
});
if (m_initialSelection != null) {
m_viewer.setSelection(m_initialSelection);
}
m_viewer.expandAll();
return overall;
}
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;
}
use of org.eclipse.jface.viewers.ViewerFilter in project ACS by ACS-Community.
the class EventListPart method notifyEventTypeFilterChanged.
/**
* @see alma.acs.eventGui2.parts.IEventListPart#notifyEventTypeFilterChange(java.lang.String)
*/
@Override
public void notifyEventTypeFilterChanged(final String filterText) {
// System.out.println("EventListPart#notifyEventTypeFilterChange : " + filterText);
if (tableFilter != null) {
viewer.removeFilter(tableFilter);
}
tableFilter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (filterText.equals("")) {
return true;
}
EventData row = (EventData) element;
String column = row.getEventTypeName();
if (column.toUpperCase(Locale.ENGLISH).contains(filterText.toUpperCase(Locale.ENGLISH))) {
return true;
}
return false;
}
};
viewer.addFilter(tableFilter);
viewer.refresh();
}
use of org.eclipse.jface.viewers.ViewerFilter in project translationstudio8 by heartsome.
the class ConversionWizardPage method createFilesGroup.
/**
* 创建文件列表区域
* @param contents
* ;
*/
private Composite createFilesGroup(Composite contents) {
Composite filesComposite = new Composite(contents, SWT.NONE);
GridLayout gd = new GridLayout(2, false);
gd.marginWidth = 0;
filesComposite.setLayout(gd);
filesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
filesTable = new Table(filesComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
GridData tableData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL);
tableData.heightHint = 100;
filesTable.setLayoutData(tableData);
filesTable.setLinesVisible(true);
filesTable.setHeaderVisible(true);
filesTable.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
doSelectedEvent();
}
});
tableViewer = new TableViewer(filesTable);
lineNumColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
lineNumColumn.setText(Messages.getString("wizard.ConversionWizardPage.lineNumColumn"));
sourceColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
sourceColumn.setText(Messages.getString("wizard.ConversionWizardPage.sourceColumn"));
formatColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
formatColumn.setText(Messages.getString("wizard.ConversionWizardPage.formatColumn"));
srcEncColumn = new TableViewerColumn(tableViewer, SWT.NONE).getColumn();
srcEncColumn.setText(Messages.getString("wizard.ConversionWizardPage.srcEncColumn"));
IValueProperty[] valueProperties = BeanProperties.values(ConversionConfigBean.class, new String[] { "index", "source", "fileType", "srcEncoding" });
ViewerSupport.bind(tableViewer, new WritableList(conversionConfigBeans, ConversionConfigBean.class), valueProperties);
filesComposite.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent arg0) {
int width = filesTable.getClientArea().width;
lineNumColumn.setWidth(width * 1 / 10);
sourceColumn.setWidth(width * 5 / 10);
formatColumn.setWidth(width * 3 / 10);
srcEncColumn.setWidth(width * 1 / 10);
}
});
Composite opComp = new Composite(filesComposite, SWT.NONE);
GridLayout opCompGl = new GridLayout();
opCompGl.marginWidth = 0;
opCompGl.marginLeft = 0;
opCompGl.marginTop = 0;
opCompGl.marginHeight = 0;
opComp.setLayout(opCompGl);
GridData gd_opComp = new GridData();
gd_opComp.verticalAlignment = SWT.TOP;
opComp.setLayoutData(gd_opComp);
Button addBt = new Button(opComp, SWT.NONE);
addBt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
addBt.setText(Messages.getString("wizard.ConversionWizardPage.addbutton"));
addBt.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileFolderSelectionDialog dialog = new FileFolderSelectionDialog(getShell(), true, IResource.FILE) {
// 打开对话框时展开树形目录
public void create() {
super.create();
super.getTreeViewer().expandAll();
}
};
dialog.setMessage(Messages.getString("wizard.ConversionWizardPage.selectfiledialog.message"));
dialog.setTitle(Messages.getString("wizard.ConversionWizardPage.selectfiledialog.title"));
dialog.setDoubleClickSelects(true);
try {
dialog.setInput(EFS.getStore(ResourcesPlugin.getWorkspace().getRoot().getLocationURI()));
} catch (CoreException e1) {
LOGGER.error("", e1);
e1.printStackTrace();
}
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof LocalFile) {
LocalFile folder = (LocalFile) element;
if (folder.getName().equalsIgnoreCase(".hsConfig") || folder.getName().equalsIgnoreCase(".metadata")) {
return false;
}
String projectPath = currentProject.getLocation().toOSString();
if (projectPath.equals(folder.toString())) {
return true;
}
String xliffFolderPath = folder.toString();
String path1 = projectPath + File.separator + Constant.FOLDER_SRC;
if (xliffFolderPath.startsWith(path1)) {
for (ConversionConfigBean bean : conversionConfigBeans) {
if (xliffFolderPath.indexOf(bean.getSource()) != -1) {
return false;
}
}
return true;
}
}
return false;
}
});
dialog.create();
dialog.open();
if (dialog.getResult() != null) {
Object[] selectFiles = dialog.getResult();
for (Object selectedFile : selectFiles) {
LocalFile folder = (LocalFile) selectedFile;
ConverterViewModel model = new ConverterViewModel(Activator.getContext(), Converter.DIRECTION_POSITIVE);
Object adapter = Platform.getAdapterManager().getAdapter(ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(Path.fromOSString(folder.toString())), IConversionItem.class);
IConversionItem sourceItem = null;
if (adapter instanceof IConversionItem) {
sourceItem = (IConversionItem) adapter;
}
// 记住所选择的文件
model.setConversionItem(sourceItem);
ConversionConfigBean bean = model.getConfigBean();
// 初始化源文件路径
bean.setSource(ResourceUtils.toWorkspacePath(folder.toString()));
// 初始化源语言
bean.setSrcLang(srcLang);
bean.setTgtLangList(targetlanguage);
if (targetlanguage != null && targetlanguage.size() > 0) {
List<Language> lang = new ArrayList<Language>();
lang.add(targetlanguage.get(0));
bean.setHasSelTgtLangList(lang);
}
bean.setReplaceTarget(isReplaceTarget);
bean.setInitSegmenter(srxFile.getText());
conversionConfigBeans.add(bean);
converterViewModels.add(model);
}
loadFiles();
validate();
tableViewer.refresh();
}
}
});
Button removeBt = new Button(opComp, SWT.NONE);
removeBt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
removeBt.setText(Messages.getString("wizard.ConversionWizardPage.removebutton"));
removeBt.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (conversionConfigBeans.size() == 0) {
return;
}
ISelection sel = tableViewer.getSelection();
if (sel.isEmpty()) {
MessageDialog.openError(getShell(), Messages.getString("wizard.ConversionWizardPage.removebutton.msg1.title"), Messages.getString("wizard.ConversionWizardPage.removebutton.msg1"));
return;
}
if (sel instanceof IStructuredSelection) {
IStructuredSelection ssel = (IStructuredSelection) sel;
Object[] objs = ssel.toArray();
int index = conversionConfigBeans.indexOf(ssel.getFirstElement());
index -= ssel.size();
index = index < 0 ? 0 : index;
for (Object obj : objs) {
int i = conversionConfigBeans.indexOf(obj);
conversionConfigBeans.remove(i);
converterViewModels.remove(i);
}
loadFiles();
tableViewer.refresh();
if (!conversionConfigBeans.isEmpty()) {
tableViewer.getTable().select(index);
doSelectedEvent();
}
validate();
}
}
});
return filesComposite;
}
Aggregations