Example usage for org.eclipse.jface.viewers IFilter IFilter

List of usage examples for org.eclipse.jface.viewers IFilter IFilter

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers IFilter IFilter.

Prototype

IFilter

Source Link

Usage

From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.SourcesTreeHandler.java

License:Open Source License

@Override
protected void checkStateChanged(Object element, final boolean checked) {
    final List<IPath> modelSources = editorContext.mmpView.getSources();
    List<IPath> list = new ArrayList<IPath>();
    if (element instanceof IFile) {
        IFile file = (IFile) element;//from  www .j  a v  a  2  s  . c om
        IPath filePath = file.getProjectRelativePath();
        try {
            filePath = editorContext.pathHelper.convertProjectOrFullPathToMMP(EMMPPathContext.SOURCE, filePath);
        } catch (InvalidDriveInMMPPathException e) {
            // shouldn't happen
            ProjectUIPlugin.log(e);
            filePath = e.getPathNoDevice();
        }
        // remove won't work if file system and mmp differ in case, so
        // ensure they match
        if (!checked) {
            filePath = findFilePathInModelSources(filePath, modelSources);
            Check.checkState(filePath != null);
        }
        list.add(filePath);
    } else if (element instanceof IContainer) {
        // Flatten hierarchy into list of files. For undo/redo we want
        // just the files that need changing, not all the contained files.
        flattenContainer((IContainer) element, list, new IFilter() {
            public boolean select(Object toTest) {
                IPath filePath;
                try {
                    filePath = editorContext.pathHelper.convertProjectOrFullPathToMMP(EMMPPathContext.SOURCE,
                            (IPath) toTest);
                } catch (InvalidDriveInMMPPathException e) {
                    // shouldn't happen
                    ProjectUIPlugin.log(e);
                    filePath = e.getPathNoDevice();
                }
                boolean isInModel = findFilePathInModelSources(filePath, modelSources) != null;
                return checked != isInModel;
            }
        });
    }
    if (list.size() > 0) {
        execListCommand(checked, list, modelSources);
    }
}

From source file:com.nokia.carbide.remoteconnections.internal.registry.Registry.java

License:Open Source License

private void loadConnectionTypeExtensions() {
    List<IConnectionType> connectionTypeExtensions = new ArrayList<IConnectionType>();
    String loadError = Messages.getString("Registry.ConnectionTypeExtensionLoadError"); //$NON-NLS-1$
    RemoteConnectionsActivator.loadExtensions(CONNECTION_TYPE_EXTENSION, loadError, connectionTypeExtensions,
            new IFilter() {
                public boolean select(Object toTest) {
                    return acceptConnectionType(((IConnectionType) toTest).getIdentifier());
                }/*from w  w  w .ja v  a  2s . c  o  m*/
            });

    connectionTypeIdMap = new HashMap<String, IConnectionType>();
    for (IConnectionType connectionType : connectionTypeExtensions) {
        connectionTypeIdMap.put(connectionType.getIdentifier(), connectionType);
    }
}

From source file:com.nokia.carbide.remoteconnections.internal.registry.Registry.java

License:Open Source License

private void loadServiceExtensions() {
    services = new ArrayList<IService>();
    String loadError = Messages.getString("Registry.ServiceExtensionLoadError"); //$NON-NLS-1$
    RemoteConnectionsActivator.loadExtensions(SERVICE_EXTENSION, loadError, services, new IFilter() {
        public boolean select(Object toTest) {
            return acceptService(((IService) toTest).getIdentifier());
        }/*from  w w w . ja  v a  2s  .c  om*/
    });
}

From source file:com.nokia.carbide.remoteconnections.RemoteConnectionsActivator.java

License:Open Source License

private void loadAndStartDeviceDiscoveryAgents() {
    String loadError = Messages.getString("RemoteConnectionsActivator.DiscoveryAgentLoadError"); //$NON-NLS-1$
    discoveryAgents = new ArrayList<IDeviceDiscoveryAgent>();
    loadExtensions(DISCOVERY_AGENT_EXTENSION, loadError, discoveryAgents, new IFilter() {
        public boolean select(Object toTest) {
            if (toTest instanceof IDeviceDiscoveryAgent) {
                try {
                    IDeviceDiscoveryAgent discoveryAgent = (IDeviceDiscoveryAgent) toTest;
                    if (getStoredAgentRunningState(discoveryAgent))
                        discoveryAgent.start();
                    return true;
                } catch (Throwable e) {
                    // since we launch arbitrary code, catch any exception to prevent killing the view
                    logError(e);//  ww  w  . ja  va  2  s.c  om
                }
            }
            return false;
        }
    });
    fireDiscoveryAgentsLoaded();
}

