Search in sources :

Example 6 with Label

use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.

the class ResourceLabelsPage method onEdit.

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            final Label label = UIUtils.getFirstElement(viewer.getSelection(), Label.class);
            editLabel(label);
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label)

Example 7 with Label

use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.

the class ResourceLabelsPage method onAdd.

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

        @Override
        public void widgetSelected(SelectionEvent e) {
            IKeyValueWizardModel<Label> dialogModel = new KeyValueWizardModelBuilder<Label>().windowTitle(RESOURCE_LABEL).title("Add Label").description("Add a resource label.").keyLabel(LABEL_KEY).keyDescription(LabelKeyValidator.keyDescription).valueDescription(NLS.bind(LabelValueValidator.valueDescription, LabelValueValidator.defaultType)).groupLabel(LABEL_GROUP).keyAfterConvertValidator(new LabelKeyValidator(model.getReadOnlyLabels(), getUsedKeys())).valueAfterConvertValidator(new LabelValueValidator()).build();
            OkCancelButtonWizardDialog dialog = new OkCancelButtonWizardDialog(getShell(), new KeyValueWizard<>(UIUtils.getFirstElement(viewer.getSelection(), Label.class), dialogModel));
            if (OkCancelButtonWizardDialog.OK == dialog.open()) {
                model.addLabel(dialogModel.getKey(), dialogModel.getValue());
            }
        }
    };
}
Also used : KeyValueWizardModelBuilder(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder) LabelValueValidator(org.jboss.tools.openshift.internal.ui.validator.LabelValueValidator) LabelKeyValidator(org.jboss.tools.openshift.internal.ui.validator.LabelKeyValidator) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Example 8 with Label

use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.

the class ResourceLabelsPage method editLabel.

private void editLabel(Label label) {
    if (label == null || isReadOnly(label)) {
        return;
    }
    Set<String> usedKeys = getUsedKeys();
    usedKeys.remove(label.getKey());
    IKeyValueWizardModel<Label> dialogModel = new KeyValueWizardModelBuilder<>(label).windowTitle(RESOURCE_LABEL).title("Edit Label").description("Edit the resource label.").keyLabel(LABEL_KEY).keyDescription(LabelKeyValidator.keyDescription).valueDescription(NLS.bind(LabelValueValidator.valueDescription, LabelValueValidator.defaultType)).groupLabel(LABEL_GROUP).keyAfterConvertValidator(new LabelKeyValidator(model.getReadOnlyLabels(), usedKeys)).valueAfterConvertValidator(new LabelValueValidator()).build();
    OkCancelButtonWizardDialog dialog = new OkCancelButtonWizardDialog(getShell(), new KeyValueWizard<>(label, dialogModel));
    if (OkCancelButtonWizardDialog.OK == dialog.open()) {
        model.updateLabel(label, dialogModel.getKey(), dialogModel.getValue());
    }
}
Also used : KeyValueWizardModelBuilder(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder) LabelValueValidator(org.jboss.tools.openshift.internal.ui.validator.LabelValueValidator) LabelKeyValidator(org.jboss.tools.openshift.internal.ui.validator.LabelKeyValidator) Label(org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label) StyledString(org.eclipse.jface.viewers.StyledString) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Example 9 with Label

use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.

the class CreateApplicationFromTemplateJobTest method setUp.

@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
    labels.add(new Label("foo", "bar"));
    job = spy(new CreateApplicationFromTemplateJobRunner(project, template, parameters, labels));
    when(client.get(anyString(), anyString(), anyString())).thenThrow(OpenShiftException.class);
    when(clientCapability.getClient()).thenReturn(client);
    when(project.accept(isA(CapabilityVisitor.class), any())).thenAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock args) throws Throwable {
            if (args.getArguments()[1] instanceof IStatus) {
                CapabilityVisitor<IProjectTemplateProcessing, IStatus> visitor = (CapabilityVisitor<IProjectTemplateProcessing, IStatus>) args.getArguments()[0];
                return visitor.visit(capability);
            } else if (args.getArguments()[1] instanceof Collection) {
                CapabilityVisitor<IClientCapability, Collection> visitor = (CapabilityVisitor<IClientCapability, Collection>) args.getArguments()[0];
                return visitor.visit(clientCapability);
            }
            return null;
        }
    });
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IClientCapability(com.openshift.restclient.capability.resources.IClientCapability) Label(org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label) CapabilityVisitor(com.openshift.restclient.capability.CapabilityVisitor) Answer(org.mockito.stubbing.Answer) IProjectTemplateProcessing(com.openshift.restclient.capability.resources.IProjectTemplateProcessing) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Collection(java.util.Collection) Before(org.junit.Before)

Aggregations

Label (org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 IProjectTemplateProcessing (com.openshift.restclient.capability.resources.IProjectTemplateProcessing)2 Collection (java.util.Collection)2 IStatus (org.eclipse.core.runtime.IStatus)2 StyledString (org.eclipse.jface.viewers.StyledString)2 KeyValueWizardModelBuilder (org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder)2 OkCancelButtonWizardDialog (org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)2 LabelKeyValidator (org.jboss.tools.openshift.internal.ui.validator.LabelKeyValidator)2 LabelValueValidator (org.jboss.tools.openshift.internal.ui.validator.LabelValueValidator)2 OpenShiftException (com.openshift.restclient.OpenShiftException)1 CapabilityVisitor (com.openshift.restclient.capability.CapabilityVisitor)1 IClientCapability (com.openshift.restclient.capability.resources.IClientCapability)1 DockerImageURI (com.openshift.restclient.images.DockerImageURI)1 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)1 IImageStream (com.openshift.restclient.model.IImageStream)1 IDeploymentImageChangeTrigger (com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger)1 ITemplate (com.openshift.restclient.model.template.ITemplate)1 Status (org.eclipse.core.runtime.Status)1