Search in sources :

Example 21 with CompositeEvent

use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.

the class CreatePropertyTableColumnAction 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) {
            PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) explorerView.getFirstSelectedTreeObject();
            TreeParent owner = propertyTableRowTreeObject.getTreeObjectOwner();
            IPropertyTreeObject pto = propertyTableRowTreeObject.addNewColumn();
            if (owner instanceof DatabaseObjectTreeObject) {
                DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) owner;
                if (databaseObjectTreeObject.hasChanged()) {
                    TreeParent treeParent = databaseObjectTreeObject.getParent();
                    if (treeParent instanceof FolderTreeObject)
                        treeParent = treeParent.getParent();
                    // explorerView.reloadTreeObject(treeParent);
                    explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), pto.getPath()));
                }
            } else
                explorerView.refreshTreeObject(owner, true);
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a new column!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) Cursor(org.eclipse.swt.graphics.Cursor) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Display(org.eclipse.swt.widgets.Display) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Example 22 with CompositeEvent

use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.

the class HtmlConnectorDesignComposite method modelChanged.

public void modelChanged(HttpProxyEvent event) {
    if (!checkProxySource(event)) {
        return;
    }
    String requestString = event.getRequest();
    String responseString = event.getResponse();
    boolean https = event.isHttps();
    int status = Integer.parseInt(event.getStatus());
    // do not record client redirection
    if ((status == HttpStatus.SC_MOVED_TEMPORARILY) || (status == HttpStatus.SC_MOVED_PERMANENTLY) || (status == HttpStatus.SC_SEE_OTHER) || (status == HttpStatus.SC_TEMPORARY_REDIRECT)) {
        return;
    }
    /*if (requestString.indexOf(getServer()) == -1) {
			return;
		}*/
    Map<String, String> headers = parseResponseString(responseString);
    String contentType = headers.get(HeaderName.ContentType.value().toLowerCase());
    // record only text/html or null Content-Type ...
    if (contentType == null) {
        return;
    }
    if (MimeType.Html.is(contentType) && MimeType.Plain.is(contentType)) {
        return;
    }
    ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) Learning statement...");
    try {
        String url, method, handlerName, transactionName, statementName, scHandlerName;
        String normalizedScreenClassName, screenClassName;
        HtmlTransaction htmlTransaction = null;
        HTTPStatement httpStatement = null;
        HtmlScreenClass htmlScreenClass = null;
        HandlerStatement handlerStatement = null;
        ScHandlerStatement scHandlerStatement = null;
        // Document dom = null;
        // Log log = null;
        int size, index1;
        boolean bContinue;
        index1 = 0;
        bContinue = true;
        normalizedScreenClassName = "Unknown";
        htmlTransaction = (HtmlTransaction) htmlConnector.getLearningTransaction();
        synchronized (htmlConnector) {
            // dom = htmlConnector.getCurrentXmlDocument();
            htmlScreenClass = htmlConnector.getCurrentScreenClass();
        }
        screenClassName = htmlScreenClass.getName();
        normalizedScreenClassName = StringUtils.normalize(htmlScreenClass.getName());
        ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) current screen class is '" + screenClassName + "'");
        if (htmlTransaction != null) {
            transactionName = htmlTransaction.getName();
            ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) creating new HTTPStatement");
            ConvertigoPlugin.logDebug2(requestString);
            httpStatement = parseRequestString(requestString);
            httpStatement.setHttps(https);
            httpStatement.setPort(https ? 443 : 80);
            method = httpStatement.getMethod().toLowerCase();
            // size = httpStatement.getVariablesDefinitionSize();
            size = httpStatement.numberOfVariables();
            url = httpStatement.getUrl(htmlConnector.isHttps(), htmlConnector.getServer(), htmlConnector.getPort());
            while (bContinue) {
                statementName = method + ((index1 == 0) ? " " : " " + index1) + " (" + url + " - " + size + ")";
                statementName = StringUtils.normalize(statementName);
                httpStatement.setName(statementName);
                httpStatement.hasChanged = true;
                httpStatement.bNew = true;
                if (htmlScreenClass == null) {
                    try {
                        httpStatement.priority = 0;
                        htmlTransaction.addStatement(httpStatement);
                        ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) added new HTTPStatement to default transaction '" + transactionName + "'");
                        fireObjectChanged(new CompositeEvent(htmlTransaction));
                        Engine.theApp.fireObjectDetected(new EngineEvent(httpStatement));
                        bContinue = false;
                    } catch (ObjectWithSameNameException owsne) {
                        index1++;
                    }
                } else {
                    if (htmlConnector.isAccumulating())
                        handlerName = "on" + normalizedScreenClassName + "Exit";
                    else
                        handlerName = "on" + normalizedScreenClassName + "Entry";
                    handlerStatement = htmlTransaction.getHandlerStatement(handlerName);
                    if (handlerStatement != null) {
                        try {
                            handlerStatement.addStatement(httpStatement);
                            ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) added new HTTPStatement to handler '" + handlerName + "' of transaction '" + transactionName + "'");
                            fireObjectChanged(new CompositeEvent(handlerStatement));
                            Engine.theApp.fireObjectDetected(new EngineEvent(httpStatement));
                            bContinue = false;
                        } catch (ObjectWithSameNameException owsne) {
                            index1++;
                        }
                    } else {
                        try {
                            if (htmlConnector.isAccumulating())
                                scHandlerStatement = new ScExitHandlerStatement(normalizedScreenClassName);
                            else
                                scHandlerStatement = new ScEntryHandlerStatement(normalizedScreenClassName);
                            scHandlerName = scHandlerStatement.getName();
                            scHandlerStatement.setName(scHandlerName);
                            scHandlerStatement.hasChanged = true;
                            scHandlerStatement.bNew = true;
                            scHandlerStatement.priority = 0;
                            htmlTransaction.addStatement(scHandlerStatement);
                            ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) added new ScExitHandlerStatement '" + handlerName + "' of transaction '" + transactionName + "'");
                            try {
                                scHandlerStatement.addStatement(httpStatement);
                                ConvertigoPlugin.logDebug2("(HtmlConnectorDesignComposite) added new HTTPStatement '" + statementName + "' to ScExitHandlerStatement '" + handlerName + "'");
                                fireObjectChanged(new CompositeEvent(htmlTransaction));
                                Engine.theApp.fireObjectDetected(new EngineEvent(httpStatement));
                                bContinue = false;
                            } catch (ObjectWithSameNameException owsne) {
                                index1++;
                            }
                        }// Should not append
                         catch (ObjectWithSameNameException owsne) {
                            throw new EngineException(owsne.getMessage());
                        }
                    }
                }
            }
        } else {
            throw new EngineException("Found none learning transaction");
        }
    } catch (EngineException e) {
        ConvertigoPlugin.logException(e, "An exception occured while learning");
    }
}
Also used : HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) EngineException(com.twinsoft.convertigo.engine.EngineException) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) ScExitHandlerStatement(com.twinsoft.convertigo.beans.statements.ScExitHandlerStatement) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) ScEntryHandlerStatement(com.twinsoft.convertigo.beans.statements.ScEntryHandlerStatement) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) ScHandlerStatement(com.twinsoft.convertigo.beans.statements.ScHandlerStatement)

