annotate jface/snippets/Snippet040TableViewerSorting.d @ 88:9ed020f0c2a5

Fix the snippet040 example
author Frank Benoit <benoit@tionex.de>
date Mon, 19 May 2008 14:30:49 +0200
parents 604fa1feb76a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2006 Tom Schindl and others.
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * Tom Schindl - initial API and implementation
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * yidabu at gmail dot com ( D China http://www.d-programming-language-china.org/ )
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module jface.snippets.Snippet040TableViewerSorting;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15 // http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.snippets/Eclipse%20JFace%20Snippets/org/eclipse/jface/snippets/viewers/Snippet040TableViewerSorting.java?view=markup
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17 import dwtx.jface.viewers.CellEditor;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 import dwtx.jface.viewers.ColumnLabelProvider;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19 import dwtx.jface.viewers.ColumnViewer;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import dwtx.jface.viewers.EditingSupport;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import dwtx.jface.viewers.IStructuredContentProvider;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22 import dwtx.jface.viewers.TableViewer;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 import dwtx.jface.viewers.TableViewerColumn;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 import dwtx.jface.viewers.TextCellEditor;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 import dwtx.jface.viewers.Viewer;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 import dwtx.jface.viewers.ViewerComparator;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 import dwt.DWT;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 import dwt.events.SelectionAdapter;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 import dwt.events.SelectionEvent;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30 import dwt.layout.FillLayout;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 import dwt.widgets.Display;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 import dwt.widgets.Shell;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 import dwt.dwthelper.utils;
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
34
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 /**
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 * Example usage of ViewerComparator in tables to allow sorting
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 *
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 * @author Tom Schindl <tom.schindl@bestsolution.at>
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 *
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 */
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 void main(String[] args) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 Snippet040TableViewerSorting.main(args);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 private class MyContentProvider : IStructuredContentProvider {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 public Object[] getElements(Object inputElement) {
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
49 return (cast(ArrayWrapperT!(Person)) inputElement).array;
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52 public void dispose() {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60 public class Person {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 public String givenname;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 public String surname;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63 public String email;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 public this(String givenname, String surname, String email) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 this.givenname = givenname;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 this.surname = surname;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 this.email = email;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 protected abstract class AbstractEditingSupport : EditingSupport {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 private TextCellEditor editor;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 public this(TableViewer viewer) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77 super(viewer);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
78 this.editor = new TextCellEditor(viewer.getTable());
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
80
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
81 protected bool canEdit(Object element) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
82 return true;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
83 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
84
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
85 protected CellEditor getCellEditor(Object element) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
86 return editor;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
87 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89 protected void setValue(Object element, Object value) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90 doSetValue(element, value);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 getViewer().update(element, null);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
93
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
94 protected abstract void doSetValue(Object element, Object value);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
96
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
97 private abstract class ColumnViewerSorter : ViewerComparator {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
98 public static final int ASC = 1;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
99
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
100 public static final int NONE = 0;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
101
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
102 public static final int DESC = -1;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
103
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
104 private int direction = 0;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
105
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
106 private TableViewerColumn column;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
107
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
108 private ColumnViewer viewer;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
109
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
110 public this(ColumnViewer viewer_, TableViewerColumn column_) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
111 this.column = column_;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
112 this.viewer = viewer_;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
113 this.column.getColumn().addSelectionListener(new class() SelectionAdapter {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
114 public void widgetSelected(SelectionEvent e) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
115 this.outer.widgetSelected(e);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
116 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
117 });
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
118 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
119
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
120 private void widgetSelected(SelectionEvent e){
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
121 if( viewer.getComparator() !is null ) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
122 if( viewer.getComparator() is this ) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
123 int tdirection = direction;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
124
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
125 if( tdirection is ASC ) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
126 setSorter(this, DESC);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
127 } else if( tdirection is DESC ) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
128 setSorter(this, NONE);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
129 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
130 } else {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
131 setSorter(this, ASC);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
132 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
133 } else {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
134 setSorter(this, ASC);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
135 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
136 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
137 public void setSorter(ColumnViewerSorter sorter, int direction) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
138 if( direction is NONE ) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
139 column.getColumn().getParent().setSortColumn(null);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
140 column.getColumn().getParent().setSortDirection(DWT.NONE);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
141 viewer.setComparator(null);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
142 } else {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
143 column.getColumn().getParent().setSortColumn(column.getColumn());
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
144 sorter.direction = direction;
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
145
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
146 if( direction is ASC ) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
147 column.getColumn().getParent().setSortDirection(DWT.DOWN);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
148 } else {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
149 column.getColumn().getParent().setSortDirection(DWT.UP);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
150 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
151
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
152 if( viewer.getComparator() is sorter ) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
153 viewer.refresh();
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
154 } else {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
155 viewer.setComparator(sorter);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
156 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
157
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
158 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
159 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
160
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
161 public int compare(Viewer viewer, Object e1, Object e2) {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
162 return direction * doCompare(viewer, e1, e2);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
163 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
164
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
165 protected abstract int doCompare(Viewer viewer, Object e1, Object e2);
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
166 }
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
167
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
168 public class Snippet040TableViewerSorting {
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
169
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
170
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
171 public this(Shell shell) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
172 TableViewer v = new TableViewer(shell, DWT.BORDER | DWT.FULL_SELECTION);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173 v.setContentProvider(new MyContentProvider());
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175 TableViewerColumn column = new TableViewerColumn(v, DWT.NONE);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 column.getColumn().setWidth(200);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177 column.getColumn().setText("Givenname");
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
178 column.getColumn().setMoveable(true);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
179 column.setLabelProvider(new class() ColumnLabelProvider {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
180 public String getText(Object element) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
181 return (cast(Person) element).givenname;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
184
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
185 column.setEditingSupport(new class(v) AbstractEditingSupport {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
186 public this(TableViewer t ){
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
187 super(t);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
188 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
189 protected Object getValue(Object element) {
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
190 return new ArrayWrapperString((cast(Person) element).givenname);
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
191 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
192 protected void doSetValue(Object element, Object value) {
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
193 (cast(Person) element).givenname = stringcast(value);
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
194 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
195 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
196
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
197 ColumnViewerSorter cSorter = new class(v,column) ColumnViewerSorter {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
198 this(TableViewer t, TableViewerColumn c ){
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
199 super(t,c);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
200 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
201 protected int doCompare(Viewer viewer, Object e1, Object e2) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
202 Person p1 = cast(Person) e1;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
203 Person p2 = cast(Person) e2;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
204 return p1.givenname.compareToIgnoreCase(p2.givenname);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
205 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
206 };
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
207
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
208 column = new TableViewerColumn(v, DWT.NONE);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
209 column.getColumn().setWidth(200);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
210 column.getColumn().setText("Surname");
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
211 column.getColumn().setMoveable(true);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
212 column.setLabelProvider(new class() ColumnLabelProvider {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
213 public String getText(Object element) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
214 return (cast(Person) element).surname;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
215 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
216 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
217
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
218 column.setEditingSupport(new class(v) AbstractEditingSupport {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
219 this(TableViewer t ){
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
220 super(t);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
221 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
222 protected Object getValue(Object element) {
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
223 return stringcast((cast(Person) element).surname);
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
224 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
225 protected void doSetValue(Object element, Object value) {
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
226 (cast(Person) element).surname = stringcast(value);
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
227 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
228 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
229
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
230 new class(v,column) ColumnViewerSorter {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
231 this(TableViewer t, TableViewerColumn c ){
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
232 super(t,c);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
233 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
234 protected int doCompare(Viewer viewer, Object e1, Object e2) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
235 Person p1 = cast(Person) e1;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
236 Person p2 = cast(Person) e2;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
237 return p1.surname.compareToIgnoreCase(p2.surname);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
238 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
239 };
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
240
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
241 column = new TableViewerColumn(v, DWT.NONE);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
242 column.getColumn().setWidth(200);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
243 column.getColumn().setText("E-Mail");
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
244 column.getColumn().setMoveable(true);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
245 column.setLabelProvider(new class() ColumnLabelProvider {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
246 public String getText(Object element) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
247 return (cast(Person) element).email;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
248 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
249 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
250
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
251 column.setEditingSupport(new class(v) AbstractEditingSupport {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
252 this(TableViewer t ){
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
253 super(t);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
254 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
255 protected Object getValue(Object element) {
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
256 return stringcast((cast(Person) element).email);
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
257 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
258 protected void doSetValue(Object element, Object value) {
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
259 (cast(Person) element).email = stringcast(value);
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
260 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
261 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
262 new class(v,column) ColumnViewerSorter {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
263 this(TableViewer t, TableViewerColumn c ){
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
264 super(t,c);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
265 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
266 protected int doCompare(Viewer viewer, Object e1, Object e2) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
267 Person p1 = cast(Person) e1;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
268 Person p2 = cast(Person) e2;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
269 return p1.email.compareToIgnoreCase(p2.email);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
270 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
271 };
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
272
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
273 Person[] model = createModel();
88
9ed020f0c2a5 Fix the snippet040 example
Frank Benoit <benoit@tionex.de>
parents: 87
diff changeset
274 v.setInput( new ArrayWrapperT!(Person)(model));
87
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
275 v.getTable().setLinesVisible(true);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
276 v.getTable().setHeaderVisible(true);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
277 cSorter.setSorter(cSorter, ColumnViewerSorter.ASC);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
278 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
279
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
280 private Person[] createModel() {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
281 Person[] elements = new Person[4];
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
282 elements[0] = new Person("Tom", "Schindl",
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
283 "tom.schindl@bestsolution.at");
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
284 elements[1] = new Person("Boris", "Bokowski",
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
285 "Boris_Bokowski@ca.ibm.com");
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
286 elements[2] = new Person("Tod", "Creasey", "Tod_Creasey@ca.ibm.com");
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
287 elements[3] = new Person("Wayne", "Beaton", "wayne@eclipse.org");
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
288
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
289 return elements;
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
290 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
291
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
292 /**
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
293 * @param args
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
294 */
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
295 public static void main(String[] args) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
296 Display display = new Display();
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
297
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
298 Shell shell = new Shell(display);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
299 shell.setLayout(new FillLayout());
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
300 new Snippet040TableViewerSorting(shell);
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
301 shell.open();
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
302
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
303 while (!shell.isDisposed()) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
304 if (!display.readAndDispatch())
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
305 display.sleep();
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
306 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
307 display.dispose();
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
308 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
309
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
310 }