Search in sources :

Example 11 with ProjectUpdater

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

the class LibExtension method update.

@Override
public boolean update(WorkflowProject project, IProgressMonitor monitor) throws ExtensionModuleException, InterruptedException {
    monitor.worked(5);
    try {
        ProjectUpdater updater = new ProjectUpdater(project, MdwPlugin.getSettings());
        updater.addAppLibs(getZipFile(project), new SubProgressMonitor(monitor, 90));
        monitor.worked(5);
    } catch (InterruptedException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new ExtensionModuleException(ex.getMessage(), ex);
    }
    return true;
}
Also used : ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 12 with ProjectUpdater

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

the class ProjectSection method setSelection.

@Override
public void setSelection(WorkflowElement selection) {
    if (project != null)
        project.removeElementChangeListener(this);
    project = (WorkflowProject) selection;
    project.addElementChangeListener(this);
    // dispose controls to render dynamically
    if (sourceProjectEditor != null)
        sourceProjectEditor.dispose();
    if (jdbcUrlEditor != null)
        jdbcUrlEditor.dispose();
    if (hostEditor != null)
        hostEditor.dispose();
    if (portEditor != null)
        portEditor.dispose();
    if (webContextRootEditor != null)
        webContextRootEditor.dispose();
    if (updateServerCacheEditor != null)
        updateServerCacheEditor.dispose();
    if (localProjectEditor != null)
        localProjectEditor.dispose();
    if (localProjectInfoEditor != null)
        localProjectInfoEditor.dispose();
    if (mdwVersionEditor != null)
        mdwVersionEditor.dispose();
    if (appVersionEditor != null)
        appVersionEditor.dispose();
    // source project text field
    sourceProjectEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    sourceProjectEditor.setLabel("Source Project");
    sourceProjectEditor.setWidth(200);
    sourceProjectEditor.render(composite);
    sourceProjectEditor.setValue(project.getSourceProjectName());
    sourceProjectEditor.setEditable(false);
    if (!project.checkRequiredVersion(6, 0)) {
        // jdbc url text field
        jdbcUrlEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
        jdbcUrlEditor.setLabel("JDBC URL");
        jdbcUrlEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                project.getMdwDataSource().setJdbcUrlWithCredentials(((String) newValue).trim());
                project.getMdwDataSource().setEntrySource("projectSection");
                WorkflowProjectManager.updateProject(project);
                project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwDataSource());
            }
        });
        jdbcUrlEditor.render(composite);
        jdbcUrlEditor.setValue(project.getMdwDataSource().getJdbcUrlWithMaskedCredentials());
        jdbcUrlEditor.setEditable(!project.isReadOnly());
    }
    // host text field
    hostEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    hostEditor.setLabel("Server Host");
    hostEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.getServerSettings().setHost((String) newValue);
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getServerSettings());
        }
    });
    hostEditor.render(composite);
    hostEditor.setValue(project.getServerSettings().getHost());
    hostEditor.setEditable(!project.isReadOnly());
    // port text field
    portEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    portEditor.setLabel("Server Port");
    portEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.getServerSettings().setPort(Integer.parseInt(((String) newValue).trim()));
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getServerSettings());
        }
    });
    portEditor.render(composite);
    portEditor.setValue(project.getServerSettings().getPort());
    portEditor.setEditable(!project.isReadOnly());
    // web context root text field
    webContextRootEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    webContextRootEditor.setLabel("Web Context Root");
    webContextRootEditor.setWidth(200);
    if (project.isRemote()) {
        webContextRootEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                project.setWebContextRoot(((String) newValue).trim());
                WorkflowProjectManager.updateProject(project);
                project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getServerSettings());
            }
        });
    }
    webContextRootEditor.render(composite);
    webContextRootEditor.setValue(project.getWebContextRoot());
    webContextRootEditor.setEditable(!project.isReadOnly() && project.isRemote());
    // refresh server cache checkbox
    updateServerCacheEditor = new PropertyEditor(project, PropertyEditor.TYPE_CHECKBOX);
    updateServerCacheEditor.setLabel("Update Server Cache");
    updateServerCacheEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            project.setUpdateServerCache(Boolean.parseBoolean(newValue.toString()));
            WorkflowProjectManager.updateProject(project);
            project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.isUpdateServerCache());
        }
    });
    updateServerCacheEditor.render(composite);
    updateServerCacheEditor.setValue(project.isUpdateServerCache());
    updateServerCacheEditor.setEditable(!project.isReadOnly());
    // mdw version combo
    if (project.isRemote()) {
        mdwVersionEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
    } else {
        mdwVersionEditor = new PropertyEditor(project, PropertyEditor.TYPE_COMBO);
        String releaseUrl = mdwSettings.getMdwReleasesUrl();
        if (project.getMdwMajorVersion() < 6)
            mdwSettings.setMdwReleasesUrl(mdwSettings.getInternalRepositoryUrl());
        List<String> versionOptions = mdwSettings.getMdwVersions();
        mdwSettings.setMdwReleasesUrl(releaseUrl);
        if (!versionOptions.contains(project.getMdwVersion()))
            versionOptions.add(project.getMdwVersion());
        mdwVersionEditor.setValueOptions(versionOptions);
        mdwVersionEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                if (!project.isRemote() && !newValue.equals("")) {
                    project.setMdwVersion((String) newValue);
                    WorkflowProjectManager.updateProject(project);
                    if (MessageDialog.openQuestion(getShell(), "Update Framework Libraries", "Download updated framework libraries to match MDW Version selection?")) {
                        ProjectUpdater updater = new ProjectUpdater(getProject(), MdwPlugin.getSettings());
                        try {
                            updater.updateFrameworkJars(null);
                            ExtensionModulesUpdater modulesUpdater = new ExtensionModulesUpdater(getProject());
                            modulesUpdater.doUpdate(getShell());
                        } catch (Exception ex) {
                            PluginMessages.uiError(getShell(), ex, "Update Framework Libraries", getProject());
                        }
                    }
                    if (getProject().isOsgi())
                        MessageDialog.openInformation(getShell(), "MDW Version Changed", "The MDW version has been updated in the plug-in settings file.  Please update any MDW dependencies in your pom.xml build file.");
                }
            }
        });
    }
    mdwVersionEditor.setLabel("MDW Version");
    mdwVersionEditor.setWidth(100);
    mdwVersionEditor.render(composite);
    mdwVersionEditor.setValue(project.getMdwVersion());
    mdwVersionEditor.setEditable(!project.isReadOnly() && !project.isRemote());
    // app version
    if (!project.isCloudProject() && !"Unknown".equals(project.getAppVersion())) {
        appVersionEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
        appVersionEditor.setLabel("App Version");
        appVersionEditor.setWidth(200);
        appVersionEditor.render(composite);
        appVersionEditor.setValue(project.getAppVersion());
        appVersionEditor.setEditable(false);
    }
    if (!project.isRemote()) {
        // local project text field
        localProjectEditor = new PropertyEditor(project, PropertyEditor.TYPE_TEXT);
        localProjectEditor.setLabel("Workspace Project");
        localProjectEditor.setWidth(200);
        localProjectEditor.setReadOnly(true);
        localProjectEditor.render(composite);
        if (project.isCloudProject())
            localProjectEditor.setValue(project.getSourceProjectName());
        else
            localProjectEditor.setValue(project.getEarProjectName());
        if (!project.isOsgi()) {
            // local project info field
            localProjectInfoEditor = new PropertyEditor(project, PropertyEditor.TYPE_LINK);
            localProjectInfoEditor.setLabel("Workspace Project Settings");
            localProjectInfoEditor.addValueChangeListener(new ValueChangeListener() {

                public void propertyValueChanged(Object newValue) {
                    final IProject proj = project.isCloudProject() ? project.getSourceProject() : project.getEarProject();
                    PropertyDialog dialog = PropertyDialog.createDialogOn(getShell(), "mdw.workflow.mdwServerConnectionsPropertyPage", proj);
                    if (dialog != null)
                        dialog.open();
                }
            });
            localProjectInfoEditor.render(composite);
        }
    }
    composite.layout(true);
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) PropertyDialog(org.eclipse.ui.internal.dialogs.PropertyDialog) ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) ExtensionModulesUpdater(com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater) IProject(org.eclipse.core.resources.IProject)

