-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make monitors delegate to SWTMonitor when possible
- Loading branch information
1 parent
8955e23
commit aecf9b4
Showing
2 changed files
with
66 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package edu.umd.cs.guitar.ripper; | ||
|
||
import edu.umd.cs.guitar.event.EventManager; | ||
import edu.umd.cs.guitar.event.GEvent; | ||
import edu.umd.cs.guitar.model.SWTApplication; | ||
import edu.umd.cs.guitar.model.SWTConstants; | ||
import edu.umd.cs.guitar.util.GUITARLog; | ||
|
||
/** | ||
* Contains actions common to {@link SWTRipperMonitor} and | ||
* {@link SWTReplayerMonitor}. | ||
* | ||
* @author Gabe Gorelick | ||
*/ | ||
public class SWTMonitor { | ||
|
||
private final SWTApplication application; | ||
|
||
public SWTMonitor(SWTGuitarConfiguration config, SWTApplication app) { | ||
this.application = app; | ||
} | ||
|
||
public void cleanUp() { | ||
application.getDisplay().syncExec(new Runnable() { | ||
@Override | ||
public void run() { | ||
application.getDisplay().dispose(); | ||
} | ||
}); | ||
GUITARLog.log.info("Display disposed"); | ||
} | ||
|
||
/** | ||
* Register the default supported events. | ||
* | ||
* @see EventManager | ||
* @see SWTConstants#DEFAULT_SUPPORTED_EVENTS | ||
*/ | ||
public void registerEvents() { | ||
EventManager em = EventManager.getInstance(); | ||
|
||
for (Class<? extends GEvent> event : SWTConstants.DEFAULT_SUPPORTED_EVENTS) { | ||
em.registerEvent(event); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,18 +29,20 @@ | |
import edu.umd.cs.guitar.util.GUITARLog; | ||
|
||
/** | ||
* Monitor for {@link SWTRipper} to handle SWT specific features. Adapted from | ||
* <code>JFCRipperMonitor</code>. | ||
* | ||
* Monitor for the ripper to handle SWT specific features | ||
* | ||
* @see GRipperMonitor | ||
* | ||
* @author Gabe Gorelick | ||
* @author <a href="mailto:[email protected]"> Matt Kirn </a> | ||
* @author <a href="mailto:[email protected]"> Alex Loeb </a> | ||
*/ | ||
public class SWTRipperMonitor extends GRipperMonitor { | ||
|
||
private SWTApplication application; | ||
private SWTRipperConfiguration configuration; | ||
private final SWTApplication application; | ||
private final SWTRipperConfiguration configuration; | ||
|
||
// monitor to delegate actions shared with replayer to | ||
private final SWTMonitor monitor; | ||
|
||
private List<String> sRootWindows = new ArrayList<String>(); | ||
|
||
|
@@ -58,19 +60,20 @@ public class SWTRipperMonitor extends GRipperMonitor { | |
/** | ||
* Constructor | ||
* | ||
* @param configuration | ||
* @param config | ||
* ripper configuration | ||
* @param app | ||
*/ | ||
public SWTRipperMonitor(SWTRipperConfiguration configuration, SWTApplication app) { | ||
public SWTRipperMonitor(SWTRipperConfiguration config, SWTApplication app) { | ||
super(); | ||
|
||
if (configuration == null) { | ||
configuration = new SWTRipperConfiguration(); | ||
if (config == null) { | ||
config = new SWTRipperConfiguration(); | ||
} | ||
|
||
this.configuration = configuration; | ||
this.configuration = config; | ||
this.application = app; | ||
this.monitor = new SWTMonitor(configuration, app); | ||
|
||
// don't store application.getDisplay because it's still null at this point | ||
} | ||
|
@@ -119,23 +122,15 @@ public void run() { | |
@Override | ||
public void setUp() { | ||
|
||
// Registering default supported events | ||
|
||
monitor.registerEvents(); | ||
EventManager em = EventManager.getInstance(); | ||
|
||
for (Class<? extends GEvent> event : SWTConstants.DEFAULT_SUPPORTED_EVENTS) { | ||
em.registerEvent(event); | ||
} | ||
|
||
// Registering customized supported event | ||
// Class<? extends GEvent> gCustomizedEvents; | ||
|
||
String[] sCustomizedEventList; | ||
if (configuration.getCustomizedEventList() != null) | ||
String[] sCustomizedEventList = new String[0]; | ||
if (configuration.getCustomizedEventList() != null) { | ||
sCustomizedEventList = configuration.getCustomizedEventList() | ||
.split(GUITARConstants.CMD_ARGUMENT_SEPARATOR); | ||
else | ||
sCustomizedEventList = new String[0]; | ||
} | ||
|
||
for (String sEvent : sCustomizedEventList) { | ||
try { | ||
|
@@ -145,7 +140,6 @@ public void setUp() { | |
} catch (ClassNotFoundException e) { | ||
GUITARLog.log.error(e); | ||
} | ||
|
||
} | ||
|
||
// Set up parameters | ||
|
@@ -157,13 +151,7 @@ public void setUp() { | |
|
||
@Override | ||
public void cleanUp() { | ||
application.getDisplay().syncExec(new Runnable() { | ||
@Override | ||
public void run() { | ||
application.getDisplay().dispose(); | ||
} | ||
}); | ||
GUITARLog.log.info("Display disposed"); | ||
monitor.cleanUp(); | ||
} | ||
|
||
@Override | ||
|