Skip to content

Commit accbed8

Browse files
committed
Merge scijava-plugins-platforms codebase
In preparation for unifying to a single scijava-desktop component.
2 parents 54d4dc7 + fb6d439 commit accbed8

File tree

6 files changed

+482
-3
lines changed

6 files changed

+482
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
/.classpath
12
/.idea/
3+
/.project
4+
/.settings/
25
/target/

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2023 - 2025, SciJava developers.
1+
Copyright (c) 2010 - 2025, SciJava developers.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification,

pom.xml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
<name>SciJava Links</name>
1717
<description>URL scheme handlers for SciJava.</description>
1818
<url>https://github.com/scijava/scijava-links</url>
19-
<inceptionYear>2023</inceptionYear>
19+
<inceptionYear>2010</inceptionYear>
2020
<organization>
2121
<name>SciJava</name>
2222
<url>https://scijava.org/</url>
2323
</organization>
24-
2524
<licenses>
2625
<license>
2726
<name>Simplified BSD License</name>
@@ -37,6 +36,7 @@
3736
<roles>
3837
<role>founder</role>
3938
<role>lead</role>
39+
<role>developer</role>
4040
<role>debugger</role>
4141
<role>reviewer</role>
4242
<role>support</role>
@@ -45,6 +45,16 @@
4545
</developer>
4646
</developers>
4747
<contributors>
48+
<contributor>
49+
<name>Mark Hiner</name>
50+
<url>https://imagej.net/User:Hinerm</url>
51+
<properties><id>hinerm</id></properties>
52+
</contributor>
53+
<contributor>
54+
<name>Johannes Schindelin</name>
55+
<url>https://imagej.net/User:Schindelin</url>
56+
<properties><id>dscho</id></properties>
57+
</contributor>
4858
<contributor>
4959
<name>Marwan Zouinkhi</name>
5060
<url>https://imagej.net/people/mzouink</url>
@@ -58,6 +68,13 @@
5868
<name>Image.sc Forum</name>
5969
<archive>https://forum.image.sc/tag/scijava</archive>
6070
</mailingList>
71+
<mailingList>
72+
<name>SciJava</name>
73+
<subscribe>https://groups.google.com/group/scijava</subscribe>
74+
<unsubscribe>https://groups.google.com/group/scijava</unsubscribe>
75+
<post>scijava@googlegroups.com</post>
76+
<archive>https://groups.google.com/group/scijava</archive>
77+
</mailingList>
6178
</mailingLists>
6279

6380
<scm>
@@ -85,10 +102,20 @@
85102
</properties>
86103

