* Target.SELF toegevoegd.
* Voormalige Events hernoemd naar States (Press, Release, Hold) --> Nu komt Event vrij als naam voor de parent van Task en toekomstig Feedback --> Exception namen nagelopen, controleren! * Aantal classes verplaatst (Sequence en SequenceListener)
This commit is contained in:
@@ -208,21 +208,21 @@ public class PlayerUI extends JPanel implements ActionListener, ChangeListener,
|
|||||||
setLayout(new AbsoluteLayout());
|
setLayout(new AbsoluteLayout());
|
||||||
config = Config.getInstance();
|
config = Config.getInstance();
|
||||||
ui.setConfig(config);
|
ui.setConfig(config);
|
||||||
playlistUI = new PlaylistUI();
|
/*playlistUI = new PlaylistUI();
|
||||||
playlistUI.setSkin(ui);
|
playlistUI.setSkin(ui);
|
||||||
playlistUI.setPlayer(this);
|
playlistUI.setPlayer(this);
|
||||||
equalizerUI = new EqualizerUI();
|
equalizerUI = new EqualizerUI();
|
||||||
equalizerUI.setSkin(ui);
|
equalizerUI.setSkin(ui);*/
|
||||||
loadSkin();
|
loadSkin();
|
||||||
// DnD support.
|
// DnD support.
|
||||||
DropTargetAdapter dnd = new DropTargetAdapter()
|
/*DropTargetAdapter dnd = new DropTargetAdapter()
|
||||||
{
|
{
|
||||||
public void processDrop(Object data)
|
public void processDrop(Object data)
|
||||||
{
|
{
|
||||||
processDnD(data);
|
processDnD(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, true);
|
DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, true);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadSkin()
|
public void loadSkin()
|
||||||
@@ -278,9 +278,9 @@ public class PlayerUI extends JPanel implements ActionListener, ChangeListener,
|
|||||||
ui.getAcEqualizer().removeActionListener(this);
|
ui.getAcEqualizer().removeActionListener(this);
|
||||||
ui.getAcEqualizer().addActionListener(this);
|
ui.getAcEqualizer().addActionListener(this);
|
||||||
// Playlist toggle
|
// Playlist toggle
|
||||||
add(ui.getAcPlaylist(), ui.getAcPlaylist().getConstraints());
|
/*add(ui.getAcPlaylist(), ui.getAcPlaylist().getConstraints());
|
||||||
ui.getAcPlaylist().removeActionListener(this);
|
ui.getAcPlaylist().removeActionListener(this);
|
||||||
ui.getAcPlaylist().addActionListener(this);
|
ui.getAcPlaylist().addActionListener(this);*/
|
||||||
// Shuffle toggle
|
// Shuffle toggle
|
||||||
add(ui.getAcShuffle(), ui.getAcShuffle().getConstraints());
|
add(ui.getAcShuffle(), ui.getAcShuffle().getConstraints());
|
||||||
ui.getAcShuffle().removeActionListener(this);
|
ui.getAcShuffle().removeActionListener(this);
|
||||||
@@ -294,9 +294,9 @@ public class PlayerUI extends JPanel implements ActionListener, ChangeListener,
|
|||||||
ui.getAcVolume().removeChangeListener(this);
|
ui.getAcVolume().removeChangeListener(this);
|
||||||
ui.getAcVolume().addChangeListener(this);
|
ui.getAcVolume().addChangeListener(this);
|
||||||
// Balance
|
// Balance
|
||||||
add(ui.getAcBalance(), ui.getAcBalance().getConstraints());
|
/*add(ui.getAcBalance(), ui.getAcBalance().getConstraints());
|
||||||
ui.getAcBalance().removeChangeListener(this);
|
ui.getAcBalance().removeChangeListener(this);
|
||||||
ui.getAcBalance().addChangeListener(this);
|
ui.getAcBalance().addChangeListener(this);*/
|
||||||
// Seek bar
|
// Seek bar
|
||||||
add(ui.getAcPosBar(), ui.getAcPosBar().getConstraints());
|
add(ui.getAcPosBar(), ui.getAcPosBar().getConstraints());
|
||||||
ui.getAcPosBar().removeChangeListener(this);
|
ui.getAcPosBar().removeChangeListener(this);
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ public class StandalonePlayer extends JFrame implements Loader
|
|||||||
}
|
}
|
||||||
config = Config.getInstance();
|
config = Config.getInstance();
|
||||||
config.load(initConfig);
|
config.load(initConfig);
|
||||||
config.setTopParent(this);
|
//config.setTopParent(this);
|
||||||
if (showPlaylist != null)
|
if (showPlaylist != null)
|
||||||
{
|
{
|
||||||
if (showPlaylist.equalsIgnoreCase("true"))
|
if (showPlaylist.equalsIgnoreCase("true"))
|
||||||
@@ -288,14 +288,14 @@ public class StandalonePlayer extends JFrame implements Loader
|
|||||||
mp.loadUI(this);
|
mp.loadUI(this);
|
||||||
setContentPane(mp);
|
setContentPane(mp);
|
||||||
setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
|
setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
|
||||||
eqWin = new JWindow(this);
|
/*eqWin = new JWindow(this);
|
||||||
eqWin.setContentPane(mp.getEqualizerUI());
|
eqWin.setContentPane(mp.getEqualizerUI());
|
||||||
eqWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
|
eqWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
|
||||||
eqWin.setVisible(false);
|
eqWin.setVisible(false);
|
||||||
plWin = new JWindow(this);
|
plWin = new JWindow(this);
|
||||||
plWin.setContentPane(mp.getPlaylistUI());
|
plWin.setContentPane(mp.getPlaylistUI());
|
||||||
plWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
|
plWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight()));
|
||||||
plWin.setVisible(false);
|
plWin.setVisible(false);*/
|
||||||
// Window listener
|
// Window listener
|
||||||
addWindowListener(new WindowAdapter()
|
addWindowListener(new WindowAdapter()
|
||||||
{
|
{
|
||||||
@@ -306,18 +306,18 @@ public class StandalonePlayer extends JFrame implements Loader
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Keyboard shortcut
|
// Keyboard shortcut
|
||||||
setKeyBoardShortcut();
|
//setKeyBoardShortcut();
|
||||||
// Display front-end
|
// Display front-end
|
||||||
setLocation(config.getXLocation(), config.getYLocation());
|
setLocation(config.getXLocation(), config.getYLocation());
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
if (config.isPlaylistEnabled()) plWin.setVisible(true);
|
//if (config.isPlaylistEnabled()) plWin.setVisible(true);
|
||||||
if (config.isEqualizerEnabled()) eqWin.setVisible(true);
|
//if (config.isEqualizerEnabled()) eqWin.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install keyboard shortcuts.
|
* Install keyboard shortcuts.
|
||||||
*/
|
*/
|
||||||
public void setKeyBoardShortcut()
|
/*public void setKeyBoardShortcut()
|
||||||
{
|
{
|
||||||
KeyStroke jKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false);
|
KeyStroke jKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false);
|
||||||
KeyStroke ctrlPKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK, false);
|
KeyStroke ctrlPKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK, false);
|
||||||
@@ -359,7 +359,7 @@ public class StandalonePlayer extends JFrame implements Loader
|
|||||||
setKeyboardAction(preferenceID, ctrlPKeyStroke, preferencesAction);
|
setKeyboardAction(preferenceID, ctrlPKeyStroke, preferencesAction);
|
||||||
setKeyboardAction(skinbrowserID, altSKeyStroke, skinbrowserAction);
|
setKeyboardAction(skinbrowserID, altSKeyStroke, skinbrowserAction);
|
||||||
setKeyboardAction(stopplayerID, vKeyStroke, stopplayerAction);
|
setKeyboardAction(stopplayerID, vKeyStroke, stopplayerAction);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set keyboard key shortcut for the whole player.
|
* Set keyboard key shortcut for the whole player.
|
||||||
@@ -367,7 +367,7 @@ public class StandalonePlayer extends JFrame implements Loader
|
|||||||
* @param key
|
* @param key
|
||||||
* @param action
|
* @param action
|
||||||
*/
|
*/
|
||||||
public void setKeyboardAction(String id, KeyStroke key, Action action)
|
/*public void setKeyboardAction(String id, KeyStroke key, Action action)
|
||||||
{
|
{
|
||||||
mp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(key, id);
|
mp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(key, id);
|
||||||
mp.getActionMap().put(id, action);
|
mp.getActionMap().put(id, action);
|
||||||
@@ -375,13 +375,13 @@ public class StandalonePlayer extends JFrame implements Loader
|
|||||||
mp.getPlaylistUI().getActionMap().put(id, action);
|
mp.getPlaylistUI().getActionMap().put(id, action);
|
||||||
mp.getEqualizerUI().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(key, id);
|
mp.getEqualizerUI().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(key, id);
|
||||||
mp.getEqualizerUI().getActionMap().put(id, action);
|
mp.getEqualizerUI().getActionMap().put(id, action);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void loaded()
|
public void loaded()
|
||||||
{
|
{
|
||||||
DragAdapter dragAdapter = new DragAdapter(this);
|
/*DragAdapter dragAdapter = new DragAdapter(this);
|
||||||
mp.getSkin().getAcTitleBar().addMouseListener(dragAdapter);
|
mp.getSkin().getAcTitleBar().addMouseListener(dragAdapter);
|
||||||
mp.getSkin().getAcTitleBar().addMouseMotionListener(dragAdapter);
|
mp.getSkin().getAcTitleBar().addMouseMotionListener(dragAdapter);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close()
|
public void close()
|
||||||
@@ -396,7 +396,7 @@ public class StandalonePlayer extends JFrame implements Loader
|
|||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see javazoom.jlgui.player.amp.skin.Loader#togglePlaylist(boolean)
|
* @see javazoom.jlgui.player.amp.skin.Loader#togglePlaylist(boolean)
|
||||||
*/
|
*/
|
||||||
public void togglePlaylist(boolean enabled)
|
/*public void togglePlaylist(boolean enabled)
|
||||||
{
|
{
|
||||||
if (plWin != null)
|
if (plWin != null)
|
||||||
{
|
{
|
||||||
@@ -419,7 +419,7 @@ public class StandalonePlayer extends JFrame implements Loader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void toggleEqualizer(boolean enabled)
|
public void toggleEqualizer(boolean enabled)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ package pm;
|
|||||||
|
|
||||||
import pm.exception.device.DeviceExitException;
|
import pm.exception.device.DeviceExitException;
|
||||||
import pm.exception.device.DeviceInitialiseException;
|
import pm.exception.device.DeviceInitialiseException;
|
||||||
import pm.macro.Event;
|
import pm.macro.Sequence;
|
||||||
import pm.macro.event.Hold;
|
import pm.macro.SequenceListener;
|
||||||
import pm.macro.event.Press;
|
import pm.macro.State;
|
||||||
import pm.macro.event.Release;
|
import pm.macro.state.Hold;
|
||||||
import pm.macro.event.Sequence;
|
import pm.macro.state.Press;
|
||||||
import pm.macro.event.SequenceListener;
|
import pm.macro.state.Release;
|
||||||
import pm.task.Continuous;
|
import pm.task.Continuous;
|
||||||
import pm.task.Stopper;
|
import pm.task.Stopper;
|
||||||
import pm.task.TaskManager;
|
|
||||||
import pm.task.TaskListener;
|
import pm.task.TaskListener;
|
||||||
|
|
||||||
public abstract class Device extends TaskListener {
|
public abstract class Device extends TaskListener {
|
||||||
@@ -18,7 +17,7 @@ public abstract class Device extends TaskListener {
|
|||||||
|
|
||||||
public Device() {
|
public Device() {
|
||||||
super();
|
super();
|
||||||
sequenceListener = new SequenceListener();
|
sequenceListener = new SequenceListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register macro's */
|
/* Register macro's */
|
||||||
@@ -26,15 +25,15 @@ public abstract class Device extends TaskListener {
|
|||||||
sequenceListener.add(sequence, task);
|
sequenceListener.add(sequence, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void add(Event event, Task task) {
|
protected void add(State state, Task task) {
|
||||||
add(new Sequence(event), task);
|
add(new Sequence(state), task);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void add(Press press, Task task, boolean macro) {
|
protected void add(Press press, Task task, boolean macro) {
|
||||||
if (macro) {
|
if (macro) {
|
||||||
add(new Macro(press), task);
|
add(new Macro(press), task);
|
||||||
} else {
|
} else {
|
||||||
add((Event) press, task);
|
add((State) press, task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ public abstract class Device extends TaskListener {
|
|||||||
add(stopSequence, new Stopper(continuous));
|
add(stopSequence, new Stopper(continuous));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void add(Event startEvent, Event stopEvent, Continuous continuous) {
|
protected void add(State startEvent, State stopEvent, Continuous continuous) {
|
||||||
add(startEvent, continuous);
|
add(startEvent, continuous);
|
||||||
add(stopEvent, new Stopper(continuous));
|
add(stopEvent, new Stopper(continuous));
|
||||||
}
|
}
|
||||||
@@ -69,13 +68,13 @@ public abstract class Device extends TaskListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Recognize events */
|
/* Recognize events */
|
||||||
protected void add(Event event) {
|
protected void add(State state) {
|
||||||
sequenceListener.add(event);
|
sequenceListener.add(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Device default methods */
|
/* Device default methods */
|
||||||
public void initialise() throws DeviceInitialiseException {}
|
public void initialise() throws DeviceInitialiseException {}
|
||||||
|
|
||||||
public void exit() throws DeviceExitException {
|
public void exit() throws DeviceExitException {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,36 +4,36 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import pm.exception.MacroException;
|
import pm.exception.MacroException;
|
||||||
import pm.exception.macro.MacroEventOrderException;
|
import pm.exception.macro.MacroEventOrderException;
|
||||||
import pm.macro.Event;
|
import pm.macro.Sequence;
|
||||||
import pm.macro.event.Sequence;
|
import pm.macro.State;
|
||||||
import pm.macro.event.Hold;
|
import pm.macro.state.Hold;
|
||||||
import pm.macro.event.Press;
|
import pm.macro.state.Press;
|
||||||
import pm.macro.event.Release;
|
import pm.macro.state.Release;
|
||||||
|
|
||||||
public class Macro extends Sequence {
|
public class Macro extends Sequence {
|
||||||
public Macro(Press press) {
|
public Macro(Press press) {
|
||||||
Button button = press.getButton();
|
Button button = press.getButton();
|
||||||
this.eventArray = new Event[] {press, new Release(button)};
|
this.eventArray = new State[] {press, new Release(button)};
|
||||||
}
|
}
|
||||||
|
|
||||||
public Macro(Event... eventArray) throws MacroException {
|
public Macro(State... eventArray) throws MacroException {
|
||||||
ArrayList<Button> holdList = new ArrayList<Button>();
|
ArrayList<Button> holdList = new ArrayList<Button>();
|
||||||
ArrayList<Event> eventList = new ArrayList<Event>();
|
ArrayList<State> eventList = new ArrayList<State>();
|
||||||
for (Event event : eventArray) {
|
for (State state : eventArray) {
|
||||||
Button button = event.getButton();
|
Button button = state.getButton();
|
||||||
if (event instanceof Press) {
|
if (state instanceof Press) {
|
||||||
if (holdList.contains(button)) {
|
if (holdList.contains(button)) {
|
||||||
throw new MacroEventOrderException("Press events cannot follow hold events for the same button.");
|
throw new MacroEventOrderException("Press events cannot follow hold events for the same button.");
|
||||||
}
|
}
|
||||||
eventList.add(event);
|
eventList.add(state);
|
||||||
eventList.add(new Release(button));
|
eventList.add(new Release(button));
|
||||||
} else if (event instanceof Release) {
|
} else if (state instanceof Release) {
|
||||||
if (!holdList.contains(button)) {
|
if (!holdList.contains(button)) {
|
||||||
throw new MacroEventOrderException("Cannot release a button that is not held.");
|
throw new MacroEventOrderException("Cannot release a button that is not held.");
|
||||||
}
|
}
|
||||||
holdList.remove(button);
|
holdList.remove(button);
|
||||||
eventList.add(event);
|
eventList.add(state);
|
||||||
} else if (event instanceof Hold) {
|
} else if (state instanceof Hold) {
|
||||||
if (holdList.contains(button)) {
|
if (holdList.contains(button)) {
|
||||||
throw new MacroEventOrderException("Cannot hold a button more than once.");
|
throw new MacroEventOrderException("Cannot hold a button more than once.");
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,6 @@ public class Macro extends Sequence {
|
|||||||
if (!holdList.isEmpty()) {
|
if (!holdList.isEmpty()) {
|
||||||
throw new MacroEventOrderException("One or more buttons are not released.");
|
throw new MacroEventOrderException("One or more buttons are not released.");
|
||||||
}
|
}
|
||||||
eventArray = (Event[]) eventList.toArray(new Event[0]);
|
eventArray = (State[]) eventList.toArray(new State[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,7 @@ public class Main extends TaskListener {
|
|||||||
//add(new WMPApplication());
|
//add(new WMPApplication());
|
||||||
//add(new GomPlayerApplication());
|
//add(new GomPlayerApplication());
|
||||||
//add(new WinampApplication());
|
//add(new WinampApplication());
|
||||||
add(new iTunesApplication());
|
//add(new iTunesApplication());
|
||||||
for (Application application : applicationCycle) {
|
for (Application application : applicationCycle) {
|
||||||
try {
|
try {
|
||||||
application.initialise();
|
application.initialise();
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Task(Action action) {
|
public Task(Action action) {
|
||||||
this(action, Target.MAIN);
|
this(action, Target.SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action getAction() {
|
public Action getAction() {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package pm.device.javainput;
|
package pm.device.javainput;
|
||||||
|
|
||||||
import pm.Button;
|
import pm.Button;
|
||||||
import pm.exception.event.UnknownDirectionException;
|
import pm.exception.button.UnknownDirectionException;
|
||||||
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
||||||
|
|
||||||
public enum DirectionButton implements Button {
|
public enum DirectionButton implements Button {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
|||||||
|
|
||||||
import pm.Button;
|
import pm.Button;
|
||||||
import pm.Device;
|
import pm.Device;
|
||||||
import pm.exception.EventException;
|
import pm.exception.StateException;
|
||||||
import pm.exception.device.DeviceInitialiseException;
|
import pm.exception.device.DeviceInitialiseException;
|
||||||
import pm.exception.device.DeviceNotFoundException;
|
import pm.exception.device.DeviceNotFoundException;
|
||||||
import pm.macro.event.Press;
|
import pm.macro.state.Press;
|
||||||
import pm.macro.event.Release;
|
import pm.macro.state.Release;
|
||||||
|
|
||||||
public abstract class JavaInputDevice extends Device {
|
public abstract class JavaInputDevice extends Device {
|
||||||
protected JavaInputListener javaInputListener;
|
protected JavaInputListener javaInputListener;
|
||||||
@@ -35,7 +35,7 @@ public abstract class JavaInputDevice extends Device {
|
|||||||
//System.out.println(event);
|
//System.out.println(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processEvent(JXInputButtonEvent event) throws EventException {
|
public void processEvent(JXInputButtonEvent event) throws StateException {
|
||||||
Button button = getButton(event);
|
Button button = getButton(event);
|
||||||
if (event.getButton().getState()) {
|
if (event.getButton().getState()) {
|
||||||
System.out.println("Press: " + button);
|
System.out.println("Press: " + button);
|
||||||
@@ -46,7 +46,7 @@ public abstract class JavaInputDevice extends Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processEvent(JXInputDirectionalEvent event) throws EventException {
|
public void processEvent(JXInputDirectionalEvent event) throws StateException {
|
||||||
Button button = getButton(event);
|
Button button = getButton(event);
|
||||||
if (event.getDirectional().isCentered()) {
|
if (event.getDirectional().isCentered()) {
|
||||||
if (previousDirectionalButton != null) {
|
if (previousDirectionalButton != null) {
|
||||||
@@ -60,8 +60,8 @@ public abstract class JavaInputDevice extends Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Button getButton(JXInputButtonEvent event) throws EventException;
|
protected abstract Button getButton(JXInputButtonEvent event) throws StateException;
|
||||||
protected abstract Button getButton(JXInputDirectionalEvent event) throws EventException;
|
protected abstract Button getButton(JXInputDirectionalEvent event) throws StateException;
|
||||||
|
|
||||||
public static JXInputDevice getDevice(String name) throws DeviceNotFoundException {
|
public static JXInputDevice getDevice(String name) throws DeviceNotFoundException {
|
||||||
int numberOfDevices = JXInputManager.getNumberOfDevices();
|
int numberOfDevices = JXInputManager.getNumberOfDevices();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package pm.device.javainput;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import pm.exception.EventException;
|
import pm.exception.StateException;
|
||||||
|
|
||||||
import de.hardcode.jxinput.Axis;
|
import de.hardcode.jxinput.Axis;
|
||||||
import de.hardcode.jxinput.Button;
|
import de.hardcode.jxinput.Button;
|
||||||
@@ -86,13 +86,13 @@ public class JavaInputListener implements Runnable, JXInputAxisEventListener, JX
|
|||||||
if (!buttonEventQueue.isEmpty()) {
|
if (!buttonEventQueue.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
javaInputDevice.processEvent(buttonEventQueue.poll());
|
javaInputDevice.processEvent(buttonEventQueue.poll());
|
||||||
} catch (EventException e) {}
|
} catch (StateException e) {}
|
||||||
sleep = false;
|
sleep = false;
|
||||||
}
|
}
|
||||||
if (!directionalEventQueue.isEmpty()) {
|
if (!directionalEventQueue.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
javaInputDevice.processEvent(directionalEventQueue.poll());
|
javaInputDevice.processEvent(directionalEventQueue.poll());
|
||||||
} catch (EventException e) {e.printStackTrace();}
|
} catch (StateException e) {e.printStackTrace();}
|
||||||
sleep = false;
|
sleep = false;
|
||||||
}
|
}
|
||||||
if (sleep) {
|
if (sleep) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package pm.device.javainput.extreme3d;
|
|||||||
|
|
||||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||||
import pm.Button;
|
import pm.Button;
|
||||||
import pm.exception.event.UnknownButtonException;
|
import pm.exception.button.UnknownButtonException;
|
||||||
|
|
||||||
public enum Extreme3DButton implements Button {
|
public enum Extreme3DButton implements Button {
|
||||||
ONE ("Button 0"),
|
ONE ("Button 0"),
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import pm.Task;
|
|||||||
import pm.device.javainput.DirectionButton;
|
import pm.device.javainput.DirectionButton;
|
||||||
import pm.device.javainput.JavaInputDevice;
|
import pm.device.javainput.JavaInputDevice;
|
||||||
import pm.exception.MacroException;
|
import pm.exception.MacroException;
|
||||||
|
import pm.exception.button.UnknownButtonException;
|
||||||
|
import pm.exception.button.UnknownDirectionException;
|
||||||
import pm.exception.device.DeviceInitialiseException;
|
import pm.exception.device.DeviceInitialiseException;
|
||||||
import pm.exception.event.UnknownButtonException;
|
import pm.macro.state.Hold;
|
||||||
import pm.exception.event.UnknownDirectionException;
|
import pm.macro.state.Press;
|
||||||
import pm.macro.event.Hold;
|
import pm.macro.state.Release;
|
||||||
import pm.macro.event.Press;
|
|
||||||
import pm.macro.event.Release;
|
|
||||||
import pm.value.Action;
|
import pm.value.Action;
|
||||||
import pm.value.Target;
|
import pm.value.Target;
|
||||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package pm.device.javainput.rumblepad;
|
|||||||
|
|
||||||
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
import de.hardcode.jxinput.event.JXInputButtonEvent;
|
||||||
import pm.Button;
|
import pm.Button;
|
||||||
import pm.exception.event.UnknownButtonException;
|
import pm.exception.button.UnknownButtonException;
|
||||||
|
|
||||||
public enum RumblepadButton implements Button {
|
public enum RumblepadButton implements Button {
|
||||||
ONE ("Button 0"),
|
ONE ("Button 0"),
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import pm.Button;
|
|||||||
import pm.Task;
|
import pm.Task;
|
||||||
import pm.device.javainput.DirectionButton;
|
import pm.device.javainput.DirectionButton;
|
||||||
import pm.device.javainput.JavaInputDevice;
|
import pm.device.javainput.JavaInputDevice;
|
||||||
|
import pm.exception.button.UnknownButtonException;
|
||||||
|
import pm.exception.button.UnknownDirectionException;
|
||||||
import pm.exception.device.DeviceInitialiseException;
|
import pm.exception.device.DeviceInitialiseException;
|
||||||
import pm.exception.event.UnknownButtonException;
|
import pm.macro.state.Hold;
|
||||||
import pm.exception.event.UnknownDirectionException;
|
import pm.macro.state.Press;
|
||||||
import pm.macro.event.Hold;
|
|
||||||
import pm.macro.event.Press;
|
|
||||||
import pm.task.Continuous;
|
import pm.task.Continuous;
|
||||||
import pm.task.Dynamic;
|
import pm.task.Dynamic;
|
||||||
import pm.value.Action;
|
import pm.value.Action;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package pm.device.jintellitype;
|
|||||||
import com.melloware.jintellitype.JIntellitype;
|
import com.melloware.jintellitype.JIntellitype;
|
||||||
|
|
||||||
import pm.Button;
|
import pm.Button;
|
||||||
import pm.exception.event.UnknownButtonException;
|
import pm.exception.button.UnknownButtonException;
|
||||||
|
|
||||||
public enum CommandButton implements Button {
|
public enum CommandButton implements Button {
|
||||||
BROWSER_BACKWARD (JIntellitype.APPCOMMAND_BROWSER_BACKWARD),
|
BROWSER_BACKWARD (JIntellitype.APPCOMMAND_BROWSER_BACKWARD),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import com.melloware.jintellitype.JIntellitype;
|
import com.melloware.jintellitype.JIntellitype;
|
||||||
|
|
||||||
import pm.macro.event.Press;
|
import pm.macro.state.Press;
|
||||||
import pm.value.Key;
|
import pm.value.Key;
|
||||||
|
|
||||||
public class Hotkey extends Press {
|
public class Hotkey extends Press {
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import com.melloware.jintellitype.JIntellitype;
|
|||||||
|
|
||||||
import pm.Device;
|
import pm.Device;
|
||||||
import pm.Task;
|
import pm.Task;
|
||||||
import pm.exception.EventException;
|
import pm.exception.StateException;
|
||||||
import pm.exception.device.DeviceInitialiseException;
|
import pm.exception.device.DeviceInitialiseException;
|
||||||
import pm.macro.event.Hold;
|
import pm.macro.state.Hold;
|
||||||
import pm.macro.event.Press;
|
import pm.macro.state.Press;
|
||||||
import pm.macro.event.Release;
|
import pm.macro.state.Release;
|
||||||
import pm.task.Continuous;
|
import pm.task.Continuous;
|
||||||
import pm.value.Action;
|
import pm.value.Action;
|
||||||
import pm.value.Command;
|
import pm.value.Command;
|
||||||
@@ -63,7 +63,7 @@ public class JIntellitypeDevice extends Device implements HotkeyListener, Intell
|
|||||||
System.out.println(commandButton);
|
System.out.println(commandButton);
|
||||||
add(new Press(commandButton));
|
add(new Press(commandButton));
|
||||||
add(new Release(commandButton));
|
add(new Release(commandButton));
|
||||||
} catch (EventException e) {
|
} catch (StateException e) {
|
||||||
e.printStackTrace(); // Todo: deze exception verder omhoog gooien
|
e.printStackTrace(); // Todo: deze exception verder omhoog gooien
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Scanner;
|
|||||||
|
|
||||||
import pm.Listener;
|
import pm.Listener;
|
||||||
import pm.Task;
|
import pm.Task;
|
||||||
|
import pm.exception.task.TaskNotSupportedException;
|
||||||
import pm.task.TaskManager;
|
import pm.task.TaskManager;
|
||||||
import pm.value.Action;
|
import pm.value.Action;
|
||||||
import pm.value.Target;
|
import pm.value.Target;
|
||||||
@@ -22,8 +23,10 @@ public class InputListener extends Listener {
|
|||||||
String string = input.next().toUpperCase();
|
String string = input.next().toUpperCase();
|
||||||
if(string != null) {
|
if(string != null) {
|
||||||
try {
|
try {
|
||||||
TaskManager.add(
|
try {
|
||||||
new Task(Action.valueOf(string), Target.APPLICATION));
|
TaskManager.add(
|
||||||
|
new Task(Action.valueOf(string), Target.APPLICATION));
|
||||||
|
} catch (TaskNotSupportedException e) {}
|
||||||
} catch(IllegalArgumentException e) {}
|
} catch(IllegalArgumentException e) {}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package pm.device.wiimote;
|
package pm.device.wiimote;
|
||||||
|
|
||||||
import pm.Button;
|
import pm.Button;
|
||||||
import pm.exception.event.UnknownButtonException;
|
import pm.exception.button.UnknownButtonException;
|
||||||
|
|
||||||
public enum WiimoteButton implements Button {
|
public enum WiimoteButton implements Button {
|
||||||
TWO (0x0001),
|
TWO (0x0001),
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ import pm.Button;
|
|||||||
import pm.Device;
|
import pm.Device;
|
||||||
import pm.Task;
|
import pm.Task;
|
||||||
import pm.device.wiimote.gesture.GestureDevice;
|
import pm.device.wiimote.gesture.GestureDevice;
|
||||||
|
import pm.exception.button.UnknownButtonException;
|
||||||
import pm.exception.device.DeviceInitialiseException;
|
import pm.exception.device.DeviceInitialiseException;
|
||||||
import pm.exception.event.UnknownButtonException;
|
import pm.macro.state.Hold;
|
||||||
import pm.macro.event.Hold;
|
import pm.macro.state.Press;
|
||||||
import pm.macro.event.Press;
|
import pm.macro.state.Release;
|
||||||
import pm.macro.event.Release;
|
|
||||||
import pm.task.Continuous;
|
import pm.task.Continuous;
|
||||||
import pm.task.Dynamic;
|
import pm.task.Dynamic;
|
||||||
import pm.value.Action;
|
import pm.value.Action;
|
||||||
@@ -48,20 +48,20 @@ public class WiimoteDevice extends Device implements GestureListener {
|
|||||||
public void initialise() throws DeviceInitialiseException {
|
public void initialise() throws DeviceInitialiseException {
|
||||||
wiimote = wiimoteService.getDevice(this);
|
wiimote = wiimoteService.getDevice(this);
|
||||||
wiimote.activateMotionSensing();
|
wiimote.activateMotionSensing();
|
||||||
/*add(
|
add(
|
||||||
new Hold(WiimoteButton.A),
|
new Hold(WiimoteButton.A),
|
||||||
new Task(Action.TRAIN, Target.DEVICE),
|
new Task(Action.TRAIN),
|
||||||
new Task(Action.STOP, Target.DEVICE));
|
new Task(Action.STOP));
|
||||||
add(
|
add(
|
||||||
new Press(WiimoteButton.B),
|
new Press(WiimoteButton.B),
|
||||||
new Task(Action.SAVE, Target.DEVICE));
|
new Task(Action.SAVE));
|
||||||
add(
|
add(
|
||||||
new Press(WiimoteButton.DOWN),
|
new Press(WiimoteButton.DOWN),
|
||||||
new Task(Action.LOAD, Target.DEVICE));
|
new Task(Action.LOAD));
|
||||||
add(
|
add(
|
||||||
new Hold(WiimoteButton.HOME),
|
new Hold(WiimoteButton.HOME),
|
||||||
new Task(Action.RECOGNIZE, Target.DEVICE),
|
new Task(Action.RECOGNIZE),
|
||||||
new Task(Action.STOP, Target.DEVICE));*/
|
new Task(Action.STOP));
|
||||||
add(
|
add(
|
||||||
new Press(WiimoteButton.A),
|
new Press(WiimoteButton.A),
|
||||||
new Task(Action.PLAY, Target.APPLICATION));
|
new Task(Action.PLAY, Target.APPLICATION));
|
||||||
|
|||||||
5
java/src/pm/exception/ButtonException.java
Normal file
5
java/src/pm/exception/ButtonException.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
package pm.exception;
|
||||||
|
|
||||||
|
public class ButtonException extends Exception {
|
||||||
|
protected static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package pm.exception;
|
package pm.exception;
|
||||||
|
|
||||||
public class EventException extends Exception {
|
public class StateException extends Exception {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
}
|
}
|
||||||
7
java/src/pm/exception/button/UnknownButtonException.java
Normal file
7
java/src/pm/exception/button/UnknownButtonException.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package pm.exception.button;
|
||||||
|
|
||||||
|
import pm.exception.StateException;
|
||||||
|
|
||||||
|
public class UnknownButtonException extends StateException {
|
||||||
|
protected static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package pm.exception.button;
|
||||||
|
|
||||||
|
import pm.exception.ButtonException;
|
||||||
|
|
||||||
|
public class UnknownDirectionException extends ButtonException {
|
||||||
|
protected static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package pm.exception.event;
|
|
||||||
|
|
||||||
import pm.exception.EventException;
|
|
||||||
|
|
||||||
public class UnknownButtonException extends EventException {
|
|
||||||
protected static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package pm.exception.event;
|
|
||||||
|
|
||||||
import pm.exception.EventException;
|
|
||||||
|
|
||||||
public class UnknownDirectionException extends EventException {
|
|
||||||
protected static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package pm.exception.task;
|
||||||
|
|
||||||
|
public class TaskNotSupportedException extends Exception {
|
||||||
|
protected static final long serialVersionUID = 1L;
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package pm.macro;
|
package pm.macro;
|
||||||
|
|
||||||
import pm.macro.event.Sequence;
|
|
||||||
|
|
||||||
public class Active {
|
public class Active {
|
||||||
protected Sequence sequence;
|
protected Sequence sequence;
|
||||||
@@ -15,9 +14,9 @@ public class Active {
|
|||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean next(Event event) {
|
public boolean next(State state) {
|
||||||
Event next = sequence.get(++step);
|
State next = sequence.get(++step);
|
||||||
return next == null ? false : event.equals(next);
|
return next == null ? false : state.equals(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean last() {
|
public boolean last() {
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package pm.macro.event;
|
package pm.macro;
|
||||||
|
|
||||||
import pm.macro.Event;
|
|
||||||
|
|
||||||
|
|
||||||
public class Sequence {
|
public class Sequence {
|
||||||
protected Event[] eventArray;
|
protected State[] eventArray;
|
||||||
|
|
||||||
public Sequence(Event... eventArray) {
|
public Sequence(State... eventArray) {
|
||||||
this.eventArray = eventArray;
|
this.eventArray = eventArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ public class Sequence {
|
|||||||
return eventArray.length;
|
return eventArray.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Event get(int i) {
|
public State get(int i) {
|
||||||
return eventArray.length > 0 ? eventArray[i] : null;
|
return eventArray.length > 0 ? eventArray[i] : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,40 +1,42 @@
|
|||||||
package pm.macro.event;
|
package pm.macro;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import pm.Device;
|
|
||||||
import pm.Task;
|
import pm.Task;
|
||||||
import pm.macro.Active;
|
import pm.task.TaskListener;
|
||||||
import pm.macro.Event;
|
|
||||||
import pm.task.TaskManager;
|
import pm.task.TaskManager;
|
||||||
|
|
||||||
public class SequenceListener {
|
public class SequenceListener {
|
||||||
public ArrayList<Sequence> sequenceList;
|
protected TaskListener taskListener;
|
||||||
public HashMap<Sequence, Task> taskMap;
|
protected ArrayList<Sequence> sequenceList;
|
||||||
public ArrayList<Active> activeList;
|
protected HashMap<Sequence, Task> taskMap;
|
||||||
|
protected ArrayList<Active> activeList;
|
||||||
|
|
||||||
public SequenceListener() {
|
public SequenceListener(TaskListener taskListener) {
|
||||||
|
this.taskListener = taskListener;
|
||||||
sequenceList = new ArrayList<Sequence>();
|
sequenceList = new ArrayList<Sequence>();
|
||||||
taskMap = new HashMap<Sequence, Task>();
|
taskMap = new HashMap<Sequence, Task>();
|
||||||
activeList = new ArrayList<Active>();
|
activeList = new ArrayList<Active>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(Sequence sequence, Task task) {
|
public int add(Sequence sequence, Task task) {
|
||||||
|
int id = sequenceList.size();
|
||||||
sequenceList.add(sequence);
|
sequenceList.add(sequence);
|
||||||
taskMap.put(sequence, task);
|
taskMap.put(sequence, task);
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(Event event) {
|
public void add(State state) {
|
||||||
for (Sequence sequence : sequenceList) {
|
for (Sequence sequence : sequenceList) {
|
||||||
activeList.add(new Active(sequence));
|
activeList.add(new Active(sequence));
|
||||||
}
|
}
|
||||||
ArrayList<Active> removeList = new ArrayList<Active>();
|
ArrayList<Active> removeList = new ArrayList<Active>();
|
||||||
for (Active active : activeList) {
|
for (Active active : activeList) {
|
||||||
if (active.next(event)) {
|
if (active.next(state)) {
|
||||||
if (active.last()) {
|
if (active.last()) {
|
||||||
Task task = taskMap.get(active.getSequence());
|
Task task = taskMap.get(active.getSequence());
|
||||||
TaskManager.add(task);
|
TaskManager.add(taskListener, task);
|
||||||
removeList.add(active);
|
removeList.add(active);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2,10 +2,10 @@ package pm.macro;
|
|||||||
|
|
||||||
import pm.Button;
|
import pm.Button;
|
||||||
|
|
||||||
public abstract class Event {
|
public abstract class State {
|
||||||
protected Button button;
|
protected Button button;
|
||||||
|
|
||||||
public Event(Button button) {
|
public State(Button button) {
|
||||||
this.button = button;
|
this.button = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ public abstract class Event {
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Event event) {
|
public boolean equals(State state) {
|
||||||
return event.getClass().equals(getClass()) && event.getButton().equals(button);
|
return state.getClass().equals(getClass()) && state.getButton().equals(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package pm.macro.event;
|
|
||||||
|
|
||||||
import pm.Button;
|
|
||||||
import pm.macro.Event;
|
|
||||||
|
|
||||||
public class Hold extends Event {
|
|
||||||
public Hold(Button button) {
|
|
||||||
super(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package pm.macro.event;
|
|
||||||
|
|
||||||
import pm.Button;
|
|
||||||
import pm.macro.Event;
|
|
||||||
|
|
||||||
public class Press extends Event {
|
|
||||||
public Press(Button button) {
|
|
||||||
super(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package pm.macro.event;
|
|
||||||
|
|
||||||
import pm.Button;
|
|
||||||
import pm.macro.Event;
|
|
||||||
|
|
||||||
public class Release extends Event {
|
|
||||||
public Release(Button button) {
|
|
||||||
super(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
10
java/src/pm/macro/state/Hold.java
Normal file
10
java/src/pm/macro/state/Hold.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package pm.macro.state;
|
||||||
|
|
||||||
|
import pm.Button;
|
||||||
|
import pm.macro.State;
|
||||||
|
|
||||||
|
public class Hold extends State {
|
||||||
|
public Hold(Button button) {
|
||||||
|
super(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
java/src/pm/macro/state/Press.java
Normal file
10
java/src/pm/macro/state/Press.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package pm.macro.state;
|
||||||
|
|
||||||
|
import pm.Button;
|
||||||
|
import pm.macro.State;
|
||||||
|
|
||||||
|
public class Press extends State {
|
||||||
|
public Press(Button button) {
|
||||||
|
super(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
java/src/pm/macro/state/Release.java
Normal file
10
java/src/pm/macro/state/Release.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package pm.macro.state;
|
||||||
|
|
||||||
|
import pm.Button;
|
||||||
|
import pm.macro.State;
|
||||||
|
|
||||||
|
public class Release extends State {
|
||||||
|
public Release(Button button) {
|
||||||
|
super(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import pm.Device;
|
|||||||
import pm.Main;
|
import pm.Main;
|
||||||
import pm.Task;
|
import pm.Task;
|
||||||
import pm.application.ApplicationCycle;
|
import pm.application.ApplicationCycle;
|
||||||
|
import pm.exception.task.TaskNotSupportedException;
|
||||||
import pm.value.Target;
|
import pm.value.Target;
|
||||||
|
|
||||||
public class TaskManager {
|
public class TaskManager {
|
||||||
@@ -22,40 +23,54 @@ public class TaskManager {
|
|||||||
taskListenerList.add(taskListener);
|
taskListenerList.add(taskListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add(Task task) {
|
public static void add(TaskListener self, Task task) {
|
||||||
if (task instanceof Stopper) {
|
if (task instanceof Stopper) {
|
||||||
Stopper stopper = (Stopper) task;
|
Stopper stopper = (Stopper) task;
|
||||||
stopper.stop();
|
stopper.stop();
|
||||||
} else {
|
} else {
|
||||||
Target target = task.getTarget();
|
Target target = task.getTarget();
|
||||||
if (target.equals(Target.APPLICATION)) {
|
switch (target) {
|
||||||
applicationCycle.current().add(task);
|
case SELF:
|
||||||
} else {
|
self.add(task);
|
||||||
for (TaskListener taskListener : taskListenerList) {
|
break;
|
||||||
switch (target) {
|
case APPLICATION:
|
||||||
case ALL:
|
applicationCycle.current().add(task);
|
||||||
taskListener.add(task);
|
break;
|
||||||
case MAIN:
|
default:
|
||||||
if (taskListener instanceof Main) {
|
for (TaskListener taskListener : taskListenerList) {
|
||||||
|
switch (target) {
|
||||||
|
case ALL:
|
||||||
taskListener.add(task);
|
taskListener.add(task);
|
||||||
}
|
case MAIN:
|
||||||
break;
|
if (taskListener instanceof Main) {
|
||||||
case DEVICES:
|
taskListener.add(task);
|
||||||
if (taskListener instanceof Device) {
|
}
|
||||||
taskListener.add(task);
|
break;
|
||||||
}
|
case DEVICES:
|
||||||
break;
|
if (taskListener instanceof Device) {
|
||||||
case APPLICATIONS:
|
taskListener.add(task);
|
||||||
if (taskListener instanceof Application) {
|
}
|
||||||
taskListener.add(task);
|
break;
|
||||||
}
|
case APPLICATIONS:
|
||||||
break;
|
if (taskListener instanceof Application) {
|
||||||
|
taskListener.add(task);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void add(Task task) throws TaskNotSupportedException {
|
||||||
|
Target target = task.getTarget();
|
||||||
|
if (target.equals(Target.SELF)) {
|
||||||
|
throw new TaskNotSupportedException();
|
||||||
|
}
|
||||||
|
add(null, task);
|
||||||
|
}
|
||||||
|
|
||||||
public static void remove(TaskListener taskListener) {
|
public static void remove(TaskListener taskListener) {
|
||||||
taskListenerList.remove(taskListener);
|
taskListenerList.remove(taskListener);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package pm.value;
|
package pm.value;
|
||||||
|
|
||||||
public enum Target {
|
public enum Target {
|
||||||
ALL, MAIN, DEVICES, APPLICATIONS, APPLICATION;
|
ALL, MAIN, DEVICES, APPLICATIONS, APPLICATION, SELF;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user