Search in sources :

Example 6 with ProjectSchemaReference

use of com.twinsoft.convertigo.beans.references.ProjectSchemaReference in project convertigo by convertigo.

the class CLI method generateMobileBuilder.

public void generateMobileBuilder(Project project, String mode) throws Exception {
    MobileBuilder mb = project.getMobileBuilder();
    MobileBuilderBuildMode bm = MobileBuilderBuildMode.production;
    try {
        bm = MobileBuilderBuildMode.valueOf(mode);
    } catch (Exception e) {
    }
    mb.setAppBuildMode(bm);
    List<Project> projects = new ArrayList<>();
    projects.add(project);
    int i = 0;
    do {
        for (Reference ref : projects.get(i).getReferenceList()) {
            if (ref instanceof ProjectSchemaReference) {
                ProjectSchemaReference pref = (ProjectSchemaReference) ref;
                Project p = Engine.theApp.referencedProjectManager.importProject(pref.getParser());
                if (p == null) {
                    Engine.logConvertigo.warn("Failed to import project reference: " + pref.getProjectName() + " (ignored)");
                } else if (!projects.contains(p)) {
                    projects.add(p);
                }
            }
        }
    } while (++i < projects.size());
    Collections.reverse(projects);
    for (Project p : projects) {
        MobileBuilder.initBuilder(p, true);
    }
    Collections.reverse(projects);
    for (Project p : projects) {
        MobileBuilder.releaseBuilder(p, true);
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) Reference(com.twinsoft.convertigo.beans.core.Reference) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) ArrayList(java.util.ArrayList) MobileBuilderBuildMode(com.twinsoft.convertigo.engine.enums.MobileBuilderBuildMode) IOException(java.io.IOException)

Example 7 with ProjectSchemaReference

use of com.twinsoft.convertigo.beans.references.ProjectSchemaReference in project convertigo by convertigo.

the class ProjectExplorerView method loadedProjectsHaveReferences.

private boolean loadedProjectsHaveReferences() {
    ViewContentProvider provider = (ViewContentProvider) viewer.getContentProvider();
    if (provider != null) {
        Object[] objects = provider.getChildren(provider.getTreeRoot());
        for (int i = 0; i < objects.length; i++) {
            TreeObject treeObject = (TreeObject) objects[i];
            if (treeObject instanceof ProjectTreeObject) {
                // Check for references on projects
                ProjectTreeObject projectTreeObject = (ProjectTreeObject) treeObject;
                List<Reference> references = ((Project) projectTreeObject.getObject()).getReferenceList();
                if (references.size() > 0) {
                    for (Reference reference : references) {
                        if (reference instanceof ProjectSchemaReference) {
                            return true;
                        }
                    }
                }
                // Check for sequences (potential call steps)
                List<Sequence> sequences = ((Project) projectTreeObject.getObject()).getSequencesList();
                if (sequences.size() > 0) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) IEditorReference(org.eclipse.ui.IEditorReference) Reference(com.twinsoft.convertigo.beans.core.Reference) 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) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Point(org.eclipse.swt.graphics.Point)

Example 8 with ProjectSchemaReference

use of com.twinsoft.convertigo.beans.references.ProjectSchemaReference in project convertigo by convertigo.

the class List method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element root = document.getDocumentElement();
    Element projectsListElement = document.createElement("projects");
    root.appendChild(projectsListElement);
    boolean isStudio = Engine.isStudioMode();
    for (String projectName : Engine.theApp.databaseObjectsManager.getAllProjectNamesList()) {
        try {
            if (isStudio && projectName.startsWith("mobilebuilder_tpl_")) {
                continue;
            }
            Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
            if (project == null) {
                continue;
            }
            String deployDate = "n/a";
            File file = new File(Engine.projectDir(projectName) + ".car");
            if (file.exists())
                deployDate = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, request.getLocale()).format(new Date(file.lastModified()));
            String comment = project.getComment();
            if (comment.length() > 100)
                comment = comment.substring(0, 100) + "...";
            String version = project.getVersion();
            DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, request.getLocale());
            String exported = project.getInfoForProperty("exported", df, request.getLocale());
            Element projectElement = document.createElement("project");
            projectElement.setAttribute("name", projectName);
            projectElement.setAttribute("comment", comment);
            projectElement.setAttribute("version", version);
            projectElement.setAttribute("exported", exported);
            projectElement.setAttribute("exportedTs", "" + project.getExportTime());
            projectElement.setAttribute("deployDate", deployDate);
            projectElement.setAttribute("deployDateTs", "" + file.lastModified());
            if (Engine.theApp.databaseObjectsManager.symbolsProjectCheckUndefined(projectName)) {
                projectElement.setAttribute("undefined_symbols", "true");
            }
            for (Reference ref : project.getReferenceList()) {
                if (ref instanceof ProjectSchemaReference) {
                    ProjectSchemaReference prjRef = (ProjectSchemaReference) ref;
                    if (prjRef.getParser().isValid() && Engine.theApp.databaseObjectsManager.getOriginalProjectByName(prjRef.getParser().getProjectName(), true) == null) {
                        projectElement.setAttribute("missingDependencies", "true");
                        break;
                    }
                }
            }
            projectsListElement.appendChild(projectElement);
        } catch (EngineException e) {
            String message = "Unable to get project information ('" + projectName + "')";
            Engine.logAdmin.error(message, e);
        }
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) Reference(com.twinsoft.convertigo.beans.core.Reference) Element(org.w3c.dom.Element) DateFormat(java.text.DateFormat) EngineException(com.twinsoft.convertigo.engine.EngineException) File(java.io.File) Date(java.util.Date)

