|
Lines 25-31
Link Here
|
| 25 |
import org.eclipse.swt.graphics.Rectangle; |
25 |
import org.eclipse.swt.graphics.Rectangle; |
| 26 |
import org.eclipse.swt.widgets.Composite; |
26 |
import org.eclipse.swt.widgets.Composite; |
| 27 |
import org.eclipse.swt.widgets.Control; |
27 |
import org.eclipse.swt.widgets.Control; |
|
|
28 |
import org.eclipse.swt.widgets.Event; |
| 28 |
import org.eclipse.swt.widgets.Item; |
29 |
import org.eclipse.swt.widgets.Item; |
|
|
30 |
import org.eclipse.swt.widgets.Listener; |
| 29 |
import org.eclipse.swt.widgets.Table; |
31 |
import org.eclipse.swt.widgets.Table; |
| 30 |
import org.eclipse.swt.widgets.TableItem; |
32 |
import org.eclipse.swt.widgets.TableItem; |
| 31 |
import org.eclipse.swt.widgets.Widget; |
33 |
import org.eclipse.swt.widgets.Widget; |
|
Lines 46-51
Link Here
|
| 46 |
*/ |
48 |
*/ |
| 47 |
public class TableViewer extends StructuredViewer { |
49 |
public class TableViewer extends StructuredViewer { |
| 48 |
|
50 |
|
|
|
51 |
//A flag to indicate if the |
| 52 |
private boolean isVirtual = false; |
| 49 |
/** |
53 |
/** |
| 50 |
* Internal table viewer implementation. |
54 |
* Internal table viewer implementation. |
| 51 |
*/ |
55 |
*/ |
|
Lines 60-66
Link Here
|
| 60 |
* This viewer's table editor. |
64 |
* This viewer's table editor. |
| 61 |
*/ |
65 |
*/ |
| 62 |
private TableEditor tableEditor; |
66 |
private TableEditor tableEditor; |
| 63 |
|
67 |
|
| 64 |
/** |
68 |
/** |
| 65 |
* Creates a table viewer on a newly-created table control under the given |
69 |
* Creates a table viewer on a newly-created table control under the given |
| 66 |
* parent. The table control is created using the SWT style bits |
70 |
* parent. The table control is created using the SWT style bits |
|
Lines 100-108
Link Here
|
| 100 |
*/ |
104 |
*/ |
| 101 |
public TableViewer(Table table) { |
105 |
public TableViewer(Table table) { |
| 102 |
this.table = table; |
106 |
this.table = table; |
|
|
107 |
|
| 108 |
isVirtual = (table.getStyle() | SWT.VIRTUAL) > 0; |
| 103 |
hookControl(table); |
109 |
hookControl(table); |
| 104 |
tableEditor = new TableEditor(table); |
110 |
tableEditor = new TableEditor(table); |
| 105 |
initTableViewerImpl(); |
111 |
initTableViewerImpl(); |
|
|
112 |
|
| 113 |
if(isVirtual) |
| 114 |
table.addListener(SWT.SetData, new Listener() { |
| 115 |
public void handleEvent(Event e) { |
| 116 |
TableItem item = (TableItem)e.item; |
| 117 |
Object element = item.getData(); |
| 118 |
updateItem(item, element); |
| 119 |
} |
| 120 |
}); |
| 121 |
|
| 106 |
} |
122 |
} |
| 107 |
|
123 |
|
| 108 |
/** |
124 |
/** |
|
Lines 124-132
Link Here
|
| 124 |
for (int i = 0; i < filtered.length; i++) { |
140 |
for (int i = 0; i < filtered.length; i++) { |
| 125 |
Object element = filtered[i]; |
141 |
Object element = filtered[i]; |
| 126 |
int index = indexForElement(element); |
142 |
int index = indexForElement(element); |
| 127 |
updateItem(new TableItem(getTable(), SWT.NONE, index), element); |
143 |
TableItem newItem = new TableItem(getTable(), SWT.NONE, index); |
|
|
144 |
if(isVirtual) |
| 145 |
newItem.setData(element); |
| 146 |
else |
| 147 |
updateItem(newItem, element); |
| 128 |
} |
148 |
} |
| 129 |
} |
149 |
} |
|
|
150 |
|
| 151 |
|
| 130 |
|
152 |
|
| 131 |
/** |
153 |
/** |
| 132 |
* Adds the given element to this table viewer. If this viewer does not have |
154 |
* Adds the given element to this table viewer. If this viewer does not have |