List of usage examples for org.eclipse.jface.viewers ComboViewer setLabelProvider
@Override public void setLabelProvider(IBaseLabelProvider labelProvider)
Viewer
framework method ensures that the given label provider is an instance of ILabelProvider
. From source file:org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite) *//*from w w w . j a v a 2 s . c om*/ @Override protected Control createDialogArea(final Composite parent) { setTitle(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.2")); //$NON-NLS-1$ setMessage(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.3")); //$NON-NLS-1$ final Group composite = new Group(parent, SWT.NONE); composite.setLayout(new GridLayout(3, false)); // composite.setText( "Eigenschaften" ); // Also set layoutData as it is not set by parent. Maybe fixed in 3.3? composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Name final Label nameLabel = new Label(composite, SWT.NONE); nameLabel.setText(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.4")); //$NON-NLS-1$ final Text nameText = new Text(composite, SWT.BORDER); final GridData nameData = new GridData(SWT.FILL, SWT.CENTER, true, false); nameData.horizontalSpan = 2; nameText.setLayoutData(nameData); // Color final Label colorLabel = new Label(composite, SWT.NONE); colorLabel.setText(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.5")); //$NON-NLS-1$ final Button colorButton = new Button(composite, SWT.PUSH); final GridData colorData = new GridData(SWT.FILL, SWT.CENTER, true, false); colorButton.setLayoutData(colorData); final Scale alphaSlider = new Scale(composite, SWT.HORIZONTAL); final GridData alphaData = new GridData(SWT.FILL, SWT.CENTER, true, false); alphaData.widthHint = 150; alphaSlider.setLayoutData(alphaData); alphaSlider.setIncrement(1); alphaSlider.setMinimum(0); alphaSlider.setMaximum(255); alphaSlider.setPageIncrement(20); // Stroke final Label sizeLabel = new Label(composite, SWT.NONE); sizeLabel.setText(Messages.getString("org.kalypso.ui.editor.diagrameditor.actions.EditDiagCurveDialog.6")); //$NON-NLS-1$ final ComboViewer dashCombo = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY); dashCombo.getControl().setFont(composite.getDisplay().getSystemFont()); final GridData dashData = new GridData(SWT.FILL, SWT.CENTER, true, false); dashCombo.getCombo().setLayoutData(dashData); // Better would be some fixed-sized font, but what is the best way to find it? final Font comboFont = JFaceResources.getFont(JFaceResources.TEXT_FONT); dashCombo.getCombo().setFont(comboFont); dashCombo.setLabelProvider(new DashTypeLabelProvider()); dashCombo.setContentProvider(new ArrayContentProvider()); dashCombo.setInput(DashType.KNOWN_DASHS); final Scale sizeSlider = new Scale(composite, SWT.HORIZONTAL); final GridData sizeData = new GridData(SWT.FILL, SWT.CENTER, true, false); sizeData.widthHint = 150; sizeSlider.setLayoutData(sizeData); sizeSlider.setIncrement(1); sizeSlider.setMinimum(1); sizeSlider.setMaximum(10); sizeSlider.setPageIncrement(5); // hook-listeners nameText.addModifyListener(new ModifyListener() { @Override public void modifyText(final ModifyEvent e) { handleNameTextModified(nameText); updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider); } }); colorButton.addSelectionListener(new SelectionAdapter() { /** * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(final SelectionEvent e) { handleColorButtonSelected(); updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider); } }); colorButton.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(final DisposeEvent e) { if (colorButton.getImage() != null) colorButton.getImage().dispose(); } }); alphaSlider.addSelectionListener(new SelectionAdapter() { /** * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(final SelectionEvent e) { handleAlphaSliderSelected(alphaSlider); updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider); } }); sizeSlider.addSelectionListener(new SelectionAdapter() { /** * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(final SelectionEvent e) { handleSizeSliderSelected(sizeSlider); updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider); } }); dashCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { handleTypeSelectionChanged((IStructuredSelection) event.getSelection()); updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider); } }); // Initalize controls if (m_name == NAME_UNDEF) nameText.setEditable(false); else nameText.setText(m_name); if (m_color == LineProperties.COLOR_UNDEF) { } else alphaSlider.setSelection(m_alpha); if (m_size != LineProperties.SIZE_UNDEF) sizeSlider.setSelection(m_size.intValue()); dashCombo.setSelection(new StructuredSelection(m_dash)); updateControl(nameText, colorButton, sizeSlider, dashCombo, alphaSlider); return super.createDialogArea(parent); }
From source file:org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.java
License:Open Source License
private void createTypeControl() { /* line type combo */ // combo text final Label comboTextLabel = new Label(this, SWT.NONE); comboTextLabel.setText(Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.2")); //$NON-NLS-1$ final ComboViewer lineTypeCombo = new ComboViewer(this, SWT.READ_ONLY); final GridData comboGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); lineTypeCombo.getControl().setLayoutData(comboGridData); lineTypeCombo.setContentProvider(new ArrayContentProvider()); final String[] types = new String[4]; types[0] = Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.3"); //$NON-NLS-1$ types[1] = Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.4"); //$NON-NLS-1$ types[2] = Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.5"); //$NON-NLS-1$ types[3] = Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.6"); //$NON-NLS-1$ lineTypeCombo.setInput(types);/*from w ww . j a v a2 s. c o m*/ lineTypeCombo.setSelection(new StructuredSelection(lineTypeCombo.getElementAt(0))); lineTypeCombo.setLabelProvider(new LabelProvider() { /** * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object) */ @Override public String getText(final Object element) { return super.getText(element); } }); // selection listener lineTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override @SuppressWarnings("synthetic-access") //$NON-NLS-1$ public void selectionChanged(final SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) event.getSelection(); final Object element = selection.getFirstElement(); final String string = (String) element; if (string == Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.8")) //$NON-NLS-1$ { final float[] dashArray = new float[2]; dashArray[0] = 1; dashArray[1] = 0; m_stroke.setDashArray(dashArray); } else if (string == Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.9")) //$NON-NLS-1$ { final float[] dashArray = new float[2]; dashArray[0] = 10f; dashArray[1] = 5f; m_stroke.setDashArray(dashArray); } else if (string == Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.10")) //$NON-NLS-1$ { final float[] dashArray = new float[2]; dashArray[0] = 2f; dashArray[1] = 1.9f; m_stroke.setDashArray(dashArray); } else if (string == Messages.getString("org.kalypso.ui.editor.sldEditor.StrokeEditorComposite.11")) //$NON-NLS-1$ { final float[] dashArray = new float[4]; dashArray[0] = 10f; dashArray[1] = 5f; dashArray[2] = 2f; dashArray[3] = 1.9f; m_stroke.setDashArray(dashArray); } contentChanged(); } }); }
From source file:org.kalypso.ui.editor.styleeditor.graphic.WellKnownNameValue.java
License:Open Source License
public void configureViewer(final ComboViewer viewer) { viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setInput(WellKnownName.values()); }
From source file:org.kalypso.ui.editor.styleeditor.placement.LinePlacementControlValue.java
License:Open Source License
public void configureViewer(final ComboViewer viewer) { viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setInput(PlacementType.values()); }
From source file:org.kalypso.ui.editor.styleeditor.rule.AddSymbolizerComposite.java
License:Open Source License
private boolean init(final Composite parent) { new Label(parent, SWT.NONE).setText(Messages.getString("AddSymbolizerComposite_0")); //$NON-NLS-1$ new Label(parent, SWT.NONE).setText(Messages.getString("AddSymbolizerComposite_1")); //$NON-NLS-1$ new Label(parent, SWT.NONE); // Geometry-Selection Combo final ComboViewer geometryChooser = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY); final Combo geometryCombo = geometryChooser.getCombo(); geometryCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); geometryChooser.setContentProvider(new ArrayContentProvider()); geometryChooser.setLabelProvider(new LabelProvider() { @Override/* w ww.j av a2 s. c o m*/ public String getText(final Object element) { final IValuePropertyType pt = (IValuePropertyType) element; return AnnotationUtilities.getAnnotation(pt.getAnnotation(), null, IAnnotation.ANNO_LABEL); } }); final IValuePropertyType[] geomProperties = m_featureType.getAllGeometryProperties(); geometryChooser.setInput(geomProperties); geometryChooser.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) event.getSelection(); handleGeometrySelected((IValuePropertyType) selection.getFirstElement()); } }); // Symbolizer Combo m_symbolizerChooser = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY); final Combo symbolizerCombo = m_symbolizerChooser.getCombo(); symbolizerCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); m_symbolizerChooser.setContentProvider(new ArrayContentProvider()); m_symbolizerChooser.setLabelProvider(new LabelProvider()); m_symbolizerChooser.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) event.getSelection(); handleSymbolizerChanged((SymbolizerType) selection.getFirstElement()); } }); if (geomProperties.length > 0) geometryChooser.setSelection(new StructuredSelection(geomProperties[0])); else { geometryChooser.setSelection(StructuredSelection.EMPTY); geometryCombo.setEnabled(false); symbolizerCombo.setEnabled(false); } return geomProperties.length > 0; }
From source file:org.kalypso.ui.editor.styleeditor.stroke.StrokeLineCapValue.java
License:Open Source License
public void configureViewer(final ComboViewer viewer) { viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setInput(LineCap.values());//w ww.j av a 2s . c om }
From source file:org.kalypso.ui.editor.styleeditor.stroke.StrokeLineJoinValue.java
License:Open Source License
public void configureViewer(final ComboViewer viewer) { viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setInput(LineJoin.values());/* ww w .j ava2s. com*/ }
From source file:org.kalypso.ui.editor.styleeditor.style.FeatureTypeStylePropertiesComposite.java
License:Open Source License
private void createFeatureTypeField(final FormToolkit toolkit, final Composite parent) { final String tooltip = Messages.getString("FeatureTypeStylePropertiesComposite_6"); //$NON-NLS-1$ toolkit.createLabel(parent, Messages.getString("FeatureTypeStylePropertiesComposite_7")) //$NON-NLS-1$ .setToolTipText(tooltip);/*from ww w.j a va 2 s .c o m*/ final ComboViewer viewer = new ComboViewer(parent, SWT.NONE); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider()); viewer.setSorter(new ViewerSorter()); viewer.setInput(findTypes()); final Combo control = viewer.getCombo(); control.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); control.setToolTipText(tooltip); toolkit.adapt(control, true, true); final ISWTObservableValue controlObserver = SWTObservables.observeText(control); final IConverter converter = new StringToQNameConverter(); m_binding.bindValue(controlObserver, new FeatureTypeStyleFeatureTypeValue(m_input), converter); }
From source file:org.kalypso.ui.editor.styleeditor.symbolizer.GeometryValue.java
License:Open Source License
public void configureViewer(final ComboViewer viewer) { final IStyleInput<S> input = getSource(); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(new LabelProvider() { @Override//from ww w . ja va 2s . co m public String getText(final Object element) { if (element == ELEMENT_NOT_SET) return MessageBundle.STYLE_EDITOR_FIELD_NOT_SET; if (element instanceof QName) { final IFeatureType ft = input.getFeatureType(); final IPropertyType pt = ft.getProperty((QName) element); return AnnotationUtilities.getAnnotation(pt.getAnnotation(), null, IAnnotation.ANNO_LABEL); } return super.getText(element); } }); viewer.setInput(createInput(input)); }
From source file:org.kalypso.ui.editor.styleeditor.symbolizer.TextSymbolizerLabelField.java
License:Open Source License
public void configureViewer(final ComboViewer viewer) { viewer.setLabelProvider(new LabelProvider()); viewer.setContentProvider(new ArrayContentProvider()); viewer.setInput(createInput(getSource())); }