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;
}
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;
}
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());
}
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);
}
}
}
};
}
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);
}
}
};
}
Aggregations