use of org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog in project jbosstools-openshift by jbosstools.
the class DeployImagePage method onBrowseImage.
private SelectionAdapter onBrowseImage() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (model.getDockerConnection() == null) {
MessageDialog.openError(getShell(), "A Docker connection must be selected", MISSING_DOCKER_CONNECTION_MSG);
return;
}
final ListDockerImagesWizard wizard = new ListDockerImagesWizard(model.getDockerConnection(), model.getImageName());
final OkCancelButtonWizardDialog wizardDialog = new OkCancelButtonWizardDialog(getShell(), wizard);
wizardDialog.setPageSize(500, 400);
if (Window.OK == wizardDialog.open()) {
// this bypasses validation
model.setImageName(wizard.getSelectedImageName());
}
}
};
}
use of org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog in project jbosstools-openshift by jbosstools.
the class ListDockerImagesWizardPage method doCreateControls.
@SuppressWarnings("unchecked")
@Override
protected void doCreateControls(final Composite parent, final DataBindingContext dbc) {
GridLayoutFactory.fillDefaults().margins(10, 10).numColumns(2).applyTo(parent);
// filter image by name
final Label filterByNameLabel = new Label(parent, SWT.SEARCH);
filterByNameLabel.setText("Filter:");
filterByNameLabel.setToolTipText("Filter images by their name");
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(false, false).applyTo(filterByNameLabel);
final Text filterByNameText = new Text(parent, SWT.BORDER);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(filterByNameText);
// table with all images
final Table dockerImagesTable = new Table(parent, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.H_SCROLL);
final TableViewer dockerImagesTableViewer = new TableViewer(dockerImagesTable);
dockerImagesTable.setHeaderVisible(true);
dockerImagesTable.setLinesVisible(true);
addTableViewerColum(dockerImagesTableViewer, "Name", SWT.NONE, SWT.LEFT, 200, new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
return ((DockerImageTag) element).getRepoName();
}
});
addTableViewerColum(dockerImagesTableViewer, "Tag", SWT.NONE, SWT.LEFT, 100, new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
return ((DockerImageTag) element).getTag();
}
});
addTableViewerColum(dockerImagesTableViewer, "Image ID", SWT.NONE, SWT.LEFT, 150, new ColumnLabelProvider() {
@Override
public String getText(final Object element) {
return ((DockerImageTag) element).getId();
}
});
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).span(2, 1).hint(200, 100).applyTo(dockerImagesTable);
// observe the viewer content
dockerImagesTableViewer.setContentProvider(new ObservableListContentProvider());
// observe the viewer content
dockerImagesTableViewer.setInput(BeanProperties.list(ListDockerImagesWizardModel.class, ListDockerImagesWizardModel.DOCKER_IMAGES).observe(model));
// filter by name
final ViewerFilter imageNameFilter = new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return ((DockerImageTag) element).getRepoName().contains(filterByNameText.getText());
}
};
dockerImagesTableViewer.addFilter(imageNameFilter);
filterByNameText.addModifyListener(onFilterImages(dockerImagesTableViewer));
// bind selection
dbc.bindValue(ViewerProperties.singleSelection().observe(dockerImagesTableViewer), BeanProperties.value(ListDockerImagesWizardModel.SELECTED_DOCKER_IMAGE).observe(model));
dockerImagesTableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IWizardContainer container = getWizard().getContainer();
if (container instanceof OkCancelButtonWizardDialog) {
((OkCancelButtonWizardDialog) container).autoFinish();
}
}
});
// load the Docker images
try {
getContainer().run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
model.setDockerImages(model.getDockerConnection().getImages(true));
}
});
} catch (InvocationTargetException | InterruptedException e) {
OpenShiftUIActivator.getDefault().getLogger().logError(e);
}
}
use of org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog in project jbosstools-openshift by jbosstools.
the class ServicePortDialog method open.
/**
* Opens this dialog.
*
* @return the return code, ie, the value of the button that the user
* clicked to close the dialog.
*/
public int open() {
final IWizardPage page = this;
Wizard wizard = new Wizard() {
@Override
public boolean performFinish() {
return true;
}
@Override
public void addPages() {
addPage(page);
}
};
wizard.setNeedsProgressMonitor(true);
wizard.setWindowTitle("Service Ports");
this.setWizard(wizard);
OkCancelButtonWizardDialog dialog = new OkCancelButtonWizardDialog(getShell(), wizard);
return dialog.open();
}
use of org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog in project jbosstools-openshift by jbosstools.
the class DeleteResourcesHandler method openDialog.
private void openDialog(Connection connection, String namespace, Shell shell) {
WizardDialog dialog = new OkCancelButtonWizardDialog("Delete", shell, new DeleteResourcesWizard(connection, namespace));
dialog.setPageSize(DIALOG_SIZE);
dialog.open();
}
use of org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog in project jbosstools-openshift by jbosstools.
the class EnvironmentVariablePage method onAdd.
private SelectionListener onAdd() {
return new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Set<String> usedKeys = model.getEnvironmentVariables().stream().filter(v -> !model.isEnvironmentVariableDeleted(v)).map(v -> v.getKey()).collect(Collectors.toSet());
IKeyValueWizardModel<KeyValueItem> dialogModel = new KeyValueWizardModelBuilder<KeyValueItem>().windowTitle(ENVIRONMENT_VARIABLE_LABEL).title("Add " + ENVIRONMENT_VARIABLE_LABEL).description(NLS.bind("Add an {0}.", ENVIRONMENT_VARIABLE_LABEL.toLowerCase())).keyLabel(ENVIRONMENT_VARIABLE_KEY_LABEL).groupLabel(ENVIRONMENT_VARIABLE_LABEL).keyAfterConvertValidator(new EnvironmentVarKeyValidator(usedKeys)).build();
OkCancelButtonWizardDialog dialog = new OkCancelButtonWizardDialog(getShell(), new KeyValueWizard<>(dialogModel));
if (OkCancelButtonWizardDialog.OK == dialog.open()) {
model.addEnvironmentVariable(dialogModel.getKey(), dialogModel.getValue());
selectEnvVarByKey(dialogModel.getKey());
}
}
};
}
Aggregations