annotate jface/snippets/Snippet040TableViewerSorting.d @ 87:604fa1feb76a

Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
author Frank Benoit <benoit@tionex.de>
date Mon, 19 May 2008 13:56:25 +0200
parents
children 9ed020f0c2a5
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
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 // 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
17
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.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
19 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
20 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
21 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
22 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
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30 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
31 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
32 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
33 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
34 import dwt.dwthelper.utils;
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 public class 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
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 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
49
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 public Object[] getElements(Object inputElement) {
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 return cast (Person[]) inputElement;
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 }
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 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
55 }
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 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
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 }
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
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 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
63 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
64 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
65 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
66
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 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
68 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
69 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
70 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
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 }
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
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 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
76 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
77
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 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
79 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
80 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
81 }
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
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 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
84 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
85 }
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
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 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
88 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
89 }
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
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 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
92 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
93 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
94 }
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 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
97 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
98
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
99 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
100 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
101 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
102
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 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
114 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
115 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
116 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117 protected Object getValue(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
118 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
119 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120 protected 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
121 (cast(Person) element).givenname = value.toString();
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 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
126 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
127 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
128 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129 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
130 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
131 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
132 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
133 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134 };
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
145
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
146 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
147 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
148 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
149 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
150 protected Object getValue(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
151 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
152 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
153 protected 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
154 (cast(Person) element).surname = value.toString();
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
157
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
158 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
159 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
160 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
161 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 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
163 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
164 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
165 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
166 }
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 };
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 }
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 });
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
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.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
180 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
181 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
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 protected Object getValue(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
184 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
185 }
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 protected 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
187 (cast(Person) element).email = value.toString();
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 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
190 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
191 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
192 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
193 }
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 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
195 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
196 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
197 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
198 }
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 };
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 Person[] model = 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
202 v.setInput(model);
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 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
204 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
205 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
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 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
209 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
210 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
211 "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
212 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
213 "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
214 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
215 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
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 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
218 }
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
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 private static abstract class ColumnViewerSorter : 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
221 public static final int ASC = 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
222
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
223 public static final int NONE = 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
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 public static final int DESC = -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
226
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 private int direction = 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
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 private TableViewerColumn column;
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
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 private ColumnViewer 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
232
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 public this(ColumnViewer viewer_, TableViewerColumn column_) {
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 this.column = column_;
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 this.viewer = 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
236 this.column.getColumn().addSelectionListener(new class() 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
237
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 public void widgetSelected(SelectionEvent e) {
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 if( this.viewer.getComparator() !is 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
240 if( this.viewer.getComparator() == this ) {
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 int tdirection = this.direction;
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
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 if( tdirection == 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
244 setSorter(this, DESC);
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 } else if( tdirection == DESC ) {
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 setSorter(this, 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
247 }
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 } else {
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 setSorter(this, 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
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 } else {
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 setSorter(this, 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
253 }
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 });
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
256 }
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 public void setSorter(ColumnViewerSorter sorter, int direction) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
259 if( direction == 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
260 column.getColumn().getParent().setSortColumn(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
261 column.getColumn().getParent().setSortDirection(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
262 viewer.setComparator(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
263 } else {
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 column.getColumn().getParent().setSortColumn(column.getColumn());
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 sorter.direction = direction;
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
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 if( direction == 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
268 column.getColumn().getParent().setSortDirection(DWT.DOWN);
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 } else {
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 column.getColumn().getParent().setSortDirection(DWT.UP);
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 if( viewer.getComparator() == sorter ) {
604fa1feb76a Added jface snippet040, thanks to yidabu. It still has compile problems, that need further examination.
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
274 viewer.refresh();
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 } else {
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 viewer.setComparator(sorter);
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 }
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 }
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
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 public int compare(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
283 return direction * doCompare(viewer, e1, 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
284 }
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
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 protected abstract 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
287 }
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 /**
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 * @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
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 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
293 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
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 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
296 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
297 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
298 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
299
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 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
301 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
302 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
303 }
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 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
305 }
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 }