De manager heeft nu werkende knoppen!... De JavaInputDevice lijkt niet meer te werken.
This commit is contained in:
@@ -27,6 +27,7 @@ public abstract class Device extends EventHandler implements Titled, Exitable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
log.fatal("start");
|
||||||
sequenceListener = new SequenceListener(this);
|
sequenceListener = new SequenceListener(this);
|
||||||
super.start();
|
super.start();
|
||||||
}
|
}
|
||||||
@@ -96,6 +97,6 @@ public abstract class Device extends EventHandler implements Titled, Exitable {
|
|||||||
log.error(e);
|
log.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stop();
|
super.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class GUI extends JFrame {
|
|||||||
protected static final String DEVICE_TITLE = "Devices";
|
protected static final String DEVICE_TITLE = "Devices";
|
||||||
|
|
||||||
protected Mimis mimis;
|
protected Mimis mimis;
|
||||||
|
protected TextArea textArea;
|
||||||
|
|
||||||
public GUI(Mimis mimis, Manager<Application> applicationManager, Manager<Device> deviceManager) {
|
public GUI(Mimis mimis, Manager<Application> applicationManager, Manager<Device> deviceManager) {
|
||||||
super(TITLE);
|
super(TITLE);
|
||||||
@@ -34,7 +35,7 @@ public class GUI extends JFrame {
|
|||||||
setLayout(new GridLayout(0, 1));
|
setLayout(new GridLayout(0, 1));
|
||||||
JPanel controlPanel = createControlPanel(applicationManager, deviceManager);
|
JPanel controlPanel = createControlPanel(applicationManager, deviceManager);
|
||||||
add(controlPanel);
|
add(controlPanel);
|
||||||
JPanel feedbackPanel = createFeedbackPanel();
|
JPanel feedbackPanel = createTextPanel();
|
||||||
add(feedbackPanel);
|
add(feedbackPanel);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
@@ -60,24 +61,31 @@ public class GUI extends JFrame {
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JPanel createFeedbackPanel() {
|
protected JPanel createTextPanel() {
|
||||||
JPanel feedbackPanel = new JPanel();
|
JPanel textPanel = new JPanel();
|
||||||
TextArea textArea = new TextArea();
|
textArea = new TextArea();
|
||||||
textArea.setEditable(false);
|
textArea.setEditable(false);
|
||||||
feedbackPanel.add(textArea);
|
textPanel.add(textArea);
|
||||||
return feedbackPanel;
|
return textPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processWindowEvent(WindowEvent e) {
|
protected void processWindowEvent(WindowEvent e) {
|
||||||
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
||||||
log.debug("Window closing");
|
log.debug("Window closing");
|
||||||
exit();
|
stop();
|
||||||
mimis.stop();
|
mimis.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void exit() {
|
protected void stop() {
|
||||||
log.debug("Dispose");
|
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void write(String string) {
|
||||||
|
textArea.append(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
textArea.setText(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import mimis.manager.Titled;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
|
||||||
public class Manager<T extends Worker & Titled & Exitable> extends Worker {
|
public class Manager<T extends Worker & Titled & Exitable> extends Worker {
|
||||||
protected Log log = LogFactory.getLog(getClass());
|
protected Log log = LogFactory.getLog(getClass());
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package mimis;
|
|||||||
|
|
||||||
import mimis.event.EventHandler;
|
import mimis.event.EventHandler;
|
||||||
import mimis.event.EventRouter;
|
import mimis.event.EventRouter;
|
||||||
|
import mimis.event.Feedback;
|
||||||
import mimis.exception.worker.ActivateException;
|
import mimis.exception.worker.ActivateException;
|
||||||
|
import mimis.feedback.TextFeedback;
|
||||||
import mimis.util.ArrayCycle;
|
import mimis.util.ArrayCycle;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
|
||||||
@@ -72,15 +74,21 @@ public class Mimis extends EventHandler {
|
|||||||
switch (action) {
|
switch (action) {
|
||||||
case NEXT:
|
case NEXT:
|
||||||
eventRouter.set(applicationCycle.next());
|
eventRouter.set(applicationCycle.next());
|
||||||
System.out.println(applicationCycle.current());
|
add(new TextFeedback("Next application: " + applicationCycle.current().title()));
|
||||||
break;
|
break;
|
||||||
case PREVIOUS:
|
case PREVIOUS:
|
||||||
eventRouter.set(applicationCycle.previous());
|
eventRouter.set(applicationCycle.previous());
|
||||||
System.out.println(applicationCycle.current());
|
add(new TextFeedback("Previous application: " + applicationCycle.current().title()));
|
||||||
break;
|
break;
|
||||||
case EXIT:
|
case EXIT:
|
||||||
stop();
|
stop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void feedback(Feedback feedback) {
|
||||||
|
if (feedback instanceof TextFeedback) {
|
||||||
|
gui.write(((TextFeedback) feedback).getText());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package mimis;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
|
|
||||||
public class Test {
|
|
||||||
public void start() throws IOException {
|
|
||||||
Class<Application> application = Application.class;
|
|
||||||
Class<?> test = application.getEnclosingClass();
|
|
||||||
System.out.println(test);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] argv) throws IOException {
|
|
||||||
new Test().start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,6 +26,7 @@ public abstract class JavaInputDevice extends Device {
|
|||||||
protected Button previousDirectionalButton;
|
protected Button previousDirectionalButton;
|
||||||
|
|
||||||
public void activate(String name) throws ActivateException {
|
public void activate(String name) throws ActivateException {
|
||||||
|
log.fatal("act");
|
||||||
try {
|
try {
|
||||||
javaInputListener = new JavaInputListener(this, getDevice(name));
|
javaInputListener = new JavaInputListener(this, getDevice(name));
|
||||||
} catch (DeviceNotFoundException e) {
|
} catch (DeviceNotFoundException e) {
|
||||||
@@ -35,8 +36,10 @@ public abstract class JavaInputDevice extends Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
|
if (active) {
|
||||||
javaInputListener.deactivate();
|
javaInputListener.deactivate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void processEvent(JXInputAxisEvent event) {
|
public void processEvent(JXInputAxisEvent event) {
|
||||||
log.trace("JXInputAxisEvent: " + event);
|
log.trace("JXInputAxisEvent: " + event);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import mimis.event.task.Continuous;
|
|||||||
import mimis.event.task.Dynamic;
|
import mimis.event.task.Dynamic;
|
||||||
import mimis.exception.button.UnknownButtonException;
|
import mimis.exception.button.UnknownButtonException;
|
||||||
import mimis.exception.button.UnknownDirectionException;
|
import mimis.exception.button.UnknownDirectionException;
|
||||||
|
import mimis.exception.worker.ActivateException;
|
||||||
import mimis.macro.state.Hold;
|
import mimis.macro.state.Hold;
|
||||||
import mimis.macro.state.Press;
|
import mimis.macro.state.Press;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
@@ -22,8 +23,14 @@ public class RumblepadDevice extends JavaInputDevice {
|
|||||||
super(NAME);
|
super(NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void activate() throws ActivateException {
|
||||||
|
super.activate();
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
super.start();
|
log.fatal("start");
|
||||||
|
|
||||||
add(
|
add(
|
||||||
new Press(RumblepadButton.ONE),
|
new Press(RumblepadButton.ONE),
|
||||||
new Task(Target.APPLICATION, Action.PLAY));
|
new Task(Target.APPLICATION, Action.PLAY));
|
||||||
@@ -35,10 +42,10 @@ public class RumblepadDevice extends JavaInputDevice {
|
|||||||
new Task(Target.APPLICATION, Action.RESUME));
|
new Task(Target.APPLICATION, Action.RESUME));
|
||||||
add(
|
add(
|
||||||
new Press(RumblepadButton.SIX),
|
new Press(RumblepadButton.SIX),
|
||||||
new Task(Target.APPLICATION, Action.NEXT));
|
new Task(Target.MIMIS, Action.NEXT));
|
||||||
add(
|
add(
|
||||||
new Press(RumblepadButton.EIGHT),
|
new Press(RumblepadButton.EIGHT),
|
||||||
new Task(Target.APPLICATION, Action.PREVIOUS));
|
new Task(Target.MIMIS, Action.PREVIOUS));
|
||||||
add(
|
add(
|
||||||
new Hold(RumblepadButton.FIVE),
|
new Hold(RumblepadButton.FIVE),
|
||||||
new Dynamic(Action.FORWARD, Target.APPLICATION, 200, -30));
|
new Dynamic(Action.FORWARD, Target.APPLICATION, 200, -30));
|
||||||
@@ -51,6 +58,7 @@ public class RumblepadDevice extends JavaInputDevice {
|
|||||||
add(
|
add(
|
||||||
new Hold(RumblepadButton.TEN),
|
new Hold(RumblepadButton.TEN),
|
||||||
new Continuous(Action.VOLUME_UP, Target.APPLICATION, 100));
|
new Continuous(Action.VOLUME_UP, Target.APPLICATION, 100));
|
||||||
|
super.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {
|
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {
|
||||||
|
|||||||
15
java/src/mimis/feedback/TextFeedback.java
Normal file
15
java/src/mimis/feedback/TextFeedback.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package mimis.feedback;
|
||||||
|
|
||||||
|
import mimis.event.Feedback;
|
||||||
|
|
||||||
|
public class TextFeedback extends Feedback {
|
||||||
|
protected String text;
|
||||||
|
|
||||||
|
public TextFeedback(String text) {
|
||||||
|
this.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText() {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ import mimis.exception.worker.DeactivateException;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
// Eventueel handigere knoppen gebruiken ivm terugtogglen
|
|
||||||
public class SelectButton<T extends Worker & Titled> extends JToggleButton implements ItemListener {
|
public class SelectButton<T extends Worker & Titled> extends JToggleButton implements ItemListener {
|
||||||
protected Log log = LogFactory.getLog(getClass());
|
protected Log log = LogFactory.getLog(getClass());
|
||||||
|
|
||||||
@@ -23,29 +22,25 @@ public class SelectButton<T extends Worker & Titled> extends JToggleButton imple
|
|||||||
public SelectButton(T activatable) {
|
public SelectButton(T activatable) {
|
||||||
this.activatable = activatable;
|
this.activatable = activatable;
|
||||||
setText(activatable.title());
|
setText(activatable.title());
|
||||||
setRolloverEnabled(false);
|
|
||||||
addItemListener(this);
|
addItemListener(this);
|
||||||
//setFocusable(false);
|
|
||||||
//getModel().setRollover(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void itemStateChanged(ItemEvent itemEvent) {
|
public void itemStateChanged(ItemEvent itemEvent) {
|
||||||
//setSelected();
|
|
||||||
int state = itemEvent.getStateChange();
|
int state = itemEvent.getStateChange();
|
||||||
if (state == ItemEvent.SELECTED) {
|
if (state == ItemEvent.SELECTED) {
|
||||||
System.out.println("Selected");
|
log.trace("Selected: " + activatable.title());
|
||||||
|
setPressed(false);
|
||||||
try {
|
try {
|
||||||
activatable.activate();
|
activatable.activate();
|
||||||
} catch (ActivateException e) {
|
} catch (ActivateException e) {
|
||||||
// Het knopje moet worden terug getoggled
|
|
||||||
log.error(e);
|
log.error(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Deselected");
|
log.trace("Deselected: " + activatable.title());
|
||||||
|
setPressed(true);
|
||||||
try {
|
try {
|
||||||
activatable.deactivate();
|
activatable.deactivate();
|
||||||
} catch (DeactivateException e) {
|
} catch (DeactivateException e) {
|
||||||
// Het knopje moet worden terug getoggled
|
|
||||||
log.error(e);
|
log.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user