use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter in project jbosstools-openshift by jbosstools.
the class AbstractProjectPage method getLoadResourcesJobBuilder.
/**
* Create and configure the list of jobs that need to be performed during
* resource loading. The base behavior is to load the projects and force project
* creation if no project exists.
*
* @param closeAfter
* return parameter if wizard needs to be closed (may be updated)
* @param closeOnCancel
* true if the wizard need to be closed
* @return the job builder
*/
protected JobChainBuilder getLoadResourcesJobBuilder(final boolean[] closeAfter, final boolean closeOnCancel) {
JobChainBuilder builder = new JobChainBuilder(new AbstractDelegatingMonitorJob("Loading projects...") {
@Override
protected IStatus doRun(IProgressMonitor monitor) {
try {
model.loadResources();
} catch (OpenShiftException e) {
closeAfter[0] = closeOnCancel;
String problem = e.getStatus() == null ? e.getMessage() : e.getStatus().getMessage();
return OpenShiftUIActivator.statusFactory().errorStatus(problem, e);
}
return Status.OK_STATUS;
}
});
builder.runWhenSuccessfullyDone(new UIJob("Verifying required project...") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!model.hasProjects()) {
List<IProject> projects = new ObservableTreeItem2ModelConverter().convert(model.getProjectItems());
Connection connection = model.getConnection();
NewProjectWizard newProjectWizard = new NewProjectWizard(connection, projects);
if (Dialog.CANCEL == WizardUtils.openWizardDialog(newProjectWizard, getShell())) {
closeAfter[0] = closeOnCancel;
return Status.CANCEL_STATUS;
} else {
model.loadResources();
model.setProject(newProjectWizard.getProject());
}
}
return Status.OK_STATUS;
}
});
return builder;
}
use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter in project jbosstools-openshift by jbosstools.
the class ApplicationSourceListPage method createServerTemplateControls.
private IObservableValue createServerTemplateControls(TabFolder tabFolder, TabFolderTraverseListener tabFolderTraverseListener, IObservableValue uploadTemplate, DataBindingContext dbc) {
TabItem serverTemplatesTab = new TabItem(tabFolder, SWT.NONE);
serverTemplatesTab.setText("Server application source");
Composite parent = new Composite(tabFolder, SWT.NONE);
GridLayoutFactory.fillDefaults().margins(10, 6).spacing(2, 2).applyTo(parent);
serverTemplatesTab.setControl(parent);
// filter text
final Text txtTemplateFilter = UIUtils.createSearchText(parent);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(txtTemplateFilter);
IObservableValue eclipseProjectObservable = BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_ECLIPSE_PROJECT).observe(model);
DataBindingUtils.addDisposableValueChangeListener(new IValueChangeListener() {
@Override
public void handleValueChange(ValueChangeEvent event) {
filterTemplates(txtTemplateFilter, (org.eclipse.core.resources.IProject) event.getObservableValue().getValue());
}
}, eclipseProjectObservable, txtTemplateFilter);
filterTemplates(txtTemplateFilter, model.getEclipseProject());
// the list of templates
this.templatesViewer = createServerTemplatesViewer(parent, txtTemplateFilter);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(400, 180).applyTo(templatesViewer.getControl());
IObservableValue selectedViewerServerTemplate = ViewerProperties.singleSelection().observe(templatesViewer);
ValueBindingBuilder.bind(selectedViewerServerTemplate).converting(new ObservableTreeItem2ModelConverter(IApplicationSource.class)).to(BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_SERVER_APP_SOURCE).observe(model)).converting(new Model2ObservableTreeItemConverter(ApplicationSourceTreeItems.INSTANCE)).in(dbc);
templatesViewer.addDoubleClickListener(onServerTemplateDoubleClicked());
txtTemplateFilter.addModifyListener(onFilterTextTyped(templatesViewer));
tabFolderTraverseListener.bindTabControls(tabFolder.getItemCount() - 1, txtTemplateFilter, templatesViewer.getTree());
return selectedViewerServerTemplate;
}
use of org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter in project jbosstools-openshift by jbosstools.
the class ServerSettingsWizardPage method createResourceTree.
@SuppressWarnings("unchecked")
private IViewerObservableValue createResourceTree(ServerSettingsWizardPageModel model, SashForm resourceControlsContainer, DataBindingContext dbc) {
Composite resourceTreeContainer = new Composite(resourceControlsContainer, SWT.None);
GridLayoutFactory.fillDefaults().applyTo(resourceTreeContainer);
// filter
Text selectorText = UIUtils.createSearchText(resourceTreeContainer);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).applyTo(selectorText);
// resource tree
final TreeViewer resourcesViewer = createResourcesTreeViewer(resourceTreeContainer, model, selectorText);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(RESOURCE_TREE_WIDTH, RESOURCE_TREE_HEIGHT).applyTo(resourcesViewer.getControl());
resourcesViewer.addDoubleClickListener(onDoubleClickService());
IObservableList<ObservableTreeItem> resourceItemsObservable = BeanProperties.list(ServerSettingsWizardPageModel.PROPERTY_RESOURCE_ITEMS).observe(model);
DataBindingUtils.addDisposableListChangeListener(onResourceItemsChanged(resourcesViewer), resourceItemsObservable, resourcesViewer.getTree());
selectorText.addModifyListener(onFilterTextModified(resourcesViewer));
IViewerObservableValue selectedResourceTreeItem = ViewerProperties.singleSelection().observe(resourcesViewer);
ValueBindingBuilder.bind(selectedResourceTreeItem).converting(new ObservableTreeItem2ModelConverter(IResource.class)).validatingAfterConvert(value -> {
if ((value instanceof IResource) && OpenShiftServerUtils.isAllowedForServerAdapter((IResource) value)) {
return ValidationStatus.ok();
}
return ValidationStatus.cancel("Please select a resource that this adapter will be bound to.");
}).to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_RESOURCE).observe(model)).converting(new Model2ObservableTreeItemConverter(new ServerSettingsWizardPageModel.ResourceTreeItemsFactory())).in(dbc);
return selectedResourceTreeItem;
}
Aggregations