Skip to content

Commit 72370df

Browse files
committed
Merge branch 'mega-split'
This branch migrates many non-image-specific services from the ImageJ core component. This includes the module and command frameworks, including widgets (module preprocessing that handles inputs) and displays (module postprocessing that handles outputs). It also includes the menu, options, platform, script and tool services. Migrated from: https://github.com/imagej/imagej/tree/imagej-2.0.0-beta-7.9/core/core/src/main/java/imagej
2 parents 3210a47 + 19effef commit 72370df

File tree

224 files changed

+24049
-504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+24049
-504
lines changed

src/main/java/org/scijava/AbstractGateway.java

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,29 @@
3535
import org.scijava.app.AppService;
3636
import org.scijava.app.SciJavaApp;
3737
import org.scijava.app.StatusService;
38+
import org.scijava.command.CommandService;
39+
import org.scijava.console.ConsoleService;
40+
import org.scijava.display.DisplayService;
3841
import org.scijava.event.EventHistory;
3942
import org.scijava.event.EventService;
43+
import org.scijava.io.IOService;
44+
import org.scijava.io.RecentFileService;
4045
import org.scijava.log.LogService;
46+
import org.scijava.menu.MenuService;
47+
import org.scijava.module.ModuleService;
4148
import org.scijava.object.ObjectService;
49+
import org.scijava.options.OptionsService;
50+
import org.scijava.platform.AppEventService;
51+
import org.scijava.platform.PlatformService;
4252
import org.scijava.plugin.AbstractRichPlugin;
4353
import org.scijava.plugin.PluginService;
54+
import org.scijava.script.ScriptService;
4455
import org.scijava.service.Service;
56+
import org.scijava.text.TextService;
4557
import org.scijava.thread.ThreadService;
58+
import org.scijava.tool.IconService;
59+
import org.scijava.tool.ToolService;
60+
import org.scijava.widget.WidgetService;
4661

4762
/**
4863
* Abstract superclass for {@link Gateway} implementations.
@@ -81,11 +96,31 @@ public Service get(final String serviceClassName) {
8196

8297
// -- Gateway methods - services --
8398

99+
@Override
100+
public AppEventService appEvent() {
101+
return get(AppEventService.class);
102+
}
103+
84104
@Override
85105
public AppService app() {
86106
return get(AppService.class);
87107
}
88108

109+
@Override
110+
public CommandService command() {
111+
return get(CommandService.class);
112+
}
113+
114+
@Override
115+
public ConsoleService console() {
116+
return get(ConsoleService.class);
117+
}
118+
119+
@Override
120+
public DisplayService display() {
121+
return get(DisplayService.class);
122+
}
123+
89124
@Override
90125
public EventHistory eventHistory() {
91126
return get(EventHistory.class);
@@ -96,31 +131,86 @@ public EventService event() {
96131
return get(EventService.class);
97132
}
98133

134+
@Override
135+
public IconService icon() {
136+
return get(IconService.class);
137+
}
138+
139+
@Override
140+
public IOService io() {
141+
return get(IOService.class);
142+
}
143+
99144
@Override
100145
public LogService log() {
101146
return get(LogService.class);
102147
}
103148

149+
@Override
150+
public MenuService menu() {
151+
return get(MenuService.class);
152+
}
153+
154+
@Override
155+
public ModuleService module() {
156+
return get(ModuleService.class);
157+
}
158+
104159
@Override
105160
public ObjectService object() {
106161
return get(ObjectService.class);
107162
}
108163

164+
@Override
165+
public OptionsService options() {
166+
return get(OptionsService.class);
167+
}
168+
169+
@Override
170+
public PlatformService platform() {
171+
return get(PlatformService.class);
172+
}
173+
109174
@Override
110175
public PluginService plugin() {
111176
return get(PluginService.class);
112177
}
113178

179+
@Override
180+
public RecentFileService recentFile() {
181+
return get(RecentFileService.class);
182+
}
183+
184+
@Override
185+
public ScriptService script() {
186+
return get(ScriptService.class);
187+
}
188+
114189
@Override
115190
public StatusService status() {
116191
return get(StatusService.class);
117192
}
118193

194+
@Override
195+
public TextService text() {
196+
return get(TextService.class);
197+
}
198+
119199
@Override
120200
public ThreadService thread() {
121201
return get(ThreadService.class);
122202
}
123203

204+
@Override
205+
public ToolService tool() {
206+
return get(ToolService.class);
207+
}
208+
209+
@Override
210+
public WidgetService widget() {
211+
return get(WidgetService.class);
212+
}
213+
124214
// -- Gateway methods - application --
125215

126216
@Override
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* #%L
3+
* SciJava Common shared library for SciJava software.
4+
* %%
5+
* Copyright (C) 2009 - 2014 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava;
33+
34+
/**
35+
* An operation that can be canceled.
36+
*
37+
* @author Curtis Rueden
38+
*/
39+
public interface Cancelable {
40+
41+
/** Gets whether the operation has been canceled. */
42+
boolean isCanceled();
43+
44+
/**
45+
* Cancels the operation execution, with the given reason for doing so.
46+
* <p>
47+
* This method merely sets the operation status to canceled; it cannot
48+
* necessarily stop the operation itself. That is, it is the responsibility of
49+
* each individual operation to check {@link #isCanceled()} in a timely manner
50+
* during execution, and stop doing whatever it is doing if the flag has been
51+
* tripped.
52+
* </p>
53+
*
54+
* @param reason A message describing why the operation is being canceled.
55+
*/
56+
void cancel(String reason);
57+
58+
/**
59+
* Gets a message describing why the operation was canceled.
60+
*
61+
* @return The reason for cancelation, which may be null if no reason was
62+
* given, or if the operation was not in fact canceled.
63+
*/
64+
String getCancelReason();
65+
66+
}

