Mercurial > projects > dwt-mac
annotate dwt/custom/TreeEditor.d @ 150:1ec7c20355bd
Fixes #38
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Wed, 10 Jun 2009 20:51:17 +0200 |
parents | 07399639c0c8 |
children |
rev | line source |
---|---|
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
1 /******************************************************************************* |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
3 * All rights reserved. This program and the accompanying materials |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
5 * which accompanies this distribution, and is available at |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
6 * http://www.eclipse.org/legal/epl-v10.html |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
7 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
8 * Contributors: |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
9 * IBM Corporation - initial API and implementation |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
10 * Port to the D programming language: |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
11 * Frank Benoit <benoit@tionex.de> |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
12 *******************************************************************************/ |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
13 module dwt.custom.TreeEditor; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
14 |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
15 import dwt.dwthelper.utils; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
16 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
17 |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
18 import dwt.DWT; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
19 import dwt.events.ControlEvent; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
20 import dwt.events.ControlListener; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
21 import dwt.events.TreeEvent; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
22 import dwt.events.TreeListener; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
23 import dwt.graphics.Rectangle; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
24 import dwt.widgets.Control; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
25 import dwt.widgets.Display; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
26 import dwt.widgets.Tree; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
27 import dwt.widgets.TreeColumn; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
28 import dwt.widgets.TreeItem; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
29 import dwt.custom.ControlEditor; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
30 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
31 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
32 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
33 * A TreeEditor is a manager for a Control that appears above a cell in a Tree and tracks with the |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
34 * moving and resizing of that cell. It can be used to display a text widget above a cell |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
35 * in a Tree so that the user can edit the contents of that cell. It can also be used to display |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
36 * a button that can launch a dialog for modifying the contents of the associated cell. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
37 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
38 * <p> Here is an example of using a TreeEditor: |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
39 * <code><pre> |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
40 * final Tree tree = new Tree(shell, DWT.BORDER); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
41 * for (int i = 0; i < 3; i++) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
42 * TreeItem item = new TreeItem(tree, DWT.NONE); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
43 * item.setText("item " + i); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
44 * for (int j = 0; j < 3; j++) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
45 * TreeItem subItem = new TreeItem(item, DWT.NONE); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
46 * subItem.setText("item " + i + " " + j); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
47 * } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
48 * } |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
49 * |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
50 * final TreeEditor editor = new TreeEditor(tree); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
51 * //The editor must have the same size as the cell and must |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
52 * //not be any smaller than 50 pixels. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
53 * editor.horizontalAlignment = DWT.LEFT; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
54 * editor.grabHorizontal = true; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
55 * editor.minimumWidth = 50; |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
56 * |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
57 * tree.addSelectionListener(new SelectionAdapter() { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
58 * public void widgetSelected(SelectionEvent e) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
59 * // Clean up any previous editor control |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
60 * Control oldEditor = editor.getEditor(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
61 * if (oldEditor !is null) oldEditor.dispose(); |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
62 * |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
63 * // Identify the selected row |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
64 * TreeItem item = (TreeItem)e.item; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
65 * if (item is null) return; |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
66 * |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
67 * // The control that will be the editor must be a child of the Tree |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
68 * Text newEditor = new Text(tree, DWT.NONE); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
69 * newEditor.setText(item.getText()); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
70 * newEditor.addModifyListener(new ModifyListener() { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
71 * public void modifyText(ModifyEvent e) { |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
72 * Text text = (Text)editor.getEditor(); |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
73 * editor.getItem().setText(text.getText()); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
74 * } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
75 * }); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
76 * newEditor.selectAll(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
77 * newEditor.setFocus(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
78 * editor.setEditor(newEditor, item); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
79 * } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
80 * }); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
81 * </pre></code> |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
82 * |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
83 * @see <a href="http://www.eclipse.org/swt/snippets/#treeeditor">TreeEditor snippets</a> |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
84 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
85 */ |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
86 |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
87 public class TreeEditor : ControlEditor { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
88 Tree tree; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
89 TreeItem item; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
90 int column = 0; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
91 ControlListener columnListener; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
92 TreeListener treeListener; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
93 Runnable timer; |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
94 static const int TIMEOUT = 1500; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
95 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
96 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
97 * Creates a TreeEditor for the specified Tree. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
98 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
99 * @param tree the Tree Control above which this editor will be displayed |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
100 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
101 */ |
5 | 102 public this (Tree tree) { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
103 super(tree); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
104 this.tree = tree; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
105 |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
106 columnListener = new class() ControlListener { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
107 public void controlMoved(ControlEvent e){ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
108 layout(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
109 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
110 public void controlResized(ControlEvent e){ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
111 layout(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
112 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
113 }; |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
114 timer = new class() Runnable { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
115 public void run() { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
116 layout (); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
117 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
118 }; |
150 | 119 treeListener = new class(this) TreeListener { |
120 TreeEditor td; | |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
121 Runnable runnable; |
150 | 122 |
123 this (TreeEditor td) { | |
124 this.td = td; | |
125 | |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
126 runnable = new class() Runnable { |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
127 public void run() { |
150 | 128 if (td.editor is null || td.editor.isDisposed()) return; |
129 if (td.tree.isDisposed()) return; | |
130 td.layout(); | |
131 td.editor.setVisible(true); | |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
132 } |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
133 }; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
134 } |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
135 public void treeCollapsed(TreeEvent e) { |
150 | 136 if (td.editor is null || td.editor.isDisposed ()) return; |
137 td.editor.setVisible(false); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
138 e.display.asyncExec(runnable); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
139 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
140 public void treeExpanded(TreeEvent e) { |
150 | 141 if (td.editor is null || td.editor.isDisposed ()) return; |
142 td.editor.setVisible(false); | |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
143 e.display.asyncExec(runnable); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
144 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
145 }; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
146 tree.addTreeListener(treeListener); |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
147 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
148 // To be consistent with older versions of DWT, grabVertical defaults to true |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
149 grabVertical = true; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
150 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
151 |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
152 override Rectangle computeBounds () { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
153 if (item is null || column is -1 || item.isDisposed()) return new Rectangle(0, 0, 0, 0); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
154 Rectangle cell = item.getBounds(column); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
155 Rectangle rect = item.getImageBounds(column); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
156 cell.x = rect.x + rect.width; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
157 cell.width -= rect.width; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
158 Rectangle area = tree.getClientArea(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
159 if (cell.x < area.x + area.width) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
160 if (cell.x + cell.width > area.x + area.width) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
161 cell.width = area.x + area.width - cell.x; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
162 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
163 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
164 Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, minimumHeight); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
165 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
166 if (grabHorizontal) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
167 if (tree.getColumnCount() is 0) { |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
168 // Bounds of tree item only include the text area - stretch out to include |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
169 // entire client area |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
170 cell.width = area.x + area.width - cell.x; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
171 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
172 editorRect.width = Math.max(cell.width, minimumWidth); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
173 } |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
174 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
175 if (grabVertical) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
176 editorRect.height = Math.max(cell.height, minimumHeight); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
177 } |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
178 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
179 if (horizontalAlignment is DWT.RIGHT) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
180 editorRect.x += cell.width - editorRect.width; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
181 } else if (horizontalAlignment is DWT.LEFT) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
182 // do nothing - cell.x is the right answer |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
183 } else { // default is CENTER |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
184 editorRect.x += (cell.width - editorRect.width)/2; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
185 } |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
186 // don't let the editor overlap with the + / - of the tree |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
187 editorRect.x = Math.max(cell.x, editorRect.x); |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
188 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
189 if (verticalAlignment is DWT.BOTTOM) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
190 editorRect.y += cell.height - editorRect.height; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
191 } else if (verticalAlignment is DWT.TOP) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
192 // do nothing - cell.y is the right answer |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
193 } else { // default is CENTER |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
194 editorRect.y += (cell.height - editorRect.height)/2; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
195 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
196 return editorRect; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
197 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
198 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
199 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
200 * Removes all associations between the TreeEditor and the row in the tree. The |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
201 * tree and the editor Control are <b>not</b> disposed. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
202 */ |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
203 public override void dispose () { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
204 if (tree !is null && !tree.isDisposed()) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
205 if (this.column > -1 && this.column < tree.getColumnCount()){ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
206 TreeColumn treeColumn = tree.getColumn(this.column); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
207 treeColumn.removeControlListener(columnListener); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
208 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
209 if (treeListener !is null) tree.removeTreeListener(treeListener); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
210 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
211 columnListener = null; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
212 treeListener = null; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
213 tree = null; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
214 item = null; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
215 column = 0; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
216 timer = null; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
217 super.dispose(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
218 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
219 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
220 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
221 * Returns the zero based index of the column of the cell being tracked by this editor. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
222 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
223 * @return the zero based index of the column of the cell being tracked by this editor |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
224 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
225 * @since 3.1 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
226 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
227 public int getColumn () { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
228 return column; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
229 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
230 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
231 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
232 * Returns the TreeItem for the row of the cell being tracked by this editor. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
233 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
234 * @return the TreeItem for the row of the cell being tracked by this editor |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
235 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
236 public TreeItem getItem () { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
237 return item; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
238 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
239 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
240 void resize () { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
241 layout(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
242 /* |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
243 * On some platforms, the table scrolls when an item that |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
244 * is partially visible at the bottom of the table is |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
245 * selected. Ensure that the correct row is edited by |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
246 * laying out one more time in a timerExec(). |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
247 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
248 if (tree !is null) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
249 Display display = tree.getDisplay(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
250 display.timerExec(-1, timer); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
251 display.timerExec(TIMEOUT, timer); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
252 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
253 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
254 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
255 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
256 * Sets the zero based index of the column of the cell being tracked by this editor. |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
257 * |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
258 * @param column the zero based index of the column of the cell being tracked by this editor |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
259 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
260 * @since 3.1 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
261 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
262 public void setColumn(int column) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
263 int columnCount = tree.getColumnCount(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
264 // Separately handle the case where the tree has no TreeColumns. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
265 // In this situation, there is a single default column. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
266 if (columnCount is 0) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
267 this.column = (column is 0) ? 0 : -1; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
268 resize(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
269 return; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
270 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
271 if (this.column > -1 && this.column < columnCount){ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
272 TreeColumn treeColumn = tree.getColumn(this.column); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
273 treeColumn.removeControlListener(columnListener); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
274 this.column = -1; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
275 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
276 |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
277 if (column < 0 || column >= tree.getColumnCount()) return; |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
278 |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
279 this.column = column; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
280 TreeColumn treeColumn = tree.getColumn(this.column); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
281 treeColumn.addControlListener(columnListener); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
282 resize(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
283 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
284 |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
285 /** |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
286 * Specifies the <code>TreeItem</code> that is to be edited. |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
287 * |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
288 * @param item the item to be edited |
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
289 */ |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
290 public void setItem (TreeItem item) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
291 this.item = item; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
292 resize(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
293 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
294 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
295 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
296 * Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
297 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
298 * <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Tree control |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
299 * specified in the TreeEditor constructor. |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
300 * |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
301 * @param editor the Control that is displayed above the cell being edited |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
302 * @param item the TreeItem for the row of the cell being tracked by this editor |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
303 * @param column the zero based index of the column of the cell being tracked by this editor |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
304 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
305 * @since 3.1 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
306 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
307 public void setEditor (Control editor, TreeItem item, int column) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
308 setItem(item); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
309 setColumn(column); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
310 setEditor(editor); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
311 } |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
312 public override void setEditor (Control editor) { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
313 super.setEditor(editor); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
314 resize(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
315 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
316 |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
317 /** |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
318 * Specify the Control that is to be displayed and the cell in the tree that it is to be positioned above. |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
319 * |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
320 * <p>Note: The Control provided as the editor <b>must</b> be created with its parent being the Tree control |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
321 * specified in the TreeEditor constructor. |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
322 * |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
323 * @param editor the Control that is displayed above the cell being edited |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
324 * @param item the TreeItem for the row of the cell being tracked by this editor |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
325 */ |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
326 public void setEditor (Control editor, TreeItem item) { |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
327 setItem(item); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
328 setEditor(editor); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
329 } |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
330 |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
331 public override void layout () { |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
332 if (tree is null || tree.isDisposed()) return; |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
333 if (item is null || item.isDisposed()) return; |
0
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
334 int columnCount = tree.getColumnCount(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
335 if (columnCount is 0 && column !is 0) return; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
336 if (columnCount > 0 && (column < 0 || column >= columnCount)) return; |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
337 super.layout(); |
380af2bdd8e5
Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff
changeset
|
338 } |
41
6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
Frank Benoit <benoit@tionex.de>
parents:
7
diff
changeset
|
339 |
123 | 340 } |