List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer
public ComboViewer(Composite parent, int style)
From source file:gda.rcp.views.OpenViewListBoxComposite.java
License:Open Source License
public OpenViewListBoxComposite(Composite parent, int style, String label, String tooltipText, List<OpenViewOption> options) { super(parent, style); setLayout(new GridLayout(1, false)); defOption = options.get(0);/*from w ww . ja v a 2 s. c o m*/ Group grpShow = new Group(this, SWT.NONE); GridData gd_grpShow = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_grpShow.widthHint = 151; grpShow.setLayoutData(gd_grpShow); grpShow.setText(label); grpShow.setLayout(new FillLayout(SWT.HORIZONTAL)); comboShow = new ComboViewer(grpShow, SWT.READ_ONLY); comboShow.getControl().setToolTipText(tooltipText); comboShow.setContentProvider(ArrayContentProvider.getInstance()); comboShow.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof OpenViewOption) { OpenViewOption opt = (OpenViewOption) element; return opt.getLabel(); } return super.getText(element); } }); comboShow.setInput(options); comboShowObservableValue = ViewersObservables.observeSingleSelection(comboShow); showOptionObserveValue = PojoObservables.observeValue(this, showOptionName); DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(comboShowObservableValue, showOptionObserveValue); showOptionObserveValue.setValue(defOption); // GridDataFactory.fillDefaults().grab(true, false).applyTo(comboShow.getControl()); }
From source file:gov.redhawk.datalist.ui.views.OptionsComposite.java
License:Open Source License
public void createControl(Composite main) { final Composite parent = new Composite(main, SWT.None); parent.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); parent.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).create()); final ComboViewer captureCombo = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); captureCombo.setContentProvider(new ArrayContentProvider()); captureCombo.setLabelProvider(new LabelProvider()); captureCombo.setInput(new Object[] { CaptureMethod.NUMBER, CaptureMethod.INDEFINITELY }); ctx.bindValue(ViewerProperties.singleSelection().observe(captureCombo), BeanProperties.value("processType").observe(settings)); samplesTxt = new Text(parent, SWT.BORDER); samplesTxt.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); ctx.bindValue(WidgetProperties.enabled().observe(samplesTxt), BeanProperties.value("processType").observe(settings), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy().setConverter(new Converter(CaptureMethod.class, Boolean.class) { @Override//from w ww . j av a2 s. c o m public Object convert(Object fromObject) { if (fromObject == CaptureMethod.INDEFINITELY) { return false; } return true; } })); Binding binding = ctx.bindValue(WidgetProperties.text(SWT.Modify).observe(samplesTxt), BeanProperties.value("samples").observe(settings), new UpdateValueStrategy().setBeforeSetValidator(new IValidator() { @Override public IStatus validate(Object obj) { Double value = (Double) obj; if (Double.valueOf(value) <= 0) { return ValidationStatus.error(settings.getProcessType() + " must be greater than 0."); } if (value > Integer.MAX_VALUE) { return ValidationStatus.error(settings.getProcessType() + " must be less than or equal to " + Integer.MAX_VALUE + "."); } if ((value - value.intValue()) > 0) { return ValidationStatus .error(settings.getProcessType() + " must be a positive integer."); } if (value > 1000000) { return ValidationStatus.warning("For this sample size, you may run out of heap space."); } return ValidationStatus.ok(); } }), null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); final IObservableValue running = BeanProperties.value("running").observe(state); final IObservableValue pType = BeanProperties.value("processType").observe(settings); ComputedValue enabledSamples = new ComputedValue(Boolean.class) { @Override protected Object calculate() { return !(Boolean) running.getValue() && pType.getValue() != CaptureMethod.INDEFINITELY; } }; ctx.bindValue(WidgetProperties.enabled().observe(samplesTxt), enabledSamples, new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), null); final Label unitsLabel = new Label(parent, SWT.None); unitsLabel.setText(""); GridData unitsLayout = new GridData(); unitsLayout.widthHint = 20; unitsLabel.setLayoutData(unitsLayout); settings.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("processType".equals(evt.getPropertyName())) { CaptureMethod method = (CaptureMethod) evt.getNewValue(); if (method == CaptureMethod.INDEFINITELY) { settings.setSamples(1); unitsLabel.setText(""); } else { if (method == CaptureMethod.CLOCK_TIME || method == CaptureMethod.SAMPLE_TIME) { unitsLabel.setText("(s)"); } else { unitsLabel.setText(""); } settings.setSamples(1024); } } } }); Label label = new Label(parent, SWT.None); label.setText("Number of Dimensions:"); Combo columnsCombo = new Combo(parent, SWT.BORDER | SWT.SINGLE | SWT.DROP_DOWN); columnsCombo.setText(REAL); columnsCombo.add(REAL, 0); columnsCombo.add(COMPLEX, 1); columnsCombo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); ctx.bindValue(WidgetProperties.enabled().observe(columnsCombo), BeanProperties.value("running").observe(state), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy().setConverter(new Converter(Boolean.class, Boolean.class) { @Override public Boolean convert(Object fromObject) { return !((Boolean) fromObject); } })); binding = ctx.bindValue(WidgetProperties.selection().observe(columnsCombo), BeanProperties.value("dimensions").observe(settings), new UpdateValueStrategy().setAfterGetValidator(new IValidator() { @Override public IStatus validate(Object value) { if (REAL.equalsIgnoreCase((String) value)) { return ValidationStatus.ok(); } else if (COMPLEX.equalsIgnoreCase((String) value)) { return ValidationStatus.ok(); } else { try { Integer intValue = Integer.valueOf((String) value); if (intValue > 0) { return ValidationStatus.ok(); } } catch (NumberFormatException e) { // PASS } } return ValidationStatus .error("Please enter a positive integer or choose one of the options below."); } }).setConverter(new Converter(String.class, Integer.class) { @Override public Object convert(Object fromObject) { if (REAL.equalsIgnoreCase((String) fromObject)) { return 1; } else if (COMPLEX.equalsIgnoreCase((String) fromObject)) { return 2; } else { return Integer.valueOf((String) fromObject); } } }), null); ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT); button = new Button(parent, SWT.None); button.setLayoutData(GridDataFactory.fillDefaults().create()); button.setImage(resources.get("icons/start.gif")); button.setToolTipText("Start Acquire"); button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (state.isRunning) { stopAcquire(); } else { startAcquire(); } } }); ctx.bindValue(WidgetProperties.enabled().observe(button), new AggregateValidationStatus(ctx, AggregateValidationStatus.MAX_SEVERITY), new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), new UpdateValueStrategy().setConverter(new Converter(IStatus.class, Boolean.class) { @Override public Object convert(Object fromObject) { return ((IStatus) fromObject).getSeverity() != IStatus.ERROR; } })); }
From source file:gov.redhawk.explorer.wizard.StartWaveformPage.java
License:Open Source License
/** * {@inheritDoc}//from w ww .ja va2s .c o m */ @Override public void createControl(final Composite parent) { final Composite container = new Composite(parent, SWT.NULL); final GridLayout layout = new GridLayout(); container.setLayout(layout); layout.numColumns = 2; Label label = new Label(container, SWT.NULL); label.setText("Type:"); this.waveformType = new ComboViewer(container, SWT.BORDER | SWT.READ_ONLY); GridData gd = new GridData(GridData.FILL_HORIZONTAL); this.waveformType.getControl().setLayoutData(gd); this.waveformType.setContentProvider(new ArrayContentProvider()); this.waveformType.setLabelProvider(new LabelProvider()); this.waveformType.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { // If there is something selected, load the list of available waveforms if (!event.getSelection().isEmpty()) { final String type = (String) ((IStructuredSelection) event.getSelection()).getFirstElement(); StartWaveformPage.this.waveformList .setInput(StartWaveformPage.this.waveMap.get(type).toArray()); StartWaveformPage.this.waveformList.getControl().setEnabled(true); } else { // Otherwise, remove everything and show nothing clearWaveformList(); } } }); label = new Label(container, SWT.NULL); label.setText("Waveform:"); label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true)); this.waveformList = new ListViewer(container, SWT.BORDER | SWT.V_SCROLL); gd = new GridData(GridData.FILL_BOTH); this.waveformList.getControl().setLayoutData(gd); this.waveformList.setContentProvider(new ArrayContentProvider()); this.waveformList.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { // Show either a string, or the waveform name if (element instanceof String) { return element.toString(); } else if (element instanceof WaveMapping) { return ((WaveMapping) element).getWaveformName(); } return super.getText(element); } }); this.waveformList.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { // Selecting a waveform indicates completability of the wizard StartWaveformPage.this.setPageComplete(!event.getSelection().isEmpty()); } }); clearWaveformList(); setControl(container); }
From source file:gov.redhawk.frontend.ui.wizard.TunerAllocationWizardPage.java
License:Open Source License
private void createGroupControls(Composite parent) { GridLayoutFactory.fillDefaults().numColumns(2).applyTo(parent); Composite comp1 = new Composite(parent, SWT.NONE); comp1.setLayout(new FillLayout()); GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(comp1); tunerAlloc = new Button(comp1, SWT.RADIO); tunerAlloc.setText("Allocate a Tuner"); tunerAlloc.addSelectionListener(allocationModeListener); tunerAlloc.setSelection(true);//from w w w . j a v a2 s . c o m listenerAlloc = new Button(comp1, SWT.RADIO); listenerAlloc.setText("Allocate a listener on an existing Tuner"); listenerAlloc.addSelectionListener(allocationModeListener); Composite comp2 = new Composite(parent, SWT.NONE); comp2.setLayout(new FillLayout()); GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(comp2); listenBySearch = new Button(comp2, SWT.RADIO); listenBySearch.setText("Match by search parameters"); listenBySearch.setToolTipText( "Search for a Tuner that matches the specified frequency, bandwidth, and sample rate, and allocate as a listener on that Tuner"); listenBySearch.addSelectionListener(allocationModeListener); listenBySearch.setSelection(true); listenBySearch.setEnabled(false); listenById = new Button(comp2, SWT.RADIO); listenById.setText("Match by existing Allocation ID"); listenById.setToolTipText( "Search for a Tuner with Allocation ID matching the ID specified in the \"Existing Tuner Allocation ID\" field, and allocate as a listener on that Tuner"); listenById.addSelectionListener(allocationModeListener); listenById.setEnabled(false); Label targetAllocLabel = new Label(parent, SWT.NONE); targetAllocLabel.setText("Existing Tuner Allocation ID"); targetAllocText = new Text(parent, SWT.BORDER); targetAllocText.setToolTipText( "If you would like to create a Listener allocation for a specific tuner, enter its Allocation ID here"); targetAllocText.setEnabled(false); GridDataFactory.fillDefaults().grab(true, false).applyTo(targetAllocText); Label allocIdLabel = new Label(parent, SWT.NONE); allocIdLabel.setText("Your Allocation ID"); allocIdText = new Text(parent, SWT.BORDER); allocIdText.setToolTipText( "Enter any ID for ease of reference. Additional characters will be appended after this name, to ensure uniqueness"); GridDataFactory.fillDefaults().grab(true, false).applyTo(allocIdText); Label typeLabel = new Label(parent, SWT.NONE); typeLabel.setText("Tuner Type"); typeCombo = new ComboViewer(parent, SWT.NONE | SWT.READ_ONLY); typeCombo.setContentProvider(new ArrayContentProvider()); GridDataFactory.fillDefaults().grab(true, false).applyTo(typeCombo.getControl()); tunerControls.add(typeCombo.getControl()); Label cfLabel = new Label(parent, SWT.NONE); cfLabel.setText("Center Frequency (MHz)"); cfText = new Text(parent, SWT.BORDER); tunerControls.add(cfText); GridDataFactory.fillDefaults().grab(true, false).applyTo(cfText); Label bwLabel = new Label(parent, SWT.NONE); bwLabel.setText("Bandwidth (MHz)"); Composite bwComp = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(bwComp); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(bwComp); bwText = new Text(bwComp, SWT.BORDER); tunerControls.add(bwText); GridDataFactory.fillDefaults().grab(true, false).applyTo(bwText); bwAnyValue = new Button(bwComp, SWT.CHECK); tunerControls.add(bwAnyValue); bwAnyValue.setText("Any Value"); bwAnyValue.addSelectionListener(new UseAnyValueListener()); GridDataFactory.fillDefaults().grab(false, false).applyTo(bwAnyValue); Label srLabel = new Label(parent, SWT.NONE); srLabel.setText("Sample Rate (Msps)"); Composite srComp = new Composite(parent, SWT.NONE); GridDataFactory.fillDefaults().grab(true, false).applyTo(srComp); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(srComp); srText = new Text(srComp, SWT.BORDER); tunerControls.add(srText); GridDataFactory.fillDefaults().grab(true, false).applyTo(srText); srAnyValue = new Button(srComp, SWT.CHECK); tunerControls.add(srAnyValue); srAnyValue.setText("Any Value"); srAnyValue.addSelectionListener(new UseAnyValueListener()); GridDataFactory.fillDefaults().grab(false, false).applyTo(srAnyValue); Label bwTolLabel = new Label(parent, SWT.NONE); bwTolLabel.setText("Bandwidth Tolerance (%)"); bwTolText = new Text(parent, SWT.BORDER); tunerControls.add(bwTolText); GridDataFactory.fillDefaults().grab(true, false).applyTo(bwTolText); Label srTolLabel = new Label(parent, SWT.NONE); srTolLabel.setText("Sample Rate Tolerance (%)"); srTolText = new Text(parent, SWT.BORDER); tunerControls.add(srTolText); GridDataFactory.fillDefaults().grab(true, false).applyTo(srTolText); Label rfFlowIdLabel = new Label(parent, SWT.NONE); rfFlowIdLabel.setText("RF Flow ID"); rfFlowIdText = new Text(parent, SWT.BORDER); rfFlowIdText.setToolTipText( "If you would like to allocate tuners for a specific input source, enter the RF Flow ID of the source here"); tunerControls.add(rfFlowIdText); GridDataFactory.fillDefaults().grab(true, false).applyTo(rfFlowIdText); }
From source file:gov.redhawk.ide.codegen.frontend.ui.wizard.FrontEndTunerOptionsWizardPage.java
License:Open Source License
private Composite createDigitalIn(Composite parent) { Composite digitalIn = new Composite(parent, SWT.SHADOW_NONE); digitalIn.setLayout(new GridLayout(2, false)); Label digitalInputTypeLabel = new Label(digitalIn, SWT.None); digitalInputTypeLabel.setText("Digital Input Type: "); ComboViewer digitalInputCombo = new ComboViewer(digitalIn, SWT.READ_ONLY); digitalInputCombo.setContentProvider(new ArrayContentProvider()); digitalInputCombo.setLabelProvider(definitionComboViewerLabelProvider); digitalInputCombo.setInput(propertyTypes); ctx.bindValue(ViewersObservables.observeSingleSelection(digitalInputCombo), EMFObservables .observeValue(this.feiDevice, FrontendPackage.Literals.FEI_DEVICE__DIGITAL_INPUT_TYPE)); ctx.bindValue(WidgetProperties.enabled().observe(digitalInputCombo.getCombo()), EMFObservables .observeValue(this.feiDevice, FrontendPackage.Literals.FEI_DEVICE__HAS_DIGITAL_INPUT)); return digitalIn; }
From source file:gov.redhawk.ide.codegen.frontend.ui.wizard.FrontEndTunerOptionsWizardPage.java
License:Open Source License
private Composite createDigitalOut(Composite parent) { Composite digitalOut = new Composite(parent, SWT.SHADOW_NONE); digitalOut.setLayout(new GridLayout(2, false)); digitalOut.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(30, 0) .align(SWT.CENTER, SWT.CENTER).create()); Label digitalOutputTypeLabel = new Label(digitalOut, SWT.None); digitalOutputTypeLabel.setText("Digital Output Type: "); ComboViewer digitalOutputCombo = new ComboViewer(digitalOut, SWT.READ_ONLY); digitalOutputCombo.setContentProvider(new ArrayContentProvider()); digitalOutputCombo.setLabelProvider(definitionComboViewerLabelProvider); digitalOutputCombo.setInput(propertyTypes); ctx.bindValue(ViewersObservables.observeSingleSelection(digitalOutputCombo), EMFObservables .observeValue(this.feiDevice, FrontendPackage.Literals.FEI_DEVICE__DIGITAL_OUTPUT_TYPE)); ctx.bindValue(WidgetProperties.enabled().observe(digitalOutputCombo.getCombo()), EMFObservables .observeValue(this.feiDevice, FrontendPackage.Literals.FEI_DEVICE__HAS_DIGITAL_OUTPUT)); Button multiOutCheck = new Button(digitalOut, SWT.CHECK); multiOutCheck.setText("Multi-out"); ctx.bindValue(WidgetProperties.selection().observe(multiOutCheck), EMFObservables.observeValue(this.feiDevice, FrontendPackage.Literals.FEI_DEVICE__MULTI_OUT)); ctx.bindValue(WidgetProperties.enabled().observe(multiOutCheck), EMFObservables.observeValue(this.feiDevice, FrontendPackage.Literals.FEI_DEVICE__HAS_DIGITAL_OUTPUT)); return digitalOut; }
From source file:gov.redhawk.ide.codegen.frontend.ui.wizard.FrontEndTunerOptionsWizardPage.java
License:Open Source License
private void createTransmitterGroup(Composite client) { Group transmitterGroup = new Group(client, SWT.SHADOW_ETCHED_IN); transmitterGroup.setText("Transmitter Properties"); transmitterGroup.setLayout(new GridLayout(4, false)); transmitterGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); Label numDigitalInLabel = new Label(transmitterGroup, SWT.None); numDigitalInLabel.setText("Number of Digital input ports: "); Spinner numDigitalSpinner = new Spinner(transmitterGroup, SWT.BORDER); GC gc = new GC(numDigitalSpinner); try {//from www . ja v a 2 s .c om Point size = gc.textExtent("XXX"); numDigitalSpinner.setLayoutData(GridDataFactory.fillDefaults().hint(size.x, SWT.DEFAULT).create()); } finally { gc.dispose(); } numDigitalSpinner.setMinimum(1); ctx.bindValue(WidgetProperties.selection().observe(numDigitalSpinner), EMFObservables.observeValue( this.feiDevice, FrontendPackage.Literals.FEI_DEVICE__NUMBER_OF_DIGITAL_INPUTS_FOR_TX)); Label digitalInputTypeLabel = new Label(transmitterGroup, SWT.None); digitalInputTypeLabel.setText("Digital Input Type: "); digitalInputTypeLabel .setLayoutData(GridDataFactory.fillDefaults().indent(50, 0).align(SWT.CENTER, SWT.CENTER).create()); ComboViewer digitalInputCombo = new ComboViewer(transmitterGroup, SWT.READ_ONLY); digitalInputCombo.setContentProvider(new ArrayContentProvider()); digitalInputCombo.setLabelProvider(definitionComboViewerLabelProvider); digitalInputCombo.setInput(propertyTypes); ctx.bindValue(ViewersObservables.observeSingleSelection(digitalInputCombo), EMFObservables .observeValue(this.feiDevice, FrontendPackage.Literals.FEI_DEVICE__DIGITAL_INPUT_TYPE_FOR_TX)); }
From source file:gov.redhawk.ide.codegen.jet.java.ui.JavaJetGeneratorPropertiesWizardPage.java
License:Open Source License
/** * {@inheritDoc}/*from w w w . ja v a 2 s . c o m*/ */ @Override public void createControl(final Composite parent) { final Composite client = new Composite(parent, SWT.NULL); client.setLayout(new GridLayout(2, false)); Label label; final GridDataFactory labelFactory = GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL); label = new Label(client, SWT.NULL); label.setText("Generator:"); label.setLayoutData(labelFactory.create()); this.generatorLabel = new Text(client, SWT.READ_ONLY | SWT.SINGLE | SWT.BORDER); this.generatorLabel.setEnabled(false); this.generatorLabel.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); label = new Label(client, SWT.NULL); label.setText("Template:"); this.templateViewer = new ComboViewer(client, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY | SWT.DROP_DOWN); this.templateViewer.getControl() .setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); this.templateViewer.setContentProvider(new ArrayContentProvider()); this.templateViewer.setLabelProvider(new LabelProvider() { /** * {@inheritDoc} */ @Override public String getText(final Object element) { if (element instanceof ITemplateDesc) { return ((ITemplateDesc) element).getName(); } return super.getText(element); } }); this.templateViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final ITemplateDesc desc = (ITemplateDesc) ((IStructuredSelection) event.getSelection()) .getFirstElement(); if (desc != null) { if (desc != JavaJetGeneratorPropertiesWizardPage.this.selectedTemplate) { JavaJetGeneratorPropertiesWizardPage.this.selectedTemplate = desc; // Remove the old templates properties final EList<Property> properties = JavaJetGeneratorPropertiesWizardPage.this.implSettings .getProperties(); if (properties.size() != 0) { properties.clear(); } JavaJetGeneratorPropertiesWizardPage.this.packageName = null; final List<IPropertyDescriptor> propList = new ArrayList<IPropertyDescriptor>(); // Add the new templates properties for (final IPropertyDescriptor value : desc.getPropertyDescriptors()) { final Property p = CodegenFactory.eINSTANCE.createProperty(); if (!value.isDeprecated()) { p.setId(value.getKey()); p.setValue(value.getDefaultValue()); properties.add(p); if (!JavaGeneratorProperties.PROP_PACKAGE.equals(value.getKey())) { propList.add(value); } else { p.setValue(JavaGeneratorProperties.getPackage( JavaJetGeneratorPropertiesWizardPage.this.softPkg, JavaJetGeneratorPropertiesWizardPage.this.impl, JavaJetGeneratorPropertiesWizardPage.this.implSettings)); JavaJetGeneratorPropertiesWizardPage.this.packageName = p; } } } // Update the properties displayed JavaJetGeneratorPropertiesWizardPage.this.propertiesViewer.setInput(propList); // Unbind the old properties and bind the new ones if (JavaJetGeneratorPropertiesWizardPage.this.propBinding != null) { JavaJetGeneratorPropertiesWizardPage.this.bindings .remove(JavaJetGeneratorPropertiesWizardPage.this.propBinding); } JavaJetGeneratorPropertiesWizardPage.this.propBinding = createPropertyBinding(); JavaJetGeneratorPropertiesWizardPage.this.bindings .add(JavaJetGeneratorPropertiesWizardPage.this.propBinding); } // Save the new template and update the tooltip JavaJetGeneratorPropertiesWizardPage.this.implSettings.setTemplate(desc.getId()); JavaJetGeneratorPropertiesWizardPage.this.templateViewer.getCombo() .setToolTipText(desc.getDescription()); } else { JavaJetGeneratorPropertiesWizardPage.this.implSettings.setTemplate(null); } } }); label = new Label(client, SWT.NULL); label.setText("Output Directory:"); this.outputDirText = new Text(client, SWT.BORDER); this.outputDirText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); label = new Label(client, SWT.NULL); label.setText("Package:"); label.setLayoutData(labelFactory.create()); this.packageNameText = new Text(client, SWT.SINGLE | SWT.BORDER); this.packageNameText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); createExtraArea(client, labelFactory, ((GridLayout) client.getLayout()).numColumns); label = new Label(client, SWT.NULL); label.setText("Properties:"); label.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP).create()); this.propertiesViewer = new CheckboxTableViewer(new Table(client, SWT.CHECK | SWT.READ_ONLY | SWT.BORDER)); ColumnViewerToolTipSupport.enableFor(this.propertiesViewer); this.propertiesViewer.setContentProvider(new ArrayContentProvider()); final CellLabelProvider labelProvider = new CellLabelProvider() { public String getText(final Object element) { String text = ""; if (element instanceof IPropertyDescriptor) { if (((IPropertyDescriptor) element).getName().length() != 0) { text = ((IPropertyDescriptor) element).getName(); } else { text = ((IPropertyDescriptor) element).getKey(); } } return text; } @Override public String getToolTipText(final Object element) { String text = "No description available for this property"; if (element instanceof IPropertyDescriptor) { final String desc = ((IPropertyDescriptor) element).getDescription(); if (desc != null && desc.length() != 0) { text = desc; } } return text; } @Override public Point getToolTipShift(final Object object) { return new Point(5, 5); // SUPPRESS CHECKSTYLE MagicNumber } @Override public int getToolTipDisplayDelayTime(final Object object) { return JavaJetGeneratorPropertiesWizardPage.TOOLTIP_DELAY_MILLIS; } @Override public int getToolTipTimeDisplayed(final Object object) { return JavaJetGeneratorPropertiesWizardPage.TOOLTIP_DISPLAY_TIME_MILLIS; } @Override public void update(final ViewerCell cell) { cell.setText(getText(cell.getElement())); } }; this.propertiesViewer.setLabelProvider(labelProvider); this.propertiesViewer.setFilters(createPropertiesViewerFilter()); this.propertiesViewer.getControl() .setLayoutData(GridDataFactory.fillDefaults().span(1, 2).grab(false, true).create()); if (this.configured) { bind(); } this.created = true; setControl(client); }
From source file:gov.redhawk.ide.codegen.ui.BaseGeneratorPropertiesComposite.java
License:Open Source License
/** * Creates the generator entry./*from w ww . j a v a 2 s . co m*/ * * @param client the client * @param toolkit the toolkit * @param actionBars the action bars */ private void createGeneratorEntry() { final Label label = this.toolkit.createLabel(this, "Generator:"); label.setForeground(this.toolkit.getColors().getColor(IFormColors.TITLE)); this.generatorViewer = new ComboViewer(this, SWT.SINGLE | SWT.READ_ONLY | SWT.DROP_DOWN); this.generatorViewer.getControl().addListener(SWT.MouseVerticalWheel, new Listener() { @Override public void handleEvent(Event event) { event.doit = false; } }); this.generatorViewer.setContentProvider(new ArrayContentProvider()); this.generatorViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { final ICodeGeneratorDescriptor desc = (ICodeGeneratorDescriptor) element; return desc.getName(); } }); this.generatorViewer.getControl() .setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create()); this.generatorViewer.setInput(RedhawkCodegenActivator.getCodeGeneratorsRegistry().getCodegens()); this.generatorViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final ICodeGeneratorDescriptor desc = (ICodeGeneratorDescriptor) ((IStructuredSelection) event .getSelection()).getFirstElement(); if (desc == null) { BaseGeneratorPropertiesComposite.this.templateViewer.setInput(Collections.EMPTY_LIST); } else { ITemplateDesc[] templates = RedhawkCodegenActivator.getCodeGeneratorTemplatesRegistry() .findTemplatesByCodegen(desc.getId()); BaseGeneratorPropertiesComposite.this.templateViewer.setInput(templates); } } }); }
From source file:gov.redhawk.ide.codegen.ui.BaseGeneratorPropertiesComposite.java
License:Open Source License
/** * Creates the template entry./*ww w .jav a 2 s . com*/ * * @param client the client * @param toolkit the toolkit * @param actionBars the action bars */ private void createTemplateEntry() { final Label label = this.toolkit.createLabel(this, "Template:"); label.setForeground(this.toolkit.getColors().getColor(IFormColors.TITLE)); label.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP).create()); this.templateViewer = new ComboViewer(this, SWT.READ_ONLY | SWT.SINGLE | SWT.DROP_DOWN); this.templateViewer.getControl().addListener(SWT.MouseVerticalWheel, new Listener() { @Override public void handleEvent(Event event) { event.doit = false; } }); this.templateViewer.getControl() .setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, false).create()); this.templateViewer.getControl().setToolTipText("Template for the code generator"); this.templateViewer.setContentProvider(new ArrayContentProvider()); this.templateViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { final ITemplateDesc desc = (ITemplateDesc) element; return desc.getName(); } }); this.templateViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final ITemplateDesc desc = (ITemplateDesc) ((IStructuredSelection) event.getSelection()) .getFirstElement(); final EditingDomain dom = BaseGeneratorPropertiesComposite.this.domain; if ((dom != null) && (desc != null) && (desc != BaseGeneratorPropertiesComposite.this.selectedTemplate)) { // Save the selected Template and update the ImplementationSettings BaseGeneratorPropertiesComposite.this.selectedTemplate = desc; // Check if the template has actually changed // - this gets called when selecting implementations in the // implementation list and we don't want change properties // - this gets called when you actually click the dropdown, // here we actually want to change the properties if (!desc.getId().equals(BaseGeneratorPropertiesComposite.this.implSettings.getTemplate())) { final Command command = SetCommand.create(dom, BaseGeneratorPropertiesComposite.this.implSettings, CodegenPackage.Literals.IMPLEMENTATION_SETTINGS__TEMPLATE, desc.getId()); dom.getCommandStack().execute(command); // Change the enablement of the port map if the new // template supports it BaseGeneratorPropertiesComposite.this.portMapComposite .setEnabled(BaseGeneratorPropertiesComposite.this.getEnablePortMap()); // Update the properties display and rebind templateSelected(desc); } } } }); }