Search in sources :

Example 11 with IProjectFacetVersion

use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project mdw-designer by CenturyLinkCloud.

the class ServerSettingsPage method initValues.

public void initValues() {
    configurator = ServerConfigurator.Factory.create(getServerSettings());
    ContainerType type = ServerSettings.getContainerTypeFromClass(this.getClass().getSimpleName());
    if (type != null) {
        String prevServerHome = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_HOME);
        if (prevServerHome.length() > 0)
            getServerSettings().setHome(prevServerHome);
        if (getServerSettings().getHome() != null)
            serverHomeTextField.setText(getServerSettings().getHome());
        if (getServerSettings().isServiceMix())
            getServerSettings().setContainerVersion("4.4.1");
        if (getServerSettings().isFuse())
            getServerSettings().setContainerVersion("6.1.0");
        String prevJdkHome = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_JDK_HOME);
        if (prevJdkHome.length() > 0)
            getServerSettings().setJdkHome(prevJdkHome);
        if (getServerSettings().getJdkHome() != null)
            jdkHomeTextField.setText(getServerSettings().getJdkHome());
        String prevServerHost = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_HOST);
        if (prevServerHost.length() > 0 && getProject().isRemote())
            getServerSettings().setHost(prevServerHost);
        else
            getServerSettings().setHost(ServerSettings.DEFAULT_HOST);
        serverHostTextField.setText(getServerSettings().getHost());
        String prevServerPort = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_PORT);
        if (prevServerPort.length() > 0 && getProject().isRemote()) {
            try {
                getServerSettings().setPort(Integer.parseInt(prevServerPort));
            } catch (NumberFormatException ex) {
                MdwPlugin.setStringPref(type + "-" + ProjectPersist.MDW_SERVER_PORT, String.valueOf(getDefaultServerPort()));
            }
        } else {
            getServerSettings().setPort(getDefaultServerPort());
        }
        serverPortTextField.setText(String.valueOf(getServerSettings().getPort()));
        String prevServerUser = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_USER);
        if (prevServerUser.length() > 0)
            getServerSettings().setUser(prevServerUser);
        else
            getServerSettings().setUser(getDefaultServerUser());
        serverUserTextField.setText(getServerSettings().getUser());
    }
    if (!getProject().checkRequiredVersion(5, 0)) {
        IProjectFacetVersion pfv = ProjectFacetsManager.getProjectFacet("mdw.workflow").getVersion("1.1");
        IFacetedProjectWorkingCopy wc = ((ModifyFacetedProjectWizard) getWizard()).getFacetedProjectWorkingCopy();
        wc.changeProjectFacetVersion(pfv);
    }
}
Also used : IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) ContainerType(com.centurylink.mdw.plugin.project.model.ServerSettings.ContainerType) ModifyFacetedProjectWizard(org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)

Example 12 with IProjectFacetVersion

use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion 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 13 with IProjectFacetVersion

use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project sling by apache.

the class ProjectAdapter method installFacet.

public void installFacet(String facetId, String facetVersion) throws CoreException {
    IFacetedProject facetedProject = ProjectFacetsManager.create(project);
    IProjectFacet slingBundleFacet = ProjectFacetsManager.getProjectFacet(facetId);
    IProjectFacetVersion projectFacetVersion = slingBundleFacet.getVersion(facetVersion);
    facetedProject.installProjectFacet(projectFacetVersion, null, new NullProgressMonitor());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet)

Example 14 with IProjectFacetVersion

use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project webtools.sourceediting by eclipse.

the class ConvertJob method runInWorkspace.

public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
    try {
        IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(JSDT_FACET);
        IFacetedProject facetedProject = ProjectFacetsManager.create(fProject);
        if (facetedProject != null && fProject.isAccessible()) {
            if (fInstall) {
                IProjectFacetVersion latestVersion = projectFacet.getLatestVersion();
                facetedProject.installProjectFacet(latestVersion, null, monitor);
            }
            if (fUseExplicitWorkingCopy) {
                IFacetedProjectWorkingCopy copy = facetedProject.createWorkingCopy();
                Set fixed = new HashSet(facetedProject.getFixedProjectFacets());
                fixed.add(projectFacet);
                copy.setFixedProjectFacets(fixed);
                copy.commitChanges(new NullProgressMonitor());
                copy.dispose();
            } else {
                Set fixed = new HashSet(facetedProject.getFixedProjectFacets());
                if (!fixed.contains(projectFacet)) {
                    fixed.add(projectFacet);
                    facetedProject.setFixedProjectFacets(fixed);
                }
            }
        }
    } catch (IllegalArgumentException e) {
    // unknown facet ID, bad installation configuration?
    } catch (Exception e) {
        Logger.logException(e);
    }
    return Status.OK_STATUS;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFacetedProject(org.eclipse.wst.common.project.facet.core.IFacetedProject) Set(java.util.Set) HashSet(java.util.HashSet) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) IProjectFacet(org.eclipse.wst.common.project.facet.core.IProjectFacet) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException) HashSet(java.util.HashSet)

Example 15 with IProjectFacetVersion

use of org.eclipse.wst.common.project.facet.core.IProjectFacetVersion in project webtools.sourceediting by eclipse.

the class DataModelFacetCreationWizardPage method getPrimaryFacetVersion.

public IProjectFacetVersion getPrimaryFacetVersion() {
    IProjectFacetVersion fv = null;
    if (this.primaryProjectFacet.getVersions().size() > 1) {
        final int selectedIndex = this.primaryVersionCombo.getSelectionIndex();
        if (selectedIndex != -1) {
            final String fvstr = this.primaryVersionCombo.getItem(selectedIndex);
            fv = this.primaryProjectFacet.getVersion(fvstr);
        }
    } else {
        fv = this.primaryProjectFacet.getDefaultVersion();
    }
    return fv;
}
Also used : IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)

Aggregations

IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)22 IProjectFacet (org.eclipse.wst.common.project.facet.core.IProjectFacet)10 CoreException (org.eclipse.core.runtime.CoreException)7 IFacetedProject (org.eclipse.wst.common.project.facet.core.IFacetedProject)5 IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)5 HashSet (java.util.HashSet)4 IPreset (org.eclipse.wst.common.project.facet.core.IPreset)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)3 Action (org.eclipse.wst.common.project.facet.core.IFacetedProject.Action)3 Iterator (java.util.Iterator)2 IProject (org.eclipse.core.resources.IProject)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 ILibraryProvider (org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider)2 LibraryInstallDelegate (org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate)2 IRuntime (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)2 ModifyFacetedProjectWizard (org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard)2 MdwProgressMonitorDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog)1 ContainerType (com.centurylink.mdw.plugin.project.model.ServerSettings.ContainerType)1