|
20 | 20 |
|
21 | 21 | package net.sf.eclipsecs.ui.actions; |
22 | 22 |
|
23 | | -import java.util.ArrayList; |
| 23 | +import java.util.Arrays; |
24 | 24 | import java.util.Collection; |
25 | | -import java.util.Collections; |
26 | 25 | import java.util.List; |
27 | | - |
28 | | -import net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy; |
29 | | -import net.sf.eclipsecs.core.config.ICheckConfiguration; |
30 | | -import net.sf.eclipsecs.core.config.ICheckConfigurationWorkingSet; |
31 | | -import net.sf.eclipsecs.core.projectconfig.IProjectConfiguration; |
32 | | -import net.sf.eclipsecs.core.projectconfig.ProjectConfigurationFactory; |
33 | | -import net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy; |
34 | | -import net.sf.eclipsecs.core.util.CheckstylePluginException; |
35 | | -import net.sf.eclipsecs.ui.CheckstyleUIPlugin; |
36 | | -import net.sf.eclipsecs.ui.Messages; |
| 26 | +import java.util.stream.Collectors; |
37 | 27 |
|
38 | 28 | import org.eclipse.core.resources.IProject; |
| 29 | +import org.eclipse.core.resources.ResourcesPlugin; |
39 | 30 | import org.eclipse.core.resources.WorkspaceJob; |
40 | 31 | import org.eclipse.core.runtime.IProgressMonitor; |
41 | 32 | import org.eclipse.core.runtime.IStatus; |
42 | 33 | import org.eclipse.core.runtime.Status; |
43 | 34 | import org.eclipse.jface.action.IAction; |
44 | | -import org.eclipse.jface.viewers.ArrayContentProvider; |
45 | 35 | import org.eclipse.jface.viewers.ISelection; |
46 | 36 | import org.eclipse.jface.viewers.IStructuredSelection; |
47 | 37 | import org.eclipse.jface.window.Window; |
48 | 38 | import org.eclipse.ui.IObjectActionDelegate; |
49 | 39 | import org.eclipse.ui.IWorkbenchPart; |
50 | | -import org.eclipse.ui.dialogs.ListDialog; |
| 40 | +import org.eclipse.ui.dialogs.ElementListSelectionDialog; |
51 | 41 | import org.eclipse.ui.model.WorkbenchLabelProvider; |
52 | 42 |
|
| 43 | +import net.sf.eclipsecs.core.config.CheckConfigurationWorkingCopy; |
| 44 | +import net.sf.eclipsecs.core.config.ICheckConfiguration; |
| 45 | +import net.sf.eclipsecs.core.config.ICheckConfigurationWorkingSet; |
| 46 | +import net.sf.eclipsecs.core.projectconfig.IProjectConfiguration; |
| 47 | +import net.sf.eclipsecs.core.projectconfig.ProjectConfigurationFactory; |
| 48 | +import net.sf.eclipsecs.core.projectconfig.ProjectConfigurationWorkingCopy; |
| 49 | +import net.sf.eclipsecs.core.util.CheckstylePluginException; |
| 50 | +import net.sf.eclipsecs.ui.CheckstyleUIPlugin; |
| 51 | +import net.sf.eclipsecs.ui.Messages; |
| 52 | + |
53 | 53 | /** |
54 | 54 | * Action to configure one ore more projects at once by using another project as |
55 | 55 | * blueprint. |
@@ -79,18 +79,17 @@ public void selectionChanged(IAction action, ISelection selection) { |
79 | 79 |
|
80 | 80 | @Override |
81 | 81 | public void run(IAction action) { |
82 | | - |
83 | | - IProject[] projects = CheckstyleUIPlugin.getWorkspace().getRoot().getProjects(); |
84 | | - List<IProject> filteredProjects = new ArrayList<>(); |
85 | | - Collections.addAll(filteredProjects, projects); |
| 82 | + List<IProject> filteredProjects = Arrays |
| 83 | + .stream(ResourcesPlugin.getWorkspace().getRoot().getProjects()) |
| 84 | + .filter(IProject::isAccessible) |
| 85 | + .collect(Collectors.toList()); |
86 | 86 |
|
87 | 87 | filteredProjects.removeAll(mSelectedProjects); |
88 | 88 |
|
89 | | - ListDialog dialog = new ListDialog(mPart.getSite().getShell()); |
| 89 | + ElementListSelectionDialog dialog = new ElementListSelectionDialog(mPart.getSite().getShell(), |
| 90 | + new WorkbenchLabelProvider()); |
| 91 | + dialog.setElements(filteredProjects.toArray(new IProject[0])); |
90 | 92 | dialog.setHelpAvailable(false); |
91 | | - dialog.setInput(filteredProjects); |
92 | | - dialog.setContentProvider(new ArrayContentProvider()); |
93 | | - dialog.setLabelProvider(new WorkbenchLabelProvider()); |
94 | 93 | dialog.setMessage(Messages.ConfigureProjectFromBluePrintAction_msgSelectBlueprintProject); |
95 | 94 | dialog.setTitle(Messages.ConfigureProjectFromBluePrintAction_titleSelectBlueprintProject); |
96 | 95 | if (Window.OK == dialog.open()) { |
|
0 commit comments