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 5236 Details for
Bug 15054
OwnerData or "virtual" Table support
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.
An improved version of TableVirtual
TableVirtual.java (text/plain), 5.48 KB, created by
Michael Scharf
on 2003-06-18 22:30:12 EDT
(
hide
)
Description:
An improved version of TableVirtual
Filename:
MIME Type:
Creator:
Michael Scharf
Created:
2003-06-18 22:30:12 EDT
Size:
5.48 KB
patch
obsolete
>/** > * @author Kosta > * @author Michael.Scharf@windriver.com > * source http://sourceforge.net/projects/eclipsecolorer/ > * Component Library > * Modifications my Michael.Scharf@windriver.com > */ >package org.eclipse.swt.widgets; >import org.eclipse.swt.SWT; >import org.eclipse.swt.graphics.Image; >import org.eclipse.swt.internal.win32.LRESULT; >import org.eclipse.swt.internal.win32.LVITEM; >import org.eclipse.swt.internal.win32.NMHDR; >import org.eclipse.swt.internal.win32.NMLISTVIEW; >import org.eclipse.swt.internal.win32.OS; >import org.eclipse.swt.internal.win32.TCHAR; >public class TableVirtual extends Table { > /** > * Interface to a virtual table label provider. > * @author Michael.Scharf@windriver.com > */ > public interface IVirtualTableLabelProvider { > /** > * Get the text associated with a specifeid table cell. > * @param row > * @param column > * @return null or the text to be displayed in this cell. The text length will be > * truncated at 256 characters. > */ > String getColumnText(int row, int column); > /** > * Get the image associated with a specifeid table cell. > * @param row > * @param column > * @return null or the icon to be displayed in this cell. > */ > Image getColumnImage(int row, int column); > }; > private IVirtualTableLabelProvider m_LabelProvider; > public TableVirtual(Composite parent, int style) { > super(parent, checkStyle(style)); > } > /** > * Sets the virtual lable provider for this VirtualTable. > * @param labelProvider > */ > public void setVirtualLabelProvider(IVirtualTableLabelProvider labelProvider) { > m_LabelProvider = labelProvider; > } > int widgetStyle() { > int bits = super.widgetStyle(); > bits |= 0x1000; > return bits; > } > void createItem(TableItem item, int index) { > // DO NOTHING! > // This is called by the constructor of TableItem and > // has some sideeffects we don't want for virtual tables... > } > /** > * Create sets the number of rows of the virtual table. > * @param cnt The number of cells of the virtual table. > */ > public void createItems(int cnt) { > // To save memory we allocate only ONE TableItam and share > // it for all cells. This is a trick to avoid the use of too much > // memory. Obvouisly, this breaks all TableItem related methods > // inherited from Table. > // TODO eliminate items totally and build a pure virtual table without the > // heritage of TableItem. > > // The allocation of items unnecessary memory overdead, > // but needed because Table relys on it. > items = new TableItem[cnt]; > TableItem item = makeTableItem(0); > for (int i = 0; i < cnt; i++) { > // Comment this in to see the memory consumption difference... > // item = makeTableItem(i); > items[i] = item; > } > // > OS.SendMessage(handle, 0x1000 + 47, cnt, 0); // LVM_SETITEMCOUNT > } > /** > * A little helper method to create TableItems > * @param i > * @return a new TableItem for position i > */ > private TableItem makeTableItem(int i) { > LVITEM lvItem = new LVITEM(); > lvItem.iItem = i; > lvItem.iImage = OS.I_IMAGENONE; > lvItem.mask = OS.LVIF_IMAGE; > TableItem item=new TableItem(this, SWT.NONE); > return item; > } > LRESULT wmNotifyChild(int wParam, int lParam) { > NMHDR hdr = new NMHDR(); > OS.MoveMemory(hdr, lParam, NMHDR.sizeof); > switch (hdr.code) { > case 0xFFFFFF4F: // LVN_GETDISPINFOW wide strings > //case 0xFFFFFF6A: // LVN_GETDISPINFOA win95 no wide strings (is this needed???) > // see Microsoft Visual Studio/VC98/Include/COMMCTRL.H > { > NMLISTVIEW pnmlv = new NMLISTVIEW(); > OS.MoveMemory(pnmlv, lParam, NMLISTVIEW.sizeof); > // > int item = pnmlv.iSubItem; > int column = pnmlv.uNewState; > if ((pnmlv.iItem & OS.LVIF_IMAGE) != 0) { > if ((m_LabelProvider != null) /*&& (column == 0)*/) { > Image image = m_LabelProvider.getColumnImage(item, column); > if (image != null) { > // because we don't have the datastructure > // we fake setting the icon integer by mapping it > // to an array of int > int[] data = new int[NMLISTVIEW.sizeof / 4]; > OS.MoveMemory(data, lParam, NMLISTVIEW.sizeof); > // 10 is the position of the iImage > data[10] = imageIndex(image); > OS.MoveMemory(lParam, data, NMLISTVIEW.sizeof); > } > } > } > if ((pnmlv.iItem & OS.LVIF_TEXT) != 0) { > String string=null; > if (m_LabelProvider != null) > string = m_LabelProvider.getColumnText(item, column); > if(string!=null) { > if (string.length() > 256) > string = string.substring(0, 256); > TCHAR buffer = new TCHAR(getCodePage(), string, true); > int byteCount = buffer.length() * TCHAR.sizeof; > OS.MoveMemory(pnmlv.x, buffer, byteCount); > } > } > } > } // switch > return super.wmNotifyChild(wParam, lParam); > } > public void selectItem(int item) { > OS.SendMessage(handle, OS.LVM_GETITEMSTATE, item, OS.LVIS_SELECTED | OS.LVIS_FOCUSED); > LVITEM lvItem = new LVITEM(); > lvItem.mask = OS.LVIF_STATE; > lvItem.stateMask = OS.LVIS_SELECTED | OS.LVIS_FOCUSED; > lvItem.state |= OS.LVIS_SELECTED | OS.LVIS_FOCUSED; > OS.SendMessage(handle, OS.LVM_SETITEMSTATE, item, lvItem); > } > /* (non-Javadoc) > * @see org.eclipse.swt.widgets.Widget#releaseWidget() > */ > void releaseWidget() { > // Table.releaseWidget for huge tables was very slow because > // it releases each of the virtual TableItams in items.... > // Therefore we set the number of tableitems to 0 ;-) > createItems(0); > super.releaseWidget(); > } > >}
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 15054
: 5236 |
5237