Java 类org.eclipse.ui.dialogs.ISelectionStatusValidator 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:MoveMembersWizard.java   
private void openTypeSelectionDialog(){
    int elementKinds= IJavaSearchConstants.TYPE;
    final IJavaSearchScope scope= createWorkspaceSourceScope();
    FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
        getWizard().getContainer(), scope, elementKinds);
    dialog.setTitle(RefactoringMessages.MoveMembersInputPage_choose_Type);
    dialog.setMessage(RefactoringMessages.MoveMembersInputPage_dialogMessage);
    dialog.setValidator(new ISelectionStatusValidator(){
        public IStatus validate(Object[] selection) {
            Assert.isTrue(selection.length <= 1);
            if (selection.length == 0)
                return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
            Object element= selection[0];
            if (! (element instanceof IType))
                return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
            IType type= (IType)element;
            return validateDestinationType(type, type.getElementName());
        }
    });
    dialog.setInitialPattern(createInitialFilter());
    if (dialog.open() == Window.CANCEL)
        return;
    IType firstResult= (IType)dialog.getFirstResult();
    fDestinationField.setText(firstResult.getFullyQualifiedName('.'));
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:MoveMembersWizard.java   
private void openTypeSelectionDialog(){
    int elementKinds= IJavaSearchConstants.TYPE;
    final IJavaSearchScope scope= createWorkspaceSourceScope();
    FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
        getWizard().getContainer(), scope, elementKinds);
    dialog.setTitle(RefactoringMessages.MoveMembersInputPage_choose_Type);
    dialog.setMessage(RefactoringMessages.MoveMembersInputPage_dialogMessage);
    dialog.setValidator(new ISelectionStatusValidator(){
        public IStatus validate(Object[] selection) {
            Assert.isTrue(selection.length <= 1);
            if (selection.length == 0)
                return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
            Object element= selection[0];
            if (! (element instanceof IType))
                return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
            IType type= (IType)element;
            return validateDestinationType(type, type.getElementName());
        }
    });
    dialog.setInitialPattern(createInitialFilter());
    if (dialog.open() == Window.CANCEL)
        return;
    IType firstResult= (IType)dialog.getFirstResult();
    fDestinationField.setText(firstResult.getFullyQualifiedName('.'));
}
项目:bento    文件:FindFileDialog.java   
private void init() {
    FindFileDialog listDialog = this;

    // ElementListSelectionDialog listDialog = new ElementListSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), labelProvider);      
    listDialog.setStatusLineAboveButtons(true);

    listDialog.setValidator(new ISelectionStatusValidator() {
        @Override
        public IStatus validate(Object[] selection) {
            IResource r = (IResource) selection[0];
            return new Status(IStatus.INFO, Activator.PLUGIN_ID, r.getProjectRelativePath().toPortableString());
        }
    });

    listDialog.setMultipleSelection(false);
    listDialog.setTitle("ATL files in the workspace");
    listDialog.setMessage("");
    // listDialog.setElements(list.toArray());
    // listDialog.open();                       
}
项目:typescript.java    文件:WorkspaceResourceSelectionDialog.java   
public WorkspaceResourceSelectionDialog(Shell parent, Mode mode) {
    super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
    this.mode = mode;
    setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
            if (selection.length > 0 && checkMode(selection[0])) {
                return new Status(IStatus.OK, TypeScriptUIPlugin.PLUGIN_ID, IStatus.OK, EMPTY_STRING, null);
            }
            return new Status(IStatus.ERROR, TypeScriptUIPlugin.PLUGIN_ID, IStatus.ERROR, EMPTY_STRING, null);
        }
    });
    setInput(ResourcesPlugin.getWorkspace().getRoot());
}
项目:jsbuild-eclipse    文件:FileSelectionDialog.java   
public FileSelectionDialog(Shell parent, List<IFile> files, String title,
        String message, String filterExtension, String filterMessage) {
    super(parent, new WorkbenchLabelProvider(),
            new WorkbenchContentProvider());

    setTitle(title);
    setMessage(message);
    fFilter = new FileFilter(files, filterExtension);
    fFilterMessage = filterMessage;
    setInput(ResourcesPlugin.getWorkspace().getRoot());
    setComparator(new ResourceComparator(ResourceComparator.NAME));

    ISelectionStatusValidator validator = new ISelectionStatusValidator() {
        @Override
        public IStatus validate(Object[] selection) {
            if (selection.length == 0) {
                return new Status(IStatus.ERROR,
                        JSBuildFileUIPlugin.PLUGIN_ID, 0, "", null);
            }
            for (int i = 0; i < selection.length; i++) {
                if (!(selection[i] instanceof IFile)) {
                    return new Status(IStatus.ERROR,
                            JSBuildFileUIPlugin.PLUGIN_ID, 0, "", null);
                }
            }
            return new Status(IStatus.OK, JSBuildFileUIPlugin.PLUGIN_ID, 0,
                    "", null);
        }
    };
    setValidator(validator);
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeExceptionsControl.java   
private IType chooseException() {
    IJavaElement[] elements= new IJavaElement[] { fProject.getJavaProject() };
    final IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);

    FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
            PlatformUI.getWorkbench().getProgressService(), scope, IJavaSearchConstants.CLASS);
    dialog.setTitle(RefactoringMessages.ChangeExceptionsControl_choose_title);
    dialog.setMessage(RefactoringMessages.ChangeExceptionsControl_choose_message);
    dialog.setInitialPattern("*Exception*"); //$NON-NLS-1$
    dialog.setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
            if (selection.length == 0)
                return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
            try {
                return checkException((IType)selection[0]);
            } catch (JavaModelException e) {
                JavaPlugin.log(e);
                return StatusInfo.OK_STATUS;
            }
        }
    });

    if (dialog.open() == Window.OK) {
        return (IType) dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:JarManifestWizardPage.java   
/**
 * Creates and returns a dialog to choose an existing workspace file.
 * @param title the title
 * @param message the dialog message
 * @return the dialog
 */
protected ElementTreeSelectionDialog createWorkspaceFileSelectionDialog(String title, String message) {
    int labelFlags= JavaElementLabelProvider.SHOW_BASICS
                    | JavaElementLabelProvider.SHOW_OVERLAY_ICONS
                    | JavaElementLabelProvider.SHOW_SMALL_ICONS;
    final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(labelFlags), new ProblemsLabelDecorator(null));
    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), provider, new StandardJavaElementContentProvider());
    dialog.setComparator(new JavaElementComparator());
    dialog.setAllowMultiple(false);
    dialog.setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
            StatusInfo res= new StatusInfo();
            // only single selection
            if (selection.length == 1 && (selection[0] instanceof IFile))
                res.setOK();
            else
                res.setError(""); //$NON-NLS-1$
            return res;
        }
    });
    dialog.addFilter(new EmptyInnerPackageFilter());
    dialog.addFilter(new LibraryFilter());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setStatusLineAboveButtons(true);
    dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot()));
    return dialog;
}
项目:Eclipse-Postfix-Code-Completion    文件:NewSourceFolderWizardPage.java   
private IFolder chooseFolder(String title, String message, IPath initialPath) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IProject currProject= fCurrJProject.getProject();

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currProject);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    IResource res= currProject.findMember(initialPath);
    if (res != null) {
        dialog.setInitialSelection(res);
    }

    if (dialog.open() == Window.OK) {
        return (IFolder) dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:BuildPathsBlock.java   
private IContainer chooseContainer() {
    Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    IProject[] allProjects= fWorkspaceRoot.getProjects();
    ArrayList<IProject> rejectedElements= new ArrayList<IProject>(allProjects.length);
    IProject currProject= fCurrJProject.getProject();
    for (int i= 0; i < allProjects.length; i++) {
        if (!allProjects[i].equals(currProject)) {
            rejectedElements.add(allProjects[i]);
        }
    }
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IResource initSelection= null;
    if (fOutputLocationPath != null) {
        initSelection= fWorkspaceRoot.findMember(fOutputLocationPath);
    }

    FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp);
    dialog.setTitle(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_title);
    dialog.setValidator(validator);
    dialog.setMessage(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_description);
    dialog.addFilter(filter);
    dialog.setInput(fWorkspaceRoot);
    dialog.setInitialSelection(initSelection);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

    if (dialog.open() == Window.OK) {
        return (IContainer)dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:AddSourceFolderWizardPage.java   
private IFolder chooseFolder(String title, String message, IPath initialPath) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IProject currProject= fNewElement.getJavaProject().getProject();

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp) {
        @Override
        protected Control createDialogArea(Composite parent) {
            Control result= super.createDialogArea(parent);
            PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
            return result;
        }
    };
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currProject);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    IResource res= currProject.findMember(initialPath);
    if (res != null) {
        dialog.setInitialSelection(res);
    }

    if (dialog.open() == Window.OK) {
        return (IFolder) dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ChangeExceptionsControl.java   
private IType chooseException() {
    IJavaElement[] elements= new IJavaElement[] { fProject.getJavaProject() };
    final IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);

    FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
            PlatformUI.getWorkbench().getProgressService(), scope, IJavaSearchConstants.CLASS);
    dialog.setTitle(RefactoringMessages.ChangeExceptionsControl_choose_title);
    dialog.setMessage(RefactoringMessages.ChangeExceptionsControl_choose_message);
    dialog.setInitialPattern("*Exception*"); //$NON-NLS-1$
    dialog.setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
            if (selection.length == 0)
                return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
            try {
                return checkException((IType)selection[0]);
            } catch (JavaModelException e) {
                JavaPlugin.log(e);
                return StatusInfo.OK_STATUS;
            }
        }
    });

    if (dialog.open() == Window.OK) {
        return (IType) dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JarManifestWizardPage.java   
/**
 * Creates and returns a dialog to choose an existing workspace file.
 * @param title the title
 * @param message the dialog message
 * @return the dialog
 */
protected ElementTreeSelectionDialog createWorkspaceFileSelectionDialog(String title, String message) {
    int labelFlags= JavaElementLabelProvider.SHOW_BASICS
                    | JavaElementLabelProvider.SHOW_OVERLAY_ICONS
                    | JavaElementLabelProvider.SHOW_SMALL_ICONS;
    final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(labelFlags), new ProblemsLabelDecorator(null));
    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), provider, new StandardJavaElementContentProvider());
    dialog.setComparator(new JavaElementComparator());
    dialog.setAllowMultiple(false);
    dialog.setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
            StatusInfo res= new StatusInfo();
            // only single selection
            if (selection.length == 1 && (selection[0] instanceof IFile))
                res.setOK();
            else
                res.setError(""); //$NON-NLS-1$
            return res;
        }
    });
    dialog.addFilter(new EmptyInnerPackageFilter());
    dialog.addFilter(new LibraryFilter());
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.setStatusLineAboveButtons(true);
    dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot()));
    return dialog;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewSourceFolderWizardPage.java   
