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 128470 Details for
Bug 268135
[Viewers] [CellEditors] Table with SWT.MULTI and TableViewerEditor problem
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.
Test snippet
Snippet036FocusBorderCellHighlighter.java (text/plain), 6.84 KB, created by
Thomas Schindl
on 2009-03-11 18:42:24 EDT
(
hide
)
Description:
Test snippet
Filename:
MIME Type:
Creator:
Thomas Schindl
Created:
2009-03-11 18:42:24 EDT
Size:
6.84 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 > *******************************************************************************/ > >package org.eclipse.jface.snippets.viewers; > >import org.eclipse.jface.resource.FontRegistry; >import org.eclipse.jface.viewers.CellEditor; >import org.eclipse.jface.viewers.ColumnViewerEditor; >import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent; >import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; >import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter; >import org.eclipse.jface.viewers.ICellModifier; >import org.eclipse.jface.viewers.IStructuredContentProvider; >import org.eclipse.jface.viewers.ITableColorProvider; >import org.eclipse.jface.viewers.ITableFontProvider; >import org.eclipse.jface.viewers.ITableLabelProvider; >import org.eclipse.jface.viewers.LabelProvider; >import org.eclipse.jface.viewers.TableViewer; >import org.eclipse.jface.viewers.TableViewerEditor; >import org.eclipse.jface.viewers.TableViewerFocusCellManager; >import org.eclipse.jface.viewers.TextCellEditor; >import org.eclipse.jface.viewers.Viewer; >import org.eclipse.jface.viewers.ViewerCell; >import org.eclipse.swt.SWT; >import org.eclipse.swt.graphics.Color; >import org.eclipse.swt.graphics.Font; >import org.eclipse.swt.graphics.Image; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Shell; >import org.eclipse.swt.widgets.TableColumn; > >/** > * Example of a different focus cell rendering with a simply focus border > * > * @author Tom Schindl <tom.schindl@bestsolution.at> > * > */ >public class Snippet036FocusBorderCellHighlighter { > > 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 static boolean flag = true; > > public class MyModel { > public int counter; > > public MyModel(int counter) { > this.counter = counter; > } > > public String toString() { > return "Item " + this.counter; > } > } > > public class MyLabelProvider extends LabelProvider implements > ITableLabelProvider, ITableFontProvider, ITableColorProvider { > FontRegistry registry = new FontRegistry(); > > public Image getColumnImage(Object element, int columnIndex) { > return null; > } > > public String getColumnText(Object element, int columnIndex) { > return "Column " + columnIndex + " => " + element.toString(); > } > > public Font getFont(Object element, int columnIndex) { > return null; > } > > public Color getBackground(Object element, int columnIndex) { > return null; > } > > public Color getForeground(Object element, int columnIndex) { > return null; > } > > } > > public Snippet036FocusBorderCellHighlighter(final Shell shell) { > final TableViewer v = new TableViewer(shell, SWT.BORDER|SWT.MULTI|SWT.FULL_SELECTION); > v.setLabelProvider(new MyLabelProvider()); > v.setContentProvider(new MyContentProvider()); > > v.setCellEditors(new CellEditor[] { new TextCellEditor(v.getTable()), new TextCellEditor(v.getTable()), new TextCellEditor(v.getTable()) }); > v.setCellModifier(new ICellModifier() { > > public boolean canModify(Object element, String property) { > return true; > } > > public Object getValue(Object element, String property) { > return "Column " + property + " => " + element.toString(); > } > > public void modify(Object element, String property, Object value) { > > } > > }); > > v.setColumnProperties(new String[] {"1","2","3"}); > > TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(v,new FocusCellOwnerDrawHighlighter(v) { > protected Color getUnselectedCellBackgroundColor(ViewerCell cell) { > return shell.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION); > } > > protected Color getUnselectedCellForegroundColor(ViewerCell cell) { > return shell.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT); > } > > protected Color getSelectedCellBackgroundColor(ViewerCell cell) { > return shell.getDisplay().getSystemColor(SWT.COLOR_BLUE); > } > > protected Color getSelectedCellForegroundColor(ViewerCell cell) { > return shell.getDisplay().getSystemColor(SWT.COLOR_WHITE); > } > }); > ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(v) { > protected boolean isEditorActivationEvent( > ColumnViewerEditorActivationEvent event) { > return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL > || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION > || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) > || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; > } > }; > > TableViewerEditor.create(v, focusCellManager, actSupport, ColumnViewerEditor.TABBING_HORIZONTAL > | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR > | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION); > > > TableColumn column = new TableColumn(v.getTable(), SWT.NONE); > column.setWidth(200); > column.setMoveable(true); > column.setText("Column 1"); > > column = new TableColumn(v.getTable(), SWT.NONE); > column.setWidth(200); > column.setMoveable(true); > column.setText("Column 2"); > > column = new TableColumn(v.getTable(), SWT.NONE); > column.setWidth(200); > column.setMoveable(true); > column.setText("Column 3"); > > > MyModel[] model = createModel(); > v.setInput(model); > v.getTable().setLinesVisible(true); > v.getTable().setHeaderVisible(true); > } > > private MyModel[] createModel() { > MyModel[] elements = new MyModel[10]; > > for (int i = 0; i < 10; i++) { > elements[i] = new MyModel(i); > } > > return elements; > } > > /** > * @param args > */ > public static void main(String[] args) { > Display display = new Display(); > > Shell shell = new Shell(display); > shell.setLayout(new FillLayout()); > new Snippet036FocusBorderCellHighlighter(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 268135
:
128469
| 128470 |
197612
|
211087