src/main/java/org/scijava/Gateway.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,30 @@
3434
import org.scijava.app.App;
3535
import org.scijava.app.AppService;
3636
import org.scijava.app.StatusService;
37+
import org.scijava.command.CommandService;
38+
import org.scijava.console.ConsoleService;
39+
import org.scijava.display.DisplayService;
3740
import org.scijava.event.EventHistory;
3841
import org.scijava.event.EventService;
42+
import org.scijava.io.IOService;
43+
import org.scijava.io.RecentFileService;
3944
import org.scijava.log.LogService;
45+
import org.scijava.menu.MenuService;
46+
import org.scijava.module.ModuleService;
4047
import org.scijava.object.ObjectService;
48+
import org.scijava.options.OptionsService;
49+
import org.scijava.platform.AppEventService;
50+
import org.scijava.platform.PlatformService;
4151
import org.scijava.plugin.Plugin;
4252
import org.scijava.plugin.PluginService;
4353
import org.scijava.plugin.RichPlugin;
54+
import org.scijava.script.ScriptService;
4455
import org.scijava.service.Service;
56+
import org.scijava.text.TextService;
4557
import org.scijava.thread.ThreadService;
58+
import org.scijava.tool.IconService;
59+
import org.scijava.tool.ToolService;
60+
import org.scijava.widget.WidgetService;
4661

4762
/**
4863
* Interface for convenience classes that wrap a {@link Context} to provide
@@ -127,22 +142,52 @@ public interface Gateway extends RichPlugin {
127142

128143
// -- Gateway methods - services --
129144

145+
AppEventService appEvent();
146+
130147
AppService app();
131148

149+
CommandService command();
150+
151+
ConsoleService console();
152+
153+
DisplayService display();
154+
132155
EventHistory eventHistory();
133156

134157
EventService event();
135158

159+
IconService icon();
160+
161+
IOService io();
162+
136163
LogService log();
137164

165+
MenuService menu();
166+
167+
ModuleService module();
168+
138169
ObjectService object();
139170

171+
OptionsService options();
172+
173+
PlatformService platform();
174+
140175
PluginService plugin();
141176

177+
RecentFileService recentFile();
178+
179+
ScriptService script();
180+
142181
StatusService status();
143182

183+
TextService text();
184+
144185
ThreadService thread();
145186

187+
ToolService tool();
188+
189+
WidgetService widget();
190+
146191
// -- Gateway methods - application --
147192

148193
/** @see org.scijava.app.AppService */
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* #%L
3+
* SciJava Common shared library for SciJava software.
4+
* %%
5+
* Copyright (C) 2009 - 2014 Board of Regents of the University of
6+
* Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
7+
* Institute of Molecular Cell Biology and Genetics.
8+
* %%
9+
* Redistribution and use in source and binary forms, with or without
10+
* modification, are permitted provided that the following conditions are met:
11+
*
12+
* 1. Redistributions of source code must retain the above copyright notice,
13+
* this list of conditions and the following disclaimer.
14+
* 2. Redistributions in binary form must reproduce the above copyright notice,
15+
* this list of conditions and the following disclaimer in the documentation
16+
* and/or other materials provided with the distribution.
17+
*
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28+
* POSSIBILITY OF SUCH DAMAGE.
29+
* #L%
30+
*/
31+
32+
package org.scijava;
33+
34+
import java.io.Serializable;
35+
36+
/**
37+
* An object which can express itself by some unique string.
38+
* <p>
39+
* Two objects that produce the same identifier string can be considered
40+
* equivalent by some metric. The main use case for these identifiers is as a
41+
* weak form of long-term serialization:
42+
* </p>
43+
* <ol>
44+
* <li>An object's identifier is saved to long-term storage such as disk.</li>
45+
* <li>Later, in a new JVM, the identifier is retrieved from disk.</li>
46+
* <li>An existing index of objects is queried to find the object (if any) whose
47+
* identifier matches the retrieved one.</li>
48+
* </ol>
49+
* <p>
50+
* In this way, objects themselves do not need to be {@link Serializable}, nor
51+
* do multiple potentially equivalent objects need to be synthesized and then
52+
* compared using {@link #equals}.
53+
* </p>
54+
*
55+
* @author Curtis Rueden
56+
*/
57+
public interface Identifiable {
58+
59+
/** Gets a string intended to function as an identifier for the object. */
60+
String getIdentifier();
61+
62+
}

0 commit comments

Comments
 (0)