use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class WebHooksComponent method createControls.
private void createControls(Collection<IBuildConfig> buildConfigs, Composite parent) {
GridLayoutFactory.fillDefaults().applyTo(this);
Link webhookExplanation = new Link(this, SWT.WRAP);
webhookExplanation.setText("<a>Webhook triggers</a> allow you to trigger a new build by sending a request to the OpenShift API endpoint.");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(webhookExplanation);
webhookExplanation.addSelectionListener(onWebhookExplanationClicked());
for (IBuildConfig buildConfig : buildConfigs) {
Group hooksGroup = new Group(this, SWT.None);
hooksGroup.setText("Webhooks for " + buildConfig.getSourceURI());
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(hooksGroup);
GridLayoutFactory.fillDefaults().numColumns(3).margins(10, 10).applyTo(hooksGroup);
createHookWidgets(buildConfig, hooksGroup);
}
}
use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class ResourceDetailsContentProvider method addBuildConfigProperties.
private void addBuildConfigProperties(Collection<ResourceProperty> properties, IBuildConfig config) {
IBuildStrategy buildStrategy = config.getBuildStrategy();
addStrategyTypeProperties(properties, buildStrategy);
properties.add(new ResourceProperty("source URL", config.getSourceURI()));
properties.add(new ResourceProperty("output to", config.getOutputRepositoryName()));
List<String> triggers = config.getBuildTriggers().stream().map(trigger -> trigger.getType().toString()).collect(Collectors.toList());
properties.add(new ResourceProperty("build triggers", triggers));
}
use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method testAreRelatedForBuildConfigAndService.
@Test
public void testAreRelatedForBuildConfigAndService() {
// given
// when
// then
assertThat(areRelated((IBuildConfig) null, (IService) null)).isFalse();
// given
// when
// then
assertThat(areRelated(mock(IBuildConfig.class), (IService) null)).isFalse();
// given
// when
// then
assertThat(areRelated((IBuildConfig) null, mock(IService.class))).isFalse();
// given
IBuildConfig buildConfig = mock(IBuildConfig.class);
when(buildConfig.getName()).thenReturn("42");
IService service = mock(IService.class);
when(service.getName()).thenReturn("24");
// when
// then
assertThat(areRelated(buildConfig, service)).isFalse();
// given
buildConfig = mock(IBuildConfig.class);
when(buildConfig.getName()).thenReturn("42");
service = mock(IService.class);
when(service.getName()).thenReturn("42");
// when
// then
assertThat(areRelated(buildConfig, service)).isTrue();
}
use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class ResourceUtilsTest method testGetBuildConfigForService.
@Test
public void testGetBuildConfigForService() {
// given
// when
IBuildConfig matchingConfig = getBuildConfigFor(SERVICE_42, Arrays.asList(BUILDCONFIGS));
// then
assertThat(matchingConfig).isEqualTo(BUILDCONFIGS[1]);
// when
matchingConfig = getBuildConfigFor(SERVICE_42, null);
// then
assertThat(matchingConfig).isNull();
// when
matchingConfig = getBuildConfigFor((IService) null, Arrays.asList(BUILDCONFIGS));
// then
assertThat(matchingConfig).isNull();
// when
matchingConfig = getBuildConfigFor(ResourceMocks.createResource(IService.class, ResourceKind.SERVICE, config -> when(config.getName()).thenReturn("0")), Arrays.asList(BUILDCONFIGS));
// then
assertThat(matchingConfig).isNull();
}
use of com.openshift.restclient.model.IBuildConfig in project jbosstools-openshift by jbosstools.
the class BuildConfigWizardPage method doCreateControls.
@Override
protected void doCreateControls(Composite parent, DataBindingContext dbc) {
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(parent);
GridLayoutFactory.fillDefaults().applyTo(parent);
Group buildConfigsGroup = new Group(parent, SWT.NONE);
buildConfigsGroup.setText("Existing Build Configs:");
GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).applyTo(buildConfigsGroup);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(buildConfigsGroup);
// build configs tree
TreeViewer buildConfigsViewer = createBuildConfigsViewer(new Tree(buildConfigsGroup, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL), model, dbc);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 200).span(1, 2).applyTo(buildConfigsViewer.getControl());
final IObservableValue selectedItem = BeanProperties.value(IBuildConfigPageModel.PROPERTY_SELECTED_ITEM).observe(model);
Binding selectedBuildConfigBinding = ValueBindingBuilder.bind(ViewerProperties.singleSelection().observe(buildConfigsViewer)).converting(new ObservableTreeItem2ModelConverter()).to(selectedItem).converting(new Model2ObservableTreeItemConverter()).in(dbc);
dbc.addValidationStatusProvider(new MultiValidator() {
@Override
protected IStatus validate() {
if (!(selectedItem.getValue() instanceof IBuildConfig)) {
return ValidationStatus.cancel("Please select the existing build config that you want to import");
} else {
return ValidationStatus.ok();
}
}
});
IObservableValue connectionObservable = BeanProperties.value(IBuildConfigPageModel.PROPERTY_CONNECTION).observe(model);
DataBindingUtils.addDisposableValueChangeListener(onConnectionChanged(buildConfigsViewer, model), connectionObservable, buildConfigsViewer.getTree());
ControlDecorationSupport.create(selectedBuildConfigBinding, SWT.LEFT | SWT.TOP, null, new RequiredControlDecorationUpdater(true));
// refresh button
Button refreshButton = new Button(buildConfigsGroup, SWT.PUSH);
refreshButton.setText("&Refresh");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).hint(100, SWT.DEFAULT).applyTo(refreshButton);
refreshButton.addSelectionListener(onRefresh(buildConfigsViewer, model));
// filler
Label fillerLabel = new Label(buildConfigsGroup, SWT.NONE);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, true).applyTo(fillerLabel);
// details
ExpandableComposite expandable = new ExpandableComposite(buildConfigsGroup, SWT.None);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(expandable);
expandable.setText("Build config Details");
expandable.setExpanded(true);
GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).spacing(0, 0).applyTo(expandable);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(expandable);
Composite detailsContainer = new Composite(expandable, SWT.NONE);
GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.FILL).grab(true, false).hint(SWT.DEFAULT, 150).applyTo(detailsContainer);
IObservableValue selectedService = new WritableValue();
ValueBindingBuilder.bind(selectedItem).to(selectedService).notUpdatingParticipant().in(dbc);
new BuildConfigDetailViews(selectedService, detailsContainer, dbc).createControls();
expandable.setClient(detailsContainer);
expandable.addExpansionListener(new IExpansionListener() {
@Override
public void expansionStateChanging(ExpansionEvent e) {
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
buildConfigsGroup.update();
buildConfigsGroup.layout(true);
}
});
loadBuildConfigs(model);
}
Aggregations