Skip to content

Commit 045242f

Browse files
committed
SystemInformation: show a progress bar
For whatever reason, computing all the system information takes several seconds. So let's report progress as we go. This might still not be granular enough, depending on which loop(s) are taking the most time. Can be improved further later as needed.
1 parent 8c7060c commit 045242f

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/main/java/org/scijava/plugins/commands/debug/SystemInformation.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.scijava.ItemIO;
4646
import org.scijava.app.App;
4747
import org.scijava.app.AppService;
48+
import org.scijava.app.StatusService;
4849
import org.scijava.command.Command;
4950
import org.scijava.plugin.Parameter;
5051
import org.scijava.plugin.Plugin;
@@ -76,19 +77,29 @@ public class SystemInformation implements Command {
7677
@Parameter
7778
private AppService appService;
7879

80+
@Parameter
81+
private StatusService statusService;
82+
7983
@Parameter(label = "System Information", type = ItemIO.OUTPUT)
8084
private String info;
8185

8286
// -- Runnable methods --
8387

8488
@Override
8589
public void run() {
90+
int progress = 0, max = 8;
91+
statusService.showStatus(0, max, "Gathering system information");
92+
8693
final StringBuilder sb = new StringBuilder();
8794

8895
// dump basic version information (similar to the status bar)
96+
8997
sb.append(appService.getApp().getInfo(false) + NL);
9098

99+
statusService.showProgress(++progress, max);
100+
91101
// dump information about available SciJava applications
102+
92103
final Map<String, App> apps = appService.getApps();
93104
for (final String name : apps.keySet()) {
94105
final App app = apps.get(name);
@@ -104,6 +115,8 @@ public void run() {
104115
}
105116
}
106117

118+
statusService.showProgress(++progress, max);
119+
107120
// dump all available Maven metadata on the class path
108121

109122
final List<POM> poms = POM.getAllPOMs();
@@ -125,6 +138,8 @@ public void run() {
125138
}
126139
}
127140

141+
statusService.showProgress(++progress, max);
142+
128143
// output libraries in sorted order
129144
final ArrayList<POM> sortedPOMs = new ArrayList<POM>(poms);
130145
Collections.sort(sortedPOMs);
@@ -151,15 +166,21 @@ public void run() {
151166
if (orgURL != null) sb.append("\torganization URL = " + orgURL + NL);
152167
}
153168

169+
statusService.showProgress(++progress, max);
170+
154171
// compute the set of known plugin types
172+
155173
final List<PluginInfo<?>> plugins = context.getPluginIndex().getAll();
156174
final HashSet<Class<? extends SciJavaPlugin>> pluginTypeSet =
157175
new HashSet<Class<? extends SciJavaPlugin>>();
158176
for (final PluginInfo<?> plugin : plugins) {
159177
pluginTypeSet.add(plugin.getPluginType());
160178
}
161179

180+
statusService.showProgress(++progress, max);
181+
162182
// convert to a list of plugin types, sorted by fully qualified class name
183+
163184
final ArrayList<Class<? extends SciJavaPlugin>> pluginTypes =
164185
new ArrayList<Class<? extends SciJavaPlugin>>(pluginTypeSet);
165186
Collections.sort(pluginTypes, new Comparator<Class<?>>() {
@@ -171,17 +192,27 @@ public int compare(final Class<?> c1, final Class<?> c2) {
171192

172193
});
173194

195+
statusService.showProgress(++progress, max);
196+
174197
// dump the list of available plugins, organized by plugin type
198+
175199
for (final Class<? extends SciJavaPlugin> pluginType : pluginTypes) {
176200
dumpPlugins(sb, pluginType);
177201
}
178202

203+
statusService.showProgress(++progress, max);
204+
179205
// dump system properties
206+
180207
sb.append(NL);
181208
sb.append("-- System properties --" + NL);
182209
sb.append(getSystemProperties());
183210

211+
statusService.showProgress(++progress, max);
212+
184213
info = sb.toString();
214+
215+
statusService.clearStatus();
185216
}
186217

187218
// -- Utility methods --

0 commit comments

Comments
 (0)