Search in sources :

Example 21 with MdwProgressMonitorDialog

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

the class ProjectUpdateAction method run.

/**
 * @see IActionDelegate#run(IAction)
 */
public void run(final IAction action) {
    IProject project = null;
    WorkflowProject workflowProject = null;
    try {
        if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).getFirstElement() instanceof IProject) {
            project = (IProject) ((IStructuredSelection) selection).getFirstElement();
            workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(project);
        }
        if (workflowProject == null) {
            MessageDialog.openError(shell, "MDW Update", "Selection must be a Workflow project.");
            return;
        }
        final ProjectUpdater updater = new ProjectUpdater(workflowProject, MdwPlugin.getSettings());
        if (action.getId().equals("mdw.workflow.updateFrameworkJars")) {
            updater.updateFrameworkJars(null);
            ExtensionModulesUpdater modulesUpdater = new ExtensionModulesUpdater(workflowProject);
            modulesUpdater.doUpdate(shell);
        } else if (action.getId().equals("mdw.workflow.associateFrameworkSourceCode")) {
            ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(shell);
            final WorkflowProject wfProject = workflowProject;
            pmDialog.run(true, false, new IRunnableWithProgress() {

                public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    monitor.beginTask("Setting Java source attachment locations", 100);
                    monitor.worked(20);
                    ProjectConfigurator configurator = new ProjectConfigurator(wfProject, MdwPlugin.getSettings());
                    try {
                        configurator.createFrameworkSourceCodeAssociations(shell, monitor);
                    } catch (CoreException ex) {
                        PluginMessages.log(ex);
                    }
                }
            });
        }
    } catch (Exception ex) {
        PluginMessages.log(ex);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ProjectConfigurator(com.centurylink.mdw.plugin.project.assembly.ProjectConfigurator) CoreException(org.eclipse.core.runtime.CoreException) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ExtensionModulesUpdater(com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 22 with MdwProgressMonitorDialog

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

the class ProjectInflator method inflateCliCloudProject.

public void inflateCliCloudProject() {
    try {
        IRunnableWithProgress loader = new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    monitor.beginTask("Inflating Workflow Project", 250);
                    monitor.worked(5);
                    // Download the templates
                    Init init = new Init(new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile() + "/" + workflowProject.getName()));
                    if (workflowProject.getMdwVersion().indexOf("SNAPSHOT") > -1)
                        init.setSnapshots(true);
                    init.setMdwVersion(workflowProject.getMdwVersion());
                    init.setDiscoveryUrl(MdwPlugin.getSettings().getMdwReleasesUrl());
                    monitor.subTask("Downloading Templates");
                    monitor.worked(10);
                    init.run(new SwtProgressMonitor(monitor));
                    createGitRepository(monitor);
                    IProject sourceProject = workflowProject.getSourceProject();
                    PluginUtil.createFoldersAsNeeded(sourceProject, sourceProject.getFolder("/build/classes"), monitor);
                    PluginUtil.createFoldersAsNeeded(sourceProject, sourceProject.getFolder("/src/main/java"), monitor);
                    ProjectUpdater updater = new ProjectUpdater(getProject(), MdwPlugin.getSettings());
                    updater.updateFrameworkJars(new SubProgressMonitor(monitor, 150));
                    workflowProject.refreshProject();
                } catch (Exception ex) {
                    throw new InvocationTargetException(ex);
                }
            }
        };
        ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(MdwPlugin.getShell());
        progMonDlg.run(true, false, loader);
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Create Cloud Project", workflowProject);
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Init(com.centurylink.mdw.cli.Init) SwtProgressMonitor(com.centurylink.mdw.plugin.designer.SwtProgressMonitor) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) MdwProgressMonitorDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IProject(org.eclipse.core.resources.IProject) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) 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) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

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