Search in sources :

Example 11 with MdwProgressMonitorDialog

use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.

the class ImportPackagePage method getNextPage.

@Override
public IWizardPage getNextPage() {
    ImportPackageWizard wiz = (ImportPackageWizard) getWizard();
    final boolean distributeDisc = isDistributedDiscovery();
    if (distributeDisc || isMavenDiscovery()) {
        preselected = null;
        ((ImportPackageWizard) getWizard()).setHasOldImplementors(false);
        final boolean latestVersionsOnly;
        if (latestVersionsCheckbox != null)
            latestVersionsOnly = latestVersionsCheckbox.getSelection();
        else
            latestVersionsOnly = true;
        final String url = discoveryUrlText.getText().trim();
        final String groupId;
        if (groupIdText != null)
            groupId = groupIdText.getText().trim();
        else
            groupId = null;
        // display a progress dialog since this can take a while
        ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(getShell());
        try {
            pmDialog.run(true, true, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask("Crawling for workflow assets...", 100);
                    try {
                        if (distributeDisc) {
                            packageFolder = populateTopFolder(url, null, latestVersionsOnly, monitor);
                        } else {
                            packageFolder = populateTopFolder(null, groupId, latestVersionsOnly, monitor);
                        }
                        monitor.done();
                    } catch (InterruptedException ex) {
                        throw ex;
                    } catch (Exception ex) {
                        throw new InvocationTargetException(ex);
                    }
                }
            });
        } catch (InterruptedException iex) {
        } catch (Exception ex) {
            PluginMessages.uiError(getShell(), ex, "Discover Packages", getProject());
            return null;
        }
    } else {
        BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

            public void run() {
                try {
                    packageFolder = populateTopFolder(null, null, false, null);
                } catch (Exception ex) {
                    PluginMessages.uiError(getShell(), ex, "Import Packages", getProject());
                }
            }
        });
    }
    if (packageFolder == null) {
        return null;
    } else {
        wiz.setFolder(packageFolder);
        wiz.initializePackageSelectPage(preselected);
        return ((ImportPackageWizard) getWizard()).getImportPackageSelectPage();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) XmlException(org.apache.xmlbeans.XmlException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 12 with MdwProgressMonitorDialog

use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.

the class ProjectConfigurator method initializeWebAppJars.

public void initializeWebAppJars() {
    if (getProject().isRemote())
        return;
    final Shell shell = MdwPlugin.getShell();
    ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(shell);
    try {
        pmDialog.run(true, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Adding WebApp Libraries", 100);
                monitor.worked(5);
                try {
                    ProjectUpdater updater = new ProjectUpdater(getProject(), MdwPlugin.getSettings());
                    updater.updateWebProjectJars(monitor);
                    createFrameworkSourceCodeAssociations(shell, monitor);
                } catch (CoreException ex) {
                    PluginMessages.log(ex);
                }
            }
        });
    } catch (Exception ex) {
        PluginMessages.log(ex);
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) DotProjectUpdater(com.centurylink.mdw.plugin.project.model.DotProjectUpdater) InvocationTargetException(java.lang.reflect.InvocationTargetException) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) JavaModelException(org.eclipse.jdt.core.JavaModelException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 13 with MdwProgressMonitorDialog

use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.

the class ProjectConfigurator method initializeFrameworkJars.

public void initializeFrameworkJars() {
    final Shell shell = MdwPlugin.getShell();
    ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(shell);
    try {
        pmDialog.run(false, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Adding Framework Libraries", 100);
                monitor.worked(5);
                ProjectUpdater updater = new ProjectUpdater(getProject(), getSettings());
                updater.updateFrameworkJars(monitor);
                try {
                    SubProgressMonitor submon = new SubProgressMonitor(monitor, 75);
                    addFrameworkJarsToClasspath(submon);
                    createFrameworkSourceCodeAssociations(shell, submon);
                    monitor.done();
                } catch (CoreException ex) {
                    throw new InvocationTargetException(ex);
                }
            }
        });
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Framework Jars", getProject());
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) DotProjectUpdater(com.centurylink.mdw.plugin.project.model.DotProjectUpdater) InvocationTargetException(java.lang.reflect.InvocationTargetException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) JavaModelException(org.eclipse.jdt.core.JavaModelException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 14 with MdwProgressMonitorDialog

use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.

the class ProjectInflator method inflateCloudProject.

public void inflateCloudProject(final IRunnableContext container) {
    getProject().setCloudProject(true);
    // get a project handle
    final IProject newProjectHandle = ResourcesPlugin.getWorkspace().getRoot().getProject(workflowProject.getName());
    // get a project descriptor
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    final IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
    // create the new project operation
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            Repository newRepo = null;
            try {
                if (workflowProject.getPersistType() == PersistType.Git)
                    createGitRepository(monitor);
                CreateProjectOperation op = new CreateProjectOperation(description, "MDW Cloud Project");
                PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, monitor, WorkspaceUndoUtil.getUIInfoAdapter(shell));
            } catch (Exception ex) {
                throw new InvocationTargetException(ex);
            } finally {
                if (newRepo != null)
                    newRepo.close();
            }
        }
    };
    // run the new project creation operation
    try {
        container.run(false, false, op);
        ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(MdwPlugin.getShell());
        pmDialog.run(true, false, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Inflating Workflow Project", 250);
                monitor.worked(5);
                // configure as Java project
                ProjectConfigurator projConf = new ProjectConfigurator(getProject(), MdwPlugin.getSettings());
                projConf.setJava(new SubProgressMonitor(monitor, 3));
                ProjectUpdater updater = new ProjectUpdater(getProject(), MdwPlugin.getSettings());
                // bootstrap
                updater.updateMappingFiles(new SubProgressMonitor(monitor, 3));
                // versions
                // of
                // the
                // property
                // files
                updater.updateFrameworkJars(new SubProgressMonitor(monitor, 150));
                updater.updateWebProjectJars(new SubProgressMonitor(monitor, 50));
                try {
                    if (getProject().isOsgi())
                        projConf.addJavaProjectSourceFolder(getProject().getOsgiSettings().getSourceDir(), new SubProgressMonitor(monitor, 3));
                    else if (!getProject().isWar())
                        projConf.addJavaProjectSourceFolder("src", monitor);
                    projConf.setJavaBuildOutputPath("build/classes", new SubProgressMonitor(monitor, 5));
                    projConf.addFrameworkJarsToClasspath(monitor);
                    // add the workflow facet
                    // already
                    getProject().setSkipFacetPostInstallUpdates(true);
                    // did
                    // framework
                    // updates
                    IFacetedProject facetedProject = ProjectFacetsManager.create(getProject().getSourceProject(), true, new SubProgressMonitor(monitor, 3));
                    IProjectFacetVersion javaFacetVersion = ProjectFacetsManager.getProjectFacet("java").getDefaultVersion();
                    if (Float.parseFloat(javaFacetVersion.getVersionString()) < 1.6)
                        javaFacetVersion = ProjectFacetsManager.getProjectFacet("java").getVersion("1.6");
                    if (workflowProject.isCloudOnly())
                        javaFacetVersion = ProjectFacetsManager.getProjectFacet("java").getVersion("1.7");
                    facetedProject.installProjectFacet(javaFacetVersion, null, new SubProgressMonitor(monitor, 3));
                    IProjectFacetVersion mdwFacet = ProjectFacetsManager.getProjectFacet("mdw.workflow").getDefaultVersion();
                    facetedProject.installProjectFacet(mdwFacet, getProject(), new SubProgressMonitor(monitor, 3));
                    if (workflowProject.isOsgi()) {
                        IProjectFacet utilFacet = ProjectFacetsManager.getProjectFacet("jst.utility");
                        IProjectFacetVersion facetVer = utilFacet.getDefaultVersion();
                        IActionDefinition def = facetVer.getActionDefinition(null, IFacetedProject.Action.Type.INSTALL);
                        Object cfg = def.createConfigObject();
                        facetedProject.installProjectFacet(ProjectFacetsManager.getProjectFacet("jst.utility").getDefaultVersion(), cfg, new SubProgressMonitor(monitor, 3));
                    } else if (workflowProject.isWar()) {
                        // add the facet to the xml file
                        IFile facetsFile = workflowProject.getSourceProject().getFile(".settings/org.eclipse.wst.common.project.facet.core.xml");
                        if (facetsFile.exists()) {
                            String content = new String(PluginUtil.readFile(facetsFile));
                            int insert = content.indexOf("</faceted-project>");
                            content = content.substring(0, insert) + "  <installed facet=\"jst.web\" version=\"3.0\"/>\n" + content.substring(insert);
                            PluginUtil.writeFile(facetsFile, content, new SubProgressMonitor(monitor, 3));
                        }
                    }
                    final ProjectConfigurator configurator = new ProjectConfigurator(getProject(), MdwPlugin.getSettings());
                    if (!workflowProject.isOsgi() && !workflowProject.isWar()) {
                        MdwPlugin.getDisplay().syncExec(new Runnable() {

                            public void run() {
                                try {
                                    configurator.createFrameworkSourceCodeAssociations(MdwPlugin.getShell(), new NullProgressMonitor());
                                } catch (CoreException ex) {
                                    PluginMessages.log(ex);
                                }
                            }
                        });
                    }
                    if (workflowProject.isOsgi()) {
                        generateOsgiArtifacts(new SubProgressMonitor(monitor, 10));
                        configurator.configureOsgiProject(shell, new SubProgressMonitor(monitor, 5));
                    } else if (workflowProject.isWar()) {
                        generateWarCloudArtifacts(new SubProgressMonitor(monitor, 10));
                        // force
                        configurator.addMavenNature(new SubProgressMonitor(monitor, 5));
                    // maven
                    // refresh
                    }
                } catch (Exception ex) {
                    throw new InvocationTargetException(ex);
                }
            }
        });
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Create Cloud Project", workflowProject);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IFile(org.eclipse.core.resources.IFile) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IActionDefinition(org.eclipse.wst.common.project.facet.core.IActionDefinition) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IProject(org.eclipse.core.resources.IProject) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) FileRepository(org.eclipse.jgit.internal.storage.file.FileRepository) Repository(org.eclipse.jgit.lib.Repository) VcsRepository(com.centurylink.mdw.plugin.project.model.VcsRepository) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) IProjectDescription(org.eclipse.core.resources.IProjectDescription) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) CreateProjectOperation(org.eclipse.ui.ide.undo.CreateProjectOperation)

