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

项目:gerrit-tools    文件:ExportProjectsDialog.java   
public List<IProject> select() {
    CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(
            shell, 
            new WorkbenchLabelProvider(),
            new ProjectSelectionContentProvider()) {
        @Override
        protected Label createMessageArea(Composite composite) {
            Label label = new Label(composite, SWT.WRAP);
            if (getMessage() != null) {
                label.setText(getMessage());
            }
            label.setFont(composite.getFont());
            GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
            gd.widthHint = 300;
            label.setLayoutData(gd);
            return label;
        }
    };
    dialog.setContainerMode(true);
    dialog.setMessage("Choose projects to export");
    dialog.setTitle("Project selection");
    dialog.setInput(ResourcesPlugin.getWorkspace());
    dialog.setInitialSelection(ResourcesPlugin.getWorkspace().getRoot().getProjects());
    if (dialog.open() == Dialog.OK && dialog.getResult() != null) {
        ArrayList<IProject> projects = new ArrayList<IProject>();
        for (Object o: dialog.getResult()) {
            if (o instanceof IProject) {
                projects.add((IProject)o);
            }
        }
        return projects;
    }
    return Collections.emptyList();
}
项目:gerrit-tools    文件:ObsoleteProjectsDialog.java   
public List<IProject> select(Set<IProject> obsoleteProjects) {
    CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(
            shell, 
            new WorkbenchLabelProvider(),
            new ProjectSelectionContentProvider()) {

        @Override
        protected Label createMessageArea(Composite composite) {
            Label label = new Label(composite, SWT.WRAP);
            if (getMessage() != null) {
                label.setText(getMessage());
            }
            label.setFont(composite.getFont());
            GridData gd = new GridData(SWT.FILL, SWT.FILL, true, false);
            gd.widthHint = 300;
            label.setLayoutData(gd);
            return label;
        }
    };
    dialog.setContainerMode(true);
    dialog.setMessage("Following project has been detected as obsolete, please select those to be removed from your workspace. Note, that their contents will not be removed from the file system.");
    dialog.setTitle("Delete obsolete projects");
    dialog.setInput(obsoleteProjects);
    if (dialog.open() == Dialog.OK && dialog.getResult() != null) {
        ArrayList<IProject> projects = new ArrayList<IProject>();
        for (Object o: dialog.getResult()) {
            if (o instanceof IProject) {
                projects.add((IProject)o);
            }
        }
        return projects;
    }
    return Collections.emptyList();
}
项目:gerrit-tools    文件:CleanupChangesDialog.java   
public List<String> select(Repository repo) {
    CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(
            shell, 
            new BranchesLabelProvider(),
            new BranchesContentProvider()) {
        @Override
        public void create() {
            super.create();
            getTreeViewer().expandAll();
        }
    };
    dialog.setContainerMode(true);
    dialog.setMessage("Choose change branches to remove from local repository:");
    dialog.setTitle("Changes cleanup");
    dialog.setInput(repo);
    dialog.setInitialSelection(ResourcesPlugin.getWorkspace().getRoot().getProjects());
    if (dialog.open() == Dialog.OK && dialog.getResult() != null) {
        ArrayList<String> changes = new ArrayList<String>();
        for (Object o: dialog.getResult()) {
            if (o instanceof Change) {
                changes.add(((Change)o).getFullName());
            }
        }
        return changes;
    }
    return Collections.emptyList();
}