Search in sources :

Example 1 with IProjectRequest

use of com.openshift.restclient.model.project.IProjectRequest in project jbosstools-openshift by jbosstools.

the class OpenShift3NativeProjectUtils method createProject.

public static IProject createProject(String name, String displayName, String description, Connection connection) {
    assertTrue(StringUtils.isNotBlank(name));
    assertNotNull(displayName);
    assertNotNull(description);
    assertNotNull(connection);
    IProjectRequest request = connection.getResourceFactory().stub(ResourceKind.PROJECT_REQUEST, name);
    request.setDisplayName(StringUtils.isEmpty(displayName) ? name : displayName);
    request.setDescription(StringUtils.isEmpty(description) ? name : description);
    CreateProjectWaitCondition createProjectWaitCondition = new CreateProjectWaitCondition(connection, request);
    new WaitUntil(createProjectWaitCondition, TimePeriod.VERY_LONG);
    IProject createdProject = createProjectWaitCondition.getProject();
    /**
     * WORKAROUND: explorer wont get notified of the the new project and
     * therefore wont display it unless a manual refresh is done on the
     * connection. https://issues.jboss.org/browse/JBIDE-23513 remove
     * this wait once WatchManager is watching projects and notifies the
     * ui.
     *
     * @see WatchManager#KINDS
     */
    new WaitUntil(new OpenShiftProjectExists(createdProject.getDisplayName(), connection));
    return createdProject;
}
Also used : OpenShiftProjectExists(org.jboss.tools.openshift.reddeer.condition.OpenShiftProjectExists) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) IProjectRequest(com.openshift.restclient.model.project.IProjectRequest) IProject(com.openshift.restclient.model.IProject)

Example 2 with IProjectRequest

use of com.openshift.restclient.model.project.IProjectRequest in project jbosstools-openshift by jbosstools.

the class NewProjectWizardModel method createProject.

public IProject createProject() {
    if (connection == null) {
        OpenShiftUIActivator.getDefault().getLogger().logError("Could not create project, missing connection.");
        return null;
    }
    IProjectRequest request = connection.getResourceFactory().stub(ResourceKind.PROJECT_REQUEST, getProjectName());
    request.setDescription(getDescription());
    request.setDisplayName(getDisplayName());
    IProject project = (IProject) connection.createResource(request);
    List<IProject> newProjects = new ArrayList<>(projects);
    newProjects.add((IProject) connection.refresh(project));
    ConnectionsRegistrySingleton.getInstance().fireConnectionChanged(connection, ConnectionProperties.PROPERTY_PROJECTS, projects, Collections.unmodifiableList(newProjects));
    return this.project = project;
}
Also used : ArrayList(java.util.ArrayList) IProjectRequest(com.openshift.restclient.model.project.IProjectRequest) IProject(com.openshift.restclient.model.IProject)

Aggregations

IProject (com.openshift.restclient.model.IProject)2 IProjectRequest (com.openshift.restclient.model.project.IProjectRequest)2 ArrayList (java.util.ArrayList)1 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)1 OpenShiftProjectExists (org.jboss.tools.openshift.reddeer.condition.OpenShiftProjectExists)1