Search in sources :

Example 16 with IProject

use of com.openshift.restclient.model.IProject 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 17 with IProject

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

the class ProjectTreeSorterTest method mockProject.

IProject mockProject(String name, String displayName) {
    IProject p = Mockito.mock(IProject.class);
    when(p.getName()).thenReturn(name);
    if (displayName != null) {
        when(p.getDisplayName()).thenReturn(displayName);
    }
    return p;
}
Also used : IProject(com.openshift.restclient.model.IProject)

Example 18 with IProject

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

the class AbstractProjectPage method createProjectControls.

private void createProjectControls(Composite parent, DataBindingContext dbc) {
    Label projectLabel = new Label(parent, SWT.NONE);
    projectLabel.setText("OpenShift project: ");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(projectLabel);
    StructuredViewer projectsViewer = new ComboViewer(parent);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(projectsViewer.getControl());
    final OpenShiftExplorerLabelProvider labelProvider = new OpenShiftExplorerLabelProvider();
    projectsViewer.setContentProvider(new ObservableListContentProvider());
    projectsViewer.setLabelProvider(new ObservableTreeItemLabelProvider());
    projectsViewer.setInput(BeanProperties.list(IProjectPageModel.PROPERTY_PROJECT_ITEMS).observe(model));
    projectsViewer.setComparator(ProjectViewerComparator.createProjectTreeSorter(labelProvider));
    model.setProjectsComparator(new ProjectViewerComparator(labelProvider).asItemComparator());
    IObservableValue selectedProjectObservable = ViewerProperties.singleSelection().observe(projectsViewer);
    Binding selectedProjectBinding = ValueBindingBuilder.bind(selectedProjectObservable).converting(new ObservableTreeItem2ModelConverter(IProject.class)).validatingAfterConvert(new IValidator() {

        @Override
        public IStatus validate(Object value) {
            if (value instanceof IProject) {
                return ValidationStatus.ok();
            }
            return ValidationStatus.cancel("Please choose an OpenShift project.");
        }
    }).to(BeanProperties.value(IProjectPageModel.PROPERTY_PROJECT).observe(model)).converting(new Model2ObservableTreeItemConverter(null)).in(dbc);
    ControlDecorationSupport.create(selectedProjectBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
    IObservableValue connectionObservable = BeanProperties.value(IProjectPageModel.PROPERTY_CONNECTION).observe(model);
    DataBindingUtils.addDisposableValueChangeListener(onConnectionChanged(), connectionObservable, projectsViewer.getControl());
    Button newProjectButton = new Button(parent, SWT.PUSH);
    newProjectButton.setText("New...");
    GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL).applyTo(newProjectButton);
    UIUtils.setDefaultButtonWidth(newProjectButton);
    newProjectButton.addSelectionListener(onNewProjectClicked());
}
Also used : Binding(org.eclipse.core.databinding.Binding) ObservableTreeItemLabelProvider(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItemLabelProvider) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Label(org.eclipse.swt.widgets.Label) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) ProjectViewerComparator(org.jboss.tools.openshift.internal.ui.comparators.ProjectViewerComparator) IProject(com.openshift.restclient.model.IProject) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) IValidator(org.eclipse.core.databinding.validation.IValidator) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.treeitem.Model2ObservableTreeItemConverter) Button(org.eclipse.swt.widgets.Button) OpenShiftExplorerLabelProvider(org.jboss.tools.openshift.internal.ui.explorer.OpenShiftExplorerLabelProvider) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue)

Example 19 with IProject

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

the class ManageProjectsWizardPage method onNew.

private SelectionListener onNew() {
    return new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            NewProjectWizard newProjectWizard = new NewProjectWizard(pageModel.getConnection(), pageModel.getProjects());
            int res = WizardUtils.openWizardDialog(newProjectWizard, getShell());
            if (res == IDialogConstants.OK_ID) {
                IProject newOrSelectedProject = newProjectWizard.getProject();
                if (newOrSelectedProject != null) {
                    pageModel.setSelectedProject(newOrSelectedProject);
                }
            }
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IProject(com.openshift.restclient.model.IProject)

Example 20 with IProject

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

the class ManageProjectsWizardPage method onRemove.

private SelectionListener onRemove(final DataBindingContext dbc) {
    return new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            IProject project = pageModel.getSelectedProject();
            if (project == null) {
                return;
            }
            boolean confirm = MessageDialog.openConfirm(getShell(), OpenShiftUIMessages.ResourceDeletionDialogTitle, NLS.bind(OpenShiftUIMessages.ResourceDeletionConfirmation, project.getName()));
            if (!confirm) {
                return;
            }
            DeleteResourceJob job = OpenShiftJobs.createDeleteResourceJob(project);
            try {
                org.jboss.tools.common.ui.WizardUtils.runInWizard(job, job.getDelegatingProgressMonitor(), getContainer(), dbc);
            } catch (InvocationTargetException | InterruptedException ex) {
                OpenShiftUIActivator.getDefault().getLogger().logError(NLS.bind("Could not delete OpenShift project {0}", project.getName()), ex);
            }
        }
    };
}
Also used : DeleteResourceJob(org.jboss.tools.openshift.internal.core.job.DeleteResourceJob) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IProject(com.openshift.restclient.model.IProject) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IProject (com.openshift.restclient.model.IProject)49 Test (org.junit.Test)18 Connection (org.jboss.tools.openshift.core.connection.Connection)16 IResource (com.openshift.restclient.model.IResource)13 ArrayList (java.util.ArrayList)8 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)7 ResourceKind (com.openshift.restclient.ResourceKind)6 IStatus (org.eclipse.core.runtime.IStatus)6 ObservableTreeItem (org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem)6 List (java.util.List)5 ISelection (org.eclipse.jface.viewers.ISelection)5 IService (com.openshift.restclient.model.IService)4 IRoute (com.openshift.restclient.model.route.IRoute)4 Collection (java.util.Collection)4 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 OpenShiftException (com.openshift.restclient.OpenShiftException)3 IBuildConfig (com.openshift.restclient.model.IBuildConfig)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3