Correct compilation errors from refactored base

This commit is contained in:
2015-06-25 17:14:26 +01:00
parent ce7492d9ff
commit 4437891be6
36 changed files with 319 additions and 273 deletions

View File

@@ -86,7 +86,7 @@ public abstract class Worker {
}
}
protected void sleep() {
public void sleep() {
sleep(SLEEP);
}

View File

@@ -16,7 +16,6 @@
*/
package mimis;
import base.worker.Listener;
import mimis.input.Button;
import mimis.input.Feedback;
import mimis.input.Input;
@@ -28,8 +27,10 @@ import mimis.parser.ParserInput;
import mimis.router.Router;
import mimis.state.TaskMap;
import mimis.value.Action;
import base.work.Listen;
import base.worker.Worker.Type;
public abstract class Component extends Listener<Input> {
public abstract class Component extends Listen<Input> {
protected static final String TITLE = "Component";
protected String title;
@@ -39,11 +40,15 @@ public abstract class Component extends Listener<Input> {
this(TITLE);
}
public Component(Type type) {
super(type);
}
public Component(String title) {
this.title = title;
}
public void setRouter(Router router) {
public void setRouter(Router router) {
this.router = router;
}

View File

@@ -53,7 +53,7 @@ public class Gui extends Component {
createFrame(buttonManagerArray);
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
listen(Feedback.class);
super.activate();
}

View File

@@ -82,7 +82,7 @@ public class Main extends Mimis {
end(Action.CURRENT);
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
logger.debug("Stop managers");
@@ -112,6 +112,6 @@ public class Main extends Mimis {
}
public static void main(String[] args) {
new Main().start(false);
new Main().start();
}
}

View File

@@ -16,16 +16,17 @@
*/
package mimis;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import mimis.input.Feedback;
import mimis.input.Task;
import mimis.manager.Manager;
import mimis.parser.Parser;
import mimis.router.Router;
import mimis.util.ArrayCycle;
import mimis.value.Action;
import mimis.value.Target;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.util.ArrayCycle;
import base.worker.Worker;
public abstract class Mimis extends Component {
protected Component[] currentArray;
@@ -34,6 +35,7 @@ public abstract class Mimis extends Component {
protected ArrayCycle<Component> componentCycle;
public Mimis(Component... currentArray) {
super(Worker.Type.FOREGROUND);
this.currentArray = initialize(false, currentArray);
componentCycle = new ArrayCycle<Component>(currentArray);
router = new Router();
@@ -45,7 +47,7 @@ public abstract class Mimis extends Component {
super.activate();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
manager.stop();
}

View File

@@ -42,7 +42,7 @@ public abstract class CMDApplication extends Component implements Application {
detect = true;
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
detect = true;
if (!running) {
String path = getPath();
@@ -64,15 +64,14 @@ public abstract class CMDApplication extends Component implements Application {
public boolean active() {
if (detect) {
running = Native.isRunning(program);
if (!active && running) {
active = true;
if (!running) {
start();
}
}
return active;
return super.active();
}
protected synchronized void deactivate() throws DeactivateException {
public synchronized void deactivate() throws DeactivateException {
detect = false;
super.deactivate();
if (process != null) {

View File

@@ -42,7 +42,7 @@ public abstract class WindowsApplication extends CMDApplication {
handle = 0;
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
if (program != null) {
super.activate();
}
@@ -51,14 +51,13 @@ public abstract class WindowsApplication extends CMDApplication {
sleep(START_SLEEP);
handle = Native.getHandle(window);
}
active = handle > 0;
if (!active) {
if (handle < 0) {
throw new ActivateException();
}
}
public boolean active() {
if (!active || program == null) {
if (!super.active() || program == null) {
handle = Native.getHandle(window);
if (handle > 0 && program == null) {
start();
@@ -67,13 +66,11 @@ public abstract class WindowsApplication extends CMDApplication {
return program == null ? handle > 0 : super.active();
}
protected void deactivate() throws DeactivateException {
if (process == null) {
active = false;
} else {
super.deactivate();
public void deactivate() throws DeactivateException {
if (process != null) {
close();
}
close();
super.deactivate();
}
protected void close() {

View File

@@ -16,12 +16,12 @@
*/
package mimis.application.cmd.windows.gomplayer;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action;
import mimis.value.Amount;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.work.Work;
public class GomPlayerApplication extends WindowsApplication {
protected final static String PROGRAM = "GOM.exe";
@@ -31,48 +31,50 @@ public class GomPlayerApplication extends WindowsApplication {
protected static final int VOLUME_SLEEP = 100;
protected static final int SEEK_SLEEP = 100;
protected VolumeWorker volumeWorker;
protected SeekWorker seekWorker;
protected VolumeWork volumeWork;
protected SeekWork seekWork;
public GomPlayerApplication() {
super(PROGRAM, TITLE, WINDOW);
volumeWorker = new VolumeWorker();
seekWorker = new SeekWorker();
volumeWork = new VolumeWork();
seekWork = new SeekWork();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
volumeWorker.stop();
seekWorker.stop();
volumeWork.stop();
seekWork.stop();
}
public void exit() {
super.exit();
volumeWorker.exit();
seekWorker.exit();
volumeWork.exit();
seekWork.exit();
}
public void begin(Action action) {
logger.trace("GomPlayerApplication begin: " + action);
switch (action) {
case VOLUME_UP:
volumeWorker.start();
volumeWork.start();
break;
case VOLUME_DOWN:
volumeWorker.start();
volumeWork.start();
break;
case FORWARD:
seekWorker.start(Amount.SMALL, 1);
seekWork.start(Amount.SMALL, 1);
break;
case REWIND:
seekWorker.start(Amount.SMALL, -1);
seekWork.start(Amount.SMALL, -1);
break;
case NEXT:
seekWorker.start(Amount.MEDIUM, 1);
seekWork.start(Amount.MEDIUM, 1);
break;
case PREVIOUS:
seekWorker.start(Amount.MEDIUM, -1);
break;
seekWork.start(Amount.MEDIUM, -1);
break;
default:
break;
}
}
@@ -89,19 +91,21 @@ public class GomPlayerApplication extends WindowsApplication {
case REWIND:
case NEXT:
case PREVIOUS:
seekWorker.stop();
seekWork.stop();
break;
case VOLUME_UP:
case VOLUME_DOWN:
volumeWorker.stop();
volumeWork.stop();
break;
case FULLSCREEN:
command(0x8154);
break;
default:
break;
}
}
protected class VolumeWorker extends ThreadWorker {
protected class VolumeWork extends Work {
protected int volumeChangeSign;
public void start(int volumeChangeSign) throws ActivateException {
@@ -115,7 +119,7 @@ public class GomPlayerApplication extends WindowsApplication {
}
};
protected class SeekWorker extends ThreadWorker {
protected class SeekWork extends Work {
protected Amount amount;
protected int seekDirection;

View File

@@ -16,12 +16,12 @@
*/
package mimis.application.cmd.windows.photoviewer;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action;
import mimis.value.Key;
import mimis.value.Type;
import base.exception.worker.DeactivateException;
import base.work.Work;
public class PhotoViewerApplication extends WindowsApplication {
protected final static String TITLE = "Photo Viewer";
@@ -30,33 +30,35 @@ public class PhotoViewerApplication extends WindowsApplication {
protected static final int ZOOM_SLEEP = 100;
protected static final int DELETE_SLEEP = 2000;
protected ZoomWorker zoomWorker;
protected ZoomWork zoomWork;
protected boolean fullscreen;
public PhotoViewerApplication() {
super(TITLE, WINDOW);
zoomWorker = new ZoomWorker();
zoomWork = new ZoomWork();
fullscreen = false;
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
zoomWorker.stop();
zoomWork.stop();
}
public void exit() {
super.exit();
zoomWorker.exit();
zoomWork.exit();
}
public void begin(Action action) {
switch (action) {
case VOLUME_UP:
zoomWorker.start(1);
zoomWork.start(1);
break;
case VOLUME_DOWN:
zoomWorker.start(-1);
zoomWork.start(-1);
break;
default:
break;
}
}
@@ -65,7 +67,7 @@ public class PhotoViewerApplication extends WindowsApplication {
switch (action) {
case VOLUME_UP:
case VOLUME_DOWN:
zoomWorker.stop();
zoomWork.stop();
break;
case NEXT:
key(Type.DOWN, Key.RIGHT);
@@ -106,10 +108,12 @@ public class PhotoViewerApplication extends WindowsApplication {
end(Action.FULLSCREEN);
}*/
break;
default:
break;
}
}
protected class ZoomWorker extends ThreadWorker {
protected class ZoomWork extends Work {
protected int zoomDirection;
public void start(int zoomDirection) {

View File

@@ -16,11 +16,11 @@
*/
package mimis.application.cmd.windows.winamp;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action;
import mimis.value.Command;
import base.exception.worker.DeactivateException;
import base.work.Work;
public class WinampApplication extends WindowsApplication {
protected final static String PROGRAM = "winamp.exe";
@@ -52,8 +52,8 @@ public class WinampApplication extends WindowsApplication {
protected static final int VOLUME_SLEEP = 50;
protected static final int SEEK_SLEEP = 100;
protected VolumeWorker volumeWorker;
protected SeekWorker seekWorker;
protected VolumeWork volumeWork;
protected SeekWork seekWork;
protected double volume;
protected boolean muted;
@@ -61,37 +61,39 @@ public class WinampApplication extends WindowsApplication {
super(PROGRAM, TITLE, WINDOW);
volume = getVolume();
muted = volume == 0;
volumeWorker = new VolumeWorker();
seekWorker = new SeekWorker();
volumeWork = new VolumeWork();
seekWork = new SeekWork();
}
public void deactivate() throws DeactivateException {
super.deactivate();
volumeWorker.stop();
seekWorker.stop();
volumeWork.stop();
seekWork.stop();
}
public void exit() {
super.exit();
volumeWorker.exit();
seekWorker.exit();
volumeWork.exit();
seekWork.exit();
}
public void begin(Action action) {
logger.trace("WinampApplication begin: " + action);
switch (action) {
case VOLUME_UP:
volumeWorker.start(1);
volumeWork.start(1);
break;
case VOLUME_DOWN:
volumeWorker.start(-1);
volumeWork.start(-1);
break;
case FORWARD:
seekWorker.start(1);
seekWork.start(1);
break;
case REWIND:
seekWorker.start(-1);
seekWork.start(-1);
break;
default:
break;
}
}
@@ -117,7 +119,7 @@ public class WinampApplication extends WindowsApplication {
break;
case FORWARD:
case REWIND:
seekWorker.stop();
seekWork.stop();
break;
case MUTE:
if (muted) {
@@ -130,7 +132,7 @@ public class WinampApplication extends WindowsApplication {
break;
case VOLUME_UP:
case VOLUME_DOWN:
volumeWorker.stop();
volumeWork.stop();
break;
case SHUFFLE:
command(WINAMP_FILE_SHUFFLE);
@@ -148,6 +150,8 @@ public class WinampApplication extends WindowsApplication {
system(Command.System.MAXIMIZE);
command(WINAMP_VISPLUGIN);
break;
default:
break;
}
}
@@ -167,7 +171,7 @@ public class WinampApplication extends WindowsApplication {
return user(0, IPC_GETOUTPUTTIME) / 1000;
}
protected class VolumeWorker extends ThreadWorker {
protected class VolumeWork extends Work {
protected int volumeChangeSign;
public void start(int volumeChangeSign) {
@@ -181,7 +185,7 @@ public class WinampApplication extends WindowsApplication {
}
};
protected class SeekWorker extends ThreadWorker {
protected class SeekWork extends Work {
protected int seekDirection;
public void start(int seekDirection) {

View File

@@ -16,9 +16,9 @@
*/
package mimis.application.cmd.windows.wmp;
import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action;
import base.work.Work;
public class WMPApplication extends WindowsApplication {
protected final static String PROGRAM = "wmplayer.exe";
@@ -27,11 +27,11 @@ public class WMPApplication extends WindowsApplication {
protected static final int VOLUME_SLEEP = 120;
protected VolumeWorker volumeWorker;
protected VolumeWork volumeWork;
public WMPApplication() {
super(PROGRAM, TITLE, WINDOW);
volumeWorker = new VolumeWorker();
volumeWork = new VolumeWork();
}
public void begin(Action action) {
@@ -56,17 +56,19 @@ public class WMPApplication extends WindowsApplication {
command(18817);
break;
case VOLUME_UP:
volumeWorker.start(1);
volumeWork.start(1);
break;
case VOLUME_DOWN:
volumeWorker.start(-1);
volumeWork.start(-1);
break;
case SHUFFLE:
command(18842);
break;
case REPEAT:
command(18843);
break;
break;
default:
break;
}
}
@@ -81,12 +83,14 @@ public class WMPApplication extends WindowsApplication {
break;
case VOLUME_UP:
case VOLUME_DOWN:
volumeWorker.stop();
volumeWork.stop();
break;
default:
break;
}
}
protected class VolumeWorker extends ThreadWorker {
protected class VolumeWork extends Work {
protected int volumeChangeSign;
public void start(int volumeChangeSign) {

View File

@@ -21,7 +21,7 @@ import mimis.application.Application;
import mimis.value.Action;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import base.work.Work;
import com.dt.iTunesController.ITCOMDisabledReason;
import com.dt.iTunesController.ITTrack;
@@ -38,7 +38,7 @@ public class iTunesApplication extends Component implements Application, iTunesE
protected static final String PLAYLIST_DISLIKE = "Dislike";
protected iTunes iTunes;
protected VolumeWorker volumeWorker;
protected VolumeWork volumeWork;
protected boolean events;
public iTunesApplication() {
@@ -48,10 +48,10 @@ public class iTunesApplication extends Component implements Application, iTunesE
public iTunesApplication(boolean events) {
super(TITLE);
this.events = events;
volumeWorker = new VolumeWorker();
volumeWork = new VolumeWork();
}
protected synchronized void activate() throws ActivateException {
public synchronized void activate() throws ActivateException {
iTunes = new iTunes();
iTunes.connect();
if (events) {
@@ -63,19 +63,18 @@ public class iTunesApplication extends Component implements Application, iTunesE
public synchronized boolean active() {
try {
iTunes.getMute();
active = true;
} catch (Exception e) {
active = false;
stop();
}
return active;
return super.active();
}
protected synchronized void deactivate() throws DeactivateException {
public synchronized void deactivate() throws DeactivateException {
if (events) {
exit();
} else {
super.deactivate();
volumeWorker.stop();
volumeWork.stop();
try {
iTunes.release();
} catch (Exception e) {
@@ -89,13 +88,13 @@ public class iTunesApplication extends Component implements Application, iTunesE
try {
iTunes.quit();
} catch (Exception e) {}
volumeWorker.exit();
volumeWork.exit();
super.exit();
}
protected void begin(Action action) {
logger.trace("iTunesApplication begin: " + action);
if (!active) return;
if (!active()) return;
switch (action) {
case FORWARD:
iTunes.fastForward();
@@ -104,17 +103,19 @@ public class iTunesApplication extends Component implements Application, iTunesE
iTunes.rewind();
break;
case VOLUME_UP:
volumeWorker.start(VOLUME_CHANGE_RATE);
volumeWork.start(VOLUME_CHANGE_RATE);
break;
case VOLUME_DOWN:
volumeWorker.start(-VOLUME_CHANGE_RATE);
volumeWork.start(-VOLUME_CHANGE_RATE);
break;
default:
break;
}
}
protected void end(Action action) {
logger.trace("iTunesApplication end: " + action);
if (!active) return;
if (!active()) return;
switch (action) {
case PLAY:
iTunes.playPause();
@@ -136,7 +137,7 @@ public class iTunesApplication extends Component implements Application, iTunesE
break;
case VOLUME_UP:
case VOLUME_DOWN:
volumeWorker.stop();
volumeWork.stop();
break;
case SHUFFLE:
iTunes.toggleShuffle();
@@ -150,6 +151,8 @@ public class iTunesApplication extends Component implements Application, iTunesE
case DISLIKE:
iTunes.playlistAddCurrentTrack(PLAYLIST_DISLIKE);
break;
default:
break;
}
}
@@ -159,13 +162,13 @@ public class iTunesApplication extends Component implements Application, iTunesE
public void onDatabaseChangedEvent(int[][] deletedObjectIDs, int[][] changedObjectIDs) {}
public void onPlayerPlayEvent(ITTrack iTrack) {
if (active) {
if (active()) {
logger.trace("iTunesEvent: play");
}
}
public void onPlayerStopEvent(ITTrack iTrack) {
if (active) {
if (active()) {
logger.trace("iTunesEvent: stop");
}
}
@@ -177,7 +180,7 @@ public class iTunesApplication extends Component implements Application, iTunesE
public void onAboutToPromptUserToQuitEvent() {}
public void onSoundVolumeChangedEvent(int newVolume) {}
protected class VolumeWorker extends ThreadWorker {
protected class VolumeWork extends Work {
protected int volumeChangeRate;
public void start(int volumeChangeRate) {

View File

@@ -39,10 +39,10 @@ public class LircApplication extends Component implements Application {
}
public boolean active() {
return active = lircService.active();
return lircService.active();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
lircService.stop();
}

View File

@@ -16,58 +16,60 @@
*/
package mimis.application.lirc.ipod;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.application.lirc.LircApplication;
import mimis.device.lirc.remote.WC02IPOButton;
import mimis.value.Action;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.work.Work;
public class iPodApplication extends LircApplication {
protected static final String TITLE = "iPod";
protected static final int VOLUME_SLEEP = 100;
protected VolumeWorker volumeWorker;
protected VolumeWork volumeWork;
public iPodApplication() {
super(TITLE);
volumeWorker = new VolumeWorker();
volumeWork = new VolumeWork();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
volumeWorker.stop();
volumeWork.stop();
}
public void exit() {
super.exit();
volumeWorker.exit();
volumeWork.exit();
}
protected void begin(Action action) {
logger.trace("iPodApplication begin: " + action);
if (!active) return;
if (!active()) return;
switch (action) {
case VOLUME_UP:
try {
volumeWorker.activate(1);
volumeWork.activate(1);
} catch (ActivateException e) {
logger.error("", e);
}
break;
case VOLUME_DOWN:
try {
volumeWorker.activate(-1);
volumeWork.activate(-1);
} catch (ActivateException e) {
logger.error("", e);
}
break;
default:
break;
}
}
protected void end(Action action) {
logger.trace("iPodApplication end: " + action);
if (!active) return;
if (!active()) return;
switch (action) {
case PLAY:
send(WC02IPOButton.PLAY);
@@ -80,12 +82,14 @@ public class iPodApplication extends LircApplication {
break;
case VOLUME_UP:
case VOLUME_DOWN:
volumeWorker.stop();
volumeWork.stop();
break;
default:
break;
}
}
protected class VolumeWorker extends ThreadWorker {
protected class VolumeWork extends Work {
protected int volumeChangeRate;
public void activate(int volumeChangeRate) throws ActivateException {

View File

@@ -16,9 +16,9 @@
*/
package mimis.application.mpc;
import base.worker.ThreadWorker;
import mimis.application.cmd.windows.WindowsApplication;
import mimis.value.Action;
import base.work.Work;
public class MPCApplication extends WindowsApplication {
protected final static String PROGRAM = "mpc-hc.exe";
@@ -28,30 +28,32 @@ public class MPCApplication extends WindowsApplication {
protected static final int VOLUME_SLEEP = 50;
protected static final int SEEK_SLEEP = 50;
protected VolumeWorker volumeWorker;
protected SeekWorker seekWorker;
protected VolumeWork volumeWork;
protected SeekWork seekWork;
public MPCApplication() {
super(PROGRAM, TITLE, WINDOW);
volumeWorker = new VolumeWorker();
seekWorker = new SeekWorker();
volumeWork = new VolumeWork();
seekWork = new SeekWork();
}
public void begin(Action action) {
logger.trace("MPCApplication: " + action);
switch (action) {
case FORWARD:
seekWorker.start(1);
seekWork.start(1);
break;
case REWIND:
seekWorker.start(-1);
seekWork.start(-1);
break;
case VOLUME_UP:
volumeWorker.start(1);
volumeWork.start(1);
break;
case VOLUME_DOWN:
volumeWorker.start(-1);
volumeWork.start(-1);
break;
default:
break;
}
}
@@ -69,18 +71,20 @@ public class MPCApplication extends WindowsApplication {
break;
case FORWARD:
case REWIND:
seekWorker.stop();
seekWork.stop();
break;
case MUTE:
command(909);
break;
case VOLUME_UP:
case VOLUME_DOWN:
volumeWorker.stop();
volumeWork.stop();
break;
case FULLSCREEN:
command(830);
break;
default:
break;
}
}
@@ -88,7 +92,7 @@ public class MPCApplication extends WindowsApplication {
return TITLE;
}
protected class VolumeWorker extends ThreadWorker {
protected class VolumeWork extends Work {
protected int volumeChangeSign;
public void start(int volumeChangeSign) {
@@ -100,9 +104,9 @@ public class MPCApplication extends WindowsApplication {
command(volumeChangeSign > 0 ? 907 : 908);
sleep(VOLUME_SLEEP);
}
};
}
protected class SeekWorker extends ThreadWorker {
protected class SeekWork extends Work {
protected int seekDirection;
public void start(int seekDirection) {

View File

@@ -23,14 +23,14 @@ import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.application.cmd.CMDApplication;
import mimis.util.Native;
import mimis.value.Action;
import mimis.value.Amount;
import mimis.value.Registry;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.work.Work;
public class VLCApplication extends CMDApplication {
protected final static Registry REGISTRY = Registry.CLASSES_ROOT;
@@ -47,16 +47,16 @@ public class VLCApplication extends CMDApplication {
protected static final int VOLUME_SLEEP = 100;
protected static final int SEEK_SLEEP = 100;
protected VolumeWorker volumeWorker;
protected SeekWorker seekWorker;
protected VolumeWork volumeWorker;
protected SeekWork seekWorker;
protected int volume = 255;
protected boolean muted = false;
public VLCApplication() {
super(PROGRAM, TITLE);
volumeWorker = new VolumeWorker();
seekWorker = new SeekWorker();
volumeWorker = new VolumeWork();
seekWorker = new SeekWork();
}
public String getPath() {
@@ -79,7 +79,7 @@ public class VLCApplication extends CMDApplication {
}
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
volumeWorker.stop();
seekWorker.stop();
@@ -108,6 +108,8 @@ public class VLCApplication extends CMDApplication {
case REWIND:
seekWorker.start(Amount.SMALL, "-");
break;
default:
break;
}
} catch (ActivateException e) {
logger.error("", e);
@@ -146,6 +148,8 @@ public class VLCApplication extends CMDApplication {
case REPEAT:
command("command=pl_repeat");
break;
default:
break;
}
}
@@ -171,7 +175,7 @@ public class VLCApplication extends CMDApplication {
return TITLE;
}
protected class VolumeWorker extends ThreadWorker {
protected class VolumeWork extends Work {
protected String volumeChangeSign;
public void activate(String volumeChangeSign) throws ActivateException {
@@ -186,7 +190,7 @@ public class VLCApplication extends CMDApplication {
}
};
protected class SeekWorker extends ThreadWorker {
protected class SeekWork extends Work {
protected Amount amount;
protected String seekDirection;

View File

@@ -44,20 +44,19 @@ public abstract class JavaInputDevice extends Component implements Device {
protected JavaInputListener javaInputListener;
protected Button previousDirectionalButton;
protected void activate() throws ActivateException {
super.activate();
public void activate() throws ActivateException {
try {
JXInputDevice jxinputDevice = getDevice(name);
logger.debug(jxinputDevice.getName());
javaInputListener = new JavaInputListener(this, jxinputDevice);
} catch (DeviceNotFoundException e) {
active = false;
throw new ActivateException();
}
javaInputListener.start();
super.activate();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
javaInputListener.stop();
}

View File

@@ -19,8 +19,8 @@ package mimis.device.javainput;
import java.util.LinkedList;
import java.util.Queue;
import base.worker.ThreadWorker;
import mimis.exception.ButtonException;
import base.work.Work;
import de.hardcode.jxinput.Button;
import de.hardcode.jxinput.Directional;
import de.hardcode.jxinput.JXInputDevice;
@@ -33,7 +33,7 @@ import de.hardcode.jxinput.event.JXInputDirectionalEvent;
import de.hardcode.jxinput.event.JXInputDirectionalEventListener;
import de.hardcode.jxinput.event.JXInputEventManager;
public class JavaInputListener extends ThreadWorker implements Runnable, JXInputAxisEventListener, JXInputButtonEventListener, JXInputDirectionalEventListener {
public class JavaInputListener extends Work implements JXInputAxisEventListener, JXInputButtonEventListener, JXInputDirectionalEventListener {
protected JavaInputDevice javaInputDevice;
protected JXInputDevice jxinputDevice;
protected Queue<JXInputAxisEvent> axisEventQueue;
@@ -95,7 +95,7 @@ public class JavaInputListener extends ThreadWorker implements Runnable, JXInput
javaInputDevice.processEvent(directionalEventQueue.poll());
} catch (ButtonException e) {}
} else {
sleep();
worker.sleep();
}
}
}

View File

@@ -37,11 +37,11 @@ public class Extreme3DDevice extends JavaInputDevice {
taskMapCycle = new Extreme3DTaskMapCycle();
}
protected void activate() throws ActivateException {
super.activate();
public void activate() throws ActivateException {
parser(Action.ADD, taskMapCycle.mimis);
parser(Action.ADD, taskMapCycle.player);
parser(Action.ADD, taskMapCycle.like);
super.activate();
}
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {

View File

@@ -37,7 +37,7 @@ public class RumblepadDevice extends JavaInputDevice {
taskMapCycle = new RumblepadTaskMapCycle();
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
super.activate();
parser(Action.ADD, taskMapCycle.mimis);
parser(Action.ADD, taskMapCycle.player);

View File

@@ -46,7 +46,7 @@ public class JIntellitypeDevice extends Component implements Device, HotkeyListe
taskMapCycle = new JIntellitypeTaskMapCycle();
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
super.activate();
jit.addHotKeyListener(this);
jit.addIntellitypeListener(this);
@@ -55,7 +55,7 @@ public class JIntellitypeDevice extends Component implements Device, HotkeyListe
}
public void onIntellitype(int command) {
if (active) {
if (active()) {
try {
CommandButton commandButton = CommandButton.create(command);
route(new Press(commandButton));
@@ -67,14 +67,14 @@ public class JIntellitypeDevice extends Component implements Device, HotkeyListe
}
public void onHotKey(int id) {
if (active) {
if (active()) {
Hotkey hotkey = hotkeyList.get(id);
route(new Press(hotkey));
route(new Release(hotkey));
}
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
jit.removeHotKeyListener(this);
jit.removeIntellitypeListener(this);

View File

@@ -16,8 +16,6 @@
*/
package mimis.device.lirc;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import mimis.application.cmd.CMDApplication;
import mimis.device.Device;
import mimis.device.lirc.remote.DenonRC176Button;
@@ -33,6 +31,8 @@ import mimis.util.Native;
import mimis.util.multiplexer.SignalListener;
import mimis.value.Action;
import mimis.value.Signal;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
public class LircDevice extends CMDApplication implements Device, LircButtonListener, SignalListener<Button> {
protected final static String PROGRAM = "winlirc.exe";
@@ -53,7 +53,7 @@ public class LircDevice extends CMDApplication implements Device, LircButtonList
taskMapCycle = new LircTaskMapCycle();
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
super.activate();
lircService.start();
parser(Action.ADD, taskMapCycle.denonRC176);
@@ -63,19 +63,19 @@ public class LircDevice extends CMDApplication implements Device, LircButtonList
public boolean active() {
if (detect) {
if (active && !lircService.active()) {
if (active() && !lircService.active()) {
stop();
} else if (!active) {
} else if (!active()) {
running = Native.isRunning(PROGRAM);
if (running) {
start();
}
}
}
return active;
return super.active();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
logger.debug("Deactivate LircDevice");
super.deactivate();
lircService.stop();
@@ -105,6 +105,8 @@ public class LircDevice extends CMDApplication implements Device, LircButtonList
case END:
route(new Release(button));
break;
default:
break;
}
if (general) {

View File

@@ -48,7 +48,7 @@ public class LircService extends TcpClient {
public static void main(String[] args) {
LircService lircService = new LircService();
lircService.start(false);
lircService.start();
}
public LircService() {

View File

@@ -25,9 +25,6 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ConcurrentLinkedQueue;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.Component;
import mimis.device.Device;
import mimis.input.Feedback;
@@ -35,6 +32,9 @@ import mimis.input.Input;
import mimis.input.Task;
import mimis.value.Action;
import mimis.value.Target;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.work.Work;
public class NetworkDevice extends Component implements Device {
protected static final String TITLE = "Network";
@@ -53,7 +53,7 @@ public class NetworkDevice extends Component implements Device {
this(PORT);
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
server.start();
super.activate();
}
@@ -64,10 +64,10 @@ public class NetworkDevice extends Component implements Device {
client.stop();
}
}
return active = server.active();
return server.active();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
server.stop();
}
@@ -83,7 +83,7 @@ public class NetworkDevice extends Component implements Device {
}
}
protected class Server extends ThreadWorker {
protected class Server extends Work {
protected ServerSocket serverSocket;
protected int port;
@@ -91,7 +91,7 @@ public class NetworkDevice extends Component implements Device {
this.port = port;
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
try {
serverSocket = new ServerSocket(port);
} catch (IOException e) {
@@ -101,10 +101,10 @@ public class NetworkDevice extends Component implements Device {
}
public synchronized boolean active() {
return active = serverSocket != null && !serverSocket.isClosed();
return serverSocket != null && !serverSocket.isClosed();
}
protected synchronized void deactivate() throws DeactivateException {
public synchronized void deactivate() throws DeactivateException {
super.deactivate();
try {
route(new Feedback("[NetworkDevice] Closing server socket"));
@@ -138,7 +138,7 @@ public class NetworkDevice extends Component implements Device {
}
}
protected class Client extends ThreadWorker {
protected class Client extends Work {
protected Socket socket;
protected InputStream inputStream;
protected OutputStream outputStream;
@@ -153,7 +153,7 @@ public class NetworkDevice extends Component implements Device {
}
public boolean active() {
return active = socket.isConnected();
return socket.isConnected();
}
public void work() {
@@ -176,7 +176,7 @@ public class NetworkDevice extends Component implements Device {
}
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
send(new Task(Action.STOP, Target.SELF));
clientList.remove(this);

View File

@@ -34,17 +34,17 @@ public class PanelDevice extends Component implements Device {
taskMapCycle = new PanelTaskMapCycle();
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
panel = new Panel(this);
parser(Action.ADD, taskMapCycle.player);
super.activate();
}
public boolean active() {
return active = panel != null;
return panel != null;
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
panel.dispose();
panel = null;

View File

@@ -26,7 +26,6 @@ import mimis.input.Button;
import mimis.input.Feedback;
import mimis.input.state.Press;
import mimis.input.state.Release;
import mimis.util.ArrayCycle;
import mimis.value.Action;
import mimis.value.Signal;
@@ -40,7 +39,8 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import base.util.ArrayCycle;
import base.work.Work;
public class WiimoteDevice extends Component implements Device, GestureListener {
protected static final String TITLE = "Wiimote";
@@ -56,7 +56,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
protected GestureDevice gestureDevice;
protected MotionDevice motionDevice;
protected int gestureId;
protected LedWorker ledWorker;
protected LedWork ledWork;
protected boolean disconnect;
static {
@@ -71,11 +71,11 @@ public class WiimoteDevice extends Component implements Device, GestureListener
gestureDevice.add(this);
motionDevice = new MotionDevice(this);
gestureId = 0;
ledWorker = new LedWorker();
ledWork = new LedWork();
}
/* Worker */
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
if (wiimote == null) {
motionDevice.setRouter(router);
motionDevice.start();
@@ -107,12 +107,12 @@ public class WiimoteDevice extends Component implements Device, GestureListener
}
}
}
return active;
return super.active();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
ledWorker.stop();
ledWork.stop();
motionDevice.stop();
if (disconnect && wiimote != null) {
wiimote.disconnect();
@@ -122,7 +122,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
public void exit() {
super.exit();
ledWorker.exit();
ledWork.exit();
if (wiimote != null) {
wiimote.disconnect();
wiimote = null;
@@ -170,6 +170,8 @@ public class WiimoteDevice extends Component implements Device, GestureListener
gestureDevice.loadGesture("tmp/gesture #" + gestureId);
}
break;
default:
break;
}
}
@@ -187,6 +189,8 @@ public class WiimoteDevice extends Component implements Device, GestureListener
logger.debug("Gesture close release");
gestureDevice.close(Signal.END);
break;
default:
break;
}
}
@@ -202,12 +206,12 @@ public class WiimoteDevice extends Component implements Device, GestureListener
wiimote = wiimoteService.getDevice(this);
//wiimote.activateContinuous();
//wiimote.activateMotionSensing();
ledWorker.start();
ledWork.start();
}
/* Listeners */
public void onButtonsEvent(WiimoteButtonsEvent event) {
if (!active) {
if (!active()) {
return;
}
int pressed = event.getButtonsJustPressed() - event.getButtonsHeld();
@@ -226,7 +230,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
}
public void onMotionSensingEvent(MotionSensingEvent event) {
if (!active) {
if (!active()) {
return;
}
gestureDevice.add(event.getGforce());
@@ -243,10 +247,10 @@ public class WiimoteDevice extends Component implements Device, GestureListener
}
}
class LedWorker extends ThreadWorker {
class LedWork extends Work {
protected ArrayCycle<Integer> ledCycle;
public LedWorker() {
public LedWork() {
ledCycle = new ArrayCycle<Integer>();
ledCycle.add(1);
ledCycle.add(3);
@@ -269,7 +273,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
setLeds(1);
}
protected void work() {
public void work() {
setLeds(ledCycle.next());
sleep(LED_SLEEP);
}

View File

@@ -19,12 +19,12 @@ package mimis.device.wiimote;
import java.io.IOException;
import java.util.Scanner;
import mimis.exception.device.DeviceNotFoundException;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.exception.device.DeviceNotFoundException;
import base.work.Work;
public class WiimoteDiscovery extends ThreadWorker {
public class WiimoteDiscovery extends Work {
protected static final String WIISCAN = "wiiscan";
protected static final int TIMEOUT = 1000;
protected WiimoteDevice wiimoteDevice;
@@ -54,11 +54,14 @@ public class WiimoteDiscovery extends ThreadWorker {
String line = scanner.nextLine();
if (line.contains("error: BluetoothSetServiceState()")) {
disconnect = true;
scanner.close();
return false;
} else if (line.contains("[OK]")) {
scanner.close();
return true;
}
}
scanner.close();
} catch (IOException e) {
logger.error("", e);
} finally {
@@ -78,7 +81,7 @@ public class WiimoteDiscovery extends ThreadWorker {
}
}
protected void work() {
public void work() {
if (disconnect) {
disconnect();
disconnect = false;

View File

@@ -24,9 +24,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.Component;
import mimis.device.lirc.LircButton;
import mimis.device.lirc.remote.PhiliphsRCLE011Button;
@@ -37,6 +34,9 @@ import mimis.input.button.NumberButton;
import mimis.input.state.State;
import mimis.value.Action;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.work.Work;
public class MotionDevice extends Component {
protected WiimoteDevice wiimoteDevice;
@@ -45,7 +45,7 @@ public class MotionDevice extends Component {
protected boolean replay;
protected Action action;
public ReplayWorker replayWorker;
public ReplayWork replayWork;
public ArrayList<MotionData> motionList;
public MotionDevice(WiimoteDevice wiimoteDevice) {
@@ -54,7 +54,7 @@ public class MotionDevice extends Component {
start = -1;
replay = false;
action = Action.TRAIN;
replayWorker = new ReplayWorker();
replayWork = new ReplayWork();
motionList = new ArrayList<MotionData>();
}
@@ -64,13 +64,13 @@ public class MotionDevice extends Component {
}
public void deactivate() throws DeactivateException {
replayWorker.stop();
replayWork.stop();
super.deactivate();
}
public void exit() {
super.exit();
replayWorker.exit();
replayWork.exit();
}
public void release(Button button) {
@@ -93,6 +93,8 @@ public class MotionDevice extends Component {
case SCREEN_DOWN:
wiimoteDevice.begin(Action.LOAD);
break;
default:
break;
}
} else if (button instanceof NumberButton) {
NumberButton numberButton = (NumberButton) button;
@@ -113,9 +115,9 @@ public class MotionDevice extends Component {
start = System.currentTimeMillis();
break;
case RED:
if (replayWorker.active()) {
if (replayWork.active()) {
logger.debug("Stop replaying motion");
replayWorker.stop();
replayWork.stop();
} else {
logger.debug("Writing motion to file #" + id);
try {
@@ -136,8 +138,10 @@ public class MotionDevice extends Component {
case YELLOW:
logger.debug("Replaying motion from file #" + id);
replay = true;
replayWorker.start();
replayWork.start();
break;
default:
break;
}
}
}
@@ -151,11 +155,11 @@ public class MotionDevice extends Component {
}
}
class ReplayWorker extends ThreadWorker {
class ReplayWork extends Work {
protected ObjectInputStream objectInputStream;
protected int count, i, time;
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
try {
FileInputStream fileInputStream = new FileInputStream(String.format("tmp/motion #%d.bin", id));
objectInputStream = new ObjectInputStream(fileInputStream);
@@ -173,7 +177,7 @@ public class MotionDevice extends Component {
}
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
logger.debug(String.format("Replay stopped (%d ms)", time));
wiimoteDevice.end(action);
replay = false;
@@ -184,7 +188,8 @@ public class MotionDevice extends Component {
}
super.deactivate();
}
protected void work() {
public void work() {
if (i++ < count) {
try {
Object object = objectInputStream.readObject();
@@ -202,5 +207,4 @@ public class MotionDevice extends Component {
stop();
}
}
}
}

View File

@@ -25,20 +25,20 @@ import javax.swing.JPanel;
import javax.swing.JToggleButton;
import javax.swing.border.TitledBorder;
import base.worker.ThreadWorker;
import base.work.Work;
public class ButtonManager extends Manager {
protected static final String TITLE = "Workers";
protected String title;
protected Map<ThreadWorker, WorkerButton> buttonMap;
protected Map<Work, WorkerButton> buttonMap;
public ButtonManager(ThreadWorker... workerArray) {
this(TITLE, workerArray);
public ButtonManager(Work... workArray) {
this(TITLE, workArray);
}
public ButtonManager(String title, ThreadWorker... workerArray) {
super(workerArray);
public ButtonManager(String title, Work... workArray) {
super(workArray);
this.title = title;
createButtons();
}
@@ -52,8 +52,8 @@ public class ButtonManager extends Manager {
}
protected void createButtons() {
buttonMap = new HashMap<ThreadWorker, WorkerButton>();
for (ThreadWorker worker : workerList) {
buttonMap = new HashMap<Work, WorkerButton>();
for (Work worker : workList) {
WorkerButton button = new WorkerButton(worker);
buttonMap.put(worker, button);
}
@@ -84,8 +84,8 @@ public class ButtonManager extends Manager {
return panel;
}
protected void work() {
for (ThreadWorker worker : workerList) {
public void work() {
for (Work worker : workList) {
buttonMap.get(worker).setPressed(worker.active());
}
}

View File

@@ -29,25 +29,25 @@ import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.TitledBorder;
import base.worker.ThreadWorker;
import mimis.Component;
import mimis.input.Task;
import mimis.router.Router;
import mimis.util.ArrayCycle;
import mimis.value.Action;
import mimis.value.Signal;
import mimis.value.Target;
import base.util.ArrayCycle;
import base.work.Work;
public class CurrentButtonManager extends ButtonManager implements ActionListener {
protected Router router;
protected ArrayCycle<Component> componentCycle;
protected Map<JRadioButton, ThreadWorker> radioButtonMap;
protected Map<JRadioButton, Work> radioButtonMap;
public CurrentButtonManager(Router router, ArrayCycle<Component> componentCycle, String title, ThreadWorker... workerArray) {
super(title, workerArray);
public CurrentButtonManager(Router router, ArrayCycle<Component> componentCycle, String title, Work... workArray) {
super(title, workArray);
this.componentCycle = componentCycle;
this.router = router;
radioButtonMap = new HashMap<JRadioButton, ThreadWorker>();
radioButtonMap = new HashMap<JRadioButton, Work>();
}
public JPanel createPanel() {
@@ -77,7 +77,7 @@ public class CurrentButtonManager extends ButtonManager implements ActionListene
JRadioButton radioButton = new JRadioButton();
buttonGroup.add(radioButton);
radioButton.addActionListener(this);
radioButtonMap.put(radioButton, button.worker);
radioButtonMap.put(radioButton, button.work);
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
gridBagConstraints.weightx = 0;
gridBagLayout.setConstraints(radioButton, gridBagConstraints);
@@ -89,7 +89,7 @@ public class CurrentButtonManager extends ButtonManager implements ActionListene
public void actionPerformed(ActionEvent event) {
JRadioButton radioButton = (JRadioButton) event.getSource();
if (radioButtonMap.containsKey(radioButton)) {
ThreadWorker worker = radioButtonMap.get(radioButton);
Work worker = radioButtonMap.get(radioButton);
if (componentCycle.contains(worker)) {
while (!componentCycle.current().equals(worker)) {
componentCycle.next();
@@ -100,9 +100,9 @@ public class CurrentButtonManager extends ButtonManager implements ActionListene
}
public void currentChanged() {
ThreadWorker worker = componentCycle.current();
Work worker = componentCycle.current();
if (radioButtonMap.containsValue(worker)) {
for (Entry<JRadioButton, ThreadWorker> entry : radioButtonMap.entrySet()) {
for (Entry<JRadioButton, Work> entry : radioButtonMap.entrySet()) {
if (entry.getValue().equals(worker)) {
JRadioButton radioButton = (JRadioButton) entry.getKey();
radioButton.setSelected(true);

View File

@@ -20,47 +20,47 @@ import java.util.ArrayList;
import java.util.Arrays;
import base.exception.worker.DeactivateException;
import base.worker.ThreadIntervalWorker;
import base.worker.ThreadWorker;
import base.work.Work;
import base.worker.IntervalWork;
public class Manager extends ThreadIntervalWorker {
public class Manager extends IntervalWork {
protected static final int INTERVAL = 1000;
protected ArrayList<ThreadWorker> workerList;
protected ArrayList<Work> workList;
public Manager(ThreadWorker... workerArray) {
workerList = new ArrayList<ThreadWorker>();
add(workerArray);
public Manager(Work... workArray) {
workList = new ArrayList<Work>();
add(workArray);
}
public void add(ThreadWorker... workerArray) {
workerList.addAll(Arrays.asList(workerArray));
public void add(Work... workArray) {
workList.addAll(Arrays.asList(workArray));
}
public void remove(ThreadWorker... workerArray) {
workerList.removeAll(Arrays.asList(workerArray));
public void remove(Work... workArray) {
workList.removeAll(Arrays.asList(workArray));
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
for (ThreadWorker worker : workerList) {
for (Work worker : workList) {
worker.stop();
}
}
public void exit() {
super.exit();
for (ThreadWorker worker : workerList) {
for (Work worker : workList) {
worker.exit();
}
}
public int count() {
return workerList.size();
return workList.size();
}
protected void work() {
for (ThreadWorker worker : workerList) {
public void work() {
for (Work worker : workList) {
worker.active();
}
}

View File

@@ -26,16 +26,16 @@ import mimis.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import base.worker.ThreadWorker;
import base.work.Work;
public class WorkerButton extends JToggleButton implements MouseListener {
protected static final long serialVersionUID = 1L;
protected Logger logger = LoggerFactory.getLogger(getClass());
protected ThreadWorker worker;
protected Work work;
public WorkerButton(ThreadWorker worker) {
this.worker = worker;
public WorkerButton(Work worker) {
this.work = worker;
setFocusable(false);
addMouseListener(this);
if (worker instanceof Component) {
@@ -44,12 +44,12 @@ public class WorkerButton extends JToggleButton implements MouseListener {
}
public void mouseClicked(MouseEvent event) {
if (worker.active()) {
if (work.active()) {
logger.trace("Stop");
worker.stop();
work.stop();
} else {
logger.trace("Start");
worker.start();
work.start();
}
}

View File

@@ -21,11 +21,11 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.worker.ThreadWorker;
import mimis.input.Feedback;
import mimis.input.Task;
import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException;
import base.work.Work;
public class GlobalRouter extends Router {
protected String ip;
@@ -37,7 +37,7 @@ public class GlobalRouter extends Router {
this.port = port;
}
protected void activate() throws ActivateException {
public void activate() throws ActivateException {
try {
client = new Client(ip, port);
} catch (IOException e) {
@@ -47,7 +47,7 @@ public class GlobalRouter extends Router {
super.activate();
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
client.stop();
}
@@ -60,7 +60,7 @@ public class GlobalRouter extends Router {
}
}
class Client extends ThreadWorker {
class Client extends Work {
protected Socket socket;
protected ObjectInputStream objectInputStream;
protected ObjectOutputStream objectOutputStream;
@@ -87,7 +87,7 @@ public class GlobalRouter extends Router {
}
}
protected void deactivate() throws DeactivateException {
public void deactivate() throws DeactivateException {
super.deactivate();
try {
objectInputStream.close();

View File

@@ -17,11 +17,12 @@
package mimis.state;
import mimis.input.Input;
import mimis.util.ArrayCycle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import base.util.ArrayCycle;
public class TaskMapCycle extends ArrayCycle<TaskMap> implements Input {
protected static final long serialVersionUID = 1L;

View File

@@ -18,7 +18,7 @@ package mimis.util.swing;
import javax.swing.ImageIcon;
import mimis.util.ArrayCycle;
import base.util.ArrayCycle;
public class CycleButton extends HoldButton {

View File

@@ -18,8 +18,7 @@ package mimis.util.swing;
import javax.swing.ImageIcon;
import mimis.util.ArrayCycle;
import base.util.ArrayCycle;
public class ToggleButton extends CycleButton {
protected static final long serialVersionUID = 1L;