Search in sources :

Example 1 with Sheet

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

the class NewObjectWizard method doFinish.

private void doFinish(IProgressMonitor monitor) throws CoreException {
    String dboName, name;
    boolean bContinue = true;
    int index = 0;
    try {
        int total = 0;
        Class<?> c = getCreatedBeanClass();
        if (c != null) {
            total = 4;
            if (c.equals(WebServiceReference.class)) {
                total += ImportWsReference.getTotalTaskNumber();
            }
        }
        monitor.beginTask("Creating new object", total);
        newBean = getCreatedBean();
        if (newBean != null) {
            monitor.setTaskName("Object created");
            monitor.worked(1);
            dboName = newBean.getName();
            if (!StringUtils.isNormalized(dboName))
                throw new EngineException("Bean name is not normalized : \"" + dboName + "\".");
            // Verify if a child object with same name exist and change name
            while (bContinue) {
                if (index == 0)
                    name = dboName;
                else
                    name = dboName + index;
                newBean.setName(name);
                newBean.hasChanged = true;
                newBean.bNew = true;
                try {
                    new WalkHelper() {

                        boolean root = true;

                        boolean find = false;

                        @Override
                        protected boolean before(DatabaseObject dbo, Class<? extends DatabaseObject> dboClass) {
                            boolean isInstance = dboClass.isInstance(newBean);
                            find |= isInstance;
                            return isInstance;
                        }

                        @Override
                        protected void walk(DatabaseObject dbo) throws Exception {
                            if (root) {
                                root = false;
                                super.walk(dbo);
                                if (!find) {
                                    throw new EngineException("You cannot add to a " + newBean.getClass().getSimpleName() + " a database object of type " + parentObject.getClass().getSimpleName());
                                }
                            } else {
                                if (newBean.getName().equalsIgnoreCase(dbo.getName())) {
                                    throw new ObjectWithSameNameException("Unable to add the object because an object with the same name already exists in target.");
                                }
                            }
                        }
                    }.init(parentObject);
                    bContinue = false;
                } catch (ObjectWithSameNameException owsne) {
                    if ((parentObject instanceof HtmlTransaction) && (newBean instanceof Statement)) {
                        throw new EngineException("HtmlTransaction already contains a statement named \"" + name + "\".", owsne);
                    }
                    // Silently ignore
                    index++;
                } catch (EngineException ee) {
                    throw ee;
                } catch (Exception e) {
                    throw new EngineException("Exception in create", e);
                }
            }
            // Now add bean to target
            try {
                boolean hasChanged = parentObject.hasChanged;
                if ((newBean instanceof Statement) && (parentObject instanceof Transaction)) {
                    newBean.priority = 0;
                }
                if (newBean instanceof ScreenClass)
                    newBean.priority = parentObject.priority + 1;
                if (newBean instanceof Criteria) {
                    Connector connector = parentObject.getConnector();
                    if (parentObject.equals(((IScreenClassContainer<?>) connector).getDefaultScreenClass()))
                        throw new EngineException("You cannot add a new criterion on default screenclass.");
                }
                parentObject.add(newBean);
                monitor.setTaskName("Object added");
                monitor.worked(1);
                if (newBean instanceof HTTPStatement) {
                    HTTPStatement httpStatement = (HTTPStatement) newBean;
                    HtmlConnector connector = (HtmlConnector) httpStatement.getParentTransaction().getParent();
                    httpStatement.setMethod("GET");
                    httpStatement.setHost(connector.getServer());
                    httpStatement.setPort(connector.getPort());
                    httpStatement.setHttps(connector.isHttps());
                }
                if (newBean instanceof ContinueWithSiteClipperStatement) {
                    Project project = newBean.getProject();
                    if (project != null) {
                        String[] connectorWithSiteClipperConnector = ContinueWithSiteClipperStatement.getSiteClippersConnectorNames(project);
                        if (connectorWithSiteClipperConnector.length > 0) {
                            ((ContinueWithSiteClipperStatement) newBean).setSiteClipperConnectorName(connectorWithSiteClipperConnector[0]);
                        }
                    }
                }
                if (newBean instanceof Connector) {
                    Project project = (Project) parentObject;
                    if (project.getDefaultConnector() == null)
                        project.setDefaultConnector((Connector) newBean);
                    Connector.setupConnector(newBean);
                }
                if (newBean instanceof PageComponent) {
                    ApplicationComponent application = (ApplicationComponent) parentObject;
                    if (application.getRootPage() == null)
                        application.setRootPage((PageComponent) newBean);
                }
                if (newBean instanceof SequenceStep) {
                    Project project = newBean.getProject();
                    ((SequenceStep) newBean).setSourceSequence(project.getName() + TransactionStep.SOURCE_SEPARATOR + project.getSequencesList().get(0));
                }
                if (newBean instanceof TransactionStep) {
                    Project project = newBean.getProject();
                    Connector connector = project.getDefaultConnector();
                    Transaction transaction = connector.getDefaultTransaction();
                    ((TransactionStep) newBean).setSourceTransaction(project.getName() + TransactionStep.SOURCE_SEPARATOR + connector.getName() + TransactionStep.SOURCE_SEPARATOR + transaction.getName());
                }
                if (newBean instanceof IThenElseContainer) {
                    ThenStep thenStep = new ThenStep();
                    ((IThenElseContainer) newBean).addStep(thenStep);
                    ElseStep elseStep = new ElseStep();
                    ((IThenElseContainer) newBean).addStep(elseStep);
                }
                if (newBean instanceof IThenElseStatementContainer) {
                    ThenStatement thenStatement = new ThenStatement();
                    ((IThenElseStatementContainer) newBean).addStatement(thenStatement);
                    ElseStatement elseStatement = new ElseStatement();
                    ((IThenElseStatementContainer) newBean).addStatement(elseStatement);
                }
                if (newBean instanceof Sheet) {
                    InputStream is = null;
                    try {
                        String sheetName = newBean.getName() + ".xsl";
                        is = new FileInputStream(new File(Engine.XSL_PATH + "/customsheet.xsl"));
                        String projectName = ((DatabaseObject) parentObject).getProject().getName();
                        IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
                        final IFile file = project.getFile(sheetName);
                        if (!file.exists())
                            file.create(is, true, null);
                        ((Sheet) newBean).setUrl(sheetName);
                    } catch (Exception e) {
                    } finally {
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException e) {
                            }
                        }
                    }
                }
                if (newBean instanceof TestCase) {
                    TestCase testCase = (TestCase) newBean;
                    testCase.importRequestableVariables((RequestableObject) testCase.getParent());
                }
                if (newBean instanceof RequestableHttpVariable) {
                    RequestableHttpVariable variable = (RequestableHttpVariable) newBean;
                    AbstractHttpTransaction httpTransaction = (AbstractHttpTransaction) variable.getParent();
                    HttpMethodType httpMethodType = httpTransaction.getHttpVerb();
                    boolean isVarPost = httpMethodType.equals(HttpMethodType.PUT) || httpMethodType.equals(HttpMethodType.POST);
                    variable.setHttpMethod(isVarPost ? HttpMethodType.POST.name() : HttpMethodType.GET.name());
                    if (!(httpTransaction instanceof HtmlTransaction)) {
                        variable.setHttpName(variable.getName());
                    }
                }
                if (newBean instanceof WebServiceReference) {
                    try {
                        Project project = (Project) parentObject;
                        WebServiceReference webServiceReference = (WebServiceReference) newBean;
                        ImportWsReference wsr = new ImportWsReference(webServiceReference);
                        wsr.importInto(project);
                    } catch (Exception e) {
                        if (newBean != null) {
                            parentObject.remove(newBean);
                            parentObject.hasChanged = hasChanged;
                        }
                        throw new Exception(e);
                    }
                }
                if (newBean instanceof RestServiceReference) {
                    try {
                        Project project = (Project) parentObject;
                        RestServiceReference restServiceReference = (RestServiceReference) newBean;
                        ImportWsReference wsr = new ImportWsReference(restServiceReference);
                        wsr.importInto(project);
                    } catch (Exception e) {
                        if (newBean != null) {
                            parentObject.remove(newBean);
                            parentObject.hasChanged = hasChanged;
                        }
                        throw new Exception(e);
                    }
                }
                if (newBean instanceof SqlTransaction) {
                    SqlTransaction sqlTransaction = (SqlTransaction) newBean;
                    sqlTransaction.setSqlQuery(sqlQueriesWizardPage.getSQLQueries());
                    sqlTransaction.initializeQueries(true);
                }
                if (newBean instanceof SapJcoLogonTransaction) {
                    SapJcoLogonTransaction sapLogonTransaction = (SapJcoLogonTransaction) newBean;
                    sapLogonTransaction.addCredentialsVariables();
                }
                if (newBean instanceof AbstractCouchDbTransaction) {
                    AbstractCouchDbTransaction abstractCouchDbTransaction = (AbstractCouchDbTransaction) newBean;
                    List<CouchVariable> selectedVariables = objectInfoPage.getSelectedParameters();
                    abstractCouchDbTransaction.createVariables(selectedVariables);
                }
                ConvertigoPlugin.logInfo("New object class '" + this.className + "' named '" + newBean.getName() + "' has been added");
                monitor.setTaskName("Object setted up");
                monitor.worked(1);
                bContinue = false;
            } catch (com.twinsoft.convertigo.engine.ObjectWithSameNameException owsne) {
                if (newBean instanceof HandlerStatement) {
                    throw owsne;
                }
            }
        } else {
            throw new Exception("Could not instantiate bean!");
        }
    } catch (Exception e) {
        String message = "Unable to create a new object from class '" + this.className + "'.";
        ConvertigoPlugin.logException(e, message);
        if (objectExplorerPage != null) {
            objectExplorerPage.doCancel();
        }
    }
}
Also used : RestServiceReference(com.twinsoft.convertigo.beans.references.RestServiceReference) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) IThenElseContainer(com.twinsoft.convertigo.beans.steps.IThenElseContainer) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) HttpMethodType(com.twinsoft.convertigo.engine.enums.HttpMethodType) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) EngineException(com.twinsoft.convertigo.engine.EngineException) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) AbstractHttpTransaction(com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) AbstractCouchDbTransaction(com.twinsoft.convertigo.beans.transactions.couchdb.AbstractCouchDbTransaction) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) FileInputStream(java.io.FileInputStream) IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) SapJcoLogonTransaction(com.twinsoft.convertigo.beans.transactions.SapJcoLogonTransaction) Transaction(com.twinsoft.convertigo.beans.core.Transaction) AbstractHttpTransaction(com.twinsoft.convertigo.beans.transactions.AbstractHttpTransaction) AbstractCouchDbTransaction(com.twinsoft.convertigo.beans.transactions.couchdb.AbstractCouchDbTransaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) IFile(org.eclipse.core.resources.IFile) File(java.io.File) CouchVariable(com.twinsoft.convertigo.beans.transactions.couchdb.CouchVariable) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) IFile(org.eclipse.core.resources.IFile) SapJcoLogonTransaction(com.twinsoft.convertigo.beans.transactions.SapJcoLogonTransaction) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Criteria(com.twinsoft.convertigo.beans.core.Criteria) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) ImportWsReference(com.twinsoft.convertigo.engine.util.ImportWsReference) IThenElseStatementContainer(com.twinsoft.convertigo.beans.statements.IThenElseStatementContainer) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ContinueWithSiteClipperStatement(com.twinsoft.convertigo.beans.statements.ContinueWithSiteClipperStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) SqlTransaction(com.twinsoft.convertigo.beans.transactions.SqlTransaction) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException) IOException(java.io.IOException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) IProject(org.eclipse.core.resources.IProject) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) TestCase(com.twinsoft.convertigo.beans.core.TestCase) WebServiceReference(com.twinsoft.convertigo.beans.references.WebServiceReference) Sheet(com.twinsoft.convertigo.beans.core.Sheet) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException)