Example 23 with CompositeEvent

use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.

the class HtmlConnectorDesignComposite method createExtractionRuleFromSelection.

public void createExtractionRuleFromSelection(Document dom) throws EngineException {
    String className = "com.twinsoft.convertigo.beans.core.ExtractionRule";
    // Retrieve selected extraction rule xpath
    String extractionrulesXpath = xpathEvaluator.getSelectionXpath();
    // Retrieve parent ScreenClass
    HtmlScreenClass parentObject = getParentHtmlScreenClass();
    // Add extraction rule to screen class
    NewObjectWizard newObjectWizard = new NewObjectWizard(parentObject, className, extractionrulesXpath, dom);
    WizardDialog wzdlg = new WizardDialog(Display.getCurrent().getActiveShell(), newObjectWizard);
    wzdlg.setPageSize(850, 650);
    wzdlg.open();
    if (wzdlg.getReturnCode() != Window.CANCEL) {
        HtmlExtractionRule extractionrule = (HtmlExtractionRule) newObjectWizard.newBean;
        // Reload parent ScreenClass in Tree
        fireObjectChanged(new CompositeEvent(parentObject));
        // Set selection on new extraction rule (will expand tree to new extraction rule)
        if (extractionrule != null)
            fireObjectSelected(new CompositeEvent(extractionrule));
        // Set back selection on parent ScreenClass
        fireObjectSelected(new CompositeEvent(parentObject));
    }
}
Also used : HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass) HtmlExtractionRule(com.twinsoft.convertigo.beans.extractionrules.HtmlExtractionRule) NewObjectWizard(com.twinsoft.convertigo.eclipse.wizards.new_object.NewObjectWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent)

