Search in sources :

Example 1 with ProjectInflator

use of com.centurylink.mdw.plugin.project.assembly.ProjectInflator in project mdw-designer by CenturyLinkCloud.

the class MdwWorkbenchWindowAdvisor method postWindowOpen.

public void postWindowOpen() {
    IWorkbenchPage activePage = Activator.getActivePage();
    // check for updates
    // IHandlerService handlerService = (IHandlerService)
    // activePage.getWorkbenchWindow().getService(IHandlerService.class);
    // try
    // {
    // Object result =
    // handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", null);
    // System.out.println("result: " + result);
    // if (result != null)
    // System.out.println("result class: " + result.getClass().getName());
    // }
    // catch (Exception ex)
    // {
    // ex.printStackTrace();
    // }
    PluginMessages.log("MDW workbench startup...");
    if (activePage != null) {
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.tools");
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.dev");
        activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.designerClassic");
        activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation");
        activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation");
        activePage.hideActionSet("org.eclipse.ui.externaltools.ExternalToolsSet");
        activePage.showActionSet("org.eclipse.search.menu");
        // make sure the process explorer view is visible
        try {
            ProcessExplorerView processExplorerView = (ProcessExplorerView) activePage.showView("mdw.views.designer.processes");
            if (mdwHost != null && mdwPort != null) {
                final Shell shell = activePage.getActivePart().getSite().getShell();
                BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {

                    public void run() {
                        try {
                            discoveryException = null;
                            projectToImport = getWorkflowProject(mdwHost, mdwPort, mdwContextRoot);
                            if (projectToImport == null)
                                throw new DiscoveryException("Unable to discover workflow app at: " + mdwHost + ":" + mdwPort);
                        } catch (DiscoveryException ex) {
                            discoveryException = ex;
                        }
                    }
                });
                if (discoveryException != null)
                    throw discoveryException;
                WorkflowProject existing = WorkflowProjectManager.getInstance().getRemoteWorkflowProject(projectToImport.getName());
                if (existing != null)
                    WorkflowProjectManager.getInstance().deleteProject(existing);
                ProgressMonitorDialog progMonDlg = new ProgressMonitorDialog(shell);
                ProjectInflator projectInflator = new ProjectInflator(projectToImport, null);
                projectInflator.inflateRemoteProject(progMonDlg);
                ProjectImporter projectImporter = new ProjectImporter(projectToImport);
                projectImporter.doImport();
                processExplorerView.handleRefresh();
                // handle preselected entity
                if (preselectType != null && preselectType.trim().length() > 0 && preselectId != null && preselectId.trim().length() > 0) {
                    if (!preselectType.equals(PRESELECT_PROCESS_INSTANCE))
                        throw new UnsupportedOperationException("Unsupported preselect type: " + preselectType);
                    BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {

                        public void run() {
                            // open the process instance
                            IWorkbenchPage page = MdwPlugin.getActivePage();
                            try {
                                WorkflowProcess instance = getProcessInstance(new Long(preselectId));
                                page.openEditor(instance, "mdw.editors.process");
                                page.showView("org.eclipse.ui.views.PropertySheet");
                            } catch (PartInitException ex) {
                                PluginMessages.uiError(ex, "Open Process Instance", projectToImport);
                            }
                        }
                    });
                }
            }
        } catch (Exception ex) {
            PluginMessages.uiError(ex, "Initialize Workspace");
        }
    }
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProcessExplorerView(com.centurylink.mdw.plugin.designer.views.ProcessExplorerView) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) PartInitException(org.eclipse.ui.PartInitException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) ProjectImporter(com.centurylink.mdw.plugin.project.assembly.ProjectImporter) Shell(org.eclipse.swt.widgets.Shell) ProjectInflator(com.centurylink.mdw.plugin.project.assembly.ProjectInflator) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 2 with ProjectInflator

use of com.centurylink.mdw.plugin.project.assembly.ProjectInflator in project mdw-designer by CenturyLinkCloud.

the class CustomTaskManager method addTo.

