use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.
the class ResourceLabelsPage method createTable.
protected TableViewer createTable(Composite tableContainer) {
Table table = new Table(tableContainer, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
this.viewer = new TableViewerBuilder(table, tableContainer).contentProvider(new ArrayContentProvider()).<Label>column(new DelegatingStyledCellLabelProvider(new LabelTextProvider() {
@Override
public String getValue(Label label) {
return label.getName();
}
})).name(LABEL_KEY).align(SWT.LEFT).weight(2).minWidth(100).buildColumn().<Label>column(new DelegatingStyledCellLabelProvider(new LabelTextProvider() {
@Override
public String getValue(Label label) {
return label.getValue();
}
})).name("Value").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().buildViewer();
viewer.addDoubleClickListener(e -> editLabel((Label) ((IStructuredSelection) e.getSelection()).getFirstElement()));
viewer.setComparator(new ViewerComparator() {
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
Label first = (Label) e1;
Label other = (Label) e2;
return first.getName().compareTo(other.getName());
}
});
return viewer;
}
use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.
the class DeployImageJob method stubDeploymentConfig.
protected IResource stubDeploymentConfig(IResourceFactory factory, final String name, DockerImageURI imageUri, IImageStream is) {
IDeploymentConfig dc = factory.stub(ResourceKind.DEPLOYMENT_CONFIG, name, parameters.getProject().getName());
dc.addLabel(SELECTOR_KEY, name);
dc.addTemplateLabel(SELECTOR_KEY, name);
for (Label label : parameters.getLabels()) {
dc.addTemplateLabel(label.getName(), label.getValue());
}
dc.setReplicas(parameters.getReplicas());
dc.setReplicaSelector(SELECTOR_KEY, name);
Map<String, String> envs = getModifiedEnvVars(parameters.getEnvironmentVariables(), parameters.getImageEnvVars());
dc.addContainer(dc.getName(), imageUri, new HashSet<>(parameters.getPortSpecs()), envs, parameters.getVolumes());
dc.addTrigger(DeploymentTriggerType.CONFIG_CHANGE);
if (is != null) {
IDeploymentImageChangeTrigger imageChangeTrigger = (IDeploymentImageChangeTrigger) dc.addTrigger(DeploymentTriggerType.IMAGE_CHANGE);
imageChangeTrigger.setAutomatic(true);
imageChangeTrigger.setContainerName(name);
imageChangeTrigger.setFrom(new DockerImageURI(null, null, is.getName(), imageUri.getTag()));
imageChangeTrigger.setKind(ResourceKind.IMAGE_STREAM_TAG);
imageChangeTrigger.setNamespace(is.getNamespaceName());
}
return dc;
}
use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.
the class NewApplicationWizardModelTest method setDefaultAppLabelForImageBasedApplications.
@Test
public void setDefaultAppLabelForImageBasedApplications() {
// pre-conditions
IApplicationSource source = mock(IApplicationSource.class);
when(source.getKind()).thenReturn(ResourceKind.IMAGE_STREAM);
IImageStream imageStream = mock(IImageStream.class);
when(source.getSource()).thenReturn(imageStream);
when(imageStream.getName()).thenReturn("my-image-stream");
// operations
model.setServerAppSource(source);
// verification
verify(model, Mockito.times(1)).setLabels(Arrays.asList(new Label("app", "my-image-stream")));
}
use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.
the class CreateApplicationFromTemplateJob method doRun.
@Override
protected IStatus doRun(IProgressMonitor monitor) {
template.updateParameterValues(parameters);
for (Label label : labels) {
template.addObjectLabel(label.getName(), label.getValue());
}
IStatus status = project.accept(new CapabilityVisitor<IProjectTemplateProcessing, IStatus>() {
@Override
public IStatus visit(IProjectTemplateProcessing capability) {
try {
ITemplate processed = capability.process(template);
Collection<IResource> existing = findExistingResources(project, processed);
if (!existing.isEmpty()) {
return createErrorStatusForExistingResources(existing);
}
parameters = processed.getParameters().values();
resources = capability.apply(processed);
return handleResponse(resources);
} catch (OpenShiftException e) {
String message = e.getMessage();
if (e.getStatus() != null) {
message = e.getStatus().getMessage();
}
return new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, -1, message, e);
}
}
}, new Status(IStatus.ERROR, OpenShiftUIActivator.PLUGIN_ID, "Template processing is unsupported for this client and server combination.", null));
return status;
}
use of org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label in project jbosstools-openshift by jbosstools.
the class ResourceLabelsPage method onRemove.
private SelectionListener onRemove() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Label label = UIUtils.getFirstElement(viewer.getSelection(), Label.class);
if (MessageDialog.openQuestion(getShell(), "Remove Label", NLS.bind("Are you sure you want to delete the label {0} ", label.getName()))) {
model.removeLabel(label);
viewer.refresh();
}
}
};
}
Aggregations