List of usage examples for org.eclipse.jface.viewers ComboViewer getCombo
public Combo getCombo()
From source file:org.bonitasoft.studio.connector.model.definition.dialog.SelectPageWidgetDialog.java
License:Open Source License
private Control createRadioGroupComposite(final RadioGroup widget) { final Composite mainComposite = new Composite(section, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 0).create()); final Label orientationLabel = new Label(mainComposite, SWT.NONE); orientationLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); orientationLabel.setText(Messages.orientation); final ComboViewer orientationCombo = new ComboViewer(mainComposite, SWT.READ_ONLY | SWT.BORDER); orientationCombo.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); orientationCombo.setContentProvider(new ArrayContentProvider()); orientationCombo.setLabelProvider(new LabelProvider()); context.bindValue(ViewersObservables.observeInput(orientationCombo), PojoProperties.value(SelectPageWidgetDialog.class, "orientations").observe(this)); context.bindValue(ViewersObservables.observeSingleSelection(orientationCombo), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.RADIO_GROUP__ORIENTATION)); final Label itemsLabel = new Label(mainComposite, SWT.NONE); itemsLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.TOP).create()); itemsLabel.setText(Messages.items);//ww w . ja v a2s.co m final Composite itemComposite = new Composite(mainComposite, SWT.NONE); itemComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); itemComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); final TableViewer itemViewer = new TableViewer(itemComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI); itemViewer.getTable() .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80).create()); itemViewer.setContentProvider(new ArrayContentProvider()); final TableLayout layout = new TableLayout(); layout.addColumnData(new ColumnWeightData(100)); itemViewer.getTable().setLayout(layout); final TableViewerColumn inputNameColumn = new TableViewerColumn(itemViewer, SWT.FILL); inputNameColumn.getColumn().setText(Messages.input); inputNameColumn.setEditingSupport(new RadioGroupItemEditingSupport(itemViewer, widget)); inputNameColumn.setLabelProvider(new ColumnLabelProvider()); context.bindValue(ViewersObservables.observeInput(itemViewer), EMFObservables.observeValue(widget, ConnectorDefinitionPackage.Literals.RADIO_GROUP__CHOICES)); final Composite buttonComposite = new Composite(itemComposite, SWT.NONE); buttonComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create()); buttonComposite .setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 3).create()); final Button addButton = new Button(buttonComposite, SWT.FLAT); addButton.setText(Messages.Add); addButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); addButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { String item = generateRadioChoice(widget); widget.getChoices().add(item); itemViewer.editElement(item, 0); } }); final Button upButton = new Button(buttonComposite, SWT.FLAT); upButton.setText(Messages.up); upButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); upButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { String selected = (String) ((IStructuredSelection) itemViewer.getSelection()).getFirstElement(); int i = widget.getChoices().indexOf(selected); if (i > 0) { widget.getChoices().move(i - 1, selected); itemViewer.refresh(); } } }); final Button downButton = new Button(buttonComposite, SWT.FLAT); downButton.setText(Messages.down); downButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); downButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { String selected = (String) ((IStructuredSelection) itemViewer.getSelection()).getFirstElement(); int i = widget.getChoices().indexOf(selected); if (i < widget.getChoices().size() - 1) { widget.getChoices().move(i + 1, selected); itemViewer.refresh(); } } }); final Button removeButton = new Button(buttonComposite, SWT.FLAT); removeButton.setText(Messages.remove); removeButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { widget.getChoices().removeAll(((IStructuredSelection) itemViewer.getSelection()).toList()); itemViewer.refresh(); } }); return mainComposite; }
From source file:org.bonitasoft.studio.expression.editor.operation.OperatorSelectionDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { final Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite//from w w w . j a va 2s . co m .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, SWT.DEFAULT).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create()); final Label operatorType = new Label(mainComposite, SWT.NONE); operatorType.setText(Messages.operatorType); final ComboViewer operatorViewer = new ComboViewer(mainComposite, SWT.READ_ONLY | SWT.BORDER); operatorViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); operatorViewer.setContentProvider(new ArrayContentProvider()); operatorViewer.setLabelProvider(new OperatorLabelProvider()); operatorViewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { Expression exp = operation.getLeftOperand(); if (exp != null && !exp.getReferencedElements().isEmpty() && ExpressionConstants.VARIABLE_TYPE.equals(exp.getType())) { EObject data = exp.getReferencedElements().get(0); if (data instanceof BusinessObjectData) { return element.equals(ExpressionConstants.CREATE_BUSINESS_DATA_OPERATOR) || element.equals(ExpressionConstants.JAVA_METHOD_OPERATOR); } else if (data instanceof JavaObjectData) { return element.equals(ExpressionConstants.ASSIGNMENT_OPERATOR) || element.equals(ExpressionConstants.JAVA_METHOD_OPERATOR); } else if (data instanceof XMLData) { return element.equals(ExpressionConstants.ASSIGNMENT_OPERATOR) || element.equals(ExpressionConstants.XPATH_UPDATE_OPERATOR); } else { return element.equals(ExpressionConstants.ASSIGNMENT_OPERATOR); } } else if (exp != null && !exp.getReferencedElements().isEmpty() && ExpressionConstants.DOCUMENT_REF_TYPE.equals(exp.getType())) { return element.equals(ExpressionConstants.SET_DOCUMENT_OPERATOR); } return element.equals(ExpressionConstants.ASSIGNMENT_OPERATOR); } }); operatorViewer.setInput(operatorTypeList); section = new Section(mainComposite, Section.NO_TITLE); section.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); Expression exp = operation.getLeftOperand(); for (IOperatorEditor opEditor : operatorEditors) { if (!opEditor.appliesTo(exp) && opEditor.appliesTo(operator.getType())) { operator.setType(ExpressionConstants.ASSIGNMENT_OPERATOR); } } createOperatorEditorFor(section, operator.getType(), operator, exp); context.bindValue(ViewersObservables.observeSingleSelection(operatorViewer), EMFObservables.observeValue(operator, ExpressionPackage.Literals.OPERATOR__TYPE)); operatorViewer.addSelectionChangedListener(this); return mainComposite; }
From source file:org.bonitasoft.studio.properties.sections.iteration.IterationPropertySection.java
License:Open Source License
private IValueChangeListener createInputValueChanged(final ComboViewer comboViewer, final IViewerObservableValue observeSingleSelection, final IObservableValue dataObservableValue, final boolean stepData) { return new IValueChangeListener() { @Override// www. ja v a 2s .c om public void handleValueChange(final ValueChangeEvent event) { final EObject parentProcess = getTargetEObject(event, stepData); if (parentProcess != null) { final IObservableList newInput = EMFObservables.observeList(parentProcess, ProcessPackage.Literals.DATA_AWARE__DATA); comboViewer.setInput(newInput); newInput.addListChangeListener(new IListChangeListener() { @Override public void handleListChange(final ListChangeEvent event) { if (comboViewer != null && !comboViewer.getCombo().isDisposed()) { comboViewer.refresh(); } } }); final Object dataValue = dataObservableValue.getValue(); if (dataValue instanceof Data && newInput != null) { final Iterator<?> iterator = newInput.iterator(); while (iterator.hasNext()) { final Object object = iterator.next(); if (object instanceof Data) { if (((Data) object).getName().equals(((Data) dataValue).getName())) { observeSingleSelection.setValue(object); } } } } } } private EObject getTargetEObject(final ValueChangeEvent event, final boolean stepData) { if (stepData) { return (MultiInstantiable) event.diff.getNewValue(); } else { return ModelHelper.getParentProcess((MultiInstantiable) event.diff.getNewValue()); } } }; }
From source file:org.bonitasoft.studio.validators.ui.wizard.ValidatorWizardPage.java
License:Open Source License
protected void createTypeCombo(Composite mainComposite) { Label typeLabel = new Label(mainComposite, SWT.NONE); typeLabel.setText(Messages.validatorType); typeLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create()); final ComboViewer typeViewer = new ComboViewer(mainComposite, SWT.BORDER | SWT.READ_ONLY); typeViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); typeViewer.setContentProvider(new ArrayContentProvider()); typeViewer.setLabelProvider(new LabelProvider() { @Override/*from w w w.ja v a 2s .c o m*/ public String getText(Object element) { if (element == ValidatorType.FILED_VALIDATOR) { return Messages.fieldValidator; } else if (element == ValidatorType.PAGE_VALIDATOR) { return Messages.pageValidator; } return super.getText(element); } }); typeViewer.setInput(ValidatorType.values()); typeViewer.getCombo().setEnabled(!editMode); context.bindValue(ViewersObservables.observeSingleSelection(typeViewer), EMFObservables.observeValue(validator, ValidatorPackage.Literals.VALIDATOR_DESCRIPTOR__TYPE)); }
From source file:org.csstudio.diag.pvfields.view.PVFieldsView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { if (model == null) { new Label(parent, 0).setText("Cannot initialize"); //$NON-NLS-1$ return;/* w ww. jav a 2 s.co m*/ } gui = new GUI(parent, model); cbo_name = gui.getPVViewer(); field_value = gui.getFieldViewer(); // Allow Eclipse to listen to PV selection changes final TableViewer fields_viewer = gui.getFieldsTable(); getSite().setSelectionProvider(fields_viewer); pv_name_helper = new ComboHistoryHelper(Activator.getDefault().getDialogSettings(), PV_LIST_TAG, cbo_name.getCombo(), 10, true) { @Override public void newSelection(String pv_name) { setPVName(pv_name); pv_name_helper.addEntry(pv_name); } }; field_value_helper = new ComboHistoryHelper(Activator.getDefault().getDialogSettings(), FIELD_LIST_TAG, field_value.getCombo(), 10, true) { @Override public void newSelection(String field_value) { field_value_helper.addEntry(field_value); } }; if (memento != null) { String pv_name = memento.getString(PV_TAG); String field = memento.getString(FIELD_TAG); if (field != null && field.length() > 0) field_value.getCombo().setText(field); if (pv_name != null && pv_name.length() > 0) setPVName(pv_name); } // Stop the press when we're no more cbo_name.getCombo().addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { pv_name_helper.saveSettings(); field_value_helper.saveSettings(); } }); final ComboViewer cbo_name = gui.getPVViewer(); pv_name_helper.loadSettings(); field_value_helper.loadSettings(); // Enable 'Drop' on to combo box (entry box) new ControlSystemDropTarget(cbo_name.getCombo(), ProcessVariable.class, String.class) { @Override public void handleDrop(final Object item) { PVFieldsView.this.handleDrop(item); } }; final Table fields_table = gui.getFieldsTable().getTable(); // Enable 'Drop' on to table. new ControlSystemDropTarget(fields_table, ProcessVariable.class, String.class) { @Override public void handleDrop(final Object item) { PVFieldsView.this.handleDrop(item); } }; // Add empty context menu so that other CSS apps can // add themselves to it final MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); Menu menu = menuMgr.createContextMenu(fields_viewer.getControl()); fields_viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, fields_viewer); }
From source file:org.eclipse.birt.data.oda.pojo.ui.impl.dialogs.MethodParameterDialog.java
License:Open Source License
private void createDialogContent(Composite composite) { GridData data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2;//from w w w .j a va2 s . c o m checkBtn = new Button(composite, SWT.CHECK); checkBtn.setText(Messages.getString("MethodParameterDialog.checkBox.message")); //$NON-NLS-1$ checkBtn.setSelection(this.param instanceof VariableParameter); toBeMapped = checkBtn.getSelection(); checkBtn.setLayoutData(data); checkBtn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { toBeMapped = checkBtn.getSelection(); nameText.setEnabled(toBeMapped); nameText.setText(toBeMapped ? name : Constants.DISPLAY_NONE_VALUE); validateSyntax(); } }); Label nameLabel = new Label(composite, SWT.NONE); nameLabel.setText(Messages.getString("MethodParameterDialog.label.name")); //$NON-NLS-1$ GridData gd = new GridData(GridData.FILL_HORIZONTAL); nameText = new Text(composite, SWT.BORDER); nameText.setLayoutData(gd); nameText.setEnabled(toBeMapped); nameText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (nameText.isEnabled()) { name = nameText.getText(); } validateSyntax(); } }); Label valueLabel = new Label(composite, SWT.NONE); valueLabel.setText(Messages.getString("MethodParameterDialog.label.value")); //$NON-NLS-1$ final Text valueText = new Text(composite, SWT.BORDER); valueText.setLayoutData(gd); valueText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { value = valueText.getText(); validateSyntax(); } }); Label typeLabel = new Label(composite, SWT.NONE); typeLabel.setText(Messages.getString("MethodParameterDialog.label.dataType")); //$NON-NLS-1$ final ComboViewer comboTypes = new ComboViewer(composite, SWT.BORDER); GridData comboData = new GridData(GridData.FILL_HORIZONTAL); comboTypes.getCombo().setLayoutData(comboData); comboTypes.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object arg0) { MethodParameterType[] types = MethodParameterType.getBuiltins(); String names[] = new String[types.length]; for (int i = 0; i < types.length; i++) { names[i] = types[i].getName(); } return names; } public void dispose() { } public void inputChanged(Viewer arg0, Object arg1, Object arg2) { } }); comboTypes.setInput(""); //$NON-NLS-1$ comboTypes.getCombo().addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { type = comboTypes.getCombo().getText(); validateSyntax(); } }); comboTypes.getCombo().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { type = comboTypes.getCombo().getText(); validateSyntax(); } }); if (this.param != null) { if (toBeMapped) { nameText.setText(name == null ? "" : name); //$NON-NLS-1$ } else { nameText.setText(Constants.DISPLAY_NONE_VALUE); } valueText.setText(value == null ? "" : value); //$NON-NLS-1$ comboTypes.getCombo().setText(type == null ? "" : type); //$NON-NLS-1$ } validateSyntax(); }
From source file:org.eclipse.birt.report.data.oda.jdbc.ui.editors.SQLDataSetEditorPage.java
License:Open Source License
/** * /* ww w . j a va 2 s. c om*/ * @param filterComboViewer */ private void setFilterComboContents(ComboViewer filterComboViewer, boolean supportsProcedure) { if (filterComboViewer == null) { return; } filterComboViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { return ((List) inputElement).toArray(); } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); filterComboViewer.setLabelProvider(new LabelProvider() { public String getText(Object inputElement) { TableType type = (TableType) inputElement; return type.getDisplayName(); } }); List<TableType> types = getTableTypes(supportsProcedure); filterComboViewer.setInput(types); // Set the Default selection to the First Item , which is "All" filterComboViewer.getCombo().select(0); filterComboViewer.getCombo().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { TableType type = getSelectedFilterType(); if (type == TableType.ALL || type == TableType.TABLE) { showSystemTableCheckBox.setEnabled(true); showAliasCheckBox.setEnabled(true); } else { showSystemTableCheckBox.setEnabled(false); showAliasCheckBox.setEnabled(false); } } }); }
From source file:org.eclipse.birt.report.data.oda.jdbc_resultset.ui.editors.SQLDataSetEditorPage.java
License:Open Source License
/** * /*ww w. jav a 2 s .c o m*/ * @param filterComboViewer */ private void setFilterComboContents(ComboViewer filterComboViewer, boolean supportsProcedure) { if (filterComboViewer == null) { return; } List<FilterConfig.Type> types = new ArrayList<FilterConfig.Type>(); // Populate the Types of Data bases objects which can be retrieved types.add(Type.ALL); types.add(Type.TABLE); types.add(Type.VIEW); if (supportsProcedure) { types.add(Type.PROCEDURE); } filterComboViewer.setContentProvider(new IStructuredContentProvider() { @SuppressWarnings("unchecked") public Object[] getElements(Object inputElement) { return ((List) inputElement).toArray(); } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); filterComboViewer.setLabelProvider(new LabelProvider() { public String getText(Object inputElement) { FilterConfig.Type type = (FilterConfig.Type) inputElement; return FilterConfig.getTypeDisplayText(type); } }); filterComboViewer.setInput(types); // Set the Default selection to the First Item , which is "All" filterComboViewer.getCombo().select(0); filterComboViewer.getCombo().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Type type = getSelectedFilterType(); if (type == Type.ALL || type == Type.TABLE) { showSystemTableCheckBox.setEnabled(true); } else { showSystemTableCheckBox.setEnabled(false); } } }); }
From source file:org.eclipse.bpmn2.modeler.ui.property.editors.ComboObjectEditor.java
License:Open Source License
private ComboViewer createComboViewer(Composite parent, AdapterFactoryLabelProvider labelProvider, int style) { ComboViewer comboViewer = new ComboViewer(parent, style); comboViewer.setLabelProvider(labelProvider); Combo combo = comboViewer.getCombo(); return comboViewer; }
From source file:org.eclipse.bpmn2.modeler.ui.property.MainPropertiesComposite.java
License:Open Source License
private void createSingleItemEditor(final EStructuralFeature reference, Object eGet, Collection values) { final ComboViewer combo = new ComboViewer(this, SWT.BORDER); Combo c = combo.getCombo(); combo.setLabelProvider(LABEL_PROVIDER); c.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); toolkit.adapt(c, true, true);/*from www . j av a 2 s . c om*/ widgets.add(c); List<Object> l = null; if (values != null) { l = Arrays.asList(values.toArray()); } else if (modelHandler != null) { l = (List<Object>) modelHandler.getAll(reference.getEType().getInstanceClass()); } combo.add(""); combo.add(l.toArray()); if (eGet != null) { combo.setSelection(new StructuredSelection(eGet)); } combo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = combo.getSelection(); if (selection instanceof StructuredSelection) { Object firstElement = ((StructuredSelection) selection).getFirstElement(); if (firstElement instanceof EObject) { updateEObject(firstElement); } else if (firstElement instanceof GatewayDirection) { updateGatewayDirection(firstElement); } else { updateEObject(null); } } } public void updateEObject(final Object result) { TransactionalEditingDomain domain = bpmn2Editor.getEditingDomain(); domain.getCommandStack().execute(new RecordingCommand(domain) { @Override protected void doExecute() { be.eSet(reference, result); } }); } public void updateGatewayDirection(final Object result) { TransactionalEditingDomain domain = bpmn2Editor.getEditingDomain(); domain.getCommandStack().execute(new RecordingCommand(domain) { @Override protected void doExecute() { GatewayDirection direction = (GatewayDirection) result; be.eSet(reference, direction); } }); } }); }