@Override
public boolean addTo(WorkflowProject project, IProgressMonitor monitor) throws ExtensionModuleException {
    monitor.worked(5);
    try {
        updateApplicationXml(project, project.getWebProjectName() + ".war", project.getWebProjectName(), new SubProgressMonitor(monitor, 5));
        MdwSettings mdwSettings = MdwPlugin.getSettings();
        ProjectInflator inflator = new ProjectInflator(project, mdwSettings);
        inflator.generateWebArtifacts(new SubProgressMonitor(monitor, 5));
        ProjectUpdater updater = new ProjectUpdater(project, mdwSettings);
        ProjectConfigurator configurator = new ProjectConfigurator(project, mdwSettings);
        updater.updateWebProjectJars(new SubProgressMonitor(monitor, 30));
        configurator.createWebProjectSourceCodeAssociations(null, monitor);
        monitor.worked(5);
    } catch (Exception ex) {
        throw new ExtensionModuleException(ex.getMessage(), ex);
    }
    return true;
}
Also used : ProjectInflator(com.centurylink.mdw.plugin.project.assembly.ProjectInflator) ProjectConfigurator(com.centurylink.mdw.plugin.project.assembly.ProjectConfigurator) MdwSettings(com.centurylink.mdw.plugin.preferences.model.MdwSettings) ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) XmlException(org.apache.xmlbeans.XmlException)

Example 3 with ProjectInflator

use of com.centurylink.mdw.plugin.project.assembly.ProjectInflator in project mdw-designer by CenturyLinkCloud.

the class LocalCloudProjectWizard method performFinish.

@Override
public boolean performFinish() {
    // can depend on
    project.setDefaultFilesToIgnoreDuringUpdate();
    // container selected
    ProjectInflator projectInflator = new ProjectInflator(project, MdwPlugin.getSettings());
    if (project.checkRequiredVersion(6, 0, 3))
        projectInflator.inflateCliCloudProject();
    else
        projectInflator.inflateCloudProject(getContainer());
    WorkflowProjectManager.addProject(project);
    // take care of any extension modules
    ExtensionModulesUpdater changer = new ExtensionModulesUpdater(getProject());
    changer.setAdds(project.getExtensionModules());
    changer.doChanges(getShell());
    if (!project.isRemote() && !project.isWar()) {
        BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

            public void run() {
                // deployment assembly, and add the resources folder
                try {
                    ProjectConfigurator projConf = new ProjectConfigurator(getProject(), MdwPlugin.getSettings());
                    getProject().getSourceProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
                    if (getProject().isFilePersist())
                        projConf.removeDeploymentAssemblyResourceMappings(project.getAssetFolder());
                    else
                        projConf.removeDeploymentAssemblyResourceMappings(project.getTempFolder());
                    projConf.addDeploymentAssemblyResourceMappings(project.getSourceProject().getFolder("/src/main/resources"));
                } catch (CoreException ex) {
                    PluginMessages.uiError(ex, "Inflate Project", getProject());
                }
            }
        });
    }
    DesignerPerspective.promptForShowPerspective(activeWindow, project);
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProjectInflator(com.centurylink.mdw.plugin.project.assembly.ProjectInflator) ProjectConfigurator(com.centurylink.mdw.plugin.project.assembly.ProjectConfigurator) CoreException(org.eclipse.core.runtime.CoreException) ExtensionModulesUpdater(com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater)

Example 4 with ProjectInflator

use of com.centurylink.mdw.plugin.project.assembly.ProjectInflator in project mdw-designer by CenturyLinkCloud.

the class ImportProjectWizard method performFinish.