From source file:gov.va.isaac.mdht.otf.ui.properties.AnnotationSection.java

License:Apache License

protected ConceptVersionBI getAnnotationRefset() {
    ConceptVersionBI refset = null;/*www. j av  a  2 s .  c  o  m*/

    IFilter annotationRefsetFilter = new IFilter() {
        @Override
        public boolean select(Object object) {
            try {
                if ((object instanceof ConceptVersionBI)
                        && ((ConceptVersionBI) object).isAnnotationStyleRefex()) {
                    return true;
                }
            } catch (IOException e) {
                StatusManager.getManager().handle(
                        new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error in isAnnotationStyleRefex()", e),
                        StatusManager.SHOW | StatusManager.LOG);
            }

            return false;
        }
    };

    ConceptListDialog searchDialog = new ConceptListDialog(getPart().getSite().getShell(),
            Messages.RefsetSelection_input_title, Messages.ConceptSelection_input_message,
            annotationRefsetFilter);
    int result = searchDialog.open();
    if (Dialog.OK == result && searchDialog.getResult().length == 1) {
        refset = (ConceptVersionBI) searchDialog.getResult()[0];
    }

    return refset;
}

From source file:net.sf.eclipsensis.dialogs.NSISAssociatedHeadersPropertyPage.java

License:Open Source License

@Override
public Control createControl(final Composite parent) {
    mOriginalHeaders = mHeaderAssociationManager
            .getAssociatedHeaders((IFile) ((NSISProperties) mSettings).getResource());
    mHeaders = new HashSet<IFile>();
    initHeaders();/*from ww w  .  j a  v a  2  s  .com*/
    final IFilter filter = new IFilter() {
        public boolean select(Object toTest) {
            if (toTest instanceof IFile) {
                String ext = ((IFile) toTest).getFileExtension();
                if (ext != null && ext.equalsIgnoreCase(INSISConstants.NSH_EXTENSION)) {
                    return mHeaders != null && !mHeaders.contains(toTest);
                }
            }
            return false;
        }
    };

    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    composite.setLayout(layout);

    Label l = new Label(composite, SWT.NONE);
    l.setText(EclipseNSISPlugin.getResourceString("associated.headers.title")); //$NON-NLS-1$
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
    data.horizontalSpan = 2;
    l.setLayoutData(data);

    Table table = new Table(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL | SWT.BORDER);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn column = new TableColumn(table, SWT.LEFT, 0);
    column.setText(EclipseNSISPlugin.getResourceString("associated.headers.column.label")); //$NON-NLS-1$
    table.addControlListener(new TableResizer());

    mViewer = new TableViewer(table);
    mViewer.setContentProvider(new CollectionContentProvider());
    mViewer.setLabelProvider(new CollectionLabelProvider() {
        @Override
        public String getColumnText(Object element, int columnIndex) {
            if (element instanceof IFile) {
                return ((IFile) element).getFullPath().toString();
            }
            return null;
        }
    });
    mViewer.setComparator(new ViewerComparator() {
        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof IFile && e2 instanceof IFile) {
                return ((IFile) e1).getFullPath().toString().compareTo(((IFile) e2).getFullPath().toString());
            }
            return super.compare(viewer, e1, e2);
        }
    });
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.verticalSpan = 2;
    table.setLayoutData(data);
    Button addButton = new Button(composite, SWT.PUSH);
    addButton.setImage(CommonImages.ADD_ICON);
    addButton.setToolTipText(EclipseNSISPlugin.getResourceString("add.associated.header.toolip")); //$NON-NLS-1$
    addButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            FileSelectionDialog dialog = new FileSelectionDialog(parent.getShell(),
                    ((NSISProperties) mSettings).getResource().getParent(), filter);
            dialog.setDialogMessage(EclipseNSISPlugin.getResourceString("nsis.script.prompt")); //$NON-NLS-1$
            dialog.setHelpAvailable(false);
            if (dialog.open() == Window.OK) {
                IFile file = dialog.getFile();
                IFile script = mHeaderAssociationManager.getAssociatedScript(file);
                if (script != null && !script.equals(((NSISProperties) mSettings).getResource())
                        && mReassociateHeaderWarning.getSelection()) {

                    MessageDialogWithToggle dlg = new MessageDialogWithToggle(parent.getShell(),
                            EclipseNSISPlugin.getResourceString("confirm.title"), //$NON-NLS-1$
                            EclipseNSISPlugin.getShellImage(),
                            EclipseNSISPlugin.getFormattedString("associated.header.warning", //$NON-NLS-1$
                                    new String[] { file.getFullPath().toString(),
                                            script.getFullPath().toString() }),
                            MessageDialog.QUESTION,
                            new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL }, 0,
                            EclipseNSISPlugin.getResourceString("associated.header.toggle.message"), false); //$NON-NLS-1$
                    dlg.open();
                    if (dialog.getReturnCode() == IDialogConstants.OK_ID) {
                        mReassociateHeaderWarning.setSelection(!dlg.getToggleState());
                    } else {
                        return;
                    }
                }
                if (!mHeaders.contains(file)) {
                    mHeaders.add(file);
                    mViewer.refresh(false);
                }
            }
        }
    });
    addButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));

    final Button removeButton = new Button(composite, SWT.PUSH);
    removeButton.setImage(CommonImages.DELETE_ICON);
    removeButton.setToolTipText(EclipseNSISPlugin.getResourceString("remove.associated.header.toolip")); //$NON-NLS-1$
    removeButton.setEnabled(false);
    removeButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            IStructuredSelection sel = (IStructuredSelection) mViewer.getSelection();
            if (!sel.isEmpty()) {
                mHeaders.removeAll(sel.toList());
                mViewer.refresh(false);
            }
        }
    });
    data = new GridData(SWT.FILL, SWT.TOP, false, false);
    data.verticalSpan = 2;
    removeButton.setLayoutData(data);

    Composite c = new Composite(composite, SWT.NONE);
    data = new GridData(SWT.FILL, SWT.FILL, true, false);
    c.setLayoutData(data);
    layout = new GridLayout(2, false);
    layout.marginWidth = layout.marginHeight = 0;
    layout.horizontalSpacing = 3;
    c.setLayout(layout);

    mReassociateHeaderWarning = new Button(c, SWT.CHECK);
    mReassociateHeaderWarning.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false));
    mReassociateHeaderWarning.setSelection(NSISPreferences.getInstance().getPreferenceStore()
            .getBoolean(INSISPreferenceConstants.WARN_REASSOCIATE_HEADER));
    l = new Label(c, SWT.WRAP);
    l.setText(EclipseNSISPlugin.getResourceString("show.associated.header.warning.label")); //$NON-NLS-1$
    l.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));

    mViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            removeButton.setEnabled((selection != null && !selection.isEmpty()));
        }
    });

    mViewer.setInput(mHeaders);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(composite,
            INSISConstants.PLUGIN_CONTEXT_PREFIX + "nsis_assochdrproperties_context"); //$NON-NLS-1$
    return composite;
}

