diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-18 21:44:09 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-18 21:44:09 +0000 |
| commit | 34b16d2ffc7b40df933ba85ddb8e414121116ca5 (patch) | |
| tree | b7ba976bb34f9ec51acd10dca935b9a33d9e01f8 /sources/events | |
| parent | ace76b508e2f6c1bc420112306ebee52f478de13 (diff) | |
new Task Manager works :-)
Diffstat (limited to 'sources/events')
| -rw-r--r-- | sources/events/VSEvent.java | 16 | ||||
| -rw-r--r-- | sources/events/VSRegisteredEvents.java | 14 | ||||
| -rw-r--r-- | sources/events/implementations/ProtocolEvent.java | 31 |
3 files changed, 42 insertions, 19 deletions
diff --git a/sources/events/VSEvent.java b/sources/events/VSEvent.java index 130d1f5..bfb677d 100644 --- a/sources/events/VSEvent.java +++ b/sources/events/VSEvent.java @@ -6,6 +6,7 @@ import prefs.VSPrefs; abstract public class VSEvent extends VSPrefs { protected VSPrefs prefs; protected VSProcess process; + private String eventShortname; private String eventClassname; public void init(VSProcess process) { @@ -22,7 +23,7 @@ abstract public class VSEvent extends VSPrefs { this.eventClassname = eventClassname; } - public final String getClassname() { + public String getClassname() { return eventClassname; } @@ -30,11 +31,18 @@ abstract public class VSEvent extends VSPrefs { return VSRegisteredEvents.getName(eventClassname); } - public final String getShortname() { - return VSRegisteredEvents.getShortname(eventClassname); + public void setShortname(String eventShortname) { + this.eventShortname = eventShortname; } - public final VSProcess getProcess() { + public String getShortname() { + if (eventShortname == null) + return VSRegisteredEvents.getShortname(eventClassname); + + return eventShortname; + } + + public VSProcess getProcess() { return process; } diff --git a/sources/events/VSRegisteredEvents.java b/sources/events/VSRegisteredEvents.java index 5f73fea..cd375cd 100644 --- a/sources/events/VSRegisteredEvents.java +++ b/sources/events/VSRegisteredEvents.java @@ -59,7 +59,7 @@ public final class VSRegisteredEvents { Vector<String> vector = new Vector<String>(); for (String eventName : set) - if (!getClassname(eventName).startsWith("protocols")) + if (getClassname(eventName).startsWith("events")) vector.add(eventName); Collections.sort(vector); @@ -72,7 +72,7 @@ public final class VSRegisteredEvents { Vector<String> vector = new Vector<String>(); for (String eventClassname : set) - if (!eventClassname.startsWith("protocols")) + if (eventClassname.startsWith("events")) vector.add(eventClassname); Collections.sort(vector); @@ -93,11 +93,6 @@ public final class VSRegisteredEvents { } public static VSEvent createEventInstanceByClassname(String eventClassname, VSProcess process) { - return createEventInstanceByName(getName(eventClassname), process); - } - - public static VSEvent createEventInstanceByName(String eventName, VSProcess process) { - final String eventClassname = eventClassnames.get(eventName); final Object protocolObj = new VSClassLoader().newInstance(eventClassname); if (protocolObj instanceof VSEvent) { @@ -109,10 +104,15 @@ public final class VSRegisteredEvents { return null; } + public static VSEvent createEventInstanceByName(String eventName, VSProcess process) { + return createEventInstanceByClassname(eventClassnames.get(eventName), process); + } + private static void registerEvent(String eventClassname, String eventName, String eventShortname) { if (eventShortname == null) eventShortname = eventName; + //System.out.println(eventClassname); eventNames.put(eventClassname, eventName); eventShortnames.put(eventClassname, eventShortname); eventClassnames.put(eventName, eventClassname); diff --git a/sources/events/implementations/ProtocolEvent.java b/sources/events/implementations/ProtocolEvent.java index 096e9b6..d753978 100644 --- a/sources/events/implementations/ProtocolEvent.java +++ b/sources/events/implementations/ProtocolEvent.java @@ -2,9 +2,10 @@ package events.implementations; import core.VSProcess; import events.*; +import protocols.VSProtocol; public class ProtocolEvent extends VSEvent { - private String eventClassname; + private String protocolClassname; private boolean isClientProtocol; /* true = client, false = server */ private boolean isProtocolActivation; /* true = activate, false = deactivate */ @@ -28,24 +29,38 @@ public class ProtocolEvent extends VSEvent { return isProtocolActivation; } - public void setEventClassname(String eventClassname) { - this.eventClassname = eventClassname; + public void setProtocolClassname(String protocolClassname) { + this.protocolClassname = protocolClassname; } public void onStart() { - String type = isClientProtocol ? "client" : "server"; - String name = VSRegisteredEvents.getName(eventClassname); - process.setBoolean("sim."+name.toLowerCase()+"."+type+".enabled!", isProtocolActivation); + //String type = isClientProtocol ? " Client!" : " Server!"; + //process.setBoolean(protocolClassname + type, isProtocolActivation); + + VSProtocol protocol; + + if (!process.objectExists(protocolClassname)) { + protocol = (VSProtocol) VSRegisteredEvents.createEventInstanceByClassname(protocolClassname, process); + process.setObject(protocolClassname, protocol); + + } else { + protocol = (VSProtocol) process.getObject(protocolClassname); + } + + if (isClientProtocol) + protocol.isClient(isProtocolActivation); + + else + protocol.isServer(isProtocolActivation); StringBuffer buffer = new StringBuffer(); - buffer.append(VSRegisteredEvents.getShortname(eventClassname)); + buffer.append(VSRegisteredEvents.getShortname(protocolClassname)); buffer.append(" "); buffer.append(isClientProtocol ? prefs.getString("lang.client") : prefs.getString("lang.server")); buffer.append(" "); buffer.append(isProtocolActivation ? prefs.getString("lang.activated") : prefs.getString("lang.deactivated")); - logg(buffer.toString()); } } |
