From 88c849ff8951ce5b63aed2eda7becb328eaf8fff Mon Sep 17 00:00:00 2001 From: Bram Veenboer Date: Tue, 22 Feb 2011 18:51:46 +0000 Subject: [PATCH] Gewerkt aan items uit de TODO lijst, zie TODO voor details. --- java/src/pm/Application.java | 4 +- java/src/pm/Device.java | 4 +- java/src/pm/Main.java | 14 +++---- java/src/pm/device/gui/GUIDeviceUI.java | 22 +++++------ .../pm/device/lantextinput/LanTextDevice.java | 2 +- .../device/lantextinput/LanTextListener.java | 37 +++++-------------- java/src/pm/device/textinput/TextDevice.java | 10 +++-- java/src/pm/macro/event/SequenceListener.java | 4 +- .../{TaskGatherer.java => TaskManager.java} | 4 +- java/src/pm/todo/TODO | 24 ++++++++---- 10 files changed, 61 insertions(+), 64 deletions(-) rename java/src/pm/task/{TaskGatherer.java => TaskManager.java} (92%) diff --git a/java/src/pm/Application.java b/java/src/pm/Application.java index 6239fde..9b90a32 100644 --- a/java/src/pm/Application.java +++ b/java/src/pm/Application.java @@ -2,13 +2,13 @@ package pm; import pm.exception.application.ApplicationExitException; import pm.exception.application.ApplicationInitialiseException; -import pm.task.TaskGatherer; +import pm.task.TaskManager; import pm.task.TaskListener; public abstract class Application extends TaskListener { public Application() { super(); - TaskGatherer.add(this); + TaskManager.add(this); } public void run() { diff --git a/java/src/pm/Device.java b/java/src/pm/Device.java index c1a0a73..a5f1cf7 100644 --- a/java/src/pm/Device.java +++ b/java/src/pm/Device.java @@ -10,7 +10,7 @@ import pm.macro.event.Sequence; import pm.macro.event.SequenceListener; import pm.task.Continuous; import pm.task.Stopper; -import pm.task.TaskGatherer; +import pm.task.TaskManager; import pm.task.TaskListener; public abstract class Device extends TaskListener { @@ -19,7 +19,7 @@ public abstract class Device extends TaskListener { public Device() { super(); sequenceListener = new SequenceListener(); - TaskGatherer.add(this); + TaskManager.add(this); } /* Register macro's */ diff --git a/java/src/pm/Main.java b/java/src/pm/Main.java index aef9b37..744a3b0 100644 --- a/java/src/pm/Main.java +++ b/java/src/pm/Main.java @@ -18,7 +18,7 @@ import pm.device.wiimote.WiimoteDevice; import pm.exception.application.ApplicationExitException; import pm.exception.device.DeviceExitException; import pm.exception.device.DeviceInitialiseException; -import pm.task.TaskGatherer; +import pm.task.TaskManager; import pm.task.TaskListener; public class Main extends TaskListener { @@ -35,18 +35,18 @@ public class Main extends TaskListener { "pm.device.wiimote.WiimoteDevice"};*/ applicationCycle = new ApplicationCycle(); deviceList = new ArrayList(); - TaskGatherer.initialise(applicationCycle); - TaskGatherer.add(this); + TaskManager.initialise(applicationCycle); + TaskManager.add(this); } public void initialise() throws DeviceInitialiseException { - add(new JIntellitypeDevice()); + //add(new JIntellitypeDevice()); //add(new PlayerDevice()); //add(new RumblepadDevice()); //add(new WiimoteDevice()); //add(new GUIDevice()); //add(new TextDevice()); - //add(new LanTextDevice()); + add(new LanTextDevice()); for (Device device : deviceList) { try { device.initialise(); @@ -57,9 +57,9 @@ public class Main extends TaskListener { add(new ExampleApplication()); //add(new WMPApplication()); - add(new GomPlayerApplication()); + //add(new GomPlayerApplication()); //add(new WinampApplication()); - //add(new iTunesApplication()); + add(new iTunesApplication()); for (Application application : applicationCycle) { application.start(); } diff --git a/java/src/pm/device/gui/GUIDeviceUI.java b/java/src/pm/device/gui/GUIDeviceUI.java index d2c9da4..05d5f59 100644 --- a/java/src/pm/device/gui/GUIDeviceUI.java +++ b/java/src/pm/device/gui/GUIDeviceUI.java @@ -8,7 +8,7 @@ import javax.swing.JFrame; import pm.Action; import pm.Target; import pm.Task; -import pm.task.TaskGatherer; +import pm.task.TaskManager; import layout.TableLayout; import layout.TableLayoutConstraints; @@ -157,42 +157,42 @@ public class GUIDeviceUI extends JFrame { } protected void playAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.PLAY, Target.APPLICATION)); + TaskManager.add(new Task(Action.PLAY, Target.APPLICATION)); } protected void pauseAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.PAUSE, Target.APPLICATION)); + TaskManager.add(new Task(Action.PAUSE, Target.APPLICATION)); } protected void resumeAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.RESUME, Target.APPLICATION)); + TaskManager.add(new Task(Action.RESUME, Target.APPLICATION)); } protected void nextAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.NEXT, Target.APPLICATION)); + TaskManager.add(new Task(Action.NEXT, Target.APPLICATION)); } protected void previousAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.PREVIOUS, Target.APPLICATION)); + TaskManager.add(new Task(Action.PREVIOUS, Target.APPLICATION)); } protected void forwardAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.FORWARD, Target.APPLICATION)); + TaskManager.add(new Task(Action.FORWARD, Target.APPLICATION)); } protected void rewindAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.REWIND, Target.APPLICATION)); + TaskManager.add(new Task(Action.REWIND, Target.APPLICATION)); } protected void muteAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.MUTE, Target.APPLICATION)); + TaskManager.add(new Task(Action.MUTE, Target.APPLICATION)); } protected void volumeUpAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.VOLUME_UP, Target.APPLICATION)); + TaskManager.add(new Task(Action.VOLUME_UP, Target.APPLICATION)); } protected void volumeDownAction(ActionEvent e) { - TaskGatherer.add(new Task(Action.VOLUME_DOWN, Target.APPLICATION)); + TaskManager.add(new Task(Action.VOLUME_DOWN, Target.APPLICATION)); } } diff --git a/java/src/pm/device/lantextinput/LanTextDevice.java b/java/src/pm/device/lantextinput/LanTextDevice.java index 63b4eee..22f5f79 100644 --- a/java/src/pm/device/lantextinput/LanTextDevice.java +++ b/java/src/pm/device/lantextinput/LanTextDevice.java @@ -24,7 +24,7 @@ public class LanTextDevice extends Device implements Runnable { new LanTextListener(socket.accept()); } catch (IOException e) { e.printStackTrace(); - } + } } } diff --git a/java/src/pm/device/lantextinput/LanTextListener.java b/java/src/pm/device/lantextinput/LanTextListener.java index 7631c3f..5d6177e 100644 --- a/java/src/pm/device/lantextinput/LanTextListener.java +++ b/java/src/pm/device/lantextinput/LanTextListener.java @@ -4,20 +4,17 @@ import java.io.IOException; import java.net.Socket; import java.util.Scanner; -import pm.Action; -import pm.Target; -import pm.Task; -import pm.task.TaskGatherer; +import pm.device.textinput.TextDevice; -public class LanTextListener implements Runnable { - static final int SLEEP = 100; - - protected boolean run; +public class LanTextListener extends TextDevice { protected Socket socket; - protected Scanner input; - public LanTextListener(Socket socket){ + public LanTextListener(Socket socket) { this.socket = socket; + initialise(); + } + + public void initialise() { try { input = new Scanner(socket.getInputStream()); } catch (IOException e) { @@ -27,25 +24,11 @@ public class LanTextListener implements Runnable { new Thread(this).start(); } - public void run() { - while (run && socket.isConnected() && input.hasNext()) { - String textinput = input.next().toUpperCase(); - if(textinput != null) { - try { - TaskGatherer.add( - new Task(Action.valueOf(textinput), Target.APPLICATION)); - } catch (IllegalArgumentException e) {} - } - try { - Thread.sleep(SLEEP); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - exit(); + protected boolean running() { + return run && socket.isConnected() && input.hasNext(); } - protected void exit() { + public void exit() { run = false; try { socket.close(); diff --git a/java/src/pm/device/textinput/TextDevice.java b/java/src/pm/device/textinput/TextDevice.java index 49cfa7d..7f689a7 100644 --- a/java/src/pm/device/textinput/TextDevice.java +++ b/java/src/pm/device/textinput/TextDevice.java @@ -6,7 +6,7 @@ import pm.Action; import pm.Device; import pm.Target; import pm.Task; -import pm.task.TaskGatherer; +import pm.task.TaskManager; public class TextDevice extends Device implements Runnable { static final int SLEEP = 100; @@ -21,11 +21,11 @@ public class TextDevice extends Device implements Runnable { public void run() { run = true; - while (run) { + while (running()) { String textinput = input.next().toUpperCase(); if(textinput != null) { try { - TaskGatherer.add( + TaskManager.add( new Task(Action.valueOf(textinput), Target.APPLICATION)); } catch(IllegalArgumentException e) {} } @@ -36,4 +36,8 @@ public class TextDevice extends Device implements Runnable { } } } + + protected boolean running() { + return run && input.hasNext(); + } } diff --git a/java/src/pm/macro/event/SequenceListener.java b/java/src/pm/macro/event/SequenceListener.java index 611e18e..8987122 100644 --- a/java/src/pm/macro/event/SequenceListener.java +++ b/java/src/pm/macro/event/SequenceListener.java @@ -7,7 +7,7 @@ import pm.Device; import pm.Task; import pm.macro.Active; import pm.macro.Event; -import pm.task.TaskGatherer; +import pm.task.TaskManager; public class SequenceListener { public ArrayList sequenceList; @@ -34,7 +34,7 @@ public class SequenceListener { if (active.next(event)) { if (active.last()) { Task task = taskMap.get(active.getSequence()); - TaskGatherer.add(task); + TaskManager.add(task); removeList.add(active); } } else { diff --git a/java/src/pm/task/TaskGatherer.java b/java/src/pm/task/TaskManager.java similarity index 92% rename from java/src/pm/task/TaskGatherer.java rename to java/src/pm/task/TaskManager.java index 799c956..3717927 100644 --- a/java/src/pm/task/TaskGatherer.java +++ b/java/src/pm/task/TaskManager.java @@ -9,13 +9,13 @@ import pm.Target; import pm.Task; import pm.application.ApplicationCycle; -public class TaskGatherer { +public class TaskManager { protected static ArrayList taskListenerList; protected static ApplicationCycle applicationCycle; public static void initialise(ApplicationCycle applicationCycle) { taskListenerList = new ArrayList(); - TaskGatherer.applicationCycle = applicationCycle; + TaskManager.applicationCycle = applicationCycle; } public static void add(TaskListener taskListener) { diff --git a/java/src/pm/todo/TODO b/java/src/pm/todo/TODO index d6504d9..2471826 100644 --- a/java/src/pm/todo/TODO +++ b/java/src/pm/todo/TODO @@ -1,3 +1,6 @@ +TODO +------------ + log bijhouden mappings lezen vanuit config bestand @@ -12,16 +15,23 @@ nummerinfo weergeven, waar? via feedback? javadoc maken, class diagram opstellen enz..... -naamgeving en indeling classes/packages controleren - meer applicaties implementeren, zoals VLC, WMP, Youtube? (interface naar flash?) logo ontwerpen -exporteren naar uitvoerbare jar file - -lantextdevice generiek maken met normale textdevice - client maken die remote devices kan beheren en lokaal acties kan uitvoeren -mogelijkheid tot webstart onderzoeken \ No newline at end of file +mogelijkheid tot webstart onderzoeken + + +IN PROGRESS +------------- +naamgeving en indeling classes/packages controleren ++TaskGatherererer hernoemt naar TaskManager + +exporteren naar uitvoerbare jar file ++Eclipse kan exporteren, maar bij uitvoeren gebeurd er niets. Moet er een status scherm komen? (Een swing console bijvoorbeeld) + +DONE +------------- +lantextdevice generiek maken met normale textdevice \ No newline at end of file