use of com.openshift.restclient.model.template.IParameter in project jbosstools-openshift by jbosstools.
the class ApplicationSourceFromTemplateModelTest method updateParameterValueShouldUpdateTheParameterValue.
@Test
public void updateParameterValueShouldUpdateTheParameterValue() {
IParameter param = mock(IParameter.class);
model.updateParameterValue(param, "abc123");
verify(param).setValue(eq("abc123"));
}
use of com.openshift.restclient.model.template.IParameter in project jbosstools-openshift by jbosstools.
the class NewApplicationSummaryFromTemplateDialog method onDoubleClick.
private IDoubleClickListener onDoubleClick(final Control control) {
return new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
IParameter param = (IParameter) selection.getFirstElement();
if (param != null) {
String text = param.getValue();
if (StringUtils.isNotBlank(text)) {
String notification = param.getName() + " value copied to clipboard";
copyToClipBoard(control, text, notification);
}
}
}
};
}
use of com.openshift.restclient.model.template.IParameter in project jbosstools-openshift by jbosstools.
the class NewApplicationSummaryFromTemplateDialog method createTable.
public TableViewer createTable(Composite tableContainer) {
Table table = new Table(tableContainer, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
ICellToolTipProvider<IParameter> cellToolTipProvider = new ICellToolTipProvider<IParameter>() {
@Override
public String getToolTipText(IParameter object) {
return object.getDescription();
}
@Override
public int getToolTipDisplayDelayTime(IParameter object) {
return 0;
}
};
TableViewer viewer = new TableViewerBuilder(table, tableContainer).contentProvider(new ArrayContentProvider()).column(new IColumnLabelProvider<IParameter>() {
@Override
public String getValue(IParameter variable) {
return variable.getName();
}
}).cellToolTipProvider(cellToolTipProvider).name("Name").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().column(new IColumnLabelProvider<IParameter>() {
@Override
public String getValue(IParameter parameter) {
return TemplateParameterViewerUtils.getValueLabel(parameter);
}
}).cellToolTipProvider(cellToolTipProvider).name("Value").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().buildViewer();
viewer.setComparator(new ParameterNameViewerComparator());
viewer.addDoubleClickListener(onDoubleClick(table));
return viewer;
}
use of com.openshift.restclient.model.template.IParameter in project jbosstools-openshift by jbosstools.
the class TemplateParametersPage method buildTableViewer.
private TableViewer buildTableViewer(Table table, Composite tableContainer, ObservableMap<String, IStatus> cellsValidationStatusObservable, TableViewerCellDecorationManager decorations) {
final TableViewerBuilder builder = new TableViewerBuilder(table, tableContainer);
TableViewer tableViewer = builder.contentProvider(new ObservableListContentProvider()).column(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Assert.isLegal(cell.getElement() instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
IParameter parameter = (IParameter) cell.getElement();
String label = parameter.getName();
if (parameter.isRequired()) {
label = markRequired(label);
}
cell.setText(label);
}
private String markRequired(String label) {
return label += " *";
}
@Override
public String getToolTipText(Object object) {
Assert.isLegal(object instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
return ((IParameter) object).getDescription();
}
@Override
public int getToolTipDisplayDelayTime(Object object) {
return 0;
}
}).name("Name").align(SWT.LEFT).weight(1).minWidth(180).buildColumn().column(new CellLabelProvider() {
@Override
public void update(ViewerCell cell) {
Assert.isLegal(cell.getElement() instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
final IParameter parameter = (IParameter) cell.getElement();
String label = TemplateParameterViewerUtils.getValueLabel(parameter);
cell.setText(label);
boolean italic = ((ApplicationSourceFromTemplateModel) model).isParameterModified(parameter);
builder.applyFont(cell, italic);
IStatus validationStatus = validate(parameter);
cellsValidationStatusObservable.put(parameter.getName(), validationStatus);
decorations.toggle(!validationStatus.isOK(), cell);
}
private IStatus validate(IParameter parameter) {
if (parameter.isRequired() && StringUtils.isEmpty(parameter.getValue()) && StringUtils.isEmpty(parameter.getGeneratorName())) {
return ValidationStatus.error(NLS.bind("Parameter {0} is required, please provide a value.", parameter.getName()));
}
IStatus status = gitSourceValidator.validate(parameter);
if (!status.isOK()) {
return status;
}
return ValidationStatus.ok();
}
@Override
public String getToolTipText(Object object) {
Assert.isLegal(object instanceof IParameter, CELL_NOT_PARAMETER_ERROR);
return ((IParameter) object).getDescription();
}
@Override
public int getToolTipDisplayDelayTime(Object object) {
return 0;
}
}).name("Value").align(SWT.LEFT).weight(1).buildColumn().buildViewer();
tableViewer.setComparator(new TemplateParameterViewerUtils.ParameterNameViewerComparator());
return tableViewer;
}
use of com.openshift.restclient.model.template.IParameter in project jbosstools-openshift by jbosstools.
the class ResourceDetailsLabelProviderTest method init.
@BeforeClass
public static void init() {
IParameter p1 = mock(IParameter.class);
when(p1.getValue()).thenReturn("Dmitrii");
IParameter p2 = mock(IParameter.class);
when(p2.getValue()).thenReturn("Bocharov");
templateParameters = new HashMap<>();
templateParameters.put("name", p1);
templateParameters.put("surname", p2);
labelsProvider = new ResourceDetailsLabelProvider(templateParameters);
}
Aggregations