Example usage for org.eclipse.jface.viewers ComboViewer setLabelProvider

List of usage examples for org.eclipse.jface.viewers ComboViewer setLabelProvider

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers ComboViewer setLabelProvider.

Prototype

@Override
public void setLabelProvider(IBaseLabelProvider labelProvider) 

Source Link

Document

The list viewer implementation of this Viewer framework method ensures that the given label provider is an instance of ILabelProvider.

Usage

From source file:org.kalypso.ui.rrm.internal.map.editRelation.EditRelationViewer.java

License:Open Source License

private void createModeCombo(final Composite parent, final FormToolkit toolkit) {
    toolkit.createLabel(parent, Messages.getString("EditRelationViewer_0")); //$NON-NLS-1$

    final ComboViewer viewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
    final Control control = viewer.getControl();
    control.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    toolkit.adapt(control, true, true);//  ww w  .  j  a  v  a  2 s .  c  o m

    viewer.setLabelProvider(new LabelProvider());
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setInput(EditRelationMode.values());

    final IViewerObservableValue target = ViewersObservables.observeSinglePostSelection(viewer);
    final IObservableValue model = BeansObservables.observeValue(m_data,
            EditRelationData.PROPERTY_MODIFICATION_MODE);
    m_binding.bindValue(target, model);
}

From source file:org.kalypso.ui.rrm.internal.newproject.KalypsoNAProjectPreferences.java

License:Open Source License

@Override
public void createControl(final Composite parent) {
    final Composite topComposite = new Composite(parent, SWT.NONE);
    topComposite.setLayout(new GridLayout());
    final Group soil = new Group(topComposite, SWT.NONE);
    soil.setText(Messages.getString("KalypsoNAProjectPreferences.SoilGroupText")); //$NON-NLS-1$
    soil.setLayout(new GridLayout(2, false));
    soil.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    final Label soilLabel = new Label(soil, SWT.NONE);
    soilLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    soilLabel.setText(Messages.getString("KalypsoNAProjectPreferences.SoilGroupLable")); //$NON-NLS-1$

    /* Selection of number of soil layers */
    final ComboViewer soilCombo = new ComboViewer(soil, SWT.READ_ONLY | SWT.DROP_DOWN);
    soilCombo.setContentProvider(new ArrayContentProvider());
    soilCombo.setLabelProvider(new LabelProvider());

    final Integer[] soilInput = getSoilInput();
    soilCombo.setInput(soilInput);/*w ww .  j  a v a2 s  .c  o  m*/

    soilCombo.setSelection(new StructuredSelection(m_soilLayerNo));

    final GridData soilComboGridData = new GridData();
    soilComboGridData.widthHint = 50;
    soilComboGridData.horizontalAlignment = GridData.END;
    soilCombo.getControl().setLayoutData(soilComboGridData);

    soilCombo.getControl()
            .setToolTipText(Messages.getString("KalypsoNAProjectPreferences.SoilDataToolTipText")); //$NON-NLS-1$
    soilCombo.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            handleSoilSelectionChanged((IStructuredSelection) event.getSelection());
        }
    });

    /* Selection of number of KM-Parameters per channel */
    final Group channel = new Group(topComposite, SWT.NONE);
    channel.setText(Messages.getString("KalypsoNAProjectPreferences.KMChannelGroupText")); //$NON-NLS-1$
    channel.setLayout(new GridLayout(2, false));
    channel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    final Label channelLabel = new Label(channel, SWT.NONE);
    channelLabel.setText(Messages.getString("KalypsoNAProjectPreferences.KMChannelGroupLable")); //$NON-NLS-1$
    channelLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));

    final ComboViewer channelCombo = new ComboViewer(channel, SWT.READ_ONLY | SWT.DROP_DOWN);
    channelCombo.setContentProvider(new ArrayContentProvider());
    channelCombo.setLabelProvider(new LabelProvider());

    final Integer[] channelInput = getChannelInput();
    channelCombo.setInput(channelInput);

    final GridData channelComboGridData = new GridData();
    channelComboGridData.widthHint = 50;
    channelComboGridData.horizontalAlignment = GridData.END;
    channelCombo.getControl().setLayoutData(channelComboGridData);

    channelCombo.getControl()
            .setToolTipText(Messages.getString("KalypsoNAProjectPreferences.KMChannelDataLable")); //$NON-NLS-1$

    channelCombo.getControl().setEnabled(false);

    channelCombo.setSelection(new StructuredSelection(m_kmChannelNo));

    channelCombo.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            handleChannelSelectionChanged((IStructuredSelection) event.getSelection());
        }
    });

    setPageComplete(validatePage());
    setControl(topComposite);
}

