Search in sources :

Example 11 with UnloadedProjectTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject in project convertigo by convertigo.

the class ProjectExplorerView method unloadProjectTreeObject.

protected UnloadedProjectTreeObject unloadProjectTreeObject(ProjectTreeObject projectTreeObject) {
    if (projectTreeObject == null)
        throw new IllegalArgumentException("ProjectExplorerView.unloadProjectTreeObject(): project tree object cannot be null!");
    String projectName = projectTreeObject.getName();
    TreeParent invisibleRoot = projectTreeObject.getParent();
    if (projectTreeObject.close()) {
        UnloadedProjectTreeObject unloadedProjectTreeObject = new UnloadedProjectTreeObject(viewer, projectName);
        invisibleRoot.addChild(unloadedProjectTreeObject);
        invisibleRoot.removeChild(projectTreeObject);
        viewer.refresh();
        try {
            ConvertigoPlugin.getDefault().closeProjectPluginResource(projectName);
        } catch (CoreException e) {
            ConvertigoPlugin.logException(e, "Unable to unload the project '" + projectTreeObject.getName() + "'");
        }
        return unloadedProjectTreeObject;
    }
    return null;
}
Also used : UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) CoreException(org.eclipse.core.runtime.CoreException)

Example 12 with UnloadedProjectTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject in project convertigo by convertigo.

the class ViewContentProvider method reloadProject.

public void reloadProject(TreeObject projectTreeObject, boolean isCopy, String originalName) {
    if (!Engine.isStarted)
        return;
    synchronized (this) {
        String projectName = projectTreeObject.toString();
        if (!MigrationManager.isProjectMigrated(projectName)) {
            String message = "Could not load the project \"" + projectName + "\" while it is still migrating.";
            ConvertigoPlugin.logError(message, Boolean.TRUE);
        } else {
            try {
                if (projectTreeObject instanceof UnloadedProjectTreeObject) {
                    ProjectLoadingJob job = new ProjectLoadingJob(projectExplorerView.viewer, (UnloadedProjectTreeObject) projectTreeObject);
                    job.setUser(true);
                    job.schedule();
                } else {
                    UnloadedProjectTreeObject treeObject = projectExplorerView.unloadProjectTreeObject((ProjectTreeObject) projectTreeObject);
                    if (treeObject != null) {
                        ProjectLoadingJob job = new ProjectLoadingJob(projectExplorerView.viewer, treeObject, isCopy, originalName);
                        job.setUser(true);
                        job.schedule();
                    }
                }
            } catch (Exception e) {
                String message = "Error while loading project " + projectName;
                ConvertigoPlugin.logException(e, message);
            }
        }
    }
}
Also used : UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) CoreException(org.eclipse.core.runtime.CoreException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 13 with UnloadedProjectTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject in project convertigo by convertigo.

the class ViewContentProvider method loadProjectRootObject.

private void loadProjectRootObject(String projectName) throws Exception {
    if (projectName.startsWith("mobilebuilder_tpl_")) {
        ConvertigoPlugin.logDebug("Skip loading of the mobilebuilder template project '" + projectName + "'.");
    } else {
        TreeObject treeObject = getProjectRootObject(projectName);
        if (treeObject == null) {
            UnloadedProjectTreeObject unloadedProjectTreeObject = new UnloadedProjectTreeObject(projectExplorerView.viewer, projectName);
            invisibleRoot.addChild(unloadedProjectTreeObject);
            if (ConvertigoPlugin.getDefault().isProjectOpened(projectName)) {
                projectExplorerView.loadProject(unloadedProjectTreeObject);
            }
        }
    }
}
Also used : UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)

Example 14 with UnloadedProjectTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject in project convertigo by convertigo.

the class ProjectLoadingJob method run.

