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 89488 Details for
Bug 174739
[Viewers] TableViewer - Combo cell editor - on single click needs to open
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
A test snippet
Snippet027ComboBoxCellEditors.java (text/plain), 4.74 KB, created by
Thomas Schindl
on 2008-02-12 07:35:37 EST
(
hide
)
Description:
A test snippet
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2008-02-12 07:35:37 EST
Size:
4.74 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2006 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 > * Dinko Ivanov - bug 164365 > *******************************************************************************/ > >package org.eclipse.jface.snippets.viewers; > >import org.eclipse.jface.viewers.CellEditor; >import org.eclipse.jface.viewers.ComboBoxCellEditor; >import org.eclipse.jface.viewers.ICellModifier; >import org.eclipse.jface.viewers.IStructuredContentProvider; >import org.eclipse.jface.viewers.LabelProvider; >import org.eclipse.jface.viewers.TableViewer; >import org.eclipse.jface.viewers.Viewer; >import org.eclipse.swt.SWT; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.Table; >import org.eclipse.swt.widgets.TableColumn; >import org.eclipse.swt.widgets.TableItem; > >/** > * This snippet represents usage of the ComboBoxCell-Editor > * > * @author Tom Schindl <tom.schindl@bestsolution.at> > * > */ >public class Snippet027ComboBoxCellEditors { > private class MyCellModifier implements ICellModifier { > > private TableViewer viewer; > > public MyCellModifier(TableViewer viewer) { > this.viewer = viewer; > } > > /* > * (non-Javadoc) > * > * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, > * java.lang.String) > */ > public boolean canModify(Object element, String property) { > return true; > } > > /* > * (non-Javadoc) > * > * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, > * java.lang.String) > */ > public Object getValue(Object element, String property) { > // We need to calculate back to the index > return new Integer(((MyModel) element).counter / 10); > } > > /* > * (non-Javadoc) > * > * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, > * java.lang.String, java.lang.Object) > */ > public void modify(Object element, String property, Object value) { > TableItem item = (TableItem) element; > // We get the index and need to calculate the real value > ((MyModel) item.getData()).counter = ((Integer) value).intValue() * 10; > viewer.update(item.getData(), null); > } > } > > private class MyContentProvider implements IStructuredContentProvider { > > /* > * (non-Javadoc) > * > * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) > */ > public Object[] getElements(Object inputElement) { > return (MyModel[]) inputElement; > } > > /* > * (non-Javadoc) > * > * @see org.eclipse.jface.viewers.IContentProvider#dispose() > */ > public void dispose() { > > } > > /* > * (non-Javadoc) > * > * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, > * java.lang.Object, java.lang.Object) > */ > public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { > > } > > } > > public class MyModel { > public int counter; > > public MyModel(int counter) { > this.counter = counter; > } > > public String toString() { > return "Item " + this.counter; > } > } > > public Snippet027ComboBoxCellEditors(Shell shell) { > final Table table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION); > final TableViewer v = new TableViewer(table); > final MyCellModifier modifier = new MyCellModifier(v); > > TableColumn column = new TableColumn(table, SWT.NONE); > column.setWidth(200); > > v.setLabelProvider(new LabelProvider()); > v.setContentProvider(new MyContentProvider()); > v.setCellModifier(modifier); > v.setColumnProperties(new String[] { "column1" }); > ComboBoxCellEditor cs = new ComboBoxCellEditor( > v.getTable(), new String[] { "Zero", "Ten", "Twenty", "Thirty", > "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", > "Ninety" }); > cs.setActivationStyle(ComboBoxCellEditor.DROP_DOWN_ON_MOUSE_ACTIVATION); > v.setCellEditors(new CellEditor[] { cs }); > > MyModel[] model = createModel(); > v.setInput(model); > v.getTable().setLinesVisible(true); > } > > private MyModel[] createModel() { > MyModel[] elements = new MyModel[10]; > > for (int i = 0; i < 10; i++) { > elements[i] = new MyModel(i * 10); > } > > return elements; > } > > /** > * @param args > */ > public static void main(String[] args) { > Display display = new Display(); > Shell shell = new Shell(display); > shell.setLayout(new FillLayout()); > new Snippet027ComboBoxCellEditors(shell); > shell.open(); > > while (!shell.isDisposed()) { > if (!display.readAndDispatch()) > display.sleep(); > } > > display.dispose(); > > } > >}
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 174739
:
89487
| 89488 |
89489
|
89490