Search in sources :

Example 6 with Javelin

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);
        }
    });
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) BeanInfo(java.beans.BeanInfo) Rectangle(java.awt.Rectangle) Javelin(com.twinsoft.twinj.Javelin)

Example 7 with Javelin

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;
}
Also used : JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Javelin(com.twinsoft.twinj.Javelin)

Example 8 with Javelin

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;
    }
}
Also used : JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Javelin(com.twinsoft.twinj.Javelin) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 9 with Javelin

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() + ");");
        }
    }
}
Also used : JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Javelin(com.twinsoft.twinj.Javelin)

Example 10 with Javelin

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();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) AbstractConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.AbstractConnectorComposite) JavelinConnectorComposite(com.twinsoft.convertigo.eclipse.editors.connector.JavelinConnectorComposite) Javelin(com.twinsoft.twinj.Javelin) IEditorPart(org.eclipse.ui.IEditorPart) Cursor(org.eclipse.swt.graphics.Cursor) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) ConnectorEditorPart(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorPart) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Shell(org.eclipse.swt.widgets.Shell) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) VariableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject) Display(org.eclipse.swt.widgets.Display)

Aggregations

Javelin (com.twinsoft.twinj.Javelin)13 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)12 Rectangle (java.awt.Rectangle)5 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)4 AbstractConnectorComposite (com.twinsoft.convertigo.eclipse.editors.connector.AbstractConnectorComposite)4 ConnectorEditor (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor)4 ConnectorEditorPart (com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorPart)4 JavelinConnectorComposite (com.twinsoft.convertigo.eclipse.editors.connector.JavelinConnectorComposite)4 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)4 Cursor (org.eclipse.swt.graphics.Cursor)4 Display (org.eclipse.swt.widgets.Display)4 Shell (org.eclipse.swt.widgets.Shell)4 JavelinTransaction (com.twinsoft.convertigo.beans.transactions.JavelinTransaction)3 EngineEvent (com.twinsoft.convertigo.engine.EngineEvent)3 EngineException (com.twinsoft.convertigo.engine.EngineException)3 ScreenClassTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject)2 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)2 VariableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)2