private IFolder chooseFolder(String title, String message, IPath initialPath) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IProject currProject= fCurrJProject.getProject();

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp);
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currProject);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    IResource res= currProject.findMember(initialPath);
    if (res != null) {
        dialog.setInitialSelection(res);
    }

    if (dialog.open() == Window.OK) {
        return (IFolder) dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:BuildPathsBlock.java   
private IContainer chooseContainer() {
    Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    IProject[] allProjects= fWorkspaceRoot.getProjects();
    ArrayList<IProject> rejectedElements= new ArrayList<IProject>(allProjects.length);
    IProject currProject= fCurrJProject.getProject();
    for (int i= 0; i < allProjects.length; i++) {
        if (!allProjects[i].equals(currProject)) {
            rejectedElements.add(allProjects[i]);
        }
    }
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IResource initSelection= null;
    if (fOutputLocationPath != null) {
        initSelection= fWorkspaceRoot.findMember(fOutputLocationPath);
    }

    FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp);
    dialog.setTitle(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_title);
    dialog.setValidator(validator);
    dialog.setMessage(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_description);
    dialog.addFilter(filter);
    dialog.setInput(fWorkspaceRoot);
    dialog.setInitialSelection(initSelection);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

    if (dialog.open() == Window.OK) {
        return (IContainer)dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AddSourceFolderWizardPage.java   
private IFolder chooseFolder(String title, String message, IPath initialPath) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null);

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IProject currProject= fNewElement.getJavaProject().getProject();

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp) {
        @Override
        protected Control createDialogArea(Composite parent) {
            Control result= super.createDialogArea(parent);
            PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER);
            return result;
        }
    };
    dialog.setValidator(validator);
    dialog.setTitle(title);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currProject);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    IResource res= currProject.findMember(initialPath);
    if (res != null) {
        dialog.setInitialSelection(res);
    }

    if (dialog.open() == Window.OK) {
        return (IFolder) dialog.getFirstResult();
    }
    return null;
}
项目:filesync4eclipse    文件:InclusionExclusionDialog.java   
private void addMultipleEntries(ListDialogField field) {
    Class[] acceptedClasses = new Class[] { IFolder.class, IFile.class };
    ISelectionStatusValidator validator = new TypedElementSelectionValidator(
            acceptedClasses, true);
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses);

    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();

    String title, message;
    if (isExclusion(field)) {
        title = "Exclusion Pattern Selection";
        message = "&Choose folders or files to exclude:";
    } else {
        title = "Inclusion Pattern Selection";
        message = "&Choose folders or files to include:";
    }
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
            lp, cp);
    dialog.setTitle(title);
    dialog.setValidator(validator);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currSourceFolder);
    dialog.setInitialSelection(null);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

    if (dialog.open() == Window.OK) {
        Object[] objects = dialog.getResult();
        int existingSegments = currSourceFolder.getFullPath().segmentCount();

        for (int i = 0; i < objects.length; i++) {
            IResource curr = (IResource) objects[i];
            IPath path = curr.getFullPath().removeFirstSegments(existingSegments)
                    .makeRelative();
            String res;
            if (curr instanceof IContainer) {
                res = path.addTrailingSeparator().toString();
            } else {
                res = path.toString();
            }
            field.addElement(res);
        }
    }
}
项目:filesync4eclipse    文件:ProjectSyncPropertyPage.java   
private IPath openFileDialog(IPath path) {
    Class[] acceptedClasses = new Class[] { IFile.class, IFolder.class,
            IProject.class };
    ISelectionStatusValidator validator = new TypedElementSelectionValidator(
            acceptedClasses, false) {
        @Override
        public IStatus validate(Object[] elements) {
            if (elements.length > 1 || elements.length == 0
                    || !(elements[0] instanceof IFile)) {
                return errorStatus;
            }
            return okStatus;
        }
    };

    IProject[] allProjects = workspaceRoot.getProjects();
    ArrayList rejectedElements = new ArrayList(allProjects.length);
    for (int i = 0; i < allProjects.length; i++) {
        if (!allProjects[i].equals(project)) {
            rejectedElements.add(allProjects[i]);
        }
    }
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedElements
            .toArray());

    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();

    IResource initSelection = null;
    if (path != null) {
        initSelection = project.findMember(path);
    }

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(),
            lp, cp);
    dialog.setTitle("Variables");
    dialog.setValidator(validator);
    dialog.setMessage("Select file with variables definition");
    dialog.addFilter(filter);
    dialog.setInput(workspaceRoot);
    dialog.setInitialSelection(initSelection);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

    if (dialog.open() == Window.OK) {
        return ((IFile) dialog.getFirstResult()).getProjectRelativePath();
    }
    return null;
}
项目:filesync4eclipse    文件:InclusionExclusionEntryDialog.java   
private IPath chooseExclusionPattern() {
    Class[] acceptedClasses = new Class[] { IFolder.class, IFile.class };
    ISelectionStatusValidator validator = new TypedElementSelectionValidator(
            acceptedClasses, false);
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses);

    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();

    IPath initialPath = new Path(exclPatternDialog.getText());
    IResource initialElement = null;
    IContainer curr = currSourceFolder;
    int nSegments = initialPath.segmentCount();
    for (int i = 0; i < nSegments; i++) {
        IResource elem = curr.findMember(initialPath.segment(i));
        if (elem != null) {
            initialElement = elem;
        }
        if (elem instanceof IContainer) {
            curr = (IContainer) elem;
        } else {
            break;
        }
    }
    String title, message;
    if (isExclusion) {
        title = "Exclusion Pattern Selection";
        message = "&Choose a folder or file to exclude:";
    } else {
        title = "Inclusion Pattern Selection";
        message = "&Choose a folder or file to include:";
    }

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(
            getShell(), lp, cp);
    dialog.setTitle(title);
    dialog.setValidator(validator);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currSourceFolder);
    dialog.setInitialSelection(initialElement);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

    if (dialog.open() == Window.OK) {
        IResource res = (IResource) dialog.getFirstResult();
        IPath path = res.getFullPath().removeFirstSegments(
                currSourceFolder.getFullPath().segmentCount())
                .makeRelative();
        if (res instanceof IContainer) {
            return path.addTrailingSeparator();
        }
        return path;
    }
    return null;
}
项目:OpenSPIFe    文件:IFileFieldEditor.java   
/**
 * Helper to open the file chooser dialog.
 * 
 * @param startingDirectory
 *            the directory to open the dialog on.
 * @return File The File the user selected or <code>null</code> if they do not.
 */