Example 13 with ProjectUpdater

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

the class ServerConfigurator method createCloudBase.

protected void createCloudBase(IProject project, IProgressMonitor monitor) throws CoreException, IOException {
    try {
        String tempLoc = MdwPlugin.getSettings().getTempResourceLocation();
        PluginUtil.unzipPluginResource("earBase.jar", null, project, tempLoc, monitor);
        ProjectUpdater updater = new ProjectUpdater(getServerSettings().getProject(), MdwPlugin.getSettings());
        updater.updateMappingTemplates(project.getFolder(new Path(tempLoc + "/deploy/config")), monitor);
    } catch (Exception ex) {
        PluginMessages.log(ex);
        throw new IOException(ex.getMessage());
    }
}
Also used : Path(org.eclipse.core.runtime.Path) ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) IOException(java.io.IOException) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 14 with ProjectUpdater

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

the class WebExtension method addTo.

@Override
public boolean addTo(WorkflowProject project, IProgressMonitor monitor) throws ExtensionModuleException, InterruptedException {
    monitor.worked(5);
    try {
        ProjectUpdater updater = new ProjectUpdater(project, MdwPlugin.getSettings());
        updater.addWebLibs(getZipFile(project), new SubProgressMonitor(monitor, 90));
        monitor.worked(5);
    } catch (InterruptedException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new ExtensionModuleException(ex.getMessage(), ex);
    }
    return true;
}
Also used : ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 15 with ProjectUpdater

use of com.centurylink.mdw.plugin.project.assembly.ProjectUpdater 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)

Aggregations

ProjectUpdater (com.centurylink.mdw.plugin.project.assembly.ProjectUpdater)16 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)11 IOException (java.io.IOException)7 CoreException (org.eclipse.core.runtime.CoreException)7 IProject (org.eclipse.core.resources.IProject)4 ExtensionModulesUpdater (com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater)3 ProjectConfigurator (com.centurylink.mdw.plugin.project.assembly.ProjectConfigurator)3 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)3 MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 XmlException (org.apache.xmlbeans.XmlException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)1 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)1 MdwSettings (com.centurylink.mdw.plugin.preferences.model.MdwSettings)1 ProjectInflator (com.centurylink.mdw.plugin.project.assembly.ProjectInflator)1 GradleBuildFile (com.centurylink.mdw.plugin.project.model.GradleBuildFile)1