Search in sources :

Example 1 with OkCancelButtonWizardDialog

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());
            }
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Example 2 with OkCancelButtonWizardDialog

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);
    }
}
Also used : ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Table(org.eclipse.swt.widgets.Table) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 3 with OkCancelButtonWizardDialog

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();
}
Also used : IWizardPage(org.eclipse.jface.wizard.IWizardPage) Wizard(org.eclipse.jface.wizard.Wizard) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Example 4 with OkCancelButtonWizardDialog

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();
}
Also used : DeleteResourcesWizard(org.jboss.tools.openshift.internal.ui.wizard.resource.DeleteResourcesWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Example 5 with OkCancelButtonWizardDialog

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());
            }
        }
    };
}
Also used : EnvironmentVarKeyValidator(org.jboss.tools.openshift.internal.ui.validator.EnvironmentVarKeyValidator) TableViewer(org.eclipse.jface.viewers.TableViewer) IWizard(org.eclipse.jface.wizard.IWizard) DataBindingContext(org.eclipse.core.databinding.DataBindingContext) ObservableListContentProvider(org.eclipse.jface.databinding.viewers.ObservableListContentProvider) Table(org.eclipse.swt.widgets.Table) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IColumnLabelProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider) TableViewerBuilder(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder) WidgetProperties(org.eclipse.jface.databinding.swt.WidgetProperties) UIUtils(org.jboss.tools.openshift.internal.common.ui.utils.UIUtils) KeyValueWizard(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizard) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ValueBindingBuilder(org.jboss.tools.common.ui.databinding.ValueBindingBuilder) KeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueItem) IDeploymentConfigPageModel(org.jboss.tools.openshift.internal.ui.wizard.deployimage.IDeploymentConfigPageModel) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) AbstractOpenShiftWizardPage(org.jboss.tools.openshift.internal.common.ui.wizard.AbstractOpenShiftWizardPage) IKeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Viewer(org.eclipse.jface.viewers.Viewer) Button(org.eclipse.swt.widgets.Button) NLS(org.eclipse.osgi.util.NLS) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Set(java.util.Set) ViewerProperties(org.eclipse.jface.databinding.viewers.ViewerProperties) Collectors(java.util.stream.Collectors) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) List(java.util.List) IKeyValueWizardModel(org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueWizardModel) KeyValueWizardModelBuilder(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder) BeanProperties(org.eclipse.core.databinding.beans.BeanProperties) SWT(org.eclipse.swt.SWT) IsNotNull2BooleanConverter(org.jboss.tools.openshift.internal.common.ui.databinding.IsNotNull2BooleanConverter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog) Label(org.eclipse.swt.widgets.Label) SelectionListener(org.eclipse.swt.events.SelectionListener) KeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueItem) IKeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EnvironmentVarKeyValidator(org.jboss.tools.openshift.internal.ui.validator.EnvironmentVarKeyValidator) OkCancelButtonWizardDialog(org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)

Aggregations

OkCancelButtonWizardDialog (org.jboss.tools.openshift.internal.common.ui.wizard.OkCancelButtonWizardDialog)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 KeyValueWizardModelBuilder (org.jboss.tools.openshift.internal.common.ui.wizard.KeyValueWizardModelBuilder)3 ObservableListContentProvider (org.eclipse.jface.databinding.viewers.ObservableListContentProvider)2 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 TableViewer (org.eclipse.jface.viewers.TableViewer)2 Viewer (org.eclipse.jface.viewers.Viewer)2 Label (org.eclipse.swt.widgets.Label)2 Table (org.eclipse.swt.widgets.Table)2 LabelKeyValidator (org.jboss.tools.openshift.internal.ui.validator.LabelKeyValidator)2 LabelValueValidator (org.jboss.tools.openshift.internal.ui.validator.LabelValueValidator)2 Label (org.jboss.tools.openshift.internal.ui.wizard.common.IResourceLabelsPageModel.Label)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 DataBindingContext (org.eclipse.core.databinding.DataBindingContext)1 BeanProperties (org.eclipse.core.databinding.beans.BeanProperties)1