Example 15 with MdwProgressMonitorDialog

use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.

the class WebLogicServerConfigurator method doDeploy.

public void doDeploy(Shell shell) {
    setShell(shell);
    deployOnly = true;
    try {
        ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(shell);
        pmDialog.run(true, true, this);
    } catch (InvocationTargetException ex) {
        PluginMessages.uiError(shell, ex, "Server Deploy", getServerSettings().getProject());
    } catch (InterruptedException ex) {
        PluginMessages.log(ex);
        MessageDialog.openWarning(shell, "Server Deploy", "Deployment cancelled");
    }
}
Also used : MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)22 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)22 InvocationTargetException (java.lang.reflect.InvocationTargetException)21 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)16 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)16 CoreException (org.eclipse.core.runtime.CoreException)9 IOException (java.io.IOException)8 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)6 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)6 Shell (org.eclipse.swt.widgets.Shell)6 IProject (org.eclipse.core.resources.IProject)4 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)3 ExtensionModuleException (com.centurylink.mdw.plugin.project.extensions.ExtensionModuleException)3 ConnectException (java.net.ConnectException)3 ArrayList (java.util.ArrayList)3 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)3 ProgressMonitor (com.centurylink.mdw.common.utilities.timer.ProgressMonitor)2 SwtProgressMonitor (com.centurylink.mdw.plugin.designer.SwtProgressMonitor)2 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)2 ProjectConfigurator (com.centurylink.mdw.plugin.project.assembly.ProjectConfigurator)2