Search in sources :

Example 16 with IBuildConfig

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);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Link(org.eclipse.swt.widgets.Link)

Example 17 with IBuildConfig

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));
}
Also used : IBuildStrategy(com.openshift.restclient.model.build.IBuildStrategy) IResource(com.openshift.restclient.model.IResource) Viewer(org.eclipse.jface.viewers.Viewer) ResourceKind(com.openshift.restclient.ResourceKind) IBuildConfig(com.openshift.restclient.model.IBuildConfig) BuildStrategyType(com.openshift.restclient.model.build.BuildStrategyType) Collection(java.util.Collection) StringUtils(org.jboss.tools.openshift.common.core.utils.StringUtils) IImageStream(com.openshift.restclient.model.IImageStream) ResourceKindAndNameComparator(org.jboss.tools.openshift.internal.core.util.ResourceKindAndNameComparator) IDockerBuildStrategy(com.openshift.restclient.model.build.IDockerBuildStrategy) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) IDeploymentConfig(com.openshift.restclient.model.IDeploymentConfig) List(java.util.List) IJenkinsPipelineStrategy(com.openshift.restclient.model.build.IJenkinsPipelineStrategy) IRoute(com.openshift.restclient.model.route.IRoute) ICustomBuildStrategy(com.openshift.restclient.model.build.ICustomBuildStrategy) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ISourceBuildStrategy(com.openshift.restclient.model.build.ISourceBuildStrategy) Collections(java.util.Collections) IService(com.openshift.restclient.model.IService) IBuildStrategy(com.openshift.restclient.model.build.IBuildStrategy)

Example 18 with IBuildConfig

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();
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 19 with IBuildConfig

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();
}
Also used : IBuildConfig(com.openshift.restclient.model.IBuildConfig) IService(com.openshift.restclient.model.IService) Test(org.junit.Test)

Example 20 with IBuildConfig

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);
}
Also used : Binding(org.eclipse.core.databinding.Binding) Group(org.eclipse.swt.widgets.Group) IStatus(org.eclipse.core.runtime.IStatus) IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Label(org.eclipse.swt.widgets.Label) ObservableTreeItem2ModelConverter(org.jboss.tools.openshift.internal.ui.treeitem.ObservableTreeItem2ModelConverter) BuildConfigDetailViews(org.jboss.tools.openshift.internal.ui.server.BuildConfigDetailViews) MultiValidator(org.eclipse.core.databinding.validation.MultiValidator) WritableValue(org.eclipse.core.databinding.observable.value.WritableValue) RequiredControlDecorationUpdater(org.jboss.tools.openshift.internal.common.ui.databinding.RequiredControlDecorationUpdater) Model2ObservableTreeItemConverter(org.jboss.tools.openshift.internal.ui.wizard.importapp.BuildConfigTreeItems.Model2ObservableTreeItemConverter) IBuildConfig(com.openshift.restclient.model.IBuildConfig) Button(org.eclipse.swt.widgets.Button) Tree(org.eclipse.swt.widgets.Tree) IObservableValue(org.eclipse.core.databinding.observable.value.IObservableValue) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Aggregations

IBuildConfig (com.openshift.restclient.model.IBuildConfig)29 Test (org.junit.Test)12 IService (com.openshift.restclient.model.IService)5 IResource (com.openshift.restclient.model.IResource)4 Collection (java.util.Collection)4 DockerImageURI (com.openshift.restclient.images.DockerImageURI)3 IProject (com.openshift.restclient.model.IProject)3 ISourceBuildStrategy (com.openshift.restclient.model.build.ISourceBuildStrategy)3 IRoute (com.openshift.restclient.model.route.IRoute)3 ResourceKind (com.openshift.restclient.ResourceKind)2 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)2 IBuildStrategy (com.openshift.restclient.model.build.IBuildStrategy)2 ICustomBuildStrategy (com.openshift.restclient.model.build.ICustomBuildStrategy)2 IDockerBuildStrategy (com.openshift.restclient.model.build.IDockerBuildStrategy)2 IWebhookTrigger (com.openshift.restclient.model.build.IWebhookTrigger)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 IStatus (org.eclipse.core.runtime.IStatus)2