use of com.twinsoft.twinj.Javelin in project convertigo by convertigo.
the class JavelinConnectorComposite method handleSelectionChanged.
public void handleSelectionChanged(twinxEvent0 arg0) {
final Javelin javelin = getJavelin();
Rectangle selectedZone = javelin.getSelectionZone();
final boolean bSelected = (selectedZone != null) && (selectedZone.getWidth() != 0) && (selectedZone.getHeight() != 0);
// enable or disable New beans buttons
toolBarSetEnable("NewScreenClass", bSelected);
toolBarSetEnable("NewTagName", bSelected);
toolBarSetEnable("NewWaitAt", bSelected && connector.isLearning());
// enable or disable the link button
// getDisplay().syncExec(new Runnable() {
// public void run() {
// boolean enable = false;
// if (projectExplorerView != null) {
// BeanInfo bi =
// projectExplorerView.getFirstSelectedDatabaseObjectBeanInfo();
// if (bi != null) {
// PropertyDescriptor pd =
// ConvertigoPlugin.getDefault().getSelectedPropertyDescriptor(bi);
// try {
// enable = pd != null &&
// bSelected &&
// getLastDetectedScreenClass() != null &&
// !javelin.getSelectionZone().isEmpty() &&
// (
// pd.getPropertyEditorClass().isAssignableFrom(
// Class.forName("com.twinsoft.convertigo.eclipse.property_editors.ZoneEditor")
// ) ||
// pd.getPropertyEditorClass().isAssignableFrom(
// Class.forName("com.twinsoft.convertigo.eclipse.property_editors.JavelinAttributeEditor")
// ) ||
// pd.getPropertyEditorClass().isAssignableFrom(
// Class.forName("com.twinsoft.convertigo.eclipse.property_editors.JavelinStringEditor")
// )
// );
// } catch (ClassNotFoundException e) {
// enable = false;
// }
// }
// }
// toolBarSetEnable("Link", enable);
// }
// });
// enable or disable the add button
getDisplay().syncExec(new Runnable() {
public void run() {
boolean enable = false;
if (projectExplorerView != null) {
BeanInfo bi = ConvertigoPlugin.getDefault().getProjectExplorerView().getFirstSelectedDatabaseObjectBeanInfo();
if (bi != null) {
PropertyDescriptor pd = ConvertigoPlugin.getDefault().getSelectedPropertyDescriptor(bi);
try {
enable = pd != null && bSelected && // usefull, commented for bug #952
!javelin.getSelectionZone().isEmpty() && (pd.getPropertyEditorClass().isAssignableFrom(Class.forName("com.twinsoft.convertigo.eclipse.property_editors.ColumnEditor")));
} catch (ClassNotFoundException e) {
enable = false;
}
}
}
toolBarSetEnable("Add", enable);
}
});
}
use of com.twinsoft.twinj.Javelin in project convertigo by convertigo.
the class JavelinConnectorComposite method clear.
public void clear() {
JavelinConnector javelinConnector = (JavelinConnector) connector;
Javelin javelin = javelinConnector.javelin;
if (javelin != null) {
javelinConnector.javelin.disconnect();
frame.remove(javelin);
javelin.removetwinxListener(this);
javelin.removeZoneListener(this);
try {
Engine.theApp.sessionManager.removeSession(connector.context.contextID);
} catch (NullPointerException e) {
// Silently ignore: if the Studio is being closed, the Engine
// could
// be yet closed when this method is called, that's why the
// Engine
// instance could be null.
}
javelinConnector.javelin = null;
// if (!isClosing)
// redraw();
timeoutForConnect = 10000;
timeoutForDataStable = 7000;
dataStableThreshold = 3000;
}
if (!isClosing) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
redraw();
toolBarSetEnable("NewScreenClass", false);
toolBarSetEnable("NewTagName", false);
// toolBarSetEnable("Link", false);
toolBarSetEnable("Add", false);
}
});
}
latestBlockFactory = null;
isPlaying = false;
}
use of com.twinsoft.twinj.Javelin in project convertigo by convertigo.
the class JavelinConnectorComposite method reset.
public void reset() {
JavelinConnector javelinConnector = (JavelinConnector) connector;
Javelin javelin = javelinConnector.javelin;
int emulatorID = (int) javelinConnector.emulatorID;
switch(emulatorID) {
case Session.EmulIDSNA:
case Session.EmulIDAS400:
MessageBox messageBox = new MessageBox(getShell(), SWT.OK | SWT.CANCEL | SWT.ICON_QUESTION | SWT.APPLICATION_MODAL);
String message = "This will send a KEY_RESET to the emulator.";
messageBox.setMessage(message);
int ret = messageBox.open();
if (ret == SWT.OK) {
javelin.doAction("KEY_RESET");
Engine.logEmulators.info("KEY_RESET has been sent to the emulator, because of an user request.");
}
break;
default:
ConvertigoPlugin.warningMessageBox("The Reset function is only available for IBM emulators (3270 and AS/400).");
break;
}
}
use of com.twinsoft.twinj.Javelin in project convertigo by convertigo.
the class JavelinConnectorComposite method handleConnected.
public void handleConnected(twinxEvent0 arg0) {
toolBarSetEnable("Connect", false);
toolBarSetEnable("Disconnect", true);
JavelinConnector javelinConnector = (JavelinConnector) connector;
Javelin javelin = javelinConnector.javelin;
javelin.requestFocus();
// Learning mode
if (javelinConnector.isLearning()) {
JavelinTransaction learnTransaction = (JavelinTransaction) javelinConnector.getLearningTransaction();
synchronized (this) {
writeLine("javelin.connect(" + learnTransaction.getTimeoutForConnect() + ");");
}
}
}
use of com.twinsoft.twinj.Javelin in project convertigo by convertigo.
the class TransactionShowVariableAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
String variable = (String) ((VariableTreeObject) treeObject).getObject();
JavelinTransaction transaction = (JavelinTransaction) treeObject.getParent().getParent().getObject();
JavelinConnector javelinConnector = (JavelinConnector) transaction.getParent();
IEditorPart wpart = getConnectorEditor(javelinConnector);
if ((wpart != null) && (wpart instanceof ConnectorEditor)) {
getActivePage().activate(wpart);
ConnectorEditor connectorEditor = (ConnectorEditor) wpart;
ConnectorEditorPart connectorEditorPart = connectorEditor.getConnectorEditorPart();
AbstractConnectorComposite connectorComposite = connectorEditorPart.getConnectorComposite();
if ((connectorComposite != null) && (connectorComposite instanceof JavelinConnectorComposite)) {
Javelin javelin = ((JavelinConnectorComposite) connectorComposite).getJavelin();
ScreenClass currentScreenClass = ((JavelinConnector) connectorEditorPart.getConnector()).getCurrentScreenClass();
String normalizedScreenClassName = StringUtils.normalize(currentScreenClass.getName());
int i;
String handlerName = "on" + normalizedScreenClassName + JavelinTransaction.EVENT_ENTRY_HANDLER;
if ((i = transaction.handlers.indexOf(handlerName)) == -1) {
display.beep();
ConvertigoPlugin.logWarning("Unable to show the position of the variable \"" + variable + "\": no handler found for the current screen class!");
} else {
ConvertigoPlugin.logDebug("Found handler: " + handlerName);
// Delimit the function
int bof, eof;
bof = transaction.handlers.indexOf('{', i) + 2;
eof = transaction.handlers.indexOf("function", bof);
if (eof == -1) {
eof = transaction.handlers.lastIndexOf('}') - 1;
} else {
eof = transaction.handlers.lastIndexOf('}', eof) - 1;
}
String function = transaction.handlers.substring(bof, eof);
// Delimit the marker for generated input variables code
int idxMarker = function.indexOf("\t// begin-of-variables");
if (idxMarker == -1) {
// No variable marker, do nothing
display.beep();
ConvertigoPlugin.logWarning("Unable to show the position of the variable \"" + variable + "\": no variable marker found for the handler!");
return;
}
int idxMarker2 = function.indexOf("\t// end-of-variables", idxMarker);
String code = function.substring(idxMarker, idxMarker2);
String line = "\tjavelin.send(" + variable + ");\n";
int idxPosition = code.indexOf(line);
if (idxPosition == -1) {
ConvertigoPlugin.logDebug("No variable '" + variable + "' found into the handler!");
return;
}
idxPosition = code.lastIndexOf("moveCursor(", idxPosition) + 11;
int idxComa = code.indexOf(',', idxPosition);
int idxClosedParenthesis = code.indexOf(')', idxComa);
int x = Integer.parseInt(code.substring(idxPosition, idxComa).trim());
int y = Integer.parseInt(code.substring(idxComa + 1, idxClosedParenthesis).trim());
ConvertigoPlugin.logDebug("Variable position found: " + x + ", " + y);
javelin.moveCursor(x, y);
}
javelin.requestFocus();
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to show variable to Javelin!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
Aggregations