Search in sources :

Example 31 with ScreenClass

use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.

the class DatabaseObjectTreeObject method getPropertyValue.

public Object getPropertyValue(Object id) {
    if (id == null)
        return null;
    DatabaseObject databaseObject = getObject();
    String propertyName = (String) id;
    if (propertyName.equals(P_TYPE))
        return databaseObjectBeanDescriptor.getDisplayName();
    else if (propertyName.equals(P_JAVA_CLASS))
        return databaseObject.getClass().getName();
    else if (propertyName.equals(P_NAME))
        return databaseObject.getName();
    else if (propertyName.equals(P_QNAME))
        return databaseObject.getQName();
    else if (propertyName.equals(P_PRIORITY))
        return Long.toString(databaseObject.priority);
    else if (propertyName.equals(P_DEPTH)) {
        if (databaseObject instanceof ScreenClass)
            return Integer.toString(((ScreenClass) databaseObject).getDepth());
        else
            return org.apache.commons.lang3.StringUtils.countMatches(databaseObject.getQName(), '.');
    } else if (propertyName.equals(P_EXPORTED)) {
        return databaseObject.getProject().getInfoForProperty("exported");
    } else if (propertyName.equals(P_MIN_VERSION)) {
        return databaseObject.getProject().getMinVersion();
    } else {
        try {
            java.beans.PropertyDescriptor databaseObjectPropertyDescriptor = getPropertyDescriptor(propertyName);
            if (databaseObjectPropertyDescriptor == null) {
                return null;
            }
            Class<?> pec = databaseObjectPropertyDescriptor.getPropertyEditorClass();
            Method getter = databaseObjectPropertyDescriptor.getReadMethod();
            Object compilablePropertySourceValue = databaseObject.getCompilablePropertySourceValue(propertyName);
            Object value;
            if (compilablePropertySourceValue == null) {
                Object[] args = {};
                value = getter.invoke(databaseObject, args);
            } else {
                value = compilablePropertySourceValue;
            }
            boolean done = false;
            if (value instanceof String) {
                PropertyDescriptor propertyDescriptor = findPropertyDescriptor(id);
                if (propertyDescriptor instanceof DynamicComboBoxPropertyDescriptor) {
                    DynamicComboBoxPropertyDescriptor pd = (DynamicComboBoxPropertyDescriptor) propertyDescriptor;
                    value = pd.setValue((String) value);
                    done = true;
                }
            }
            if (done) {
            // do nothing
            } else if (value instanceof Boolean) {
                value = ((Boolean) value).booleanValue() ? Integer.valueOf(0) : Integer.valueOf(1);
            } else if ((pec != null) && (PropertyWithTagsEditor.class.isAssignableFrom(pec) || Enum.class.isAssignableFrom(pec))) {
                if (!(value instanceof Integer)) {
                    if (PropertyWithTagsEditorAdvance.class.isAssignableFrom(pec)) {
                        Method getTags = pec.getMethod("getTags", new Class[] { DatabaseObjectTreeObject.class, String.class });
                        String[] tags = (String[]) getTags.invoke(null, new Object[] { this, propertyName });
                        int i;
                        for (i = 0; i < tags.length; i++) {
                            if (tags[i].equals(value)) {
                                value = Integer.valueOf(i);
                                break;
                            }
                        }
                        // if we did not find our string in the tag list set value to index 0
                        if (i == tags.length) {
                            value = Integer.valueOf(0);
                            String message = "Incorrect property \"" + propertyName + "\" value for the object \"" + databaseObject.getName() + "\".";
                            ConvertigoPlugin.logWarning(message);
                        }
                    } else if (Enum.class.isAssignableFrom(pec)) {
                        value = Integer.valueOf(((Enum<?>) value).ordinal());
                    } else if (StringComboBoxPropertyDescriptor.class.isAssignableFrom(pec)) {
                    // nothing to do: value is a string
                    }
                }
                if ((EmulatorTechnologyEditor.class.equals(pec))) {
                    Method getEmulatorClassNames = pec.getDeclaredMethod("getEmulatorClassNames", new Class[] { DatabaseObjectTreeObject.class });
                    String[] emulatorClassNames = (String[]) getEmulatorClassNames.invoke(null, new Object[] { this });
                    for (int i = 0; i < emulatorClassNames.length; i++) {
                        if (emulatorClassNames[i].equals(value)) {
                            value = Integer.valueOf(i);
                            break;
                        }
                    }
                }
            // else simply return the combo index
            } else if (value instanceof Number) {
                value = ((Number) value).toString();
            }
            // Get property's nillable value
            if (Boolean.TRUE.equals(databaseObjectPropertyDescriptor.getValue("nillable"))) {
                try {
                    Boolean isNull = ((INillableProperty) databaseObject).isNullProperty(propertyName);
                    PropertyDescriptor pd = findPropertyDescriptor(propertyName);
                    if ((pd != null) && (pd instanceof DataOrNullPropertyDescriptor)) {
                        ((DataOrNullPropertyDescriptor) pd).setNullProperty(isNull);
                        if (isNull) {
                            // Overrides value by fake one used by property editor
                            if (value instanceof String)
                                value = "<value is null>";
                            if (value instanceof XMLVector) {
                                XMLVector<Object> xmlv = new XMLVector<Object>();
                                xmlv.add("null");
                                value = xmlv;
                            }
                        }
                    }
                } catch (Exception e) {
                    String message = "Error while trying to retrieve 'isNull' attribute of property \"" + propertyName + "\" for the object \"" + databaseObject.getName() + "\".";
                    ConvertigoPlugin.logException(e, message);
                }
            }
            // Check for property normalized value if needed
            if (Boolean.TRUE.equals(databaseObjectPropertyDescriptor.getValue(DatabaseObject.PROPERTY_XMLNAME))) {
                // Ignore compilable property source value
                if (compilablePropertySourceValue == null) {
                    if (value instanceof String) {
                        if (!XMLUtils.checkName(value.toString())) {
                            String message = "Property \"" + propertyName + "\" value for the object \"" + databaseObject.getName() + "\" isn't XML compliant.";
                            ConvertigoPlugin.logError(message, Boolean.TRUE);
                        }
                    }
                }
            }
            return value;
        } catch (Exception e) {
            String message = "Error while trying to retrieve property \"" + propertyName + "\" value for the object \"" + databaseObject.getName() + "\".";
            ConvertigoPlugin.logException(e, message);
            return null;
        }
    }
}
Also used : XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) InfoPropertyDescriptor(com.twinsoft.convertigo.eclipse.views.projectexplorer.InfoPropertyDescriptor) DynamicComboBoxPropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.DynamicComboBoxPropertyDescriptor) PropertyDescriptor(org.eclipse.ui.views.properties.PropertyDescriptor) StringComboBoxPropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.StringComboBoxPropertyDescriptor) TextPropertyDescriptor(org.eclipse.ui.views.properties.TextPropertyDescriptor) ScriptablePropertyDescriptor(com.twinsoft.convertigo.eclipse.views.projectexplorer.ScriptablePropertyDescriptor) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor) DynamicInfoPropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.DynamicInfoPropertyDescriptor) DataOrNullPropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.DataOrNullPropertyDescriptor) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) Method(java.lang.reflect.Method) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) UndefinedSymbolsException(com.twinsoft.convertigo.engine.UndefinedSymbolsException) DynamicComboBoxPropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.DynamicComboBoxPropertyDescriptor) StringComboBoxPropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.StringComboBoxPropertyDescriptor) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) PropertyWithTagsEditorAdvance(com.twinsoft.convertigo.eclipse.property_editors.PropertyWithTagsEditorAdvance) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DataOrNullPropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.DataOrNullPropertyDescriptor)