private IFile getFile(IResource resource) {
    String project = (baseURI != null ? baseURI.segment(1) : null);
    Shell shell = getShell();
    WorkspaceLabelProvider labelProvider = new WorkspaceLabelProvider();
    WorkbenchContentProvider contentProvider = new WorkbenchContentProvider();
    final WorkspaceResourceDialog dialog = new WorkspaceResourceDialog(shell, labelProvider, contentProvider) {

        @Override
        protected void fileTextModified(String text) {
            super.fileTextModified(text);
            updateOKStatus();
        }

    };
    dialog.setAllowMultiple(false);
    String decodedProject = CommonUtils.decodeUTF8(project);
    dialog.setTitle(project != null ? decodedProject : CommonUIPlugin.INSTANCE.getString("_UI_FileSelection_title"));//$NON-NLS-1$
    dialog.setMessage(null);
    dialog.setShowNewFolderControl(true);
    if (style == SWT.SAVE) {
        dialog.setShowFileControl(true);
    }
    dialog.addFilter(dialog.createDefaultViewerFilter(true));
    dialog.addFilter(new FilePatternFilter());
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    Object input = (project != null ? root.getProject(decodedProject) : null);
    if (input == null) {
        input = root;
    }
    dialog.setValidator(new ISelectionStatusValidator() {
        @Override
        public IStatus validate(Object[] selection) {
            if (selection.length == 0) {
                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, MUST_SELECT_AN_OUTPUT_FOLDER);
            } else if (selection.length > 0) {
                Object s = selection[0];
                if (s instanceof IFile) {
                    return hasValidExtension(((IFile) s).getName());
                }
            }
            return hasValidExtension(dialog.getFileText());
        }
    });

    dialog.setInput(input);
    dialog.setInitialSelection(resource);
    if (dialog.open() == Window.OK) {
        IFile file = getFileFromDialog(dialog);
        if (file != null) {
            getTextControl().setFocus();
            return file;
        }
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeSelectionDialog2.java   
public void setValidator(ISelectionStatusValidator validator) {
    fValidator= validator;
}
项目:Eclipse-Postfix-Code-Completion    文件:AddGetterSetterAction.java   
private static ISelectionStatusValidator createValidator(int entries) {
    AddGetterSetterSelectionStatusValidator validator= new AddGetterSetterSelectionStatusValidator(entries);
    return validator;
}
项目:Eclipse-Postfix-Code-Completion    文件:JarManifestWizardPage.java   
/**
 * Creates a selection dialog that lists all packages under the given package
 * fragment root.
 * The caller is responsible for opening the dialog with <code>Window.open</code>,
 * and subsequently extracting the selected packages (of type
 * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
 *
 * @param packageFragments the package fragments
 * @return a new selection dialog
 */
protected SelectionDialog createPackageDialog(Set<IJavaElement> packageFragments) {
    List<IPackageFragment> packages= new ArrayList<IPackageFragment>(packageFragments.size());
    for (Iterator<IJavaElement> iter= packageFragments.iterator(); iter.hasNext();) {
        IPackageFragment fragment= (IPackageFragment)iter.next();
        boolean containsJavaElements= false;
        int kind;
        try {
            kind= fragment.getKind();
            containsJavaElements= fragment.getChildren().length > 0;
        } catch (JavaModelException ex) {
            ExceptionHandler.handle(ex, getContainer().getShell(), JarPackagerMessages.JarManifestWizardPage_error_jarPackageWizardError_title, Messages.format(JarPackagerMessages.JarManifestWizardPage_error_jarPackageWizardError_message, JavaElementLabels.getElementLabel(fragment, JavaElementLabels.ALL_DEFAULT)));
            continue;
        }
        if (kind != IPackageFragmentRoot.K_BINARY && containsJavaElements)
            packages.add(fragment);
    }
    StandardJavaElementContentProvider cp= new StandardJavaElementContentProvider() {
        @Override
        public boolean hasChildren(Object element) {
            // prevent the + from being shown in front of packages
            return !(element instanceof IPackageFragment) && super.hasChildren(element);
        }
    };
    final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), new ProblemsLabelDecorator(null));
    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getContainer().getShell(), provider, cp);
    dialog.setDoubleClickSelects(false);
    dialog.setComparator(new JavaElementComparator());
    dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot()));
    dialog.addFilter(new EmptyInnerPackageFilter());
    dialog.addFilter(new LibraryFilter());
    dialog.addFilter(new SealPackagesFilter(packages));
    dialog.setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
            StatusInfo res= new StatusInfo();
            for (int i= 0; i < selection.length; i++) {
                if (!(selection[i] instanceof IPackageFragment)) {
                    res.setError(JarPackagerMessages.JarManifestWizardPage_error_mustContainPackages);
                    return res;
                }
            }
            res.setOK();
            return res;
        }
    });
    return dialog;
}
项目:Eclipse-Postfix-Code-Completion    文件:GenerateToStringDialog.java   
@Override
public ISelectionStatusValidator getSelectionValidator() {
    return getValidator();
}
项目:Eclipse-Postfix-Code-Completion    文件:OutputLocationDialog.java   
private IContainer chooseOutputLocation() {
    IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot();
    final Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
    IProject[] allProjects= root.getProjects();
    ArrayList<IProject> rejectedElements= new ArrayList<IProject>(allProjects.length);
    for (int i= 0; i < allProjects.length; i++) {
        if (!allProjects[i].equals(fCurrProject)) {
            rejectedElements.add(allProjects[i]);
        }
    }
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IResource initSelection= null;
    if (fOutputLocation != null) {
        initSelection= root.findMember(fOutputLocation);
    }

    FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp);
    dialog.setTitle(NewWizardMessages.OutputLocationDialog_ChooseOutputFolder_title);

       dialog.setValidator(new ISelectionStatusValidator() {
           ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
           public IStatus validate(Object[] selection) {
               IStatus typedStatus= validator.validate(selection);
               if (!typedStatus.isOK())
                   return typedStatus;
               if (selection[0] instanceof IFolder) {
                   IFolder folder= (IFolder) selection[0];
                   try {
                    IStatus result= ClasspathModifier.checkSetOutputLocationPrecondition(fEntryToEdit, folder.getFullPath(), fAllowInvalidClasspath, fCPJavaProject);
                    if (result.getSeverity() == IStatus.ERROR)
                        return result;
                   } catch (CoreException e) {
                    JavaPlugin.log(e);
                   }
                   return new StatusInfo();
               } else {
                return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
               }
           }
       });
    dialog.setMessage(NewWizardMessages.OutputLocationDialog_ChooseOutputFolder_description);
    dialog.addFilter(filter);
    dialog.setInput(root);
    dialog.setInitialSelection(initSelection);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

    if (dialog.open() == Window.OK) {
        return (IContainer)dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:ExclusionInclusionEntryDialog.java   
public static IPath[] chooseExclusionPattern(Shell shell, IContainer currentSourceFolder, String title, String message, IPath initialPath, boolean multiSelection) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class, IFile.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, multiSelection);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses);


    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IResource initialElement= null;
    if (initialPath != null) {
        IContainer curr= currentSourceFolder;
        int nSegments= initialPath.segmentCount();
        for (int i= 0; i < nSegments; i++) {
            IResource elem= curr.findMember(initialPath.segment(i));
            if (elem != null) {
                initialElement= elem;
            }
            if (elem instanceof IContainer) {
                curr= (IContainer) elem;
            } else {
                break;
            }
        }
    }

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(shell, lp, cp);
    dialog.setTitle(title);
    dialog.setValidator(validator);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currentSourceFolder);
    dialog.setInitialSelection(initialElement);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setHelpAvailable(false);

    if (dialog.open() == Window.OK) {
        Object[] objects= dialog.getResult();
        int existingSegments= currentSourceFolder.getFullPath().segmentCount();

        IPath[] resArr= new IPath[objects.length];
        for (int i= 0; i < objects.length; i++) {
            IResource currRes= (IResource) objects[i];
            IPath path= currRes.getFullPath().removeFirstSegments(existingSegments).makeRelative();
            if (currRes instanceof IContainer) {
                path= path.addTrailingSeparator();
            }
            resArr[i]= path;
        }
        return resArr;
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypeSelectionDialog2.java   
public void setValidator(ISelectionStatusValidator validator) {
    fValidator= validator;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AddGetterSetterAction.java   
private static ISelectionStatusValidator createValidator(int entries) {
    AddGetterSetterSelectionStatusValidator validator= new AddGetterSetterSelectionStatusValidator(entries);
    return validator;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JarManifestWizardPage.java   
/**
 * Creates a selection dialog that lists all packages under the given package
 * fragment root.
 * The caller is responsible for opening the dialog with <code>Window.open</code>,
 * and subsequently extracting the selected packages (of type
 * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
 *
 * @param packageFragments the package fragments
 * @return a new selection dialog
 */
protected SelectionDialog createPackageDialog(Set<IJavaElement> packageFragments) {
    List<IPackageFragment> packages= new ArrayList<IPackageFragment>(packageFragments.size());
    for (Iterator<IJavaElement> iter= packageFragments.iterator(); iter.hasNext();) {
        IPackageFragment fragment= (IPackageFragment)iter.next();
        boolean containsJavaElements= false;
        int kind;
        try {
            kind= fragment.getKind();
            containsJavaElements= fragment.getChildren().length > 0;
        } catch (JavaModelException ex) {
            ExceptionHandler.handle(ex, getContainer().getShell(), JarPackagerMessages.JarManifestWizardPage_error_jarPackageWizardError_title, Messages.format(JarPackagerMessages.JarManifestWizardPage_error_jarPackageWizardError_message, JavaElementLabels.getElementLabel(fragment, JavaElementLabels.ALL_DEFAULT)));
            continue;
        }
        if (kind != IPackageFragmentRoot.K_BINARY && containsJavaElements)
            packages.add(fragment);
    }
    StandardJavaElementContentProvider cp= new StandardJavaElementContentProvider() {
        @Override
        public boolean hasChildren(Object element) {
            // prevent the + from being shown in front of packages
            return !(element instanceof IPackageFragment) && super.hasChildren(element);
        }
    };
    final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), new ProblemsLabelDecorator(null));
    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getContainer().getShell(), provider, cp);
    dialog.setDoubleClickSelects(false);
    dialog.setComparator(new JavaElementComparator());
    dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot()));
    dialog.addFilter(new EmptyInnerPackageFilter());
    dialog.addFilter(new LibraryFilter());
    dialog.addFilter(new SealPackagesFilter(packages));
    dialog.setValidator(new ISelectionStatusValidator() {
        public IStatus validate(Object[] selection) {
            StatusInfo res= new StatusInfo();
            for (int i= 0; i < selection.length; i++) {
                if (!(selection[i] instanceof IPackageFragment)) {
                    res.setError(JarPackagerMessages.JarManifestWizardPage_error_mustContainPackages);
                    return res;
                }
            }
            res.setOK();
            return res;
        }
    });
    return dialog;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GenerateToStringDialog.java   
