Search in sources :

Example 1 with IKeyValueItem

use of org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem 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 2 with IKeyValueItem

use of org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem in project jbosstools-openshift by jbosstools.

the class EnvironmentVariablesPageModel method setEnvironmentVariables.

@Override
public void setEnvironmentVariables(List<EnvironmentVariable> envVars) {
    firePropertyChange(PROPERTY_ENVIRONMENT_VARIABLES, this.environmentVariables, this.environmentVariables = envVars);
    this.imageEnvVars.clear();
    for (IKeyValueItem label : envVars) {
        imageEnvVars.put(label.getKey(), label.getValue());
    }
}
Also used : IKeyValueItem(org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem)

Aggregations

IKeyValueItem (org.jboss.tools.openshift.internal.common.ui.wizard.IKeyValueItem)2 TableViewer (org.eclipse.jface.viewers.TableViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 Table (org.eclipse.swt.widgets.Table)1 TableViewerBuilder (org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder)1 IColumnLabelProvider (org.jboss.tools.openshift.internal.common.ui.utils.TableViewerBuilder.IColumnLabelProvider)1