protected IStatus run(IProgressMonitor monitor) {
    this.monitor = monitor;
    synchronized (unloadedProjectTreeObject) {
        if (unloadedProjectTreeObject.getParent() == null) {
            Display.getDefault().asyncExec(() -> viewer.refresh());
            return Status.OK_STATUS;
        }
        try {
            int worksNumber = 2 * ConvertigoPlugin.projectManager.getNumberOfObjects(projectName);
            monitor.beginTask("Opening project " + projectName + "...", worksNumber);
            if (monitor.isCanceled()) {
                Status status = new Status(Status.CANCEL, ConvertigoPlugin.PLUGIN_UNIQUE_ID, 0, "Project " + projectName + " not loaded because of user abort", null);
                return status;
            }
            Project project;
            try {
                monitor.subTask("Importing the project...");
                Engine.theApp.databaseObjectsManager.clearCacheIfSymbolError(projectName);
                project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName, false);
                if (project == null) {
                    unloadedProjectTreeObject.getParent().removeChild(unloadedProjectTreeObject);
                    Status status = new Status(Status.CANCEL, ConvertigoPlugin.PLUGIN_UNIQUE_ID, 0, "Project " + projectName + " doesn't exists", null);
                    return status;
                }
                monitor.subTask("Refreshing project ressources...");
                String projectDir = Engine.projectDir(projectName);
                ConvertigoPlugin.projectManager.getProjectExplorerView().createDir(projectName);
                ConvertigoPlugin.getDefault().createProjectPluginResource(projectName, projectDir, monitor);
                Engine.theApp.databaseObjectsManager.addDatabaseObjectListener(this);
                if (project.undefinedGlobalSymbols) {
                    synchronized (Engine.theApp.databaseObjectsManager) {
                        // parallel projects opening with undefined symbols, check after the first wizard
                        project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName, false);
                        if (project.undefinedGlobalSymbols) {
                            final boolean[] created = { false };
                            new WalkHelper() {

                                boolean create = false;

                                boolean forAll = false;

                                @Override
                                protected void walk(DatabaseObject databaseObject) throws Exception {
                                    if (databaseObject.isSymbolError()) {
                                        for (Entry<String, Set<String>> entry : databaseObject.getSymbolsErrors().entrySet()) {
                                            Set<String> undefinedSymbols = Engine.theApp.databaseObjectsManager.symbolsSetCheckUndefined(entry.getValue());
                                            if (!undefinedSymbols.isEmpty()) {
                                                if (!forAll) {
                                                    boolean[] response = ConvertigoPlugin.warningGlobalSymbols(projectName, databaseObject.getName(), databaseObject.getDatabaseType(), entry.getKey(), "" + databaseObject.getCompilablePropertySourceValue(entry.getKey()), undefinedSymbols, true);
                                                    create = response[0];
                                                    forAll = response[1];
                                                    created[0] |= create;
                                                }
                                                if (create) {
                                                    Engine.theApp.databaseObjectsManager.symbolsCreateUndefined(undefinedSymbols);
                                                }
                                            }
                                        }
                                    }
                                    super.walk(databaseObject);
                                }
                            }.init(project);
                            if (created[0]) {
                                project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName, false);
                            }
                        }
                    }
                }
            } finally {
                Engine.theApp.databaseObjectsManager.removeDatabaseObjectListener(this);
            }
            if (monitor.isCanceled()) {
                Status status = new Status(Status.CANCEL, ConvertigoPlugin.PLUGIN_UNIQUE_ID, 0, "Project " + projectName + " not loaded because of user abort", null);
                return status;
            }
            monitor.subTask("Creating connectors...");
            monitor.subTask("Updating tree view...");
            TreeParent invisibleRoot = unloadedProjectTreeObject.getParent();
            projectTreeObject = new ProjectTreeObject(viewer, project);
            defaultConnectorTreeObject = null;
            demoTraceTreeObject = null;
            invisibleRoot.removeChild(unloadedProjectTreeObject);
            invisibleRoot.addChild(projectTreeObject);
            ConvertigoPlugin.projectManager.setCurrentProject((ProjectTreeObject) projectTreeObject);
            ConvertigoPlugin.getDefault().getProjectPluginResource(projectName, monitor).refreshLocal(IResource.DEPTH_INFINITE, monitor);
            loadDatabaseObject(projectTreeObject, project);
            // Comment out the following line to disable the resources tree part
            // loadResource(projectTreeObject, "Resources", resourceProject.members());
            Status status = new Status(Status.OK, ConvertigoPlugin.PLUGIN_UNIQUE_ID, 0, "Project " + projectName + " loaded", null);
            return status;
        } catch (Exception e) {
            Status status = null;
            unloadedProjectTreeObject.isLoadable = false;
            if (e.getCause() instanceof ProjectInMigrationProcessException)
                status = new Status(Status.WARNING, ConvertigoPlugin.PLUGIN_UNIQUE_ID, 0, "Could not open project \"" + projectName + "\" while it was still in migration check process", e);
            else
                status = new Status(Status.ERROR, ConvertigoPlugin.PLUGIN_UNIQUE_ID, 0, "Error while loading project " + projectName, e);
            return status;
        } finally {
            // Updating the tree viewer
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    if (projectTreeObject != null) {
                        viewer.refresh();
                        ISelection selection = new StructuredSelection(projectTreeObject);
                        viewer.setSelection(selection, true);
                        if (defaultConnectorTreeObject != null && ConvertigoPlugin.getAutoOpenDefaultConnector())
                            defaultConnectorTreeObject.launchEditor();
                        TreeObjectEvent treeObjectEvent = null;
                        if (isCopy)
                            treeObjectEvent = new TreeObjectEvent(projectTreeObject, "name", originalName, projectName, 0);
                        else
                            treeObjectEvent = new TreeObjectEvent(projectTreeObject);
                        ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectAdded(treeObjectEvent);
                        viewer.getControl().getDisplay().asyncExec(new Runnable() {

                            public void run() {
                                if (demoTraceTreeObject != null)
                                    demoTraceTreeObject.play(false);
                                Engine.execute(() -> {
                                    Project.executeAutoStartSequences(projectName);
                                });
                            }
                        });
                    }
                }
            });
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Set(java.util.Set) ProjectInMigrationProcessException(com.twinsoft.convertigo.engine.ProjectInMigrationProcessException) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper) CoreException(org.eclipse.core.runtime.CoreException) ProjectInMigrationProcessException(com.twinsoft.convertigo.engine.ProjectInMigrationProcessException) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException) Project(com.twinsoft.convertigo.beans.core.Project) Entry(java.util.Map.Entry) ISelection(org.eclipse.jface.viewers.ISelection) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)