Example 9 with ProjectSchemaReference

use of com.twinsoft.convertigo.beans.references.ProjectSchemaReference in project convertigo by convertigo.

the class ProjectTreeObject method treeObjectPropertyChanged.

@Override
public void treeObjectPropertyChanged(TreeObjectEvent treeObjectEvent) {
    super.treeObjectPropertyChanged(treeObjectEvent);
    TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
    if (treeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
        String propertyName = treeObjectEvent.propertyName;
        propertyName = ((propertyName == null) ? "" : propertyName);
        // Case of a bean name has changed
        if (propertyName.equals("name")) {
            handlesBeanNameChanged(treeObjectEvent);
        } else // Case wsdlStyle of this project has changed
        if (propertyName.equals("wsdlStyle")) {
            if (databaseObject.equals(getObject())) {
            // TODO: remove this property
            }
        } else // Case schemaElementForm of this project has changed
        if (propertyName.equals("schemaElementForm")) {
            if (databaseObject.equals(getObject())) {
                updateTransactionSchemas();
            }
        } else // Case namespaceUri of a project has changed
        if (propertyName.equals("namespaceUri")) {
            if (databaseObject.equals(getObject())) {
                updateTransactionSchemas();
            }
        } else // Case of a requestable changed its WS exposition
        if (propertyName.equals("accessibility")) {
        // Nothing to do
        }
        if (this.equals(treeObject.getProjectTreeObject())) {
            if ((databaseObject instanceof RequestableStep && propertyName.startsWith("source")) || (databaseObject instanceof ProjectSchemaReference && propertyName.equals("projectName")) || (treeObject instanceof INamedSourceSelectorTreeObject && ((INamedSourceSelectorTreeObject) treeObject).getNamedSourceSelector().isNamedSource(propertyName))) {
                checkMissingProjects();
            }
        }
        // Clear schema cache
        if (this.equals(treeObject.getProjectTreeObject())) {
            Engine.theApp.schemaManager.clearCache(getName());
        }
    }
}
Also used : ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Example 10 with ProjectSchemaReference

use of com.twinsoft.convertigo.beans.references.ProjectSchemaReference in project convertigo by convertigo.

the class ProjectTreeObject method checkMissingProjects.