Example 2 with Sheet

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

the class ProjectExplorerView method loadDatabaseObject.

private void loadDatabaseObject(TreeParent parentTreeObject, DatabaseObject parentDatabaseObject, ProjectLoadingJob projectLoadingJob, final IProgressMonitor monitor) throws EngineException, IOException {
    try {
        new WalkHelper() {

            // recursion parameters
            TreeParent parentTreeObject;

            ProjectLoadingJob projectLoadingJob;

            // sibling parameters
            ObjectsFolderTreeObject currentTreeFolder = null;

            public void init(DatabaseObject databaseObject, TreeParent parentTreeObject, ProjectLoadingJob projectLoadingJob) throws Exception {
                this.parentTreeObject = parentTreeObject;
                this.projectLoadingJob = projectLoadingJob;
                walkInheritance = true;
                super.init(databaseObject);
            }

            protected ObjectsFolderTreeObject getFolder(TreeParent treeParent, int folderType) {
                ObjectsFolderTreeObject ofto = null;
                for (TreeObject to : treeParent.getChildren()) {
                    if (to instanceof ObjectsFolderTreeObject) {
                        if (((ObjectsFolderTreeObject) to).folderType == folderType) {
                            ofto = (ObjectsFolderTreeObject) to;
                            break;
                        }
                    }
                }
                if (ofto == null) {
                    ofto = new ObjectsFolderTreeObject(viewer, folderType);
                    treeParent.addChild(ofto);
                }
                return ofto;
            }

            @Override
            protected void walk(DatabaseObject databaseObject) throws Exception {
                // retrieve recursion parameters
                final TreeParent parentTreeObject = this.parentTreeObject;
                final ProjectLoadingJob projectLoadingJob = this.projectLoadingJob;
                // retrieve sibling parameters
                ObjectsFolderTreeObject currentTreeFolder = this.currentTreeFolder;
                String dboName = (databaseObject instanceof Step) ? ((Step) databaseObject).getStepNodeName() : databaseObject.getName();
                monitor.subTask("Loading databaseObject '" + dboName + "'...");
                DatabaseObjectTreeObject databaseObjectTreeObject = null;
                // first call case, the tree object already exists and its content is just refreshed
                if (parentTreeObject.getObject() == databaseObject) {
                    databaseObjectTreeObject = (DatabaseObjectTreeObject) parentTreeObject;
                } else // recursive call case, the tree object doesn't exist and must be added to the parent tree object
                {
                    int folderType = Integer.MIN_VALUE;
                    if (databaseObject instanceof Connector) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_CONNECTORS;
                        databaseObjectTreeObject = new ConnectorTreeObject(viewer, (Connector) databaseObject, false);
                    } else if (databaseObject instanceof Sequence) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SEQUENCES;
                        databaseObjectTreeObject = new SequenceTreeObject(viewer, (Sequence) databaseObject, false);
                    } else if (databaseObject instanceof MobileApplication) {
                        databaseObjectTreeObject = new MobileApplicationTreeObject(viewer, (MobileApplication) databaseObject, false);
                    } else if (databaseObject instanceof MobilePlatform) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_PLATFORMS;
                        databaseObjectTreeObject = new MobilePlatformTreeObject(viewer, (MobilePlatform) databaseObject, false);
                    } else /**
                     ***********************************************************************************************
                     */
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
                        if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
                            databaseObjectTreeObject = new MobileApplicationComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ROUTES;
                            databaseObjectTreeObject = new MobileRouteComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteEventComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            databaseObjectTreeObject = new MobileRouteEventComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteActionComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ACTIONS;
                            databaseObjectTreeObject = new MobileRouteActionComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_PAGES;
                            databaseObjectTreeObject = new MobilePageComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHARED_ACTIONS;
                            databaseObjectTreeObject = new MobileUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHARED_COMPONENTS;
                            databaseObjectTreeObject = new MobileUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_MENUS;
                            databaseObjectTreeObject = new MobileUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIAttribute) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ATTRIBUTES;
                                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIControlAttr) {
                                    folderType = ObjectsFolderTreeObject.FOLDER_TYPE_CONTROLS;
                                }
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIStyle) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_STYLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIControlVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UICompVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIStackVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIFormValidator) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VALIDATORS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIAppEvent) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIPageEvent) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIEventSubscriber) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            }
                            databaseObjectTreeObject = new MobileUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        }
                    } else /**
                     ***********************************************************************************************
                     */
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
                        if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
                            databaseObjectTreeObject = new NgxApplicationComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_PAGES;
                            databaseObjectTreeObject = new NgxPageComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHARED_ACTIONS;
                            databaseObjectTreeObject = new NgxUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHARED_COMPONENTS;
                            databaseObjectTreeObject = new NgxUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_MENUS;
                            databaseObjectTreeObject = new NgxUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                            if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIAttribute) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ATTRIBUTES;
                                if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIControlAttr) {
                                    folderType = ObjectsFolderTreeObject.FOLDER_TYPE_CONTROLS;
                                }
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicAttr) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_ATTRIBUTES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIStyle) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_STYLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIControlVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UICompVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIStackVariable) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIAppEvent) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIPageEvent) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIEventSubscriber) {
                                folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EVENTS;
                            }
                            databaseObjectTreeObject = new NgxUIComponentTreeObject(viewer, GenericUtils.cast(databaseObject), false);
                        }
                    } else if (databaseObject instanceof UrlMapper) {
                        databaseObjectTreeObject = new UrlMapperTreeObject(viewer, (UrlMapper) databaseObject, false);
                    } else if (databaseObject instanceof UrlAuthentication) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_AUTHENTICATIONS;
                        databaseObjectTreeObject = new UrlAuthenticationTreeObject(viewer, (UrlAuthentication) databaseObject, false);
                    } else if (databaseObject instanceof UrlMapping) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_MAPPINGS;
                        databaseObjectTreeObject = new UrlMappingTreeObject(viewer, (UrlMapping) databaseObject, false);
                    } else if (databaseObject instanceof UrlMappingOperation) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_OPERATIONS;
                        databaseObjectTreeObject = new UrlMappingOperationTreeObject(viewer, (UrlMappingOperation) databaseObject, false);
                    } else if (databaseObject instanceof UrlMappingParameter) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_PARAMETERS;
                        databaseObjectTreeObject = new UrlMappingParameterTreeObject(viewer, (UrlMappingParameter) databaseObject, false);
                    } else if (databaseObject instanceof UrlMappingResponse) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_RESPONSES;
                        databaseObjectTreeObject = new UrlMappingResponseTreeObject(viewer, (UrlMappingResponse) databaseObject, false);
                    } else if (databaseObject instanceof Reference) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_REFERENCES;
                        databaseObjectTreeObject = new ReferenceTreeObject(viewer, (Reference) databaseObject, false);
                    } else if (databaseObject instanceof Pool) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_POOLS;
                        databaseObjectTreeObject = new DatabaseObjectTreeObject(viewer, databaseObject, false);
                    } else if (databaseObject instanceof Transaction) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_TRANSACTIONS;
                        databaseObjectTreeObject = new TransactionTreeObject(viewer, (Transaction) databaseObject, false);
                    } else if (databaseObject instanceof ScreenClass) {
                        if (databaseObject.getParent() instanceof IScreenClassContainer<?>) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SCREEN_CLASSES;
                            databaseObjectTreeObject = new ScreenClassTreeObject(viewer, (ScreenClass) databaseObject, false);
                        } else {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_INHERITED_SCREEN_CLASSES;
                            databaseObjectTreeObject = new ScreenClassTreeObject(viewer, (ScreenClass) databaseObject, false);
                        }
                    } else if (databaseObject instanceof Sheet) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_SHEETS;
                        databaseObjectTreeObject = new SheetTreeObject(viewer, (Sheet) databaseObject, parentTreeObject.getObject() != databaseObject.getParent());
                    } else if (databaseObject instanceof TestCase) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_TESTCASES;
                        databaseObjectTreeObject = new TestCaseTreeObject(viewer, (TestCase) databaseObject, false);
                    } else if (databaseObject instanceof Variable) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
                        databaseObjectTreeObject = new VariableTreeObject2(viewer, (Variable) databaseObject, false);
                    } else if (databaseObject instanceof Step) {
                        if (databaseObject.getParent() instanceof Sequence) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_STEPS;
                        }
                        databaseObjectTreeObject = new StepTreeObject(viewer, (Step) databaseObject, false);
                    } else if (databaseObject instanceof Statement) {
                        if (databaseObject.getParent() instanceof Transaction) {
                            folderType = ObjectsFolderTreeObject.FOLDER_TYPE_FUNCTIONS;
                        }
                        databaseObjectTreeObject = new StatementTreeObject(viewer, (Statement) databaseObject, false);
                    } else if (databaseObject instanceof Criteria) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_CRITERIAS;
                        databaseObjectTreeObject = new CriteriaTreeObject(viewer, (Criteria) databaseObject, parentTreeObject.getObject() != databaseObject.getParent());
                    } else if (databaseObject instanceof ExtractionRule) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_EXTRACTION_RULES;
                        databaseObjectTreeObject = new ExtractionRuleTreeObject(viewer, (ExtractionRule) databaseObject, parentTreeObject.getObject() != databaseObject.getParent());
                    } else if (databaseObject instanceof BlockFactory) {
                        databaseObjectTreeObject = new DatabaseObjectTreeObject(viewer, databaseObject, parentTreeObject.getObject() != databaseObject.getParent());
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.core.Document) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_DOCUMENTS;
                        com.twinsoft.convertigo.beans.core.Document document = (com.twinsoft.convertigo.beans.core.Document) databaseObject;
                        String documentRenderer = document.getRenderer();
                        if (documentRenderer.equals("DesignDocumentTreeObject"))
                            databaseObjectTreeObject = new DesignDocumentTreeObject(viewer, document, false);
                        else
                            databaseObjectTreeObject = new DocumentTreeObject(viewer, document, false);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.core.Listener) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_LISTENERS;
                        com.twinsoft.convertigo.beans.core.Listener listener = (com.twinsoft.convertigo.beans.core.Listener) databaseObject;
                        String listenerRenderer = listener.getRenderer();
                        if (listenerRenderer.equals("FullSyncListenerTreeObject")) {
                            databaseObjectTreeObject = new FullSyncListenerTreeObject(viewer, listener, false);
                        } else {
                            databaseObjectTreeObject = new ListenerTreeObject(viewer, listener, false);
                        }
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.core.Index) {
                        folderType = ObjectsFolderTreeObject.FOLDER_TYPE_INDEXES;
                        databaseObjectTreeObject = new DatabaseObjectTreeObject(viewer, databaseObject, false);
                    } else {
                        // unknow DBO case !!!
                        databaseObjectTreeObject = new DatabaseObjectTreeObject(viewer, databaseObject, false);
                    }
                    // no virtual folder
                    if (folderType == Integer.MIN_VALUE) {
                        parentTreeObject.addChild(databaseObjectTreeObject);
                    } else // virtual folder creation or reuse
                    {
                        /* fixed #5416 */
                        // if (currentTreeFolder == null || currentTreeFolder.folderType != folderType) {
                        // currentTreeFolder = new ObjectsFolderTreeObject(viewer, folderType);
                        // parentTreeObject.addChild(currentTreeFolder);
                        // }
                        currentTreeFolder = getFolder(parentTreeObject, folderType);
                        currentTreeFolder.addChild(databaseObjectTreeObject);
                    }
                    // case databaseObject has been changed through dbo::preconfigure, mark projectTreeObject as modified
                    if ((databaseObject.bNew) || (databaseObject.hasChanged && !databaseObject.bNew)) {
                        databaseObjectTreeObject.hasBeenModified(true);
                    }
                    // new value of recursion parameters
                    this.parentTreeObject = databaseObjectTreeObject;
                }
                // special databaseObject cases
                if (databaseObject instanceof Project) {
                    Project project = (Project) databaseObject;
                    // Creates directories and files
                    createDirsAndFiles(project.getName());
                    // Creates or Refresh xsd and wsdl folders
                    IFolder xsdFolder, wsdlFolder = null;
                    IFolder xsdInternalFolder = null;
                    try {
                        wsdlFolder = ((ProjectTreeObject) parentTreeObject).getFolder("wsdl");
                        if (!wsdlFolder.exists())
                            wsdlFolder.create(true, true, null);
                        else
                            wsdlFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                        xsdFolder = ((ProjectTreeObject) parentTreeObject).getFolder("xsd");
                        if (!xsdFolder.exists())
                            xsdFolder.create(true, true, null);
                        else {
                            xsdInternalFolder = xsdFolder.getFolder("internal");
                            if (!xsdInternalFolder.exists())
                                xsdInternalFolder.create(true, true, null);
                            xsdFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    // Connectors
                    IFolder xsdConnectorInternalFolder = null;
                    Collection<Connector> connectors = project.getConnectorsList();
                    if (connectors.size() != 0) {
                        // Set default connector if none
                        if (project.getDefaultConnector() == null) {
                            // Report from 4.5: fix #401
                            ConvertigoPlugin.logWarning(null, "Project \"" + project.getName() + "\" has no default connector. Try to set a default one.");
                            Connector defaultConnector = connectors.iterator().next();
                            try {
                                project.setDefaultConnector(defaultConnector);
                                defaultConnector.hasChanged = true;
                            } catch (Exception e) {
                                ConvertigoPlugin.logWarning(e, "Unable to set a default connector for project \"" + project.getName() + "\"");
                            }
                        }
                        // Refresh Traces folder
                        IFolder ifolder = ((ProjectTreeObject) parentTreeObject).getFolder("Traces");
                        if (ifolder.exists()) {
                            try {
                                ifolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                            } catch (CoreException e) {
                            }
                        }
                        // Creates or Refresh internal xsd connector folders
                        for (Connector connector : connectors) {
                            try {
                                xsdConnectorInternalFolder = xsdInternalFolder.getFolder(connector.getName());
                                if (!xsdConnectorInternalFolder.exists())
                                    xsdConnectorInternalFolder.create(true, true, null);
                                else
                                    xsdConnectorInternalFolder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                } else if (databaseObject instanceof Connector) {
                    Connector connector = (Connector) databaseObject;
                    // Open connector editor
                    if (projectLoadingJob != null && connector.isDefault) {
                        projectLoadingJob.setDefaultConnectorTreeObject((ConnectorTreeObject) databaseObjectTreeObject);
                    }
                    // Traces
                    if (connector instanceof JavelinConnector) {
                        String projectName = databaseObject.getProject().getName();
                        if (projectLoadingJob == null) {
                            if (MigrationManager.isProjectMigrated(projectName)) {
                                UnloadedProjectTreeObject unloadedProjectTreeObject = new UnloadedProjectTreeObject(databaseObjectTreeObject.viewer, projectName);
                                this.projectLoadingJob = new ProjectLoadingJob(databaseObjectTreeObject.viewer, unloadedProjectTreeObject);
                                this.projectLoadingJob.loadTrace(databaseObjectTreeObject, new File(Engine.projectDir(projectName) + "/Traces/" + connector.getName()));
                            }
                        }
                        if (projectLoadingJob != null) {
                            projectLoadingJob.loadTrace(databaseObjectTreeObject, new File(Engine.projectDir(projectName) + "/Traces/" + connector.getName()));
                        }
                    }
                } else if (databaseObject instanceof Transaction) {
                    Transaction transaction = (Transaction) databaseObject;
                    // Functions
                    List<HandlersDeclarationTreeObject> treeObjects = new LinkedList<HandlersDeclarationTreeObject>();
                    String line, lineReaded;
                    int lineNumber = 0;
                    BufferedReader br = new BufferedReader(new StringReader(transaction.handlers));
                    line = br.readLine();
                    while (line != null) {
                        lineReaded = line.trim();
                        lineNumber++;
                        if (lineReaded.startsWith("function ")) {
                            try {
                                String functionName = lineReaded.substring(9, lineReaded.indexOf(')') + 1);
                                HandlersDeclarationTreeObject handlersDeclarationTreeObject = null;
                                if (functionName.endsWith(JavelinTransaction.EVENT_ENTRY_HANDLER + "()")) {
                                    handlersDeclarationTreeObject = new HandlersDeclarationTreeObject(viewer, functionName, HandlersDeclarationTreeObject.TYPE_FUNCTION_SCREEN_CLASS_ENTRY, lineNumber);
                                } else if (functionName.endsWith(JavelinTransaction.EVENT_EXIT_HANDLER + "()")) {
                                    handlersDeclarationTreeObject = new HandlersDeclarationTreeObject(viewer, functionName, HandlersDeclarationTreeObject.TYPE_FUNCTION_SCREEN_CLASS_EXIT, lineNumber);
                                } else {
                                    handlersDeclarationTreeObject = new HandlersDeclarationTreeObject(viewer, functionName, HandlersDeclarationTreeObject.TYPE_OTHER, lineNumber);
                                }
                                if (handlersDeclarationTreeObject != null) {
                                    treeObjects.add(handlersDeclarationTreeObject);
                                }
                            } catch (StringIndexOutOfBoundsException e) {
                                throw new EngineException("Exception in reading line of a transaction", e);
                            }
                        }
                        line = br.readLine();
                    }
                    if (treeObjects.size() != 0) {
                        ObjectsFolderTreeObject objectsFolderTreeObject = new ObjectsFolderTreeObject(viewer, ObjectsFolderTreeObject.FOLDER_TYPE_FUNCTIONS);
                        databaseObjectTreeObject.addChild(objectsFolderTreeObject);
                        for (HandlersDeclarationTreeObject handlersDeclarationTreeObject : treeObjects) {
                            objectsFolderTreeObject.addChild(handlersDeclarationTreeObject);
                        }
                    }
                } else if (databaseObject instanceof Sheet) {
                    addTemplates((Sheet) databaseObject, databaseObjectTreeObject);
                } else if (databaseObject instanceof ITablesProperty) {
                    ITablesProperty iTablesProperty = (ITablesProperty) databaseObject;
                    String[] tablePropertyNames = iTablesProperty.getTablePropertyNames();
                    for (int i = 0; i < tablePropertyNames.length; i++) {
                        String tablePropertyName = tablePropertyNames[i];
                        String tableRenderer = iTablesProperty.getTableRenderer(tablePropertyName);
                        XMLVector<XMLVector<Object>> xmlv = iTablesProperty.getTableData(tablePropertyName);
                        if (tableRenderer.equals("XMLTableDescriptionTreeObject")) {
                            XMLTableDescriptionTreeObject propertyXMLTableTreeObject = new XMLTableDescriptionTreeObject(viewer, tablePropertyName, xmlv, databaseObjectTreeObject);
                            databaseObjectTreeObject.addChild(propertyXMLTableTreeObject);
                        } else if (tableRenderer.equals("XMLRecordDescriptionTreeObject")) {
                            XMLRecordDescriptionTreeObject propertyXMLRecordTreeObject = new XMLRecordDescriptionTreeObject(viewer, tablePropertyName, xmlv, databaseObjectTreeObject);
                            databaseObjectTreeObject.addChild(propertyXMLRecordTreeObject);
                        }
                    }
                }
                monitor.worked(1);
                // children cannot be added in the current virtual folder
                this.currentTreeFolder = null;
                super.walk(databaseObject);
                // restore recursion parameters
                this.parentTreeObject = parentTreeObject;
                this.projectLoadingJob = projectLoadingJob;
                // restore sibling parameters
                this.currentTreeFolder = currentTreeFolder;
            }
        }.init(parentDatabaseObject, parentTreeObject, projectLoadingJob);
    } catch (EngineException e) {
        throw e;
    } catch (Exception e) {
        throw new EngineException("Exception in copyDatabaseObject", e);
    }
}
Also used : NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) BlockFactory(com.twinsoft.convertigo.beans.core.BlockFactory) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) EngineException(com.twinsoft.convertigo.engine.EngineException) Document(org.w3c.dom.Document) MobilePlatformTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePlatformTreeObject) UrlMappingTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingTreeObject) Pool(com.twinsoft.convertigo.beans.core.Pool) ExtractionRuleTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ExtractionRuleTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) UrlMapperTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMapperTreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) MobileApplicationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationTreeObject) IClosableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IClosableTreeObject) XMLRecordDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLRecordDescriptionTreeObject) DesignDocumentValidateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject) UrlMappingTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingTreeObject) DesignDocumentUpdateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) MobileApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationComponentTreeObject) UrlMappingOperationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingOperationTreeObject) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) UrlMappingResponseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingResponseTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) CriteriaTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.CriteriaTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) UrlAuthenticationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlAuthenticationTreeObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) MobileRouteActionComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteActionComponentTreeObject) ListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ListenerTreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) NgxApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxApplicationComponentTreeObject) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) IEditableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IEditableTreeObject) XMLTableDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLTableDescriptionTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) TemplateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) DesignDocumentFilterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject) VariableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) MobilePlatformTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePlatformTreeObject) ExtractionRuleTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ExtractionRuleTreeObject) MobileRouteComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteComponentTreeObject) SheetTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SheetTreeObject) UrlMapperTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMapperTreeObject) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TraceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject) DocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DocumentTreeObject) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) MobileApplicationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationTreeObject) IClosableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IClosableTreeObject) XMLRecordDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLRecordDescriptionTreeObject) DesignDocumentValidateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject) UrlMappingTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingTreeObject) DesignDocumentUpdateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) MobileApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationComponentTreeObject) UrlMappingOperationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingOperationTreeObject) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) UrlMappingResponseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingResponseTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) CriteriaTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.CriteriaTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) UrlAuthenticationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlAuthenticationTreeObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) MobileRouteActionComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteActionComponentTreeObject) ListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ListenerTreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) NgxApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxApplicationComponentTreeObject) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) IEditableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IEditableTreeObject) XMLTableDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLTableDescriptionTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) TemplateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) DesignDocumentFilterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject) VariableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) MobilePlatformTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePlatformTreeObject) ExtractionRuleTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ExtractionRuleTreeObject) MobileRouteComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteComponentTreeObject) SheetTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SheetTreeObject) UrlMapperTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMapperTreeObject) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TraceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject) DocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DocumentTreeObject) ListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ListenerTreeObject) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) IScreenClassContainer(com.twinsoft.convertigo.beans.core.IScreenClassContainer) CriteriaTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.CriteriaTreeObject) ExtractionRule(com.twinsoft.convertigo.beans.core.ExtractionRule) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Criteria(com.twinsoft.convertigo.beans.core.Criteria) SheetTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SheetTreeObject) StringReader(java.io.StringReader) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) UrlMapper(com.twinsoft.convertigo.beans.core.UrlMapper) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) IEditorReference(org.eclipse.ui.IEditorReference) Reference(com.twinsoft.convertigo.beans.core.Reference) Statement(com.twinsoft.convertigo.beans.core.Statement) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) TestCase(com.twinsoft.convertigo.beans.core.TestCase) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) BufferedReader(java.io.BufferedReader) UrlMappingOperationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingOperationTreeObject) UrlAuthentication(com.twinsoft.convertigo.beans.core.UrlAuthentication) IFolder(org.eclipse.core.resources.IFolder) UrlMapping(com.twinsoft.convertigo.beans.core.UrlMapping) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) NgxApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxApplicationComponentTreeObject) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ListenerList(org.eclipse.core.runtime.ListenerList) LinkedList(java.util.LinkedList) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) EventListenerList(javax.swing.event.EventListenerList) List(java.util.List) XMLTableDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLTableDescriptionTreeObject) MobileRouteComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteComponentTreeObject) Sequence(com.twinsoft.convertigo.beans.core.Sequence) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) Transaction(com.twinsoft.convertigo.beans.core.Transaction) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) CoreException(org.eclipse.core.runtime.CoreException) XMLRecordDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLRecordDescriptionTreeObject) Collection(java.util.Collection) IFile(org.eclipse.core.resources.IFile) File(java.io.File) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) Connector(com.twinsoft.convertigo.beans.core.Connector) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) UrlMappingResponseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingResponseTreeObject) Variable(com.twinsoft.convertigo.beans.core.Variable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) MigrationListener(com.twinsoft.convertigo.engine.MigrationListener) TreeDragListener(com.twinsoft.convertigo.eclipse.dnd.TreeDragListener) ISelectionListener(org.eclipse.ui.ISelectionListener) CompositeListener(com.twinsoft.convertigo.eclipse.editors.CompositeListener) DatabaseObjectListener(com.twinsoft.convertigo.engine.DatabaseObjectListener) Listener(org.eclipse.swt.widgets.Listener) EngineListener(com.twinsoft.convertigo.engine.EngineListener) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) MobileApplicationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationTreeObject) UrlMappingResponse(com.twinsoft.convertigo.beans.core.UrlMappingResponse) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) DocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DocumentTreeObject) FunctionStep(com.twinsoft.convertigo.beans.steps.FunctionStep) Step(com.twinsoft.convertigo.beans.core.Step) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) MobileRouteActionComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteActionComponentTreeObject) MobileApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationComponentTreeObject) ITablesProperty(com.twinsoft.convertigo.beans.core.ITablesProperty) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) UrlAuthenticationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlAuthenticationTreeObject) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineException(com.twinsoft.convertigo.engine.EngineException) Point(org.eclipse.swt.graphics.Point) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Sheet(com.twinsoft.convertigo.beans.core.Sheet)