Example 32 with ScreenClass

use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.

the class ConnectorEditorPart method objectDetected.

public void objectDetected(EngineEvent engineEvent) {
    if (!checkEventSource(engineEvent))
        return;
    final Object source = engineEvent.getSource();
    getDisplay().syncExec(() -> {
        if (source instanceof ScreenClass) {
            lastDetectedScreenClass = (ScreenClass) source;
            labelLastDetectedScreenClass.setText(lastDetectedScreenClass.getName());
            compositeOutputFooter.layout();
        }
        if (bDebug) {
            String message = MessageFormat.format("The following database object has been detected: \"{0}\"\n", new Object[] { ((DatabaseObject) source).getName() });
            try {
                ConvertigoPlugin.getDefault().debugConsoleStream.write(message);
            } catch (IOException e) {
            }
        }
    });
}
Also used : ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) EventObject(java.util.EventObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IOException(java.io.IOException)

Example 33 with ScreenClass

use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.

the class JavelinConnectorComposite method goToCurrentScreenClass.

/**
 * Highlight the current screen class in tree view
 */
public void goToCurrentScreenClass() {
    synchronized (connector) {
        ScreenClass screenClass = ((JavelinConnector) connector).getCurrentScreenClass();
        fireObjectSelected(new CompositeEvent(screenClass));
        if (connector.isLearning()) {
            if (bHandlerOpened) {
                closeScreenClassHandler("redetect");
            }
            openScreenClassHandler(true);
            getJavelin().requestFocus();
        }
    }
}
Also used : JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent)

Example 34 with ScreenClass