@Override
public ISelectionStatusValidator getSelectionValidator() {
    return getValidator();
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:OutputLocationDialog.java   
private IContainer chooseOutputLocation() {
    IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot();
    final Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class };
    IProject[] allProjects= root.getProjects();
    ArrayList<IProject> rejectedElements= new ArrayList<IProject>(allProjects.length);
    for (int i= 0; i < allProjects.length; i++) {
        if (!allProjects[i].equals(fCurrProject)) {
            rejectedElements.add(allProjects[i]);
        }
    }
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray());

    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IResource initSelection= null;
    if (fOutputLocation != null) {
        initSelection= root.findMember(fOutputLocation);
    }

    FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp);
    dialog.setTitle(NewWizardMessages.OutputLocationDialog_ChooseOutputFolder_title);

       dialog.setValidator(new ISelectionStatusValidator() {
           ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false);
           public IStatus validate(Object[] selection) {
               IStatus typedStatus= validator.validate(selection);
               if (!typedStatus.isOK())
                   return typedStatus;
               if (selection[0] instanceof IFolder) {
                   IFolder folder= (IFolder) selection[0];
                   try {
                    IStatus result= ClasspathModifier.checkSetOutputLocationPrecondition(fEntryToEdit, folder.getFullPath(), fAllowInvalidClasspath, fCPJavaProject);
                    if (result.getSeverity() == IStatus.ERROR)
                        return result;
                   } catch (CoreException e) {
                    JavaPlugin.log(e);
                   }
                   return new StatusInfo();
               } else {
                return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$
               }
           }
       });
    dialog.setMessage(NewWizardMessages.OutputLocationDialog_ChooseOutputFolder_description);
    dialog.addFilter(filter);
    dialog.setInput(root);
    dialog.setInitialSelection(initSelection);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));

    if (dialog.open() == Window.OK) {
        return (IContainer)dialog.getFirstResult();
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExclusionInclusionEntryDialog.java   
public static IPath[] chooseExclusionPattern(Shell shell, IContainer currentSourceFolder, String title, String message, IPath initialPath, boolean multiSelection) {
    Class<?>[] acceptedClasses= new Class[] { IFolder.class, IFile.class };
    ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, multiSelection);
    ViewerFilter filter= new TypedViewerFilter(acceptedClasses);


    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IResource initialElement= null;
    if (initialPath != null) {
        IContainer curr= currentSourceFolder;
        int nSegments= initialPath.segmentCount();
        for (int i= 0; i < nSegments; i++) {
            IResource elem= curr.findMember(initialPath.segment(i));
            if (elem != null) {
                initialElement= elem;
            }
            if (elem instanceof IContainer) {
                curr= (IContainer) elem;
            } else {
                break;
            }
        }
    }

    ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(shell, lp, cp);
    dialog.setTitle(title);
    dialog.setValidator(validator);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currentSourceFolder);
    dialog.setInitialSelection(initialElement);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setHelpAvailable(false);

    if (dialog.open() == Window.OK) {
        Object[] objects= dialog.getResult();
        int existingSegments= currentSourceFolder.getFullPath().segmentCount();

        IPath[] resArr= new IPath[objects.length];
        for (int i= 0; i < objects.length; i++) {
            IResource currRes= (IResource) objects[i];
            IPath path= currRes.getFullPath().removeFirstSegments(existingSegments).makeRelative();
            if (currRes instanceof IContainer) {
                path= path.addTrailingSeparator();
            }
            resArr[i]= path;
        }
        return resArr;
    }
    return null;
}
项目:birt    文件:MoveResourceDialog.java   
/**
 * Constructs a dialog for moving resource.
 * 
 * @param files
 */