Example 3 with Sheet

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

the class GetChildren method getChildren.

public static void getChildren(String qname, Element parent, int depth) throws Exception {
    DatabaseObject dbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
    List<DatabaseObject> children = dbo.getDatabaseObjectChildren();
    // Get all children of the dbo
    Element elt = createDboElement(parent.getOwnerDocument(), dbo, !children.isEmpty());
    /*
		 *  In case of ScreenClass, we have to get Criteria, ExtractionRule and Sheets manually.
		 *  If fact, if the dbo is an inherited screen class, inherited Criteria, ExtractionRule and Sheets,
		 *  won't be retrieved by the method #getDatabaseObjectChildren.
		 */
    if (dbo instanceof ScreenClass) {
        ScreenClass sc = (ScreenClass) dbo;
        boolean hasChildren = false;
        // Get all Criteria
        List<Criteria> criteria = sc.getCriterias();
        for (Criteria criterion : criteria) {
            children.remove(criterion);
            Element eltCriterion = createScreenClassChildElement(parent.getOwnerDocument(), criterion, dbo);
            elt.appendChild(eltCriterion);
            hasChildren = true;
        }
        // Get all Extraction Rules
        List<ExtractionRule> extractionRules = sc.getExtractionRules();
        for (ExtractionRule extractionRule : extractionRules) {
            children.remove(extractionRule);
            Element eltExtractionRule = createScreenClassChildElement(parent.getOwnerDocument(), extractionRule, dbo);
            elt.appendChild(eltExtractionRule);
            hasChildren = true;
        }
        // Get all Sheets
        List<Sheet> sheets = sc.getSheets();
        for (Sheet sheet : sheets) {
            children.remove(sheet);
            Element eltSheet = createScreenClassChildElement(parent.getOwnerDocument(), sheet, dbo);
            elt.appendChild(eltSheet);
            hasChildren = true;
        }
        // In case of JavelinScreenClass, we also have to get the block factory manually
        if (dbo instanceof JavelinScreenClass) {
            JavelinScreenClass jsc = (JavelinScreenClass) sc;
            BlockFactory blockFactory = jsc.getBlockFactory();
            children.remove(blockFactory);
            Element eltBlockFactory = createScreenClassChildElement(parent.getOwnerDocument(), blockFactory, dbo);
            elt.appendChild(eltBlockFactory);
            hasChildren = true;
        }
        if (hasChildren) {
            elt.setAttribute("hasChildren", "true");
        }
    }
    parent.appendChild(elt);
    if (depth > 0) {
        for (DatabaseObject child : children) {
            getChildren(child.getQName(), elt, depth - 1);
        }
    }
}
Also used : JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) BlockFactory(com.twinsoft.convertigo.beans.core.BlockFactory) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) Element(org.w3c.dom.Element) ExtractionRule(com.twinsoft.convertigo.beans.core.ExtractionRule) Criteria(com.twinsoft.convertigo.beans.core.Criteria) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Sheet(com.twinsoft.convertigo.beans.core.Sheet)