use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.

the class JavelinConnectorComposite method keyPressed.

public void keyPressed(java.awt.event.KeyEvent keyEvent) {
    ScreenClass currentScreenClass = null;
    JavelinConnector javelinConnector = (JavelinConnector) connector;
    // Learning mode
    if (javelinConnector.isLearning()) {
        synchronized (javelinConnector) {
            currentScreenClass = javelinConnector.getCurrentScreenClass();
        }
        synchronized (this) {
            char c = keyEvent.getKeyChar();
            // Avoiding handle null key char
            if (c == 0x0)
                return;
            if (Character.isLetterOrDigit(c) || c == ' ') {
                keysBuffer += c;
            } else {
                String doActionName = findActionName(javelinConnector.emulatorID, keyEvent);
                if (doActionName != null) {
                    if (learnScreenClass == null) {
                        learnScreenClass = currentScreenClass;
                    } else if (!learnScreenClass.equals(currentScreenClass)) {
                        if (javelinConnector.isAccumulating()) {
                            closeScreenClassHandler();
                            openScreenClassHandler(false);
                            closeScreenClassHandler("accumulate");
                        } else {
                            closeScreenClassHandler("redetect");
                        }
                        // learnScreenClass =
                        // projectExplorerView.getLastDetectedScreenClass();
                        learnScreenClass = currentScreenClass;
                        openScreenClassHandler(true);
                    }
                    // videotex)
                    if (bDoAction && (javelinConnector.emulatorID == 1)) {
                        long rightNow = new java.util.Date().getTime();
                        writeLine("javelin.waitSync(" + (rightNow - doActionTime) + ");");
                        bDoAction = false;
                    }
                    // Flushing alphanumeric buffer
                    if (keysBuffer.length() != 0) {
                        writeLine("javelin.send(\"" + keysBuffer + "\");");
                        keysBuffer = "";
                    }
                    // Writing emulator action
                    writeLine("javelin.doAction(\"" + doActionName + "\");");
                    bDoAction = true;
                    doActionTime = new java.util.Date().getTime();
                }
            }
        }
    }
}
Also used : JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass)

Example 35 with ScreenClass

use of com.twinsoft.convertigo.beans.core.ScreenClass in project convertigo by convertigo.

the class HttpTriggerScreenClassEditorComposite method initialize.

/**
 * This method initializes this
 */
private void initialize() {
    ScreenClassTrigger trigger = (parent.getTrigger() instanceof ScreenClassTrigger) ? (ScreenClassTrigger) parent.getTrigger() : null;
    scrClass_label = new Label(this, SWT.NONE);
    scrClass_label.setText("Screen classes");
    scrClass_list = new List(this, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
    java.util.List<HtmlScreenClass> scList = getScreenClassList();
    java.util.List<String> items = new ArrayList<String>();
    for (ScreenClass sc : scList) {
        String scName = sc.getName();
        scrClass_list.add(scName);
        if (trigger != null) {
            if (trigger.getScreenClasses().contains(scName)) {
                items.add(scName);
            }
        }
    }
    scrClass_list.setSelection(items.toArray(new String[items.size()]));
    GridData gridData2 = new GridData();
    gridData2.horizontalAlignment = GridData.FILL;
    gridData2.verticalAlignment = GridData.FILL;
    gridData2.grabExcessHorizontalSpace = true;
    scrClass_list.setLayoutData(gridData2);
    scrClass_list.setSize(400, 250);
}
Also used : ScreenClassTrigger(com.twinsoft.convertigo.engine.parsers.triggers.ScreenClassTrigger) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) GridData(org.eclipse.swt.layout.GridData) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass)

Aggregations

ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)47 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)17 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)16 Transaction (com.twinsoft.convertigo.beans.core.Transaction)16 EngineException (com.twinsoft.convertigo.engine.EngineException)15 Connector (com.twinsoft.convertigo.beans.core.Connector)14 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)13 Statement (com.twinsoft.convertigo.beans.core.Statement)13 JavelinScreenClass (com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass)10 IOException (java.io.IOException)10 Step (com.twinsoft.convertigo.beans.core.Step)9 HandlerStatement (com.twinsoft.convertigo.beans.statements.HandlerStatement)9 Criteria (com.twinsoft.convertigo.beans.core.Criteria)8 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)8 Project (com.twinsoft.convertigo.beans.core.Project)7 ScHandlerStatement (com.twinsoft.convertigo.beans.statements.ScHandlerStatement)7 ArrayList (java.util.ArrayList)7 Sheet (com.twinsoft.convertigo.beans.core.Sheet)6 FunctionStatement (com.twinsoft.convertigo.beans.statements.FunctionStatement)6 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)6