87104
<dependencies>
105+
<!-- SciJava dependencies -->
88106
<dependency>
89107
<groupId>org.scijava</groupId>
90108
<artifactId>scijava-common</artifactId>
91109
</dependency>
110+
111+
<!-- Third-party dependencies -->
112+
<dependency>
113+
<groupId>com.yuvimasory</groupId>
114+
<artifactId>orange-extensions</artifactId>
115+
<version>1.3.0</version>
116+
<scope>provided</scope>
117+
</dependency>
118+
92119
<dependency>
93120
<groupId>junit</groupId>
94121
<artifactId>junit</artifactId>
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
/*
2+
* #%L
3+
* Core platform plugins for SciJava applications.
4+
* %%
5+
* Copyright (C) 2010 - 2015 Board of Regents of the University of
6+
* Wisconsin-Madison.
7+
* %%
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions are met:
10+
*
11+
* 1. Redistributions of source code must retain the above copyright notice,
12+
* this list of conditions and the following disclaimer.
13+
* 2. Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
21+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27+
* POSSIBILITY OF SUCH DAMAGE.
28+
* #L%
29+
*/
30+
31+
package org.scijava.plugins.platforms.macos;
32+
33+
import com.apple.eawt.AboutHandler;
34+
import com.apple.eawt.AppEvent.AboutEvent;
35+
import com.apple.eawt.AppEvent.AppForegroundEvent;
36+
import com.apple.eawt.AppEvent.AppHiddenEvent;
37+
import com.apple.eawt.AppEvent.AppReOpenedEvent;
38+
import com.apple.eawt.AppEvent.OpenFilesEvent;
39+
import com.apple.eawt.AppEvent.PreferencesEvent;
40+
import com.apple.eawt.AppEvent.PrintFilesEvent;
41+
import com.apple.eawt.AppEvent.QuitEvent;
42+
import com.apple.eawt.AppEvent.ScreenSleepEvent;
43+
import com.apple.eawt.AppEvent.SystemSleepEvent;
44+
import com.apple.eawt.AppEvent.UserSessionEvent;
45+
import com.apple.eawt.AppForegroundListener;
46+
import com.apple.eawt.AppHiddenListener;
47+
import com.apple.eawt.AppReOpenedListener;
48+
import com.apple.eawt.Application;
49+
import com.apple.eawt.OpenFilesHandler;
50+
import com.apple.eawt.PreferencesHandler;
51+
import com.apple.eawt.PrintFilesHandler;
52+
import com.apple.eawt.QuitHandler;
53+
import com.apple.eawt.QuitResponse;
54+
import com.apple.eawt.ScreenSleepListener;
55+
import com.apple.eawt.SystemSleepListener;
56+
import com.apple.eawt.UserSessionListener;
57+
58+
import org.scijava.event.EventService;
59+
import org.scijava.platform.event.AppAboutEvent;
60+
import org.scijava.platform.event.AppFocusEvent;
61+
import org.scijava.platform.event.AppOpenFilesEvent;
62+
import org.scijava.platform.event.AppPreferencesEvent;
63+
import org.scijava.platform.event.AppPrintEvent;
64+
import org.scijava.platform.event.AppQuitEvent;
65+
import org.scijava.platform.event.AppReOpenEvent;
66+
import org.scijava.platform.event.AppScreenSleepEvent;
67+
import org.scijava.platform.event.AppSystemSleepEvent;
68+
import org.scijava.platform.event.AppUserSessionEvent;
69+
import org.scijava.platform.event.AppVisibleEvent;
70+
71+
/**
72+
* Rebroadcasts macOS application events as ImageJ events.
73+
*
74+
* @author Curtis Rueden
75+
*/
76+
public class MacOSAppEventDispatcher implements AboutHandler,
77+
AppForegroundListener, AppHiddenListener, AppReOpenedListener,
78+
PreferencesHandler, PrintFilesHandler, QuitHandler, ScreenSleepListener,
79+
SystemSleepListener, UserSessionListener, OpenFilesHandler
80+
{
81+
82+
private final EventService eventService;
83+
84+
public MacOSAppEventDispatcher(final EventService eventService) {
85+
this(Application.getApplication(), eventService);
86+
}
87+
88+
public MacOSAppEventDispatcher(final Application app,
89+
final EventService eventService)
90+
{
91+
this.eventService = eventService;
92+
app.setAboutHandler(this);
93+
app.setPreferencesHandler(this);
94+
app.setPrintFileHandler(this);
95+
app.setQuitHandler(this);
96+
app.addAppEventListener(this);
97+
app.setOpenFileHandler(this);
98+
}
99+
100+
// -- AboutHandler methods --
101+
102+
@Override
103+
public void handleAbout(final AboutEvent e) {
104+
eventService.publish(new AppAboutEvent());
105+
}
106+
107+
// -- PreferencesHandler methods --
108+
109+
@Override
110+
public void handlePreferences(final PreferencesEvent e) {
111+
eventService.publish(new AppPreferencesEvent());
112+
}
113+
114+
// -- PrintFilesHandler --
115+
116+
@Override
117+
public void printFiles(final PrintFilesEvent e) {
118+
eventService.publish(new AppPrintEvent());
119+
}
120+
121+
// -- QuitHandler methods --
122+
123+
@Override
124+
public void handleQuitRequestWith(final QuitEvent e, final QuitResponse r) {
125+
eventService.publish(new AppQuitEvent());
126+
r.cancelQuit();
127+
}
128+
129+
// -- UserSessionListener methods --
130+
131+
@Override
132+
public void userSessionActivated(final UserSessionEvent e) {
133+
eventService.publish(new AppUserSessionEvent(true));
134+
}
135+
136+
@Override
137+
public void userSessionDeactivated(final UserSessionEvent e) {
138+
eventService.publish(new AppUserSessionEvent(false));
139+
}
140+
141+
// -- SystemSleepListener methods --
142+
143+
@Override
144+
public void systemAboutToSleep(final SystemSleepEvent e) {
145+
eventService.publish(new AppSystemSleepEvent(true));
146+
}
147+
148+
//@Override
149+
public void systemAwoke(final SystemSleepEvent e) {
150+
eventService.publish(new AppSystemSleepEvent(false));
151+
}
152+
153+
public void systemAweoke(final SystemSleepEvent e) {
154+
// HACK: To make com.yuvimasory:orange-extensions:1.3 happy.
155+
// See: https://github.com/ymasory/OrangeExtensions/pull/10
156+
}
157+
158+
// -- ScreenSleepListener methods --
159+
160+
@Override
161+
public void screenAboutToSleep(final ScreenSleepEvent e) {
162+
eventService.publish(new AppScreenSleepEvent(true));
163+
}
164+
165+
@Override
166+
public void screenAwoke(final ScreenSleepEvent e) {
167+
eventService.publish(new AppScreenSleepEvent(false));
168+
}
169+
170+
// -- AppHiddenListener methods --
171+
172+
@Override
173+
public void appHidden(final AppHiddenEvent e) {
174+
eventService.publish(new AppVisibleEvent(false));
175+
}
176+
177+
@Override
178+
public void appUnhidden(final AppHiddenEvent e) {
179+
eventService.publish(new AppVisibleEvent(true));
180+
}
181+
182+
// -- AppForegroundListener methods --
183+
184+
@Override
185+
public void appMovedToBackground(final AppForegroundEvent e) {
186+
eventService.publish(new AppFocusEvent(false));
187+
}
188+
189+
@Override
190+
public void appRaisedToForeground(final AppForegroundEvent e) {
191+
eventService.publish(new AppFocusEvent(true));
192+
}
193+
194+
// -- AppReOpenedListener methods --
195+
196+
@Override
197+
public void appReOpened(final AppReOpenedEvent e) {
198+
eventService.publish(new AppReOpenEvent());
199+
}
200+
201+
// -- OpenFilesHandler methods --
202+
203+
@Override
204+
public void openFiles(final OpenFilesEvent event) {
205+
eventService.publish(new AppOpenFilesEvent(event.getFiles()));
206+
}
207+
208+
}

0 commit comments

Comments
 (0)