Example 4 with Sheet

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

the class ClipboardManager method paste.

public Object paste(Node node, DatabaseObject parentDatabaseObject, boolean bChangeName) throws EngineException {
    Object object = read(node);
    if (object instanceof DatabaseObject) {
        DatabaseObject databaseObject = (DatabaseObject) object;
        String dboName = databaseObject.getName();
        String name = null;
        if (objectsType != ProjectExplorerView.TREE_OBJECT_TYPE_DBO_PROJECT) {
            // Verify if object is accepted for paste
            if (!DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
                throw new EngineException("You cannot paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + databaseObject.getClass().getSimpleName());
            }
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
                if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
                    throw new EngineException("You cannot paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + databaseObject.getClass().getSimpleName());
                }
                if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, databaseObject)) {
                    String tplVersion = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getTplRequired(databaseObject);
                    throw new EngineException("Template project " + tplVersion + " compatibility required");
                }
            } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
                if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
                    throw new EngineException("You cannot paste to a " + parentDatabaseObject.getClass().getSimpleName() + " a database object of type " + databaseObject.getClass().getSimpleName());
                }
                if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(parentDatabaseObject, databaseObject)) {
                    String tplVersion = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getTplRequired(databaseObject);
                    throw new EngineException("Template project " + tplVersion + " compatibility required");
                }
            }
            // Disable the isDefault boolean flag when the connector is pasted
            if (databaseObject instanceof Connector) {
                Connector connector = (Connector) databaseObject;
                if (connector.isDefault) {
                    connector.isDefault = false;
                }
            }
            // Disable the isRoot boolean flag when the page is pasted
            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                com.twinsoft.convertigo.beans.mobile.components.PageComponent page = GenericUtils.cast(databaseObject);
                if (page.isRoot) {
                    page.isRoot = false;
                }
            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                com.twinsoft.convertigo.beans.ngx.components.PageComponent page = GenericUtils.cast(databaseObject);
                if (page.isRoot) {
                    page.isRoot = false;
                }
            }
            if (objectsType != ProjectExplorerView.TREE_OBJECT_TYPE_DBO_CONNECTOR) {
                // Disable the isDefault boolean flag when the transaction is pasted
                if (databaseObject instanceof Transaction) {
                    Transaction transaction = (Transaction) databaseObject;
                    if (transaction.isDefault) {
                        transaction.isDefault = false;
                    }
                }
            }
        }
        // Special case of project
        if (databaseObject instanceof Project) {
            return databaseObject;
        }
        boolean bContinue = true;
        int index = 0;
        long oldPriority = databaseObject.priority;
        // Verify if a child object with same name exist and change name
        while (bContinue) {
            if (bChangeName) {
                if (index == 0)
                    name = dboName;
                else
                    name = dboName + index;
                databaseObject.setName(name);
            }
            databaseObject.hasChanged = true;
            databaseObject.bNew = true;
            try {
                new WalkHelper() {

                    boolean root = true;

                    boolean find = false;

                    @Override
                    protected boolean before(DatabaseObject dbo, Class<? extends DatabaseObject> dboClass) {
                        boolean isInstance = dboClass.isInstance(databaseObject);
                        find |= isInstance;
                        return isInstance;
                    }

                    @Override
                    protected void walk(DatabaseObject dbo) throws Exception {
                        if (root) {
                            root = false;
                            super.walk(dbo);
                            if (!find) {
                            // ignore: we must accept special paste: e.g. transaction over sequence
                            }
                        } else {
                            if (databaseObject.getName().equalsIgnoreCase(dbo.getName())) {
                                throw new ObjectWithSameNameException("Unable to paste the object because an object with the same name already exists in target.");
                            }
                        }
                    }
                }.init(parentDatabaseObject);
                bContinue = false;
            } catch (ObjectWithSameNameException owsne) {
                if ((parentDatabaseObject instanceof HtmlTransaction) && (databaseObject instanceof Statement)) {
                    throw new EngineException("HtmlTransaction already contains a statement named \"" + name + "\".", owsne);
                }
                // Silently ignore
                index++;
            } catch (EngineException ee) {
                throw ee;
            } catch (Exception e) {
                throw new EngineException("Exception in paste", e);
            }
        }
        // reset ordered properties
        if (databaseObject instanceof IContainerOrdered) {
            // Mobile beans
            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent ac = GenericUtils.cast(databaseObject);
                    ac.setOrderedRoutes(getNewOrdered());
                    ac.setOrderedMenus(getNewOrdered());
                    ac.setOrderedPages(getNewOrdered());
                    ac.setOrderedComponents(getNewOrdered());
                    ac.setOrderedSharedActions(getNewOrdered());
                    ac.setOrderedSharedComponents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.RouteComponent rc = GenericUtils.cast(databaseObject);
                    rc.setOrderedActions(getNewOrdered());
                    rc.setOrderedEvents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.PageComponent pc = GenericUtils.cast(databaseObject);
                    pc.setOrderedComponents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.UIComponent uic = GenericUtils.cast(databaseObject);
                    uic.setOrderedComponents(getNewOrdered());
                }
            } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
                if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent ac = GenericUtils.cast(databaseObject);
                    ac.setOrderedMenus(getNewOrdered());
                    ac.setOrderedPages(getNewOrdered());
                    ac.setOrderedComponents(getNewOrdered());
                    ac.setOrderedSharedActions(getNewOrdered());
                    ac.setOrderedSharedComponents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.PageComponent pc = GenericUtils.cast(databaseObject);
                    pc.setOrderedComponents(getNewOrdered());
                }
                if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.UIComponent uic = GenericUtils.cast(databaseObject);
                    uic.setOrderedComponents(getNewOrdered());
                }
            }
            // Sequence beans
            if (databaseObject instanceof Sequence) {
                ((Sequence) databaseObject).setOrderedSteps(getNewOrdered());
                ((Sequence) databaseObject).setOrderedVariables(getNewOrdered());
            }
            if (databaseObject instanceof StepWithExpressions) {
                ((StepWithExpressions) databaseObject).setOrderedSteps(getNewOrdered());
            }
            if (databaseObject instanceof RequestableStep) {
                ((RequestableStep) databaseObject).setOrderedVariables(getNewOrdered());
            }
            // Transaction beans
            if (databaseObject instanceof TransactionWithVariables) {
                ((TransactionWithVariables) databaseObject).setOrderedVariables(getNewOrdered());
            }
            if (databaseObject instanceof StatementWithExpressions) {
                ((StatementWithExpressions) databaseObject).setOrderedStatements(getNewOrdered());
            }
            if (databaseObject instanceof HTTPStatement) {
                ((HTTPStatement) databaseObject).setOrderedVariables(getNewOrdered());
            }
            if (databaseObject instanceof ScreenClass) {
                ((ScreenClass) databaseObject).setOrderedCriterias(getNewOrdered());
                ((ScreenClass) databaseObject).setOrderedExtractionRules(getNewOrdered());
            }
            // TestCase bean
            if (databaseObject instanceof TestCase) {
                ((TestCase) databaseObject).setOrderedVariables(getNewOrdered());
            }
        }
        // Now add dbo to target
        try {
            if (parentDatabaseObject instanceof ScreenClass) {
                if (parentDatabaseObject instanceof JavelinScreenClass) {
                    JavelinScreenClass screenClass = (JavelinScreenClass) parentDatabaseObject;
                    if (databaseObject instanceof BlockFactory) {
                        screenClass.add(databaseObject);
                        screenClass.setBlockFactory((BlockFactory) databaseObject);
                    }
                }
                ScreenClass screenClass = (ScreenClass) parentDatabaseObject;
                if (databaseObject instanceof Criteria) {
                    if ((!screenClass.bNew) && (screenClass.equals(((IScreenClassContainer<?>) screenClass.getConnector()).getDefaultScreenClass()))) {
                        throw new EngineException("You cannot paste a new criterion to the default screen class");
                    }
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    screenClass.add(databaseObject);
                } else if (databaseObject instanceof ExtractionRule) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    screenClass.add(databaseObject);
                } else if (databaseObject instanceof Sheet) {
                    screenClass.add(databaseObject);
                } else if (databaseObject instanceof ScreenClass) {
                    databaseObject.priority = screenClass.priority + 1;
                    screenClass.add(databaseObject);
                }
            } else if (parentDatabaseObject instanceof HtmlTransaction) {
                HtmlTransaction transaction = (HtmlTransaction) parentDatabaseObject;
                if (databaseObject instanceof Sheet) {
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof TestCase) {
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof FunctionStatement) {
                    if (databaseObject instanceof StatementWithExpressions) {
                        databaseObject.priority = 0;
                    }
                    transaction.add(databaseObject);
                } else {
                    throw new EngineException("You cannot paste to an HtmlTransaction a database object of type " + databaseObject.getClass().getName());
                }
            } else if (parentDatabaseObject instanceof TransactionWithVariables) {
                TransactionWithVariables transaction = (TransactionWithVariables) parentDatabaseObject;
                if (databaseObject instanceof Sheet) {
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof TestCase) {
                    transaction.add(databaseObject);
                } else if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    transaction.add(databaseObject);
                }
            } else if (parentDatabaseObject instanceof Sequence) {
                Sequence sequence = (Sequence) parentDatabaseObject;
                if (databaseObject instanceof Sheet) {
                    sequence.add(databaseObject);
                } else if (databaseObject instanceof TestCase) {
                    sequence.add(databaseObject);
                } else if (databaseObject instanceof Step) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    sequence.add(databaseObject);
                } else if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    sequence.add(databaseObject);
                } else {
                    throw new EngineException("You cannot paste to a Sequence a database object of type " + databaseObject.getClass().getName());
                }
            } else if (parentDatabaseObject instanceof StatementWithExpressions) {
                StatementWithExpressions statement = (StatementWithExpressions) parentDatabaseObject;
                databaseObject.priority = databaseObject.getNewOrderValue();
                statement.add(databaseObject);
            } else if (parentDatabaseObject instanceof HTTPStatement) {
                HTTPStatement statement = (HTTPStatement) parentDatabaseObject;
                if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    statement.add(databaseObject);
                }
            } else if (parentDatabaseObject instanceof StepWithExpressions) {
                StepWithExpressions step = (StepWithExpressions) parentDatabaseObject;
                databaseObject.priority = databaseObject.getNewOrderValue();
                step.add(databaseObject);
            } else if (parentDatabaseObject instanceof RequestableStep) {
                RequestableStep step = (RequestableStep) parentDatabaseObject;
                if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    step.add(databaseObject);
                }
            } else if (parentDatabaseObject instanceof TestCase) {
                TestCase testCase = (TestCase) parentDatabaseObject;
                if (databaseObject instanceof Variable) {
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    testCase.add(databaseObject);
                }
            } else // MOBILE COMPONENTS
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
                if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent app = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.RouteComponent route = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteActionComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        com.twinsoft.convertigo.beans.mobile.components.RouteActionComponent rac = GenericUtils.cast(databaseObject);
                        int i = rac.getPage().lastIndexOf(".");
                        if (i != -1) {
                            String pageName = rac.getPage().substring(i);
                            String pageQName = route.getParent().getQName() + pageName;
                            rac.setPage(pageQName);
                        }
                        route.add(rac);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.RouteEventComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        route.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.PageComponent page = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        page.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) {
                    com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu menu = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        menu.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                    com.twinsoft.convertigo.beans.mobile.components.UIComponent component = GenericUtils.cast(parentDatabaseObject);
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    component.add(databaseObject);
                }
            } else // NGX COMPONENTS
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
                if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent app = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        app.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.PageComponent page = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        page.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu) {
                    com.twinsoft.convertigo.beans.ngx.components.UIDynamicMenu menu = GenericUtils.cast(parentDatabaseObject);
                    if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                        databaseObject.priority = databaseObject.getNewOrderValue();
                        menu.add(databaseObject);
                    }
                } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                    com.twinsoft.convertigo.beans.ngx.components.UIComponent component = GenericUtils.cast(parentDatabaseObject);
                    databaseObject.priority = databaseObject.getNewOrderValue();
                    component.add(databaseObject);
                }
            } else if (parentDatabaseObject == null) {
                if (databaseObject instanceof Project) {
                    if (Engine.theApp.databaseObjectsManager.existsProject(databaseObject.getName())) {
                        throw new ObjectWithSameNameException("Project already exist!");
                    }
                }
            } else {
                parentDatabaseObject.add(databaseObject);
            }
        } catch (ObjectWithSameNameException owsne) {
            if ((parentDatabaseObject instanceof HtmlTransaction) && (databaseObject instanceof Statement)) {
                throw new EngineException("HtmlTransaction already contains a statement named \"" + name + "\".", owsne);
            }
            if ((parentDatabaseObject instanceof Sequence) && (databaseObject instanceof Step)) {
                throw new EngineException("Sequence already contains a step named \"" + name + "\".", owsne);
            }
        }
        NodeList childNodes = node.getChildNodes();
        int len = childNodes.getLength();
        Node childNode;
        String childNodeName;
        for (int i = 0; i < len; i++) {
            childNode = childNodes.item(i);
            if (childNode.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            childNodeName = childNode.getNodeName();
            if (!(childNodeName.equalsIgnoreCase("property")) && !(childNodeName.equalsIgnoreCase("handlers")) && !(childNodeName.equalsIgnoreCase("wsdltype")) && !(childNodeName.equalsIgnoreCase("docdata")) && !(childNodeName.equalsIgnoreCase("dnd"))) {
                paste(childNode, databaseObject, bChangeName);
            }
        }
        // For update of sources which reference this step
        if (databaseObject instanceof Step) {
            pastedSteps.put(String.valueOf(oldPriority), (Step) databaseObject);
        }
        // For update of sources which reference this mobile component
        if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
            if (databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.IAction || databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack || databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIControlDirective || databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIForm || databaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) {
                pastedComponents.put(String.valueOf(oldPriority), GenericUtils.cast(databaseObject));
            }
        } else if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
            if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.IAction || databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack || databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIControlDirective || databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIForm || databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) {
                pastedComponents.put(String.valueOf(oldPriority), GenericUtils.cast(databaseObject));
            }
        }
        // needed
        databaseObject.isImporting = false;
        databaseObject.isSubLoaded = true;
        return databaseObject;
    } else if (object instanceof JsonData) {
        if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIPageEvent || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIAppEvent || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.mobile.components.UIActionStack) {
                JsonData jsonData = (JsonData) object;
                JSONObject json = jsonData.getData();
                if (json.has("qname")) {
                    try {
                        com.twinsoft.convertigo.beans.mobile.components.UIComponent uiComponent = GenericUtils.cast(parentDatabaseObject);
                        DatabaseObject call = com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.getComponentByName("FullSyncViewAction"));
                        if (call != null && call instanceof com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction) {
                            com.twinsoft.convertigo.beans.mobile.components.UIDynamicAction dynAction = GenericUtils.cast(call);
                            com.twinsoft.convertigo.beans.mobile.components.dynamic.IonBean ionBean = dynAction.getIonBean();
                            if (ionBean != null && ionBean.hasProperty("fsview")) {
                                call.bNew = true;
                                call.hasChanged = true;
                                ionBean.setPropertyValue("fsview", new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType(json.getString("qname")));
                                uiComponent.add(call);
                                uiComponent.hasChanged = true;
                            }
                            return call;
                        }
                    } catch (JSONException e) {
                        Engine.logStudio.warn("Failed to create a FullSyncViewAction", e);
                    }
                }
            }
        } else if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
            if (parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIPageEvent || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIAppEvent || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction || parentDatabaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
                JsonData jsonData = (JsonData) object;
                JSONObject json = jsonData.getData();
                if (json.has("qname")) {
                    try {
                        com.twinsoft.convertigo.beans.ngx.components.UIComponent uiComponent = GenericUtils.cast(parentDatabaseObject);
                        DatabaseObject call = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("FullSyncViewAction"));
                        if (call != null && call instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) {
                            com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction dynAction = GenericUtils.cast(call);
                            com.twinsoft.convertigo.beans.ngx.components.dynamic.IonBean ionBean = dynAction.getIonBean();
                            if (ionBean != null && ionBean.hasProperty("fsview")) {
                                call.bNew = true;
                                call.hasChanged = true;
                                ionBean.setPropertyValue("fsview", new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType(json.getString("qname")));
                                uiComponent.add(call);
                                uiComponent.hasChanged = true;
                            }
                            return call;
                        }
                    } catch (JSONException e) {
                        Engine.logStudio.warn("Failed to create a FullSyncViewAction", e);
                    }
                }
            }
        }
    }
    return null;
}
Also used : BlockFactory(com.twinsoft.convertigo.beans.core.BlockFactory) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) ScreenClass(com.twinsoft.convertigo.beans.core.ScreenClass) Node(org.w3c.dom.Node) EngineException(com.twinsoft.convertigo.engine.EngineException) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) StatementWithExpressions(com.twinsoft.convertigo.beans.core.StatementWithExpressions) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JavelinScreenClass(com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass) NodeList(org.w3c.dom.NodeList) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Project(com.twinsoft.convertigo.beans.core.Project) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JSONObject(org.codehaus.jettison.json.JSONObject) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) IContainerOrdered(com.twinsoft.convertigo.beans.core.IContainerOrdered) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) Connector(com.twinsoft.convertigo.beans.core.Connector) Variable(com.twinsoft.convertigo.beans.core.Variable) ExtractionRule(com.twinsoft.convertigo.beans.core.ExtractionRule) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) Criteria(com.twinsoft.convertigo.beans.core.Criteria) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) FunctionStatement(com.twinsoft.convertigo.beans.statements.FunctionStatement) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) JSONException(org.codehaus.jettison.json.JSONException) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) TestCase(com.twinsoft.convertigo.beans.core.TestCase) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) Sheet(com.twinsoft.convertigo.beans.core.Sheet)

