diff --git a/java/.classpath b/java/.classpath
index 10efc83..5014ac5 100644
--- a/java/.classpath
+++ b/java/.classpath
@@ -12,5 +12,6 @@
+
diff --git a/java/src/pm/ApplicationSelector.java b/java/src/pm/ApplicationSelector.java
new file mode 100644
index 0000000..a2dad67
--- /dev/null
+++ b/java/src/pm/ApplicationSelector.java
@@ -0,0 +1,94 @@
+package pm;
+
+import java.awt.GridLayout;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+import javax.swing.AbstractButton;
+import javax.swing.ButtonModel;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JToggleButton;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import pm.exception.application.ApplicationExitException;
+import pm.exception.application.ApplicationInitialiseException;
+import pm.util.ArrayCycle;
+
+public class ApplicationSelector extends JFrame {
+ protected static final long serialVersionUID = 1L;
+ protected final static String TITLE = "MIMIS Application Selector";
+
+ protected ArrayCycle applicationCycle;
+
+ protected JToggleButton gomPlayer;
+ protected JToggleButton windowsMediaPlayer;
+ protected JToggleButton iTunes;
+ protected JToggleButton mediaPlayerClassic;
+ protected JToggleButton vlc;
+ protected JToggleButton winamp;
+
+ protected JToggleButton[] applicationButtons = {gomPlayer, windowsMediaPlayer, iTunes, mediaPlayerClassic, vlc, winamp};
+ protected String[] applicationNames = {"GOM Player", "Windows Media Player", "iTunes", "Media Player Classic", "VLC", "Winamp"};;
+
+ public ApplicationSelector(ArrayCycle applicationCycle) {
+ super(TITLE);
+ System.out.println("Application Selector started");
+ this.applicationCycle = applicationCycle;
+ createButtons();
+ layoutButtons();
+ pack();
+ setResizable(false);
+ setVisible(true);
+ }
+
+ protected void createButtons() {
+ for (int i = 0; i < applicationButtons.length; i++) {
+ try {
+ String applicationName = applicationNames[i];
+ applicationButtons[i] = new JToggleButton(applicationName);
+ Application application = (Application) Class.forName(applicationName).newInstance();
+ ToggleChangeListener toggleChangeListener = new ToggleChangeListener(application);
+ applicationButtons[i].addChangeListener(toggleChangeListener);
+ System.out.println("App added");
+ } catch (ClassNotFoundException e) {
+ } catch (InstantiationException e) {
+ } catch (IllegalAccessException e) {}
+ }
+ }
+
+ protected void layoutButtons() {
+ JPanel applicationPanel = new JPanel(new GridLayout(0, 1));
+ for (int i = 0; i < applicationButtons.length; i++) {
+ applicationPanel.add(applicationButtons[i]);
+ }
+ add(applicationPanel);
+ }
+
+ protected class ToggleChangeListener implements ChangeListener {
+ Application application;
+
+ public ToggleChangeListener(Application application) {
+ this.application = application;
+ }
+
+ public void stateChanged(ChangeEvent changeEvent) {
+ System.out.println("Event!");
+ AbstractButton abstractButton = (AbstractButton) changeEvent.getSource();
+ ButtonModel buttonModel = abstractButton.getModel();
+ boolean armed = buttonModel.isArmed();
+ boolean pressed = buttonModel.isPressed();
+ boolean selected = buttonModel.isSelected();
+ System.out.println("Changed: " + armed + "/" + pressed + "/" + selected);
+ /*try {
+ application.initialise();
+ application.start();
+ applicationCycle.add(application);
+ } catch (ApplicationInitialiseException e) {}*/
+ /*applicationCycle.remove(application);
+ application.exit();*/
+ }
+ }
+
+}
diff --git a/java/src/pm/Main.java b/java/src/pm/Main.java
index 9168b21..816e611 100644
--- a/java/src/pm/Main.java
+++ b/java/src/pm/Main.java
@@ -2,7 +2,6 @@ package pm;
import java.util.ArrayList;
-import pm.application.itunes.iTunesApplication;
import pm.event.spreader.LocalSpreader;
import pm.exception.application.ApplicationExitException;
import pm.exception.application.ApplicationInitialiseException;
@@ -12,10 +11,12 @@ import pm.value.Action;
public class Main extends Manager {
protected ArrayCycle applicationCycle;
-
+ protected ApplicationSelector applicationSelector;
+
public Main() {
super(new LocalSpreader());
applicationCycle = new ArrayCycle();
+ applicationSelector = new ApplicationSelector(applicationCycle);
}
protected void action(Action action) {
@@ -37,9 +38,9 @@ public class Main extends Manager {
public void initialise() throws DeviceInitialiseException {
super.initialise();
- add(new iTunesApplication());
- log.error("main init");
- startApplications();
+ //add(new iTunesApplication());
+ //log.error("main init");
+ //startApplications();
}
public void exit() {
@@ -47,7 +48,7 @@ public class Main extends Manager {
stop();
}
- protected void startApplications() {
+ /*protected void startApplications() {
ArrayList removeList = new ArrayList();
for (Application application : applicationCycle) {
try {
@@ -62,9 +63,9 @@ public class Main extends Manager {
remove(application);
}
eventSpreader.set(applicationCycle.current());
- }
+ }*/
- protected void exitApplications() {
+ /*protected void exitApplications() {
System.out.println("Exit applications...");
for (Application application : applicationCycle) {
try {
@@ -72,15 +73,15 @@ public class Main extends Manager {
} catch (ApplicationExitException e) {}
}
System.out.println("Exit main...");
- }
+ }*/
- protected void add(Application application) {
+ /*protected void add(Application application) {
applicationCycle.add(application);
- }
+ }*/
- protected void remove(Application application) {
+ /*protected void remove(Application application) {
applicationCycle.remove(application);
- }
+ }*/
public void start() {
log.info("LocalManager!");
diff --git a/java/src/pm/device/panel/Panel.java b/java/src/pm/device/panel/Panel.java
index 2abd75d..f254206 100644
--- a/java/src/pm/device/panel/Panel.java
+++ b/java/src/pm/device/panel/Panel.java
@@ -21,8 +21,8 @@ public class Panel extends JFrame implements HoldButtonListener {
protected PanelButtonListener panelButtonListener;
protected ClassLoader classLoader;
- protected JTextArea feedbackArea;
- protected JScrollPane scrollPane;
+ //protected JTextArea feedbackArea;
+ //protected JScrollPane scrollPane;
protected HoldButton previousButton;
protected HoldButton rewindButton;
@@ -87,11 +87,11 @@ public class Panel extends JFrame implements HoldButtonListener {
protected void layoutControls() {
setLayout(new BorderLayout());
- layoutFeedbackPanel();
+ //layoutFeedbackPanel();
layoutControlPanel();
}
- protected void layoutFeedbackPanel() {
+ /*protected void layoutFeedbackPanel() {
JPanel feedbackPanel = new JPanel();
feedbackArea = new JTextArea(10, 32);
feedbackArea.setEditable(false);
@@ -126,7 +126,7 @@ public class Panel extends JFrame implements HoldButtonListener {
JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
scrollBar.setValue(scrollBar.getMaximum());
- }
+ }*/
protected void layoutControlPanel() {
JPanel controlPanel = new JPanel();
@@ -203,7 +203,7 @@ public class Panel extends JFrame implements HoldButtonListener {
}
/* Feedback */
- public void addFeedback(String format, Object... args) {
+ /*public void addFeedback(String format, Object... args) {
feedbackArea.append(String.format(format, args));
JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
scrollBar.setValue(scrollBar.getMaximum());
@@ -211,5 +211,5 @@ public class Panel extends JFrame implements HoldButtonListener {
public void clearFeedback() {
feedbackArea.setText("");
- }
+ }*/
}
diff --git a/java/src/pm/util/ArrayCycle.java b/java/src/pm/util/ArrayCycle.java
index 7a5372d..895dcdb 100644
--- a/java/src/pm/util/ArrayCycle.java
+++ b/java/src/pm/util/ArrayCycle.java
@@ -6,14 +6,31 @@ public class ArrayCycle extends ArrayList {
protected static final long serialVersionUID = 1L;
protected int index = 0;
+ //protected Object nonEmpty;
public ArrayCycle(E... elementArary) {
+ //nonEmpty = new Object();
for (E element : elementArary) {
add(element);
}
}
+ /*public boolean add(E element) {
+ boolean result = super.add(element);
+ synchronized (nonEmpty) {
+ nonEmpty.notifyAll();
+ }
+ return result;
+ }*/
+
public E current() {
+ /*while (index == 0) {
+ synchronized (nonEmpty) {
+ try {
+ nonEmpty.wait();
+ } catch (InterruptedException e) {}
+ }
+ }*/
return this.get(index);
}