Example 24 with CompositeEvent

use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent in project convertigo by convertigo.

the class SqlConnectorDesignComposite method createSqlTransactions.

protected void createSqlTransactions(final TableItem[] items) {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = display.getActiveShell();
    if (shell != null) {
        try {
            shell.setCursor(waitCursor);
            for (int i = 0; i < items.length; i++) {
                TableItem item = items[i];
                String callableName = item.getText(0);
                String callableDesc = item.getText(1);
                String specific_name = (String) item.getData("specific_name");
                ConvertigoPlugin.logDebug("Creating transaction for CALL '" + callableName + "' ...");
                if (specific_name.isEmpty()) {
                    specific_name = callableName;
                }
                SqlTransaction sqlTransaction = SqlConnector.createSqlTransaction(sqlConnector, callableName, specific_name);
                if (sqlTransaction != null) {
                    Transaction transaction = sqlConnector.getTransactionByName(sqlTransaction.getName());
                    if (transaction != null) {
                        try {
                            File xsdFile = new File(transaction.getSchemaFilePath());
                            if (xsdFile.exists()) {
                                xsdFile.delete();
                            }
                        } catch (Exception e) {
                        }
                        sqlConnector.remove(transaction);
                    }
                    sqlTransaction.setComment(callableDesc);
                    sqlConnector.add(sqlTransaction);
                    fireObjectChanged(new CompositeEvent(sqlConnector));
                    ConvertigoPlugin.logDebug("Transaction added.");
                }
            }
        } catch (Exception ee) {
            ConvertigoPlugin.logException(ee, "Error while creating transaction(s)");
        } finally {
            shell.setCursor(null);
            waitCursor.dispose();
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) Transaction(com.twinsoft.convertigo.beans.core.Transaction) TableItem(org.eclipse.swt.widgets.TableItem) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) Cursor(org.eclipse.swt.graphics.Cursor) File(java.io.File) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Display(org.eclipse.swt.widgets.Display)

Example 25 with CompositeEvent

use of com.twinsoft.convertigo.eclipse.editors.CompositeEvent 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)

Aggregations

CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)33 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)19 Shell (org.eclipse.swt.widgets.Shell)18 Cursor (org.eclipse.swt.graphics.Cursor)17 Display (org.eclipse.swt.widgets.Display)17 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)10 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)10 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)10 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)9 FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)9 WizardDialog (org.eclipse.jface.wizard.WizardDialog)7 HtmlScreenClass (com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass)5 DesignDocumentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject)5 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)5 Transaction (com.twinsoft.convertigo.beans.core.Transaction)4 NewObjectWizard (com.twinsoft.convertigo.eclipse.wizards.new_object.NewObjectWizard)4 File (java.io.File)4 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)3 Sequence (com.twinsoft.convertigo.beans.core.Sequence)3 Step (com.twinsoft.convertigo.beans.core.Step)3