Search in sources :

Example 1 with ExtensionModule

use of com.centurylink.mdw.plugin.project.extensions.ExtensionModule in project mdw-designer by CenturyLinkCloud.

the class WorkflowProjectManager method getAllExtensions.

private List<ExtensionModule> getAllExtensions() {
    if (allExtensions == null) {
        allExtensions = new ArrayList<ExtensionModule>();
        // read the plug-in extensions
        IExtensionRegistry registry = Platform.getExtensionRegistry();
        IExtensionPoint extensionPoint = registry.getExtensionPoint("com.centurylink.mdw.designer.ui.extensionModules");
        IExtension[] extensions = extensionPoint.getExtensions();
        for (IExtension extension : extensions) {
            for (IConfigurationElement element : extension.getConfigurationElements()) {
                try {
                    ExtensionModule module = (ExtensionModule) element.createExecutableExtension("class");
                    module.setId(element.getAttribute("id"));
                    module.setName(element.getAttribute("name"));
                    module.setDescription(element.getAttribute("description"));
                    // null
                    module.setVersion(element.getAttribute("version"));
                    // means
                    // MDW
                    // version
                    String requiredMdwVersion = element.getAttribute("requiredMdwVersion");
                    if (requiredMdwVersion != null)
                        // null
                        module.setRequiredMdwVersion(requiredMdwVersion);
                    // means
                    // any
                    // >=
                    // 5.1
                    allExtensions.add(module);
                } catch (Exception ex) {
                    PluginMessages.log("Unable to load MDW Extension for element: " + element);
                    PluginMessages.log(ex);
                }
            }
        }
    }
    Collections.sort(allExtensions);
    return allExtensions;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) IExtension(org.eclipse.core.runtime.IExtension) ExtensionModule(com.centurylink.mdw.plugin.project.extensions.ExtensionModule) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) ResourceException(org.eclipse.core.internal.resources.ResourceException) CoreException(org.eclipse.core.runtime.CoreException) JavaModelException(org.eclipse.jdt.core.JavaModelException) MdwSecurityException(com.centurylink.mdw.auth.MdwSecurityException) DiscoveryException(com.centurylink.mdw.plugin.designer.DiscoveryException) XmlException(org.apache.xmlbeans.XmlException) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry)

Example 2 with ExtensionModule

use of com.centurylink.mdw.plugin.project.extensions.ExtensionModule in project mdw-designer by CenturyLinkCloud.

the class ExtensionModulesWizardPage method drawWidgets.

/**
 * draw the widgets using a grid layout
 *
 * @param parent
 *            - the parent composite
 */
public void drawWidgets(Composite parent) {
    // create the composite to hold the widgets
    Composite composite = new Composite(parent, SWT.NULL);
    // create the layout for this wizard page
    GridLayout gl = new GridLayout();
    int ncol = 4;
    gl.numColumns = ncol;
    composite.setLayout(gl);
    extensionsTable = new ExtensionModulesTable(getProject());
    extensionsTable.create();
    extensionsTable.getTableEditor().render(composite, false);
    extensionsTable.setSelectedModules(new ArrayList<ExtensionModule>());
    extensionsTable.getTableEditor().addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            getProject().setExtensionModules(extensionsTable.getSelectedModules());
        }
    });
    setControl(composite);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) Composite(org.eclipse.swt.widgets.Composite) ExtensionModulesTable(com.centurylink.mdw.plugin.project.extensions.ExtensionModulesTable) ExtensionModule(com.centurylink.mdw.plugin.project.extensions.ExtensionModule)

Example 3 with ExtensionModule

use of com.centurylink.mdw.plugin.project.extensions.ExtensionModule in project mdw-designer by CenturyLinkCloud.

the class ProjectPersist method toXml.