@Override
public boolean performFinish() {
    if (errorMessage != null) {
        MessageDialog.openError(getShell(), "Import Project", errorMessage);
        return false;
    }
    BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

        public void run() {
            List<IProject> existingProjects = new ArrayList<>();
            for (WorkflowProject toImport : projectsToImport) {
                IProject existing = MdwPlugin.getWorkspaceRoot().getProject(toImport.getName());
                if (existing != null && existing.exists())
                    existingProjects.add(existing);
            }
            if (!existingProjects.isEmpty()) {
                String text = "Please confirm that the following workspace projects should be overwritten:";
                ListSelectionDialog lsd = new ListSelectionDialog(getShell(), existingProjects, new ExistingProjectContentProvider(), new ProjectLabelProvider(), text);
                lsd.setTitle("Existing Projects");
                lsd.setInitialSelections(existingProjects.toArray(new IProject[0]));
                lsd.open();
                Object[] results = lsd.getResult();
                if (results == null) {
                    cancel = true;
                    return;
                }
                for (IProject existing : existingProjects) {
                    boolean include = false;
                    for (Object included : results) {
                        if (existing.getName().equals(((IProject) included).getName()))
                            include = true;
                    }
                    if (include) {
                        WorkflowProjectManager.getInstance().deleteProject(existing);
                    } else {
                        WorkflowProject toRemove = null;
                        for (WorkflowProject wfp : projectList) {
                            if (wfp.getName().equals(existing.getName())) {
                                toRemove = wfp;
                                break;
                            }
                        }
                        if (toRemove != null)
                            projectsToImport.remove(toRemove);
                    }
                }
            }
        }
    });
    if (cancel)
        return false;
    if (projectsToImport.isEmpty()) {
        MessageDialog.openInformation(getShell(), "Import Projects", "No projects to import.");
        return true;
    }
    try {
        getContainer().run(false, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Importing MDW project(s)", 100);
                monitor.worked(20);
                try {
                    for (WorkflowProject workflowProject : projectsToImport) {
                        if (workflowProject.isFilePersist()) {
                            File projectDir = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile() + "/" + workflowProject.getName());
                            projectDir.mkdir();
                            String repositoryUrl = projectsToImport.get(0).getMdwVcsRepository().getRepositoryUrl();
                            if (repositoryUrl != null && repositoryUrl.length() > 0) {
                                // avoid
                                Platform.getBundle("org.eclipse.egit.ui").start();
                                // Eclipse
                                // default
                                // Authenticator
                                workflowProject.setPersistType(PersistType.Git);
                                workflowProject.getMdwVcsRepository().setProvider(VcsRepository.PROVIDER_GIT);
                                monitor.subTask("Cloning Git repository for " + workflowProject.getLabel());
                                monitor.worked(1);
                                VcsRepository gitRepo = workflowProject.getMdwVcsRepository();
                                VersionControlGit vcsGit = new VersionControlGit();
                                String user = null;
                                String password = null;
                                if (MdwPlugin.getSettings().isUseDiscoveredVcsCredentials()) {
                                    user = gitRepo.getUser();
                                    password = gitRepo.getPassword();
                                }
                                vcsGit.connect(gitRepo.getRepositoryUrl(), user, password, projectDir);
                                vcsGit.cloneRepo();
                            } else {
                                File assetDir = new File(projectDir + "/" + workflowProject.getMdwVcsRepository().getLocalPath());
                                assetDir.mkdirs();
                            }
                            monitor.worked(40 / projectsToImport.size());
                        }
                        ProjectInflator inflator = new ProjectInflator(workflowProject, MdwPlugin.getSettings());
                        inflator.inflateRemoteProject(getContainer());
                    }
                } catch (Exception ex) {
                    throw new InvocationTargetException(ex);
                }
                ProjectImporter projectImporter = new ProjectImporter(projectsToImport);
                projectImporter.doImport();
                monitor.worked(20);
                monitor.done();
            }
        });
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Import Project");
        return false;
    }
    DesignerPerspective.openPerspective(activeWindow);
    return true;
}
Also used : VersionControlGit(com.centurylink.mdw.dataaccess.file.VersionControlGit) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IProject(org.eclipse.core.resources.IProject) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ProjectImporter(com.centurylink.mdw.plugin.project.assembly.ProjectImporter) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProjectInflator(com.centurylink.mdw.plugin.project.assembly.ProjectInflator) ArrayList(java.util.ArrayList) List(java.util.List) VcsRepository(com.centurylink.mdw.plugin.project.model.VcsRepository) ListSelectionDialog(org.eclipse.ui.dialogs.ListSelectionDialog) File(java.io.File)

Aggregations

ProjectInflator (com.centurylink.mdw.plugin.project.assembly.ProjectInflator)4 ProjectConfigurator (com.centurylink.mdw.plugin.project.assembly.ProjectConfigurator)2 ProjectImporter (com.centurylink.mdw.plugin.project.assembly.ProjectImporter)2 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2 CoreException (org.eclipse.core.runtime.CoreException)2 VersionControlGit (com.centurylink.mdw.dataaccess.file.VersionControlGit)1 DiscoveryException (com.centurylink.mdw.plugin.designer.DiscoveryException)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 ProcessExplorerView (com.centurylink.mdw.plugin.designer.views.ProcessExplorerView)1 MdwSettings (com.centurylink.mdw.plugin.preferences.model.MdwSettings)1 ExtensionModulesUpdater (com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater)1 ProjectUpdater (com.centurylink.mdw.plugin.project.assembly.ProjectUpdater)1 VcsRepository (com.centurylink.mdw.plugin.project.model.VcsRepository)1 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 XmlException (org.apache.xmlbeans.XmlException)1 IProject (org.eclipse.core.resources.IProject)1