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 12980 Details for
Bug 61869
[JFace] JFace does not reflect the new color options for SWT Table and tree
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.
Standalone class displaying the benefits of a ITableColorProvider
(text/plain), 5.23 KB, created by
Gunnar Ahlberg
on 2004-07-06 09:20:58 EDT
(
hide
)
Description:
Standalone class displaying the benefits of a ITableColorProvider
Filename:
MIME Type:
Creator:
Gunnar Ahlberg
Created:
2004-07-06 09:20:58 EDT
Size:
5.23 KB
patch
obsolete
>/* > * Contributed by Gunnar Ahlberg (www.gunnarahlberg.com) > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/cpl-v10.html > * > * Contributors: > * Gunnar Ahlberg - www.gunnarahlberg.com > *******************************************************************************/ > > >import org.eclipse.swt.widgets.Composite; >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.ui.part.*; >import org.eclipse.jface.viewers.*; >import org.eclipse.swt.events.DisposeEvent; >import org.eclipse.swt.events.DisposeListener; >import org.eclipse.swt.graphics.Color; >import org.eclipse.swt.graphics.Image; >import org.eclipse.swt.layout.FillLayout; >import org.eclipse.jface.action.*; >import org.eclipse.jface.dialogs.MessageDialog; >import org.eclipse.ui.*; >import org.eclipse.swt.widgets.Menu; >import org.eclipse.swt.SWT; > > >public class ITableColorProviderTest { > private TableViewer viewer; > > class Content { > String text1 = ""; > String text2 = ""; > > /** > * @param text1 > * @param text2 > */ > public Content(String text1, String text2) { > super(); > this.text1 = text1; > this.text2 = text2; > } > /** > * @return Returns the text1. > */ > public String getText1() { > return text1; > } > /** > * @param text1 The text1 to set. > */ > public void setText1(String text1) { > this.text1 = text1; > } > /** > * @return Returns the text2. > */ > public String getText2() { > return text2; > } > /** > * @param text2 The text2 to set. > */ > public void setText2(String text2) { > this.text2 = text2; > } > > } > class ViewContentProvider implements IStructuredContentProvider { > public void inputChanged(Viewer v, Object oldInput, Object newInput) { > } > public void dispose() { > } > public Object[] getElements(Object parent) { > Content[] content = new Content[3]; > for (int i = 0; i < content.length; i++) { > String pre = "" + i + ":"; > content[i] = new Content(pre+1, pre+2); > > } > return content; > } > } > class ViewLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider, DisposeListener { > Color red = null; > Color green = null; > > /** > * > */ > public ViewLabelProvider() { > super(); > red = new Color(Display.getCurrent(), 255, 0 ,0); > green = new Color(Display.getCurrent(), 0, 255,0); > } > public String getColumnText(Object obj, int index) { > Content content = ((Content)obj); > if(index == 0) > return content.getText1(); > else > return content.getText2(); > > } > public Image getColumnImage(Object obj, int index) { > return null; > } > > /* (non-Javadoc) > * @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int) > */ > public Color getForeground(Object element, int columnIndex) { > switch (columnIndex) { > case 0: > return green; > > default: > return red; > } > } > /* (non-Javadoc) > * @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int) > */ > public Color getBackground(Object element, int columnIndex) { > switch (columnIndex) { > case 0: > return red; > default: > return green; > } > } > /* (non-Javadoc) > * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent) > */ > public void widgetDisposed(DisposeEvent e) { > red.dispose(); > green.dispose(); > > } > } > > > /** > * The constructor. > */ > public ITableColorProviderTest() { > } > > /** > * > */ > public void createPartControl(Composite parent) { > viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); > Table table = viewer.getTable(); > TableColumn column = new TableColumn(table, SWT.LEFT); > column.setText("Column 1"); > column.setWidth(100); > column = new TableColumn(table, SWT.LEFT); > column.setText("Column 2"); > column.setWidth(100); > table.setHeaderVisible(true); > table.setLinesVisible(true); > viewer.setContentProvider(new ViewContentProvider()); > viewer.setLabelProvider(new ViewLabelProvider()); > viewer.setInput(""); > parent.addDisposeListener((ViewLabelProvider)viewer.getLabelProvider()); > } > > public static void main(String[] args) { > Display dsp = new Display(); > Shell shell = new Shell(); > > shell.setLayout(new FillLayout()); > new ITableColorProviderTest().createPartControl(shell); > shell.pack(); > shell.open(); > while(shell.isDisposed() == false) { > dsp.readAndDispatch(); > } > shell.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 61869
:
12979
| 12980 |
12981