Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87254 Details for
Bug 215782
[DataBinding] [Snippet] Multi-Selection-Support-Snippet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
The Snippet
Snippet.java (text/plain), 3.71 KB, created by
Thomas Schindl
on 2008-01-18 07:41:00 EST
(
hide
)
Description:
The Snippet
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2008-01-18 07:41:00 EST
Size:
3.71 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2008 Tom Schindl and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: > * Tom Schindl - initial API and implementation > ******************************************************************************/ >import java.beans.PropertyChangeListener; >import java.beans.PropertyChangeSupport; >import java.util.ArrayList; > >import org.eclipse.core.databinding.DataBindingContext; >import org.eclipse.core.databinding.beans.BeansObservables; >import org.eclipse.core.databinding.observable.Realm; >import org.eclipse.core.databinding.observable.list.IObservableList; >import org.eclipse.jface.databinding.swt.SWTObservables; >import org.eclipse.jface.databinding.viewers.ViewersObservables; >import org.eclipse.jface.viewers.ArrayContentProvider; >import org.eclipse.jface.viewers.LabelProvider; >import org.eclipse.jface.viewers.ListViewer; >import org.eclipse.swt.SWT; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.layout.GridData; >import org.eclipse.swt.layout.GridLayout; >import org.eclipse.swt.widgets.Button; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Shell; > >/** > * Snippet to demonstrate multi-selection support added in 3.4 > */ >public class Snippet { > class Person { > private PropertyChangeSupport support = new PropertyChangeSupport(this); > private ArrayList fruits = new ArrayList(); > > public Person() { > > } > > public void addPropertyChangeListener(PropertyChangeListener listener) { > support.addPropertyChangeListener(listener); > } > > public void removePropertyChangeListener(PropertyChangeListener listener) { > support.removePropertyChangeListener(listener); > } > > public ArrayList getFruits() { > return fruits; > } > > public void setFruits(ArrayList fruits) { > this.fruits = fruits; > } > } > > class Fruit { > private String name; > > public Fruit(String name) { > this.name = name; > } > > public String toString() { > return name; > } > > } > > private Snippet(Shell shell) { > shell.setLayout(new GridLayout(1, false)); > > ArrayList fruits = new ArrayList(); > fruits.add(new Fruit("Mango")); > fruits.add(new Fruit("Orange")); > fruits.add(new Fruit("Banana")); > fruits.add(new Fruit("Grapes")); > > final Person p = new Person(); > > ListViewer viewer = new ListViewer(shell, SWT.BORDER | SWT.MULTI); > viewer.setLabelProvider(new LabelProvider()); > viewer.setContentProvider(new ArrayContentProvider()); > viewer.setInput(fruits); > viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); > > IObservableList mList = BeansObservables.observeList( > Realm.getDefault(), p, "fruits"); > IObservableList uList = ViewersObservables > .observeMultiSelection(viewer); > > DataBindingContext ctx = new DataBindingContext(); > ctx.bindList(uList, mList, null, null); > > Button button = new Button(shell, SWT.PUSH); > button.setText("Read content"); > button.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); > button.addSelectionListener(new SelectionAdapter() { > > public void widgetSelected(SelectionEvent e) { > System.err.println(p.getFruits()); > } > > }); > } > > public static void main(String[] args) { > final Display display = new Display(); > Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { > public void run() { > final Shell shell = new Shell(display); > new Snippet(shell); > shell.open(); > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) { > display.sleep(); > } > } > } > }); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 215782
: 87254