List of usage examples for org.eclipse.jface.viewers ComboViewer getControl
@Override
public Control getControl()
From source file:org.kalypso.ui.addlayer.ThemeAndPropertyChooserGroup.java
License:Open Source License
public Group createControl(final Composite parent) { final Group group = new Group(parent, SWT.NONE); group.setLayout(new GridLayout(1, false)); /* theme chooser */ final ComboViewer themeComboViewer = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY); themeComboViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); themeComboViewer.setContentProvider(new ArrayContentProvider()); themeComboViewer.setLabelProvider(new LabelProvider()); themeComboViewer.setSorter(new ViewerSorter()); final IKalypsoTheme[] polygoneThemes = MapModellHelper.filterThemes(m_modell, m_themeFilter); themeComboViewer.setInput(polygoneThemes); themeComboViewer.getControl().setEnabled(polygoneThemes.length > 0); /* Property choosers */ final Map<PropertyDescriptor, Control[]> propertyControls = new HashMap<>(); final Map<PropertyDescriptor, ComboViewer> propertyCombos = new HashMap<>(); for (final PropertyDescriptor pd : m_properties.keySet()) { createPropertyChooser(group, pd, propertyControls, propertyCombos); }//from w ww .j a v a 2 s .c o m themeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { handleSelectionChanged((IStructuredSelection) event.getSelection(), propertyCombos, propertyControls); } }); IStructuredSelection themeSelection = polygoneThemes.length > 0 ? new StructuredSelection(polygoneThemes[0]) : StructuredSelection.EMPTY; for (final PropertyDescriptor pd : propertyCombos.keySet()) { final ComboViewer viewer = propertyCombos.get(pd); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { handlePropertyChanged((IStructuredSelection) event.getSelection(), pd); } }); } // TRICKY: because setting the selection to the themes changes // the dialog-settings of the poly- and value property we have to read them immediately IDialogSettings propertySetting = null; if (m_dialogSettings != null) { final String themeSetting = m_dialogSettings.get(SETTINGS_THEME); propertySetting = m_dialogSettings.getSection(SETTINGS_PROPERTIES); if (themeSetting != null) { for (final IKalypsoTheme theme : polygoneThemes) { if (StringUtils.equals(themeSetting, theme.getName().getValue())) { themeSelection = new StructuredSelection(theme); break; } } } } themeComboViewer.setSelection(themeSelection); /* Apply dialog settings */ final Map<PropertyDescriptor, IStructuredSelection> propertySelection = new HashMap<>(); if (m_dialogSettings != null) { if (propertySetting != null) { for (final PropertyDescriptor pd : m_properties.keySet()) { final String lastProp = propertySetting.get(pd.label); if (lastProp != null) { final IPropertyType[] pts = (IPropertyType[]) propertyCombos.get(pd).getInput(); for (final IPropertyType pt : pts) { if (lastProp.equals(pt.getQName().toString())) { propertySelection.put(pd, new StructuredSelection(pt)); break; } } } } } } for (final PropertyDescriptor pd : m_properties.keySet()) { final IStructuredSelection selection = propertySelection.get(pd); if (selection != null) { propertyCombos.get(pd).setSelection(selection); } } return group; }
From source file:org.kalypso.ui.addlayer.ThemeAndPropertyChooserGroup.java
License:Open Source License
private void createPropertyChooser(final Group group, final PropertyDescriptor pd, final Map<PropertyDescriptor, Control[]> propertyControls, final Map<PropertyDescriptor, ComboViewer> propertyCombos) { /* Geo-Property chooser */ final Label label = new Label(group, SWT.NONE); label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); label.setText(pd.label);// w ww . j a va 2 s . c o m final ComboViewer comboViewer = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY); comboViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setLabelProvider(new FeatureTypeLabelProvider()); comboViewer.setSorter(new ViewerSorter()); comboViewer.setInput(new IPropertyType[] {}); propertyCombos.put(pd, comboViewer); propertyControls.put(pd, new Control[] { label, comboViewer.getControl() }); }
From source file:org.kalypso.ui.addlayer.ThemeAndPropertyChooserGroup.java
License:Open Source License
protected void handleSelectionChanged(final IStructuredSelection selection, final Map<PropertyDescriptor, ComboViewer> propertyCombos, final Map<PropertyDescriptor, Control[]> propertyControls) { final IKalypsoFeatureTheme theme = (IKalypsoFeatureTheme) selection.getFirstElement(); if (theme == m_choosenTheme) return;/*www. jav a 2s .com*/ m_choosenTheme = theme; if (theme == null) { for (final ComboViewer comboViewer : propertyCombos.values()) { comboViewer.setInput(new IPropertyType[] {}); } } else { final IFeatureType featureType = theme.getFeatureType(); for (final PropertyDescriptor pd : propertyCombos.keySet()) { final ComboViewer comboViewer = propertyCombos.get(pd); final Control[] controls = propertyControls.get(pd); final IPropertyType[] pts = PropertyUtils.filterProperties(featureType, pd.filter); comboViewer.setInput(pts); if (pts.length == 0) { comboViewer.setSelection(StructuredSelection.EMPTY); } else { comboViewer.setSelection(new StructuredSelection(pts[0])); } final boolean hideIfUnique = pd.hideIfUnique; for (final Control propertyControl : controls) { ((GridData) propertyControl.getLayoutData()).exclude = hideIfUnique && pts.length < 2; } } } if (m_dialogSettings != null) { m_dialogSettings.put(SETTINGS_THEME, m_choosenTheme == null ? "" : m_choosenTheme.getLabel()); //$NON-NLS-1$ } for (final ComboViewer comboViewer : propertyCombos.values()) { comboViewer.getControl().setEnabled(theme != null); } }
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) */// w w w. jav a2s. c o m @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);/*ww w . j a va2 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.placement.LinePlacementComposite.java
License:Open Source License
private void createPlacementControl(final Composite parent) { final FormToolkit toolkit = getToolkit(); toolkit.createLabel(parent, Messages.getString("LinePlacementComposite_0")); //$NON-NLS-1$ final ComboViewer typeViewer = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY); typeViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final LinePlacementControlValue handler = new LinePlacementControlValue(m_input); handler.configureViewer(typeViewer); final IViewerObservableValue target = ViewerProperties.singleSelection().observe(typeViewer); m_binding.bindValue(target, handler); }
From source file:org.kalypso.ui.editor.styleeditor.stroke.StrokeComposite.java
License:Open Source License
private void createLineJoinControl(final FormToolkit toolkit, final Composite parent) { toolkit.createLabel(parent, Messages.getString("StrokeComposite.1")); //$NON-NLS-1$ final ComboViewer lineJoinChooser = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY); toolkit.adapt(lineJoinChooser.getControl(), true, true); lineJoinChooser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); final StrokeLineJoinValue model = new StrokeLineJoinValue(m_input); model.configureViewer(lineJoinChooser); final IObservableValue target = ViewerProperties.singleSelection().observe(lineJoinChooser); m_binding.bindValue(target, model);/*from w w w.j av a2 s .c o m*/ }
From source file:org.kalypso.ui.editor.styleeditor.stroke.StrokeComposite.java
License:Open Source License
private void createLineCapControl(final FormToolkit toolkit, final Composite parent) { toolkit.createLabel(parent, Messages.getString("StrokeComposite.2")); //$NON-NLS-1$ final ComboViewer lineCapChooser = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY); toolkit.adapt(lineCapChooser.getControl(), true, true); lineCapChooser.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); final StrokeLineCapValue model = new StrokeLineCapValue(m_input); model.configureViewer(lineCapChooser); final IObservableValue target = ViewerProperties.singleSelection().observe(lineCapChooser); m_binding.bindValue(target, model);/*from ww w .ja v a 2 s . com*/ }
From source file:org.kalypso.ui.editor.styleeditor.symbolizer.AbstractSymbolizerComposite.java
License:Open Source License
private Control createGeometryControl(final FormToolkit toolkit, final Composite parent) { final SectionPart sectionPart = new SectionPart(parent, toolkit, ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED | Section.DESCRIPTION); final Section section = sectionPart.getSection(); section.setText(Messages.getString("AbstractSymbolizerComposite_0")); //$NON-NLS-1$ section.setDescription(Messages.getString("AbstractSymbolizerComposite_1")); //$NON-NLS-1$ final ComboViewer geometryChooser = new ComboViewer(section, SWT.DROP_DOWN | SWT.READ_ONLY); section.setClient(geometryChooser.getControl()); final GeometryValue<S> geometryHandler = new GeometryValue<>(m_input); geometryHandler.configureViewer(geometryChooser); final IViewerObservableValue target = ViewerProperties.singleSelection().observe(geometryChooser); m_binding.bindValue(target, geometryHandler); return section; }
From source file:org.kalypso.ui.editor.styleeditor.symbolizer.TextSymbolizerComposite.java
License:Open Source License
private void createLabelControl(final FormToolkit toolkit, final Composite parent) { toolkit.createLabel(parent, MessageBundle.STYLE_EDITOR_LABEL); final ComboViewer labelViewer = new ComboViewer(parent, SWT.DROP_DOWN); final Control combo = labelViewer.getControl(); toolkit.adapt(combo, true, true);/* www . j a va 2 s . c o m*/ combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); final ITypedConverter<ParameterValueType, String> converter = new ParameterValueTypeToString(); final TextSymbolizerLabelField model = new TextSymbolizerLabelField(getInput(), converter); model.configureViewer(labelViewer); final IObservableValue target = SWTObservables.observeText(combo); getBinding().bindValue(target, model, new StringToParameterValueTypeConverter(), converter); getToolkit().createLabel(parent, StringUtils.EMPTY); }