From source file:net.sf.eclipsensis.launch.NSISGeneralTab.java

License:Open Source License

@Override
protected IFilter createSettingsFilter() {
    return new IFilter() {
        public boolean select(Object toTest) {
            return !INSISSettingsConstants.SYMBOLS.equals(toTest);
        }/*  ww  w  .  jav a2s. c  om*/
    };
}

From source file:net.sf.eclipsensis.launch.NSISSymbolsTab.java

License:Open Source License

@Override
protected IFilter createSettingsFilter() {
    return new IFilter() {
        public boolean select(Object toTest) {
            return INSISSettingsConstants.SYMBOLS.equals(toTest);
        }// w  w w .jav a2 s. co  m
    };
}

From source file:org.camunda.bpm.modeler.core.property.SectionDescriptor.java

License:Open Source License

@Override
public IFilter getFilter() {
    return new IFilter() {

        @Override//from w  ww . j a  va 2 s.  c  o m
        public boolean select(Object toTest) {
            return false;
        }

    };
}

From source file:org.eclipse.cdt.internal.ui.workingsets.WorkingSetConfigurationsPage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {
    Composite result = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().margins(5, 5).applyTo(result);

    final WorkspaceSnapshot workspace = WorkingSetConfigurationManager.getDefault().createWorkspaceSnapshot();
    final IWorkingSetProxy.ISnapshot workingSet = getWorkingSet(workspace);

    if (workingSet == null) {
        new Label(result, SWT.NONE).setText(WorkingSetMessages.WSetConfigsPage_noProjects);
    } else {//from   ww  w .j  av  a  2 s  . c  o m
        block = new WorkingSetConfigurationBlock(workspace, workingSet);
        block.setWorkingSetFilter(new IFilter() {

            @Override
            public boolean select(Object toTest) {
                return toTest == workingSet;
            }
        });

        Control contents = block.createContents(result);
        contents.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    }

    return result;
}