public void checkMissingProjects(final boolean doReload) {
    synchronized (this) {
        if (isCheckMissingProjects) {
            return;
        }
        isCheckMissingProjects = true;
    }
    final Project project = getObject();
    Job.create("Check missing project for " + project.getName(), (monitor) -> {
        try {
            final Set<String> missingProjects = project.getMissingProjects().keySet();
            final Set<String> missingProjectReferences = project.getMissingProjectReferences().keySet();
            if (!missingProjects.isEmpty() || !missingProjectReferences.isEmpty()) {
                List<String> allProjects = Engine.theApp.databaseObjectsManager.getAllProjectNamesList(false);
                for (Iterator<String> i = missingProjects.iterator(); i.hasNext(); ) {
                    String targetProjectName = i.next();
                    if (allProjects.contains(targetProjectName)) {
                        Display.getDefault().syncExec(() -> {
                            try {
                                ProjectExplorerView pev = getProjectExplorerView();
                                TreeObject obj = pev.getProjectRootObject(targetProjectName);
                                if (obj != null && obj instanceof UnloadedProjectTreeObject) {
                                    pev.loadProject(((UnloadedProjectTreeObject) obj));
                                    i.remove();
                                }
                            } catch (Exception e) {
                                Engine.logStudio.warn("Failed to open \"" + targetProjectName + "\"", e);
                            }
                        });
                    }
                }
                Map<String, ProjectUrlParser> refToImport = new HashMap<>();
                for (Reference ref : project.getReferenceList()) {
                    if (ref instanceof ProjectSchemaReference) {
                        ProjectSchemaReference prjRef = (ProjectSchemaReference) ref;
                        if (missingProjects.contains(prjRef.getParser().getProjectName()) && prjRef.getParser().isValid()) {
                            refToImport.put(prjRef.getParser().getProjectName(), prjRef.getParser());
                        }
                    }
                }
                if (!refToImport.isEmpty()) {
                    Engine.execute(() -> {
                        boolean loaded = false;
                        for (ProjectUrlParser parser : refToImport.values()) {
                            try {
                                loaded |= Engine.theApp.referencedProjectManager.importProject(parser) != null;
                            } catch (Exception e) {
                                Engine.logStudio.warn("Failed to load '" + parser.getProjectName() + "'", e);
                            }
                        }
                        if (loaded) {
                            Engine.theApp.fireMigrationFinished(new EngineEvent(""));
                        }
                    });
                    return;
                }
                String message = "For \"" + project.getName() + "\" project :\n";
                for (String targetProjectName : missingProjects) {
                    message += "  > The project \"" + targetProjectName + "\" is missing\n";
                }
                for (String targetProjectName : missingProjectReferences) {
                    message += "  > The reference to project \"" + targetProjectName + "\" is missing\n";
                }
                message += "\nPlease create missing reference(s) and import missing project(s), or correct your project.";
                if (!missingProjectReferences.isEmpty()) {
                    final String msg = message;
                    final String warn = message;
                    Display.getDefault().syncExec(() -> {
                        CustomDialog customDialog = new CustomDialog(null, "Project references", msg + "\n\nDo you want to automatically add reference objects ?", 670, 250, new ButtonSpec("Always", true), new ButtonSpec("Never", false));
                        String autoCreate = ConvertigoPlugin.getProperty(ConvertigoPlugin.PREFERENCE_AUTO_CREATE_PROJECT_REFERENCE);
                        int response = autoCreate.isEmpty() ? customDialog.open() : (autoCreate.equalsIgnoreCase("true") ? 0 : 1);
                        ConvertigoPlugin.setProperty(ConvertigoPlugin.PREFERENCE_AUTO_CREATE_PROJECT_REFERENCE, response == 0 ? "true" : "false");
                        if (response == 0) {
                            for (String targetProjectName : missingProjectReferences) {
                                try {
                                    ProjectSchemaReference reference = new ProjectSchemaReference();
                                    String projectName = targetProjectName;
                                    reference.setName(targetProjectName + "_reference");
                                    projectName = ProjectUrlParser.getUrl(projectName);
                                    reference.setProjectName(projectName);
                                    reference.hasChanged = true;
                                    project.add(reference);
                                } catch (Exception e) {
                                    ConvertigoPlugin.logException(e, "failed to add a reference to '" + targetProjectName + "'");
                                }
                            }
                            try {
                                if (doReload || autoCreate.isEmpty()) {
                                    ProjectExplorerView pev = getProjectExplorerView();
                                    pev.reloadTreeObject(ProjectTreeObject.this);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            hasBeenModified(true);
                        } else {
                            Engine.logBeans.warn(warn);
                        }
                    });
                } else if (!missingProjects.isEmpty()) {
                    ConvertigoPlugin.warningMessageBox(message);
                }
            }
        } finally {
            isCheckMissingProjects = false;
        }
    }).schedule();
}
Also used : TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CoreException(org.eclipse.core.runtime.CoreException) Step(com.twinsoft.convertigo.beans.core.Step) JScriptEditorInput(com.twinsoft.convertigo.eclipse.editors.jscript.JScriptEditorInput) NamespaceUriValidator(com.twinsoft.convertigo.eclipse.property_editors.validators.NamespaceUriValidator) IPath(org.eclipse.core.runtime.IPath) PartInitException(org.eclipse.ui.PartInitException) Map(java.util.Map) IViewPart(org.eclipse.ui.IViewPart) ConnectorEditor(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor) Cursor(org.eclipse.swt.graphics.Cursor) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) GenericUtils(com.twinsoft.convertigo.engine.util.GenericUtils) IEditorInput(org.eclipse.ui.IEditorInput) PlatformUI(org.eclipse.ui.PlatformUI) Set(java.util.Set) Display(org.eclipse.swt.widgets.Display) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ConvertigoPlugin(com.twinsoft.convertigo.eclipse.ConvertigoPlugin) List(java.util.List) Reference(com.twinsoft.convertigo.beans.core.Reference) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Transaction(com.twinsoft.convertigo.beans.core.Transaction) Path(org.eclipse.core.runtime.Path) SWT(org.eclipse.swt.SWT) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) SequenceEditorInput(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditorInput) EngineException(com.twinsoft.convertigo.engine.EngineException) SequenceEditor(com.twinsoft.convertigo.eclipse.editors.sequence.SequenceEditor) SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) CouchDbConnector(com.twinsoft.convertigo.beans.connectors.CouchDbConnector) IFolder(org.eclipse.core.resources.IFolder) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) TraceFileEditorInput(com.twinsoft.convertigo.eclipse.editors.text.TraceFileEditorInput) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) HashMap(java.util.HashMap) ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) JsonIndex(com.twinsoft.convertigo.beans.couchdb.JsonIndex) ArrayList(java.util.ArrayList) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) Connector(com.twinsoft.convertigo.beans.core.Connector) IProject(org.eclipse.core.resources.IProject) IResourceDelta(org.eclipse.core.resources.IResourceDelta) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) IFile(org.eclipse.core.resources.IFile) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ICellEditorValidator(org.eclipse.jface.viewers.ICellEditorValidator) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) Shell(org.eclipse.swt.widgets.Shell) Iterator(java.util.Iterator) Viewer(org.eclipse.jface.viewers.Viewer) Job(org.eclipse.core.runtime.jobs.Job) Engine(com.twinsoft.convertigo.engine.Engine) IResourceDeltaVisitor(org.eclipse.core.resources.IResourceDeltaVisitor) CouchDbManager(com.twinsoft.convertigo.engine.providers.couchdb.CouchDbManager) Project(com.twinsoft.convertigo.beans.core.Project) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) IResource(org.eclipse.core.resources.IResource) MessageBox(org.eclipse.swt.widgets.MessageBox) IEditorReference(org.eclipse.ui.IEditorReference) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) ConnectorEditorInput(com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditorInput) ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) Set(java.util.Set) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) Reference(com.twinsoft.convertigo.beans.core.Reference) ProjectSchemaReference(com.twinsoft.convertigo.beans.references.ProjectSchemaReference) IEditorReference(org.eclipse.ui.IEditorReference) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) EngineException(com.twinsoft.convertigo.engine.EngineException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) IProject(org.eclipse.core.resources.IProject) Project(com.twinsoft.convertigo.beans.core.Project) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) Iterator(java.util.Iterator) EngineEvent(com.twinsoft.convertigo.engine.EngineEvent) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec)