public MoveResourceDialog( final Collection<File> files )
{
    super( false, false, null );
    setTitle( Messages.getString( "MoveResourceDialog.Title" ) );
    setMessage( Messages.getString( "MoveResourceDialog.Message" ) );
    setDoubleClickSelects( true );
    setAllowMultiple( false );
    setHelpAvailable( false );
    setEmptyFolderShowStatus( IResourceContentProvider.ALWAYS_SHOW_EMPTYFOLDER );
    setValidator( new ISelectionStatusValidator( ) {

        public IStatus validate( Object[] selection )
        {
            for ( Object s : selection )
            {
                if ( s instanceof ResourceEntry )
                {
                    URL url = ( (ResourceEntry) s ).getURL( );
                    try {
                        url = URIUtil.toURI(url).toURL();
                    } catch (Exception e1) {
                    }
                    for ( File f : files )
                    {
                        try
                        {
                            if ( url.equals( f.getParentFile( )
                                    .toURI( )
                                    .toURL( ) )
                                    || url.equals( f.toURI( ).toURL( ) ) )
                                return new Status( IStatus.ERROR,
                                        ReportPlugin.REPORT_UI,
                                        "" );
                        }
                        catch ( MalformedURLException e )
                        {
                        }
                    }
                }
            }
            return new Status( IStatus.OK, ReportPlugin.REPORT_UI, "" );
        }
    } );
}
项目:birt    文件:NewResourceFileDialog.java   
public void setValidator( ISelectionStatusValidator validator )
{
    fValidator = validator;
}
项目:Pydev    文件:SelectExistingOrCreateNewDialog.java   
/**
 * Creates a special validator that considers that items may be gotten from what's filtered (not only actually selected).
 */