Example 15 with UnloadedProjectTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject in project convertigo by convertigo.

the class ViewLabelProvider method getImage.

@Override
public Image getImage(Object obj) {
    try {
        String iconName = "/com/twinsoft/convertigo/beans/core/images/default_color_16x16.png";
        Image image = null;
        if (obj instanceof UnloadedProjectTreeObject) {
            String imageKey = org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
        } else if (obj instanceof ResourceTreeObject) {
            ILabelProvider workbenchLabelProvider = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider();
            image = workbenchLabelProvider.getImage(obj);
        } else if (obj instanceof FolderTreeObject) {
            String imageKey = ISharedImages.IMG_OBJ_FOLDER;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
            FolderTreeObject t_folder = (FolderTreeObject) obj;
            if (t_folder.getParent() instanceof DatabaseObjectTreeObject) {
                DatabaseObjectTreeObject parent = (DatabaseObjectTreeObject) t_folder.getParent();
                if (!parent.isEnabled())
                    image = ViewImageProvider.getImageFromCache(imageKey + "_disable", image, obj);
                else if (parent.hasAncestorDisabled())
                    image = ViewImageProvider.getImageFromCache(imageKey + "_unreachable", image, obj);
            }
        } else if (obj instanceof TemplateTreeObject) {
            String imageKey = ISharedImages.IMG_OBJ_FILE;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
        } else if (obj instanceof HandlersDeclarationTreeObject) {
            String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
        } else if (obj instanceof TraceTreeObject) {
            String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
            image = PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
        } else if (obj instanceof VariableTreeObject2) {
            VariableTreeObject2 variableTreeObject = (VariableTreeObject2) obj;
            iconName = MySimpleBeanInfo.getIconName(variableTreeObject.databaseObjectBeanInfo, BeanInfo.ICON_COLOR_16x16);
            if (iconName == null) {
                iconName = "/com/twinsoft/convertigo/beans/core/images/variable_color_16x16.png";
            }
            image = ViewImageProvider.getImageFromCache(iconName, variableTreeObject);
        } else if (obj instanceof DatabaseObjectTreeObject) {
            DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) obj;
            iconName = MySimpleBeanInfo.getIconName(databaseObjectTreeObject.getObject(), BeanInfo.ICON_COLOR_16x16);
            image = ViewImageProvider.getImageFromCache(iconName, databaseObjectTreeObject);
        } else if (obj instanceof PropertyTableTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableTreeObject) obj);
        } else if (obj instanceof PropertyTableRowTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableRowTreeObject) obj);
        } else if (obj instanceof PropertyTableColumnTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/core/images/bean_property_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (PropertyTableColumnTreeObject) obj);
        } else if (obj instanceof DesignDocumentViewTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/couchdb/images/view_color_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (DesignDocumentViewTreeObject) obj);
        } else if (obj instanceof DesignDocumentFunctionTreeObject) {
            iconName = "/com/twinsoft/convertigo/beans/couchdb/images/function_color_16x16.png";
            image = ViewImageProvider.getImageFromCache(iconName, (DesignDocumentFunctionTreeObject) obj);
        } else {
            throw new IllegalArgumentException("Unexpected tree item object");
        }
        return image;
    } catch (Exception e) {
        String message = "Error while getting tree view item image for object [" + obj.getClass().getName() + "] " + obj.toString();
        ConvertigoPlugin.logException(e, message);
        String imageKey = ISharedImages.IMG_OBJ_ELEMENT;
        if (obj instanceof TreeParent) {
            imageKey = ISharedImages.IMG_OBJ_FOLDER;
        }
        return PlatformUI.getWorkbench().getSharedImages().getImage(imageKey);
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TemplateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) Image(org.eclipse.swt.graphics.Image) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) ResourceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ResourceTreeObject) TraceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)

Aggregations

UnloadedProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject)15 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)10 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)8 ConnectorTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject)6 SequenceTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject)6 Project (com.twinsoft.convertigo.beans.core.Project)4 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)4 DesignDocumentFunctionTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject)4 DesignDocumentViewTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject)4 HandlersDeclarationTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject)4 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)4 PropertyTableColumnTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject)4 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)4 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)4 ScreenClassTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject)4 CriteriaTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.CriteriaTreeObject)3 DesignDocumentFilterTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject)3 DesignDocumentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject)3 DesignDocumentUpdateTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject)3 DesignDocumentValidateTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject)3