Gewerkt aan items uit de TODO lijst, zie TODO voor details.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class LanTextDevice extends Device implements Runnable {
|
||||
new LanTextListener(socket.accept());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user