Search in sources :

Example 1 with IColumnLabelProvider

use of org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider 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;
}
Also used : IParameter(com.openshift.restclient.model.template.IParameter) IColumnLabelProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider) Table(org.eclipse.swt.widgets.Table) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ICellToolTipProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.ICellToolTipProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerBuilder(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder) ParameterNameViewerComparator(org.jboss.tools.openshift.internal.ui.wizard.newapp.fromtemplate.TemplateParameterViewerUtils.ParameterNameViewerComparator)

Example 2 with IColumnLabelProvider

use of org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider in project jbosstools-openshift by jbosstools.

the class DeploymentConfigPage method createDataVolumeTable.

protected TableViewer createDataVolumeTable(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.dataViewer = new TableViewerBuilder(table, tableContainer).column(new IColumnLabelProvider<String>() {

        @Override
        public String getValue(String label) {
            return label;
        }
    }).name("Container Path").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().buildViewer();
    dataViewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            String first = (String) e1;
            String other = (String) e2;
            return first.compareTo(other);
        }
    });
    return dataViewer;
}
Also used : IColumnLabelProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider) Table(org.eclipse.swt.widgets.Table) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) TableViewerBuilder(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder)

Example 3 with IColumnLabelProvider

use of org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider in project jbosstools-openshift by jbosstools.

the class EnvironmentVariablePage method createEnvVarTable.

protected TableViewer createEnvVarTable(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.envViewer = new TableViewerBuilder(table, tableContainer).column(new IColumnLabelProvider<IKeyValueItem>() {

        @Override
        public String getValue(IKeyValueItem label) {
            boolean isDeleted = model.isEnvironmentVariableDeleted(label);
            return !isDeleted ? label.getKey() : "[deleted] " + label.getKey();
        }

        @Override
        public boolean isModified(IKeyValueItem e) {
            return ((EnvironmentVariable) e).isNew() || model.isEnvironmentVariableDeleted(e);
        }
    }).name("Name").align(SWT.LEFT).weight(2).minWidth(75).buildColumn().column(new IColumnLabelProvider<IKeyValueItem>() {

        @Override
        public String getValue(IKeyValueItem label) {
            if (model.isEnvironmentVariableDeleted(label)) {
                return "";
            }
            return label.getValue();
        }

        @Override
        public boolean isModified(IKeyValueItem e) {
            return model.isEnvironmentVariableModified((EnvironmentVariable) e);
        }
    }).name("Value").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().buildViewer();
    envViewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            IKeyValueItem first = (IKeyValueItem) e1;
            IKeyValueItem other = (IKeyValueItem) e2;
            return first.getKey().compareTo(other.getKey());
        }
    });
    envViewer.addDoubleClickListener(new EditHandler());
    return envViewer;
}
Also used : IColumnLabelProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider) Table(org.eclipse.swt.widgets.Table) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IKeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem) TableViewerBuilder(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder)

Example 4 with IColumnLabelProvider

use of org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider in project jbosstools-openshift by jbosstools.

the class ManageProjectsWizardPage 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);
    ICellToolTipProvider<IProject> cellToolTipProvider = new ICellToolTipProvider<IProject>() {

        @Override
        public String getToolTipText(IProject object) {
            return object.getDescription();
        }

        @Override
        public int getToolTipDisplayDelayTime(IProject object) {
            return 0;
        }
    };
    this.viewer = new TableViewerBuilder(table, tableContainer).contentProvider(new ArrayContentProvider()).column(new IColumnLabelProvider<IProject>() {

        @Override
        public String getValue(IProject project) {
            return project.getName();
        }
    }).cellToolTipProvider(cellToolTipProvider).name("Name").align(SWT.LEFT).weight(1).minWidth(75).buildColumn().column(new IColumnLabelProvider<IProject>() {

        @Override
        public String getValue(IProject project) {
            return project.getDisplayName();
        }
    }).cellToolTipProvider(cellToolTipProvider).name("Display Name").align(SWT.LEFT).weight(2).minWidth(100).buildColumn().buildViewer();
    return viewer;
}
Also used : IColumnLabelProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider) Table(org.eclipse.swt.widgets.Table) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ICellToolTipProvider(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.ICellToolTipProvider) IProject(com.openshift.restclient.model.IProject) TableViewerBuilder(org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder)

Aggregations

Table (org.eclipse.swt.widgets.Table)4 TableViewerBuilder (org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder)4 IColumnLabelProvider (org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider)4 TableViewer (org.eclipse.jface.viewers.TableViewer)3 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 ICellToolTipProvider (org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.ICellToolTipProvider)2 IProject (com.openshift.restclient.model.IProject)1 IParameter (com.openshift.restclient.model.template.IParameter)1 IKeyValueItem (org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem)1 ParameterNameViewerComparator (org.jboss.tools.openshift.internal.ui.wizard.newapp.fromtemplate.TemplateParameterViewerUtils.ParameterNameViewerComparator)1