Selectors aanzienlijk algemener gemaakt en alle bijbehorende aanpassingen gemaakt. Devices en applications zijn Activatable's. Ze worden eenmalig geïnitialiseerd. Hierbij worden alleen broodnodige dingen gedaan, maar applicaties worden nog niet gestart en er wordt nog niet naar devices gezocht. Dat gebeurd pas als er wordt geactiveerd. Als er wordt gedeactiveerd moet het object beschikbaar blijven, alleen moet de verbinding met de applicatie of het device tijdelijk worden onderbroken, om vervolgens weer opnieuw geactiveerd te kunnen worden. Pas als de exit methode wordt aangeroepen, dan moet er definitief worden verbroken. Deze methodiek moet overal nog worden ingevoerd! Er moet nog worden gewerkt aan een systeem zodat de selector ziet of een applicatie of device actief is. Het liefst met zo'n wait notify achtige truck.
This commit is contained in:
@@ -1,33 +1,30 @@
|
||||
package pm;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import pm.application.ApplicationSelector;
|
||||
import pm.application.cmd.windows.gomplayer.GomPlayerApplication;
|
||||
import pm.application.cmd.windows.winamp.WinampApplication;
|
||||
import pm.application.cmd.windows.wmp.WMPApplication;
|
||||
import pm.application.itunes.iTunesApplication;
|
||||
import pm.application.mpc.MPCApplication;
|
||||
import pm.application.vlc.VLCApplication;
|
||||
import pm.application.winamp.WinampApplication;
|
||||
import pm.event.spreader.LocalSpreader;
|
||||
import pm.exception.device.DeviceInitialiseException;
|
||||
import pm.selector.ApplicationSelector;
|
||||
import pm.util.ArrayCycle;
|
||||
import pm.value.Action;
|
||||
|
||||
public class Main extends Manager {
|
||||
public static final String TITLE = "Mimis Main";
|
||||
|
||||
protected Log log = LogFactory.getLog(getClass());
|
||||
protected ArrayCycle<Application> applicationCycle;
|
||||
protected ApplicationSelector applicationSelector;
|
||||
|
||||
|
||||
public Main() {
|
||||
super(new LocalSpreader());
|
||||
applicationCycle = new ArrayCycle<Application>();
|
||||
addApplications();
|
||||
applicationSelector = new ApplicationSelector(applicationCycle);
|
||||
eventSpreader.set(applicationCycle.current());
|
||||
}
|
||||
|
||||
protected void action(Action action) {
|
||||
System.out.println("Manager: " + action);
|
||||
log.debug(String.format("action(%s)", action));
|
||||
switch (action) {
|
||||
case NEXT:
|
||||
eventSpreader.set(applicationCycle.next());
|
||||
@@ -43,75 +40,29 @@ public class Main extends Manager {
|
||||
}
|
||||
}
|
||||
|
||||
public void initialise() throws DeviceInitialiseException {
|
||||
super.initialise();
|
||||
//add(new iTunesApplication());
|
||||
//log.error("main init");
|
||||
//startApplications();
|
||||
public void start() {
|
||||
super.start();
|
||||
Application[] applicationArray = new Application[] {
|
||||
new iTunesApplication(),
|
||||
new GomPlayerApplication(),
|
||||
new WMPApplication(),
|
||||
new MPCApplication(),
|
||||
new VLCApplication(),
|
||||
new WinampApplication()};
|
||||
applicationSelector = new ApplicationSelector(applicationArray);
|
||||
applicationCycle = new ArrayCycle<Application>(applicationArray);
|
||||
eventSpreader.set(applicationCycle.current());
|
||||
super.start(false);
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
exitDevices();
|
||||
stop();
|
||||
}
|
||||
|
||||
protected void addApplications() {
|
||||
applicationCycle.add(new GomPlayerApplication());
|
||||
applicationCycle.add(new WMPApplication());
|
||||
applicationCycle.add(new iTunesApplication());
|
||||
applicationCycle.add(new MPCApplication());
|
||||
applicationCycle.add(new VLCApplication());
|
||||
applicationCycle.add(new WinampApplication());
|
||||
}
|
||||
|
||||
/*protected void startApplications() {
|
||||
ArrayList<Application> removeList = new ArrayList<Application>();
|
||||
for (Application application : applicationCycle) {
|
||||
try {
|
||||
application.initialise();
|
||||
application.start();
|
||||
log.debug(application);
|
||||
} catch (ApplicationInitialiseException e) {
|
||||
removeList.add(application);
|
||||
}
|
||||
}
|
||||
for (Application application : removeList) {
|
||||
remove(application);
|
||||
}
|
||||
eventSpreader.set(applicationCycle.current());
|
||||
}*/
|
||||
|
||||
/*protected void exitApplications() {
|
||||
System.out.println("Exit applications...");
|
||||
for (Application application : applicationCycle) {
|
||||
try {
|
||||
application.exit();
|
||||
} catch (ApplicationExitException e) {}
|
||||
}
|
||||
System.out.println("Exit main...");
|
||||
}*/
|
||||
|
||||
/*protected void add(Application application) {
|
||||
applicationCycle.add(application);
|
||||
}*/
|
||||
|
||||
/*protected void remove(Application application) {
|
||||
applicationCycle.remove(application);
|
||||
}*/
|
||||
|
||||
public void start() {
|
||||
log.info("LocalManager!");
|
||||
try {
|
||||
initialise();
|
||||
} catch (DeviceInitialiseException e) {}
|
||||
super.start(false);
|
||||
application.exit();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Main().start();
|
||||
}
|
||||
|
||||
public String title() {
|
||||
return TITLE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user