private ISelectionStatusValidator createValidator() {
    return new ISelectionStatusValidator() {

        @Override
        public IStatus validate(Object[] selection) {
            if (selection != null && selection.length == 1) {
                return new Status(IStatus.OK, PydevPlugin.getPluginID(), getEntry(selection[0].toString()));
            }
            TreeItem[] items = getTreeViewer().getTree().getItems();
            if (selection == null || selection.length == 0) {
                //not available in selection
                if (items != null) {
                    if (items.length == 1) {
                        return new Status(IStatus.OK, PydevPlugin.getPluginID(), getEntry(items[0].getData()
                                .toString()));
                    }
                    if (items.length > 0) {
                        String textInEditor = text.getText();
                        for (TreeItem item : items) {
                            if (item.getData().toString().equals(textInEditor)) {
                                //exact match of what's written to an item, so, just use it.
                                return new Status(IStatus.OK, PydevPlugin.getPluginID(), textInEditor);
                            }
                        }
                    }
                }
            }

            if ((selection == null || selection.length == 0) && (items == null || items.length == 0)) {
                return new Status(IStatus.ERROR, PydevPlugin.getPluginID(), "No selection available.");
            }

            return new Status(IStatus.ERROR, PydevPlugin.getPluginID(), "Only 1 entry may be selected or visible.");
        }

        private String getEntry(String string) {
            if (NEW_ENTRY_TEXT.equals(string)) {
                return text.getText();
            }
            return string;
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:TypeSelectionExtension.java   
/**
 * Returns the selection validator or <code>null</code> if
 * selection validation is not required. The elements passed
 * to the selection validator are of type {@link IType}.
 *
 * @return the selection validator or <code>null</code>
 */
public ISelectionStatusValidator getSelectionValidator() {
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:FilteredTypesSelectionDialog.java   
/**
 * Sets a new validator.
 *
 * @param validator
 *            the new validator
 */
public void setValidator(ISelectionStatusValidator validator) {
    fValidator= validator;
}
项目:translationstudio8    文件:ElementTreeSelectionDialog.java   
/**
 * Sets an optional validator to check if the selection is valid.
 * The validator is invoked whenever the selection changes.
 * @param validator the validator to validate the selection.
 */
public void setValidator(ISelectionStatusValidator validator) {
    fValidator = validator;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TypeSelectionExtension.java   
/**
 * Returns the selection validator or <code>null</code> if
 * selection validation is not required. The elements passed
 * to the selection validator are of type {@link IType}.
 *
 * @return the selection validator or <code>null</code>
 */
public ISelectionStatusValidator getSelectionValidator() {
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:FilteredTypesSelectionDialog.java   
/**
 * Sets a new validator.
 *
 * @param validator
 *            the new validator
 */
public void setValidator(ISelectionStatusValidator validator) {
    fValidator= validator;
}
项目:tmxeditor8    文件:ElementTreeSelectionDialog.java   
/**
 * Sets an optional validator to check if the selection is valid.
 * The validator is invoked whenever the selection changes.
 * @param validator the validator to validate the selection.
 */
public void setValidator(ISelectionStatusValidator validator) {
    fValidator = validator;
}