LOG.info("Receiving drivers for device " + deviceName);
List<Class<? extends IDriver>> driversForDevice =
guiHandler.getDriversForDevice(deviceName);
boolean deviceCreated = false;
Device device = null;
try {
for (Class<? extends IDriver> driverClass : driversForDevice) {
StringBuilder popupBuilder = new StringBuilder();
LOG.info("Using driver: " + driverClass.getName());
PopupListener driverPopupListener = new PopupListener();
guiHandler.newPatch(library, deviceName, driverClass,
driverPopupListener);
List<PopupContainer> driverPopups =
driverPopupListener.getPopups();
for (PopupContainer popup : driverPopups) {
popupBuilder.append(popup.getContents());
popupBuilder.append("\n\n--------------------------\n\n");
}
LOG.info("Opening patch editor");
PopupListener editorPopupListener = new PopupListener();
FrameWrapper patchEditor =
guiHandler.openPatchEditor(table, -1, 0,
editorPopupListener, true);
List<PopupContainer> editorPopups =
editorPopupListener.getPopups();
for (PopupContainer popup : editorPopups) {
popupBuilder.append(popup.getContents());
popupBuilder.append("\n\n--------------------------\n\n");
}
try {
if (patchEditor == null) {
// No editor at all showed up.
continue;
}
Container component = patchEditor.component();
if (component instanceof MDIFrameProxy) {
MDIFrameProxy proxy = (MDIFrameProxy) component;
JSLFrame jslFrame = proxy.getJSLFrame();
if (jslFrame instanceof PatchEditorFrame) {
PatchEditorFrame frame =
(PatchEditorFrame) jslFrame;
IDriver driver = frame.getPatch().getDriver();
if (!deviceCreated) {
device = driver.getDevice();
createDevice(device, infoText);
deviceCreated = true;
}
createPatchDriver(patchEditor, infoText,
(IPatchDriver) driver);
} else if (jslFrame instanceof BankEditorFrame) {
BankEditorFrame frame = (BankEditorFrame) jslFrame;
IDriver driver = frame.getBankData().getDriver();
if (!deviceCreated) {
device = driver.getDevice();
createDevice(device, infoText);
deviceCreated = true;
}
createBankDriver(infoText, patchEditor,
(IBankDriver) driver);
}
}
} finally {
if (patchEditor != null) {
LOG.info("Close patch editor frame");
guiHandler.closeFrame(patchEditor, false);
}
if (library != null) {
LOG.info("Selecting library frame");
guiHandler.selectLibraryFrame(library);
}
}
}
} finally {
if (!deviceCreated) {
throw new IllegalStateException("Device was never created");
}
properties.store(new FileOutputStream(new File(outDir, device
.getClass().getSimpleName() + ".properties")), null);
deviceSpecDocument.save(new File(outDir, device.getClass()
.getSimpleName() + ".xml"));
if (library != null) {
LOG.info("Closing library");
guiHandler.closeLibrary(library);