Example 5 with Sheet

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

the class CreateFormFromTransactionAction 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) {
            Transaction transaction = null;
            Connector connector = null;
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            if (treeObject instanceof TransactionTreeObject) {
                transaction = (Transaction) treeObject.getObject();
                connector = (Connector) transaction.getParent();
                if (transaction instanceof TransactionWithVariables) {
                    TransactionWithVariables tr = (TransactionWithVariables) transaction;
                    // if (tr.getVariablesDefinitionSize() == 0) {
                    if (tr.numberOfVariables() == 0) {
                        MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.APPLICATION_MODAL);
                        messageBox.setMessage("No variables are defined for transaction " + tr.getName());
                        messageBox.open();
                    } else {
                        String xslContent = generateXSLForm(connector, tr);
                        // Refresh project resource
                        IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(tr.getProject().getName());
                        // Compute the targetXSL file name
                        String xslForm = tr.getName() + "Request.xsl";
                        IFile file = project.getFile(xslForm);
                        ByteArrayInputStream bais = new ByteArrayInputStream(xslContent.getBytes());
                        if (file.exists()) {
                            file.setContents((InputStream) bais, IFile.FORCE | IFile.KEEP_HISTORY, null);
                        } else {
                            file.create((InputStream) bais, true, null);
                        }
                        TransactionWithVariables newTrans = (TransactionWithVariables) tr.clone();
                        newTrans.hasChanged = true;
                        newTrans.bNew = true;
                        XMLVector<XMLVector<Long>> orderedVariables = new XMLVector<XMLVector<Long>>();
                        orderedVariables.add(new XMLVector<Long>());
                        newTrans.setOrderedVariables(orderedVariables);
                        newTrans.setSheetLocation(Transaction.SHEET_LOCATION_FROM_REQUESTABLE);
                        HandlerStatement handler = new HandlerStatement(HandlerStatement.EVENT_TRANSACTION_STARTED, HandlerStatement.RETURN_CANCEL);
                        newTrans.add(handler);
                        newTrans.setName(tr.getName() + "Request");
                        Sheet sheet = new Sheet();
                        sheet.setBrowser("*");
                        sheet.setUrl(xslForm);
                        newTrans.addSheet(sheet);
                        connector.add(newTrans);
                        postCreate(treeObject.getConnectorTreeObject(), newTrans);
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to generate a requestForm widget");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Connector(com.twinsoft.convertigo.beans.core.Connector) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) IFile(org.eclipse.core.resources.IFile) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) HandlerStatement(com.twinsoft.convertigo.beans.statements.HandlerStatement) Cursor(org.eclipse.swt.graphics.Cursor) IProject(org.eclipse.core.resources.IProject) MessageBox(org.eclipse.swt.widgets.MessageBox) Shell(org.eclipse.swt.widgets.Shell) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ByteArrayInputStream(java.io.ByteArrayInputStream) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) Sheet(com.twinsoft.convertigo.beans.core.Sheet) Display(org.eclipse.swt.widgets.Display)

Aggregations

Sheet (com.twinsoft.convertigo.beans.core.Sheet)9 Connector (com.twinsoft.convertigo.beans.core.Connector)6 Criteria (com.twinsoft.convertigo.beans.core.Criteria)6 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)6 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)6 Transaction (com.twinsoft.convertigo.beans.core.Transaction)6 EngineException (com.twinsoft.convertigo.engine.EngineException)6 Statement (com.twinsoft.convertigo.beans.core.Statement)5 WalkHelper (com.twinsoft.convertigo.engine.helpers.WalkHelper)5 IOException (java.io.IOException)5 ExtractionRule (com.twinsoft.convertigo.beans.core.ExtractionRule)4 Project (com.twinsoft.convertigo.beans.core.Project)4 Step (com.twinsoft.convertigo.beans.core.Step)4 TestCase (com.twinsoft.convertigo.beans.core.TestCase)4 JavelinScreenClass (com.twinsoft.convertigo.beans.screenclasses.JavelinScreenClass)4 HandlerStatement (com.twinsoft.convertigo.beans.statements.HandlerStatement)4 HtmlTransaction (com.twinsoft.convertigo.beans.transactions.HtmlTransaction)4 IFile (org.eclipse.core.resources.IFile)4 BlockFactory (com.twinsoft.convertigo.beans.core.BlockFactory)3 Sequence (com.twinsoft.convertigo.beans.core.Sequence)3