From source file:org.kalypso.ui.rrm.internal.newproject.SourceMappingComposite.java

License:Open Source License

private void addTargetProperty(final IValuePropertyType targetPT) {
    final IAnnotation annotation = targetPT.getAnnotation();

    final Label text = new Label(this, SWT.NONE);
    text.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    text.setText(annotation.getLabel());
    text.setToolTipText(annotation.getTooltip());

    final ComboViewer comboViewer = new ComboViewer(this, SWT.READ_ONLY | SWT.DROP_DOWN);
    comboViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    comboViewer.setLabelProvider(new VPTLabelProvider());
    comboViewer.setContentProvider(new ArrayContentProvider());

    m_combos.put(comboViewer, targetPT);

    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override//from  w  w  w  .ja  va2  s . c om
        public void selectionChanged(final SelectionChangedEvent event) {
            final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            handleComboSelectionChanged(targetPT, selection);
        }
    });
}

From source file:org.kalypso.ui.rrm.internal.timeseries.view.evaporation.ChooseEvaporationInputFilesPage.java

License:Open Source License

private void doAddEvaporaqtionTypeControl(final Composite body) {
    final Group group = new Group(body, SWT.NULL);
    group.setLayout(new GridLayout());
    group.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
    group.setText(Messages.getString("ChooseEvaporationInputFilesPage_3")); //$NON-NLS-1$

    final ComboViewer viewer = new ComboViewer(group, SWT.BORDER | SWT.READ_ONLY);
    viewer.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
    viewer.setLabelProvider(new LabelProvider());
    viewer.setContentProvider(new ArrayContentProvider());

    final IEvaporationCalculator[] input = m_data.getAllCalculators();

    viewer.setInput(input);/*w  w w  .  ja  va2 s. c  o  m*/

    final IViewerObservableValue target = ViewersObservables.observeSinglePostSelection(viewer);
    final IObservableValue model = BeansObservables.observeValue(m_data,
            CalculateEvaporationData.PROPERTY_CALCULATOR);
    m_binding.bindValue(target, model);
}

From source file:org.kalypso.ui.rrm.internal.timeseries.view.evaporation.ChooseEvaporationInputFilesPage.java

License:Open Source License

private void addControl(final Group group, final String type, final String property) {
    final ParameterTypeLabelProvider provider = new ParameterTypeLabelProvider();

    final Label label = new Label(group, SWT.NULL);
    label.setText(provider.getText(type));

    final Label spacer = new Label(group, SWT.NULL);
    spacer.setText(""); //$NON-NLS-1$
    final GridData data = new GridData(GridData.FILL, GridData.FILL, false, false);
    data.widthHint = data.minimumWidth = 100;
    spacer.setLayoutData(data);/*from   w  ww  .ja v  a2s.  c o  m*/

    final ComboViewer viewer = new ComboViewer(group, SWT.BORDER | SWT.READ_ONLY);
    viewer.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
    viewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(final Object element) {
            if (element instanceof TimeseriesBean) {
                return Timeserieses.getTreeLabel(((TimeseriesBean) element).getFeature());
            }

            return super.getText(element);
        }
    });
    viewer.setContentProvider(new ArrayContentProvider());

    final IViewerObservableValue target = ViewersObservables.observeSinglePostSelection(viewer);
    final IObservableValue model = BeansObservables.observeValue(m_data, property);
    m_binding.bindValue(target, model, new IValidator() {

        @Override
        public IStatus validate(final Object value) {
            if (Objects.isNull(value)) {
                setErrorMessage(Messages.getString("ChooseEvaporationInputFilesPage_14")); //$NON-NLS-1$
                return Status.CANCEL_STATUS;
            }

            return Status.OK_STATUS;
        }
    });

    final IStation station = m_data.getStation();
    final TimeseriesBean[] input = findInputFiles(station.getTimeseries(), type);
    viewer.setInput(input);

    if (ArrayUtils.isNotEmpty(input))
        viewer.setSelection(new StructuredSelection(input[0]));

    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            doUpdateDateRange();
        }

    });
}

