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

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

Introduction

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

Prototype

@Override
    public Control getControl() 

Source Link

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);// w  w  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);/*from   w  w w .ja  va2s. co 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/*ww  w.  ja  va 2 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.utils.featureBinding.FeatureBeanComposite.java

License:Open Source License

protected final void bindComboText(final ComboViewer viewer, final QName property,
        final IValidator... validators) {
    final ISWTObservableValue target = SWTObservables.observeText(viewer.getControl());
    final IObservableValue model = new FeatureBeanObservableValue(m_featureBean, property);

    if (ArrayUtils.isNotEmpty(validators))
        m_binding.bindValue(target, model, validators);
    else//from  w  w w .  j  ava2 s .c  o  m
        m_binding.bindValue(new DataBinder(target, model));
}

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 .ja  v  a  2  s.c om
    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 w  ww  .j  a  va 2  s. c o m
            .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);/*from  ww w . j  av  a 2 s. c o 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  ww.jav a2s  . c om

    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);
}

From source file:org.kalypso.ui.wizard.shape.ImportShapeFileImportPage.java

License:Open Source License

private void createStyleNameControls(final Composite parent) {
    final Label styleNameLabel = new Label(parent, SWT.NONE);
    styleNameLabel.setText(Messages.getString("org.kalypso.ui.wizard.shape.ImportShapeFileImportPage.8")); //$NON-NLS-1$

    final ComboViewer styleNameChooser = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    styleNameChooser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    styleNameChooser.setContentProvider(new ArrayContentProvider());
    styleNameChooser.setLabelProvider(new LabelProvider() {
        @Override/*from w w  w .  j  a v a  2 s .  c o m*/
        public String getText(final Object element) {
            if (element instanceof UserStyle) {
                final UserStyle userStyle = (UserStyle) element;
                final String title = userStyle.getTitle();
                if (StringUtils.isBlank(title))
                    return userStyle.getName();
                return title;
            }

            return ObjectUtils.toString(element);
        }
    });

    /* bind input */
    final IObservableValue targetInput = ViewersObservables.observeInput(styleNameChooser);
    final IObservableValue modelInput = BeansObservables.observeValue(m_data,
            ImportShapeFileData.PROPERTY_STYLES);
    m_binding.bindValue(targetInput, modelInput);

    /* bind selection */
    final IObservableValue targetSelection = ViewersObservables.observeSinglePostSelection(styleNameChooser);
    final IObservableValue modelSelection = BeansObservables.observeValue(m_data,
            ImportShapeFileData.PROPERTY_STYLE);
    m_binding.bindValue(targetSelection, modelSelection);

    /* Enablement */
    final IObservableValue modelEnablement = BeansObservables.observeValue(m_data,
            ImportShapeFileData.PROPERTY_STYLE_NAME_CONTROL_ENABLED);

    final IObservableValue targetLabelEnablement = SWTObservables.observeEnabled(styleNameLabel);
    m_binding.bindValue(targetLabelEnablement, modelEnablement);

    final IObservableValue targetComboEnablement = SWTObservables.observeEnabled(styleNameChooser.getControl());
    m_binding.bindValue(targetComboEnablement, modelEnablement);
}

From source file:org.kalypso.ui.wizards.imports.observation.ImportObservationSelectionWizardPage.java

License:Open Source License

public void createControlSource(final Composite parent) {
    final Group group = new Group(parent, SWT.NONE);
    group.setText(Messages// ww  w  .  java  2s.  c  o  m
            .getString("org.kalypso.ui.wizards.imports.observation.ImportObservationSelectionWizardPage.5")); //$NON-NLS-1$

    final GridData groupData = new GridData(SWT.FILL, SWT.FILL, true, false);
    group.setLayoutData(groupData);

    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    group.setLayout(gridLayout);

    /* file selection */
    final Label labelFilePath = new Label(group, SWT.READ_ONLY);
    labelFilePath.setText(Messages
            .getString("org.kalypso.ui.wizards.imports.observation.ImportObservationSelectionWizardPage.6")); //$NON-NLS-1$

    m_textFileSource = new Text(group, SWT.READ_ONLY | SWT.BORDER);
    m_textFileSource.setText(DEFAUL_FILE_LABEL);
    m_textFileSource.addFocusListener(this);

    final GridData textData = new GridData(SWT.FILL, SWT.FILL, true, false);
    m_textFileSource.setLayoutData(textData);

    /* Choose file button */
    final Button chooseFileButton = new Button(group, SWT.PUSH);
    chooseFileButton.setText(Messages
            .getString("org.kalypso.ui.wizards.imports.observation.ImportObservationSelectionWizardPage.7")); //$NON-NLS-1$
    final GridData chooseFileButtonGridData = new GridData();
    chooseFileButtonGridData.horizontalAlignment = GridData.END;
    chooseFileButton.setLayoutData(chooseFileButtonGridData);

    chooseFileButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
            m_sourceFile = chooseFile(m_sourceFile);
            if (m_sourceFile != null) {
                m_textFileSource.setText(m_sourceFile.getPath());
                validate();
            }
        }
    });

    final Label formatLabel = new Label(group, SWT.NONE);
    formatLabel.setText(Messages
            .getString("org.kalypso.ui.wizards.imports.observation.ImportObservationSelectionWizardPage.10")); //$NON-NLS-1$

    m_formatCombo = new ComboViewer(group, SWT.READ_ONLY | SWT.DROP_DOWN);

    final GridData formatData = new GridData(SWT.FILL, SWT.FILL, true, false);
    m_formatCombo.getControl().setLayoutData(formatData);

    m_formatCombo.add(m_adapter);

    m_formatCombo.setContentProvider(new ArrayContentProvider());

    m_formatCombo.setLabelProvider(new ILabelProvider() {
        @Override
        public Image getImage(final Object element) {
            return null;
        }

        @Override
        public String getText(final Object element) {
            return element.toString();
        }

        @Override
        public void addListener(final ILabelProviderListener listener) {
            // nothing as labelprovider will not change
        }

        @Override
        public void dispose() {
            // nothing as labelprovider will not change
        }

        @Override
        public boolean isLabelProperty(final Object element, final String property) {
            return true;
        }

        @Override
        public void removeListener(final ILabelProviderListener listener) {
            // nothing
        }
    });

    m_formatCombo.setInput(m_adapter);
    m_formatCombo.addSelectionChangedListener(this);

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

    // just a placeholder
    new Label(group, SWT.NONE);

    /* time zone selection */
    final Label timezoneLabel = new Label(group, SWT.NONE);
    timezoneLabel.setText(Messages
            .getString("org.kalypso.ui.wizards.imports.observation.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));

    m_timezone = KalypsoCorePlugin.getDefault().getTimeZone();

    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);
    }

    // just a placeholder
    new Label(group, SWT.NONE);
}