List of usage examples for org.eclipse.jface.databinding.viewers ViewerProperties multipleSelection
public static IViewerListProperty multipleSelection()
From source file:era.foss.objecteditor.specobject.AttributeDefinitionEnumComposite.java
License:Open Source License
@Override public void doBind(SpecObject specObject, AttributeValue attributeValue, EditingDomain editingDomain) { if (attributeValue == null) { valueModifyListener = new DefaultModifyListener(specObject, editingDomain); comboViewer.addSelectionChangedListener(valueModifyListener); if (attributeDefinition.getDefaultValue() != null) { comboViewer//from www .j a v a2 s . co m .setSelection(new StructuredSelection(attributeDefinition.getDefaultValue().getValues())); } else { comboViewer.setSelection(StructuredSelection.EMPTY); } } else { this.binding = dbc.bindList(ViewerProperties.multipleSelection().observe(comboViewer), EMFEditProperties.list(editingDomain, ErfPackage.Literals.ATTRIBUTE_VALUE_ENUMERATION__VALUES) .observe(attributeValue)); } }
From source file:org.bonitasoft.studio.connector.model.definition.dialog.CategorySelectionDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { final Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 300).create()); mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).create()); context = new DataBindingContext(); categoryViewer = new TreeViewer(mainComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); categoryViewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); categoryViewer.setContentProvider(new DefinitionCategoryContentProvider()); categoryViewer.setLabelProvider(new ConnectorDefinitionTreeLabelProvider(messageProvider)); categoryViewer.setInput(getAllCategories()); final IViewerObservableList observeSelection = ViewerProperties.multipleSelection().observe(categoryViewer); MultiValidator validator = new MultiValidator() { @Override// ww w . j a v a 2 s . com protected IStatus validate() { if (observeSelection.isEmpty()) { return ValidationStatus.error(""); } return ValidationStatus.ok(); } }; context.addValidationStatusProvider(validator); context.bindList(observeSelection, validator.observeValidatedList(PojoProperties.list("categories").observe(this)), null, new UpdateListStrategy()); DialogSupport.create(this, context); return mainComposite; }
From source file:org.fusesource.ide.foundation.ui.form.Forms.java
License:Open Source License
public static void bindMultipleSelection(DataBindingContext dataBindingContext, IMessageManager mmgr, IObservableList modelList, StructuredViewer profilesViewer, String propertyName, String labelText) { IViewerObservableList observe = ViewerProperties.multipleSelection().observe(profilesViewer); UpdateValueStrategy targetToModel = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); UpdateValueStrategy modelToTarget = new UpdateValueStrategy(UpdateValueStrategy.POLICY_UPDATE); targetToModel.setBeforeSetValidator(new MandatoryValidator(labelText)); modelToTarget.setBeforeSetValidator(new MandatoryValidator(labelText)); Binding bindValue = dataBindingContext.bindList(observe, modelList); final IObservableValue validationStatus = bindValue.getValidationStatus(); validationStatus.addChangeListener(//from w w w . j ava 2 s .c o m new MessageChangeListener(validationStatus, profilesViewer.getControl(), propertyName, mmgr)); }
From source file:uk.ac.stfc.isis.ibex.ui.configserver.editing.DoubleListEditor.java
License:Open Source License
/** * Constructor.//from ww w .j av a 2s . c om * * @param parent the containing composite * @param style the SWT style * @param observedProperty the property to observe * @param orderable is it orderable */ public DoubleListEditor(Composite parent, int style, String observedProperty, boolean orderable) { super(parent, style); setLayout(new GridLayout(4, false)); lblAvailable = new Label(this, SWT.NONE); lblAvailable.setText("Available:"); new Label(this, SWT.NONE); lblSelected = new Label(this, SWT.NONE); lblSelected.setText("Selected:"); new Label(this, SWT.NONE); unselectedViewer = new ListViewer(this, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); configureViewer(unselectedViewer, observedProperty); unselectedList = unselectedViewer.getList(); unselectedList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 2)); select = new Button(this, SWT.NONE); select.setEnabled(false); select.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, true, 1, 1)); select.setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui", "icons/move_right.png")); selectedViewer = new ListViewer(this, SWT.BORDER | SWT.V_SCROLL | SWT.MULTI); configureViewer(selectedViewer, observedProperty); selectedList = selectedViewer.getList(); selectedList.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 2)); btnUp = new Button(this, SWT.NONE); btnUp.setEnabled(false); GridData gd_btnUp = new GridData(SWT.LEFT, SWT.BOTTOM, false, true, 1, 1); gd_btnUp.widthHint = 25; gd_btnUp.exclude = !orderable; btnUp.setLayoutData(gd_btnUp); btnUp.setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui", "icons/move_up.png")); btnUp.setEnabled(true); if (!orderable) { new Label(this, SWT.NONE); } unselect = new Button(this, SWT.NONE); unselect.setEnabled(false); unselect.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, true, 1, 1)); unselect.setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui", "icons/move_left.png")); btnDown = new Button(this, SWT.NONE); GridData gd_btnDown = new GridData(SWT.LEFT, SWT.TOP, false, true, 1, 1); gd_btnDown.widthHint = 25; gd_btnDown.exclude = !orderable; btnDown.setLayoutData(gd_btnDown); btnDown.setImage(ResourceManager.getPluginImage("uk.ac.stfc.isis.ibex.ui", "icons/move_down.png")); btnDown.setEnabled(true); selectedItems = ViewerProperties.multipleSelection().observe(selectedViewer); unselectedItems = ViewerProperties.multipleSelection().observe(unselectedViewer); selectedList.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { // Bit of a hack as actual selecting behaviour is done on // listener, to improve use a DoubleListEditorViewModel unselect.setSelection(true); unselect.notifyListeners(SWT.Selection, new Event()); } }); unselectedList.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { // Bit of a hack as actual selecting behaviour is done on // listener, to improve use a DoubleListEditorViewModel select.setSelection(true); select.notifyListeners(SWT.Selection, new Event()); } }); // Allow only one list to have a selection clearSelectedItems = new IListChangeListener() { @Override public void handleListChange(ListChangeEvent arg0) { selectedItems.removeListChangeListener(clearUnselectedItems); selectedItems.clear(); selectedItems.addListChangeListener(clearUnselectedItems); } }; clearUnselectedItems = new IListChangeListener() { @Override public void handleListChange(ListChangeEvent arg0) { unselectedItems.removeListChangeListener(clearSelectedItems); unselectedItems.clear(); unselectedItems.addListChangeListener(clearSelectedItems); } }; selectedItems.addListChangeListener(new IListChangeListener() { @Override public void handleListChange(ListChangeEvent arg0) { unselect.setEnabled(!selectedItems.isEmpty()); } }); selectedItems.addListChangeListener(clearUnselectedItems); unselectedItems.addListChangeListener(new IListChangeListener() { @Override public void handleListChange(ListChangeEvent arg0) { select.setEnabled(!unselectedItems.isEmpty()); } }); unselectedItems.addListChangeListener(clearSelectedItems); btnUp.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (selectedList.getSelectionIndex() > 0) { int selectIndex = selectedList.getSelectionIndex(); String selected = selectedList.getItem(selectIndex); String temp = selectedList.getItem(selectIndex - 1); selectedList.setItem(selectIndex, temp); selectedList.setItem(selectIndex - 1, selected); selectedList.setSelection(selectIndex - 1); } } }); btnDown.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (selectedList.getSelectionIndex() < selectedList.getItemCount() - 1) { int selectIndex = selectedList.getSelectionIndex(); String selected = selectedList.getItem(selectIndex); String temp = selectedList.getItem(selectIndex + 1); selectedList.setItem(selectIndex + 1, selected); selectedList.setItem(selectIndex, temp); selectedList.setSelection(selectIndex + 1); } } }); }
From source file:uk.ac.stfc.isis.ibex.ui.synoptic.editor.instrument.InstrumentTreeView.java
License:Open Source License
private void bind() { DataBindingContext cnt = new DataBindingContext(); cnt.bindList(ViewerProperties.multipleSelection().observe(treeViewer), BeanProperties.list("selectedComponents").observe(synopticViewModel)); // Set menu items to disabled under some selections synopticViewModel.addPropertyChangeListener("selectedComponents", new PropertyChangeListener() { @Override/* ww w. java 2s.com*/ public void propertyChange(PropertyChangeEvent evt) { List<ComponentDescription> selected = synopticViewModel.getSelectedComponents(); mnuDeleteSelected.setEnabled(selected != null && !selected.isEmpty()); mnuCopySelected.setEnabled( selected != null && !selected.isEmpty() && synopticViewModel.selectedHaveSameParent()); } }); // Delete and copy key treeViewer.getTree().addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { synopticViewModel.removeSelectedComponent(); } else if ((e.stateMask == SWT.CTRL) && (e.keyCode == 'c')) { synopticViewModel.copySelectedComponent(); } } }); }