From source file:org.kalypso.ui.rrm.internal.utils.featureBinding.FeatureBeanComposite.java

License:Open Source License

protected final ComboViewer createPropertyCombo(final Composite parent, final LabelProvider provider,
        final Boolean writeable) {
    int style = SWT.BORDER | SWT.SINGLE;
    if (!m_generalEditable || !writeable)
        style = style | SWT.READ_ONLY;/*from   ww w .j  av  a 2s . com*/

    final ComboViewer viewer = new ComboViewer(parent, style);
    final GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    layoutData.widthHint = 180;
    viewer.getCombo().setLayoutData(layoutData);
    viewer.getCombo().setEnabled(m_generalEditable);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(provider);

    final FormToolkit toolkit = m_binding.getToolkit();
    if (toolkit != null)
        toolkit.adapt(viewer.getCombo());

    return viewer;
}

From source file:org.kalypso.ui.wizard.sensor.ImportObservationSelectionWizardPage.java

License:Open Source License

public void createControlSource(final Composite parent) {
    final Group group = new Group(parent, SWT.NONE);
    group.setLayout(new GridLayout(3, false));
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    group.setText(Messages.getString("org.kalypso.ui.wizard.sensor.ImportObservationSelectionWizardPage2")); //$NON-NLS-1$

    // line 1//from w w  w  . j a v  a2 s.c  o m
    final Label label = new Label(group, SWT.NONE);
    label.setText(Messages.getString("org.kalypso.ui.wizard.sensor.ImportObservationSelectionWizardPage3")); //$NON-NLS-1$

    final Text textFileSource = new Text(group, SWT.BORDER);
    textFileSource.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    textFileSource.setText(StringUtils.EMPTY);
    textFileSource.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            handleSourcePathModified(textFileSource.getText());
        }
    });

    final Button button = new Button(group, SWT.PUSH);
    button.setText(Messages.getString("org.kalypso.ui.wizard.sensor.ImportObservationSelectionWizardPage4")); //$NON-NLS-1$
    button.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));

    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            chooseSourceFile(textFileSource);
        }
    });

    // line 2
    final Label formatLabel = new Label(group, SWT.NONE);
    formatLabel
            .setText(Messages.getString("org.kalypso.ui.wizard.sensor.ImportObservationSelectionWizardPage5")); //$NON-NLS-1$

    m_formatCombo = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY);
    m_formatCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    m_formatCombo.setContentProvider(new ArrayContentProvider());
    m_formatCombo.setLabelProvider(new LabelProvider());
    m_formatCombo.setInput(m_adapter);

    m_formatCombo.addSelectionChangedListener(this);

    if (m_adapter.length > 0)
        m_formatCombo.setSelection(new StructuredSelection(m_adapter[0]));

    new Label(group, SWT.NONE);

    // TimeZone
    /* time zone selection */
    final Label timezoneLabel = new Label(group, SWT.NONE);
    timezoneLabel.setText(Messages.getString("ImportObservationSelectionWizardPage.0")); //$NON-NLS-1$

    final String[] tz = TimeZone.getAvailableIDs();
    Arrays.sort(tz);

    final ComboViewer comboTimeZones = new ComboViewer(group, SWT.BORDER | SWT.SINGLE);
    comboTimeZones.getControl().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));

    comboTimeZones.setContentProvider(new ArrayContentProvider());
    comboTimeZones.setLabelProvider(new LabelProvider());
    comboTimeZones.setInput(tz);

    comboTimeZones.addFilter(new TimezoneEtcFilter());

    comboTimeZones.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final IStructuredSelection selection = (IStructuredSelection) comboTimeZones.getSelection();
            updateTimeZone((String) selection.getFirstElement());
        }
    });

    comboTimeZones.getCombo().addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(final ModifyEvent e) {
            updateTimeZone(comboTimeZones.getCombo().getText());
        }
    });

    if (m_timezone != null) {
        final String id = m_timezone.getID();
        if (ArrayUtils.contains(tz, id))
            comboTimeZones.setSelection(new StructuredSelection(id));
        else
            comboTimeZones.getCombo().setText(id);
    }
}

From source file:org.kalypso.ui.wizard.sensor.ImportObservationSourcePage.java

License:Open Source License

private void createFormatControl(final Composite parent) {
    final Label formatLabel = new Label(parent, SWT.NONE);
    formatLabel//from  ww w . j  a  v a  2  s.  c  om
            .setText(Messages.getString("org.kalypso.ui.wizard.sensor.ImportObservationSelectionWizardPage5")); //$NON-NLS-1$

    final ComboViewer formatCombo = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    formatCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    formatCombo.setContentProvider(new ArrayContentProvider());
    formatCombo.setLabelProvider(new LabelProvider());

    final INativeObservationAdapter[] input = m_data.getObservationAdapters();
    formatCombo.setInput(input);

    new Label(parent, SWT.NONE);

    /* Binding */
    final IViewerObservableValue target = ViewersObservables.observeSinglePostSelection(formatCombo);
    final IObservableValue model = BeansObservables.observeValue(m_data,
            ImportObservationData.PROPERTY_ADAPTER);

    m_binding.bindValue(target, model);
}

From source file:org.kalypso.ui.wizard.sensor.ImportObservationSourcePage.java

License:Open Source License

private void createTimeZoneControl(final Composite parent) {
    final Label timezoneLabel = new Label(parent, SWT.NONE);
    timezoneLabel.setText(Messages.getString("ImportObservationSelectionWizardPage.0")); //$NON-NLS-1$

    final String[] tz = m_data.getAllTimezones();

    final ComboViewer comboTimeZones = new ComboViewer(parent, SWT.BORDER | SWT.SINGLE);
    comboTimeZones.getControl().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));

    comboTimeZones.setContentProvider(new ArrayContentProvider());
    comboTimeZones.setLabelProvider(new LabelProvider());
    comboTimeZones.setInput(tz);/* w  w w .  jav a 2s  . co m*/

    comboTimeZones.addFilter(new TimezoneEtcFilter());

    new Label(parent, SWT.NONE);

    /* Binding */
    final IViewerObservableValue targetSelection = ViewersObservables
            .observeSinglePostSelection(comboTimeZones);
    final ISWTObservableValue targetModification = SWTObservables.observeSelection(comboTimeZones.getControl());

    final IObservableValue model = BeansObservables.observeValue(m_data,
            ImportObservationData.PROPERTY_TIMEZONE);

    final DataBinder modificationBinder = new DataBinder(targetModification, model);
    modificationBinder.addTargetAfterConvertValidator(new TimezoneStringValidator());

    m_binding.bindValue(targetSelection, model);
    m_binding.bindValue(modificationBinder);
}

From source file:org.kalypso.ui.wizard.sensor.ImportObservationSourcePage.java

License:Open Source License

private void createParameterTypeControl(final Composite parent) {
    final Label formatLabel = new Label(parent, SWT.NONE);
    formatLabel.setText("Parameter Type");

    final ComboViewer parameterCombo = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    parameterCombo.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    parameterCombo.setContentProvider(new ArrayContentProvider());
    parameterCombo.setLabelProvider(new LabelProvider());

    final IAxis[] axes = m_data.getAllowedParameterAxes();
    parameterCombo.setInput(axes);//from  w  w  w.j a v a2 s.  co  m

    new Label(parent, SWT.NONE);

    /* Binding */
    final IViewerObservableValue target = ViewersObservables.observeSinglePostSelection(parameterCombo);
    final IObservableValue model = BeansObservables.observeValue(m_data,
            ImportObservationData.PROPERTY_PARAMETER_AXIS);

    m_binding.bindValue(target, model);
}