public String toXml() {
    StringBuffer sb = new StringBuffer();
    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    sb.append("<mdw-workflow>\n");
    sb.append("  <sourceProject name=\"" + workflowProject.getSourceProjectName() + "\" author=\"" + workflowProject.getAuthor() + "\"");
    if (workflowProject.isProduction())
        sb.append(" production=\"true\"");
    sb.append("/>\n");
    for (ExtensionModule extension : workflowProject.getExtensionModules()) {
        String extensionElementText = extension.writeConfigElement(workflowProject);
        if (extensionElementText != null)
            sb.append(extensionElementText);
    }
    if (// remote projects get version
    !workflowProject.isRemote())
        // dynamically from server
        sb.append("  <mdwFramework version=\"" + workflowProject.getMdwVersion() + "\"/>\n");
    ServerSettings serverSettings = workflowProject.getServerSettings();
    sb.append("  <server host=\"" + serverSettings.getHost() + "\" port=\"" + serverSettings.getPort() + "\"");
    if (!StringHelper.isEmpty(workflowProject.getWebContextRoot()))
        sb.append(" contextRoot=\"" + workflowProject.getWebContextRoot() + "\"");
    else {
        sb.append(" contextRoot=\"mdw\"");
    }
    sb.append("/>\n");
    if (workflowProject.getPersistType() == PersistType.Git) {
        sb.append("  <repository");
        VcsRepository repo = workflowProject.getMdwVcsRepository();
        sb.append(" provider=\"" + repo.getProvider() + "\"");
        if (repo.getRepositoryUrl() != null && repo.getRepositoryUrl().trim().length() > 0)
            sb.append(" url=\"").append(repo.getRepositoryUrlWithEncryptedCredentials() + "\"");
        if (repo.getBranch() != null && repo.getBranch().trim().length() > 0)
            sb.append(" branch=\"").append(repo.getBranch() + "\"");
        if (repo.getLocalPath() != null && repo.getLocalPath().trim().length() > 0)
            sb.append(" localPath=\"").append(repo.getLocalPath().replace("\\", "/") + "\"");
        if (repo.getPkgPrefixes() != null && !repo.getPkgPrefixes().isEmpty()) {
            sb.append(" pkgPrefixes=\"");
            for (int i = 0; i < repo.getPkgPrefixes().size(); i++) {
                String prefix = repo.getPkgPrefixes().get(i).trim();
                sb.append(prefix);
                if (i < repo.getPkgPrefixes().size() - 1)
                    sb.append(",");
            }
            sb.append("\"");
        }
        sb.append("/>\n");
    }
    if (!workflowProject.checkRequiredVersion(6, 0)) {
        if (workflowProject.getPersistType() != PersistType.None) {
            sb.append("  <database jdbcUrl=\"" + workflowProject.getMdwDataSource().getJdbcUrlWithEncryptedCredentials() + "\"");
            if (workflowProject.getMdwDataSource().getSchemaOwner() != null)
                sb.append(" schemaOwner=\"" + workflowProject.getMdwDataSource().getSchemaOwner() + "\"");
            sb.append("/>\n");
        }
        if (workflowProject.getFilesToIgnore() != null)
            sb.append("  <filesToIgnore duringUpdate=\"" + workflowProject.getFilesToIgnoreDuringUpdate() + "\"/>\n");
    }
    sb.append("</mdw-workflow>\n");
    return sb.toString();
}
Also used : ServerSettings(com.centurylink.mdw.plugin.project.model.ServerSettings) ExtensionModule(com.centurylink.mdw.plugin.project.extensions.ExtensionModule) VcsRepository(com.centurylink.mdw.plugin.project.model.VcsRepository)

Example 4 with ExtensionModule

use of com.centurylink.mdw.plugin.project.extensions.ExtensionModule in project mdw-designer by CenturyLinkCloud.

the class ExtensionModulesPropertyPage method createContents.

@Override
protected Control createContents(Composite parent) {
    noDefaultAndApplyButton();
    initializeWorkflowProject();
    Composite composite = createComposite(parent);
    extensionsTable = new ExtensionModulesTable(getProject());
    extensionsTable.create();
    extensionsTable.getTableEditor().render(composite, false);
    existingModules = getProject().getExtensionModules();
    List<ExtensionModule> selectedModules = new ArrayList<>();
    selectedModules.addAll(existingModules);
    extensionsTable.setSelectedModules(selectedModules);
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExtensionModulesTable(com.centurylink.mdw.plugin.project.extensions.ExtensionModulesTable) ExtensionModule(com.centurylink.mdw.plugin.project.extensions.ExtensionModule) ArrayList(java.util.ArrayList)

Example 5 with ExtensionModule

use of com.centurylink.mdw.plugin.project.extensions.ExtensionModule in project mdw-designer by CenturyLinkCloud.

the class ExtensionModulesPropertyPage method performOk.

@Override
public boolean performOk() {
    List<ExtensionModule> selectedModules = extensionsTable.getSelectedModules();
    // check for deltas
    List<ExtensionModule> adds = new ArrayList<>();
    for (ExtensionModule selected : selectedModules) {
        if (!existingModules.contains(selected))
            adds.add(selected);
    }
    List<ExtensionModule> removes = new ArrayList<>();
    for (ExtensionModule existing : existingModules) {
        if (!selectedModules.contains(existing))
            removes.add(existing);
    }
    ExtensionModulesUpdater changer = new ExtensionModulesUpdater(getProject());
    changer.setAdds(adds);
    changer.setRemoves(removes);
    changer.doChanges(getShell());
    return true;
}
Also used : ExtensionModule(com.centurylink.mdw.plugin.project.extensions.ExtensionModule) ArrayList(java.util.ArrayList) ExtensionModulesUpdater(com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater)

Aggregations

ExtensionModule (com.centurylink.mdw.plugin.project.extensions.ExtensionModule)6 ExtensionModulesTable (com.centurylink.mdw.plugin.project.extensions.ExtensionModulesTable)2 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 Composite (org.eclipse.swt.widgets.Composite)2 MdwSecurityException (com.centurylink.mdw.auth.MdwSecurityException)1 DiscoveryException (com.centurylink.mdw.plugin.designer.DiscoveryException)1 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)1 ExtensionModulesUpdater (com.centurylink.mdw.plugin.project.assembly.ExtensionModulesUpdater)1 ServerSettings (com.centurylink.mdw.plugin.project.model.ServerSettings)1 VcsRepository (com.centurylink.mdw.plugin.project.model.VcsRepository)1 UnknownHostException (java.net.UnknownHostException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 XmlException (org.apache.xmlbeans.XmlException)1 ResourceException (org.eclipse.core.internal.resources.ResourceException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1