Aggregations

ProjectSchemaReference (com.twinsoft.convertigo.beans.references.ProjectSchemaReference)16 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)9 Reference (com.twinsoft.convertigo.beans.core.Reference)9 Project (com.twinsoft.convertigo.beans.core.Project)8 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)4 Sequence (com.twinsoft.convertigo.beans.core.Sequence)4 Transaction (com.twinsoft.convertigo.beans.core.Transaction)4 ArrayList (java.util.ArrayList)4 Step (com.twinsoft.convertigo.beans.core.Step)3 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)3 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)3 EngineException (com.twinsoft.convertigo.engine.EngineException)3 CouchDbConnector (com.twinsoft.convertigo.beans.connectors.CouchDbConnector)2 Connector (com.twinsoft.convertigo.beans.core.Connector)2 ISchemaGenerator (com.twinsoft.convertigo.beans.core.ISchemaGenerator)2 ISchemaImportGenerator (com.twinsoft.convertigo.beans.core.ISchemaImportGenerator)2 XMLCopyStep (com.twinsoft.convertigo.beans.steps.XMLCopyStep)2 ConvertigoException (com.twinsoft.convertigo.engine.ConvertigoException)2 ProjectUrlParser (com.twinsoft.convertigo.engine.util.ProjectUrlParser)2 Iterator (java.util.Iterator)2