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() {
|
||||
log.fatal("start");
|
||||
sequenceListener = new SequenceListener(this);
|
||||
super.start();
|
||||
}
|
||||
@@ -96,6 +97,6 @@ public abstract class Device extends EventHandler implements Titled, Exitable {
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
stop();
|
||||
super.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class GUI extends JFrame {
|
||||
protected static final String DEVICE_TITLE = "Devices";
|
||||
|
||||
protected Mimis mimis;
|
||||
protected TextArea textArea;
|
||||
|
||||
public GUI(Mimis mimis, Manager<Application> applicationManager, Manager<Device> deviceManager) {
|
||||
super(TITLE);
|
||||
@@ -34,7 +35,7 @@ public class GUI extends JFrame {
|
||||
setLayout(new GridLayout(0, 1));
|
||||
JPanel controlPanel = createControlPanel(applicationManager, deviceManager);
|
||||
add(controlPanel);
|
||||
JPanel feedbackPanel = createFeedbackPanel();
|
||||
JPanel feedbackPanel = createTextPanel();
|
||||
add(feedbackPanel);
|
||||
setResizable(false);
|
||||
setVisible(true);
|
||||
@@ -60,24 +61,31 @@ public class GUI extends JFrame {
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected JPanel createFeedbackPanel() {
|
||||
JPanel feedbackPanel = new JPanel();
|
||||
TextArea textArea = new TextArea();
|
||||
protected JPanel createTextPanel() {
|
||||
JPanel textPanel = new JPanel();
|
||||
textArea = new TextArea();
|
||||
textArea.setEditable(false);
|
||||
feedbackPanel.add(textArea);
|
||||
return feedbackPanel;
|
||||
textPanel.add(textArea);
|
||||
return textPanel;
|
||||
}
|
||||
|
||||
protected void processWindowEvent(WindowEvent e) {
|
||||
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
|
||||
log.debug("Window closing");
|
||||
exit();
|
||||
stop();
|
||||
mimis.stop();
|
||||
}
|
||||
}
|
||||
|
||||
protected void exit() {
|
||||
log.debug("Dispose");
|
||||
protected void stop() {
|
||||
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.LogFactory;
|
||||
|
||||
|
||||
public class Manager<T extends Worker & Titled & Exitable> extends Worker {
|
||||
protected Log log = LogFactory.getLog(getClass());
|
||||
protected static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -2,7 +2,9 @@ package mimis;
|
||||
|
||||
import mimis.event.EventHandler;
|
||||
import mimis.event.EventRouter;
|
||||
import mimis.event.Feedback;
|
||||
import mimis.exception.worker.ActivateException;
|
||||
import mimis.feedback.TextFeedback;
|
||||
import mimis.util.ArrayCycle;
|
||||
import mimis.value.Action;
|
||||
|
||||
@@ -72,15 +74,21 @@ public class Mimis extends EventHandler {
|
||||
switch (action) {
|
||||
case NEXT:
|
||||
eventRouter.set(applicationCycle.next());
|
||||
System.out.println(applicationCycle.current());
|
||||
add(new TextFeedback("Next application: " + applicationCycle.current().title()));
|
||||
break;
|
||||
case PREVIOUS:
|
||||
eventRouter.set(applicationCycle.previous());
|
||||
System.out.println(applicationCycle.current());
|
||||
add(new TextFeedback("Previous application: " + applicationCycle.current().title()));
|
||||
break;
|
||||
case EXIT:
|
||||
stop();
|
||||
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;
|
||||
|
||||
public void activate(String name) throws ActivateException {
|
||||
log.fatal("act");
|
||||
try {
|
||||
javaInputListener = new JavaInputListener(this, getDevice(name));
|
||||
} catch (DeviceNotFoundException e) {
|
||||
@@ -35,7 +36,9 @@ public abstract class JavaInputDevice extends Device {
|
||||
}
|
||||
|
||||
public void deactivate() throws DeactivateException {
|
||||
javaInputListener.deactivate();
|
||||
if (active) {
|
||||
javaInputListener.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
public void processEvent(JXInputAxisEvent event) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import mimis.event.task.Continuous;
|
||||
import mimis.event.task.Dynamic;
|
||||
import mimis.exception.button.UnknownButtonException;
|
||||
import mimis.exception.button.UnknownDirectionException;
|
||||
import mimis.exception.worker.ActivateException;
|
||||
import mimis.macro.state.Hold;
|
||||
import mimis.macro.state.Press;
|
||||
import mimis.value.Action;
|
||||
@@ -22,8 +23,14 @@ public class RumblepadDevice extends JavaInputDevice {
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
public void activate() throws ActivateException {
|
||||
super.activate();
|
||||
start();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
super.start();
|
||||
log.fatal("start");
|
||||
|
||||
add(
|
||||
new Press(RumblepadButton.ONE),
|
||||
new Task(Target.APPLICATION, Action.PLAY));
|
||||
@@ -35,10 +42,10 @@ public class RumblepadDevice extends JavaInputDevice {
|
||||
new Task(Target.APPLICATION, Action.RESUME));
|
||||
add(
|
||||
new Press(RumblepadButton.SIX),
|
||||
new Task(Target.APPLICATION, Action.NEXT));
|
||||
new Task(Target.MIMIS, Action.NEXT));
|
||||
add(
|
||||
new Press(RumblepadButton.EIGHT),
|
||||
new Task(Target.APPLICATION, Action.PREVIOUS));
|
||||
new Task(Target.MIMIS, Action.PREVIOUS));
|
||||
add(
|
||||
new Hold(RumblepadButton.FIVE),
|
||||
new Dynamic(Action.FORWARD, Target.APPLICATION, 200, -30));
|
||||
@@ -51,6 +58,7 @@ public class RumblepadDevice extends JavaInputDevice {
|
||||
add(
|
||||
new Hold(RumblepadButton.TEN),
|
||||
new Continuous(Action.VOLUME_UP, Target.APPLICATION, 100));
|
||||
super.start();
|
||||
}
|
||||
|
||||
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.LogFactory;
|
||||
|
||||
// Eventueel handigere knoppen gebruiken ivm terugtogglen
|
||||
public class SelectButton<T extends Worker & Titled> extends JToggleButton implements ItemListener {
|
||||
protected Log log = LogFactory.getLog(getClass());
|
||||
|
||||
@@ -23,29 +22,25 @@ public class SelectButton<T extends Worker & Titled> extends JToggleButton imple
|
||||
public SelectButton(T activatable) {
|
||||
this.activatable = activatable;
|
||||
setText(activatable.title());
|
||||
setRolloverEnabled(false);
|
||||
addItemListener(this);
|
||||
//setFocusable(false);
|
||||
//getModel().setRollover(true);
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent itemEvent) {
|
||||
//setSelected();
|
||||
int state = itemEvent.getStateChange();
|
||||
if (state == ItemEvent.SELECTED) {
|
||||
System.out.println("Selected");
|
||||
log.trace("Selected: " + activatable.title());
|
||||
setPressed(false);
|
||||
try {
|
||||
activatable.activate();
|
||||
} catch (ActivateException e) {
|
||||
// Het knopje moet worden terug getoggled
|
||||
log.error(e);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Deselected");
|
||||
log.trace("Deselected: " + activatable.title());
|
||||
setPressed(true);
|
||||
try {
|
||||
activatable.deactivate();
|
||||
} catch (DeactivateException e) {
|
||||
// Het knopje moet worden terug getoggled
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user