|
17 | 17 | import org.eclipse.swt.events.SelectionListener; |
18 | 18 | import org.eclipse.swt.graphics.Image; |
19 | 19 | import org.eclipse.swt.graphics.Point; |
| 20 | +import org.eclipse.swt.internal.RunnableCompatibility; |
20 | 21 | import org.eclipse.swt.internal.browser.OS; |
21 | 22 | import org.eclipse.swt.internal.dnd.DragAndDrop; |
22 | 23 | import org.eclipse.swt.internal.dnd.DragEvent; |
@@ -82,75 +83,80 @@ public TableColumn (Table parent, int style) { |
82 | 83 | resizable = true; |
83 | 84 | this.parent = parent; |
84 | 85 | parent.createItem (this, parent.getColumnCount ()); |
85 | | - //configureColumn(); |
| 86 | + configureColumn(); |
86 | 87 | } |
87 | 88 |
|
88 | 89 | private void configureColumn() { |
89 | | - // TODO Auto-generated method stub |
90 | | - this.handle.style.height = (OS.getStringPlainHeight("A")+ 2) + "px"; |
91 | | -// System.out.println("configuring table column " + this.handle.style.height); |
92 | | - if(resizeHandle != null){ |
93 | | - OS.destroyHandle(resizeHandle); |
94 | | - } |
95 | | - if(resizable){ |
96 | | - resizeHandle = document.createElement("DIV"); |
97 | | - resizeHandle.className = "table-column-resize"; |
98 | | - handle.appendChild(resizeHandle); |
99 | | - } |
100 | | - if(resizable){ |
101 | | - resizeHandle.style.display = "block"; |
102 | | - resizeHandle.style.height = Math.max(0, OS.getContainerHeight(this.handle)) + "px"; |
103 | | -// System.out.println(" height is " + resizeHandle.style.height); |
104 | | - int left = 0; |
105 | | - for(int i = 0; i <= parent.indexOf(this); i++){ |
106 | | - left += Math.max(0, parent.columns[i].getWidth() + 2); |
107 | | -// System.out.println(" at " + i + " left is "+ left); |
| 90 | + handle.ondblclick = new RunnableCompatibility() { |
| 91 | + public void run() { |
| 92 | + sendEvent(SWT.DefaultSelection); |
108 | 93 | } |
109 | | - resizeHandle.style.left = (left - 3)+ "px"; |
110 | | -// System.out.println("resize handle for " + this.text + " " + resizeHandle.style.left); |
111 | | - /* |
112 | | - * Resizing the columns |
113 | | - */ |
114 | | - DragAndDrop dnd = new DragAndDrop(); |
115 | | - dnd.addDragListener(new TableColumnDND() { |
116 | | - public boolean dragEnded(DragEvent e) { |
117 | | - super.dragEnded(e); |
118 | | - Event event = new Event (); |
119 | | - //Point location = getLocation(); |
120 | | -// event.x = ScaleDND.x;//location.x; |
121 | | -// event.y = ScaleDND.y;//location.y; |
122 | | - Point p = currentLocation(e); |
123 | | - event.x = Integer.parseInt(thumb.style.left);//p.x; //SashDND.x;//location.x; |
124 | | - if (event.doit) { |
125 | | - lastX = event.x; |
126 | | - } |
127 | | - int tempWidth = lastX - Integer.parseInt(resizeHandle.style.left) + getWidth(); |
128 | | -// System.out.println("drag ends" + lastX + " " + getWidth() + " " + tempWidth); |
129 | | - setWidth(Math.max(0, tempWidth)); |
130 | | - return true; |
131 | | - } |
132 | | - |
133 | | - public boolean dragging(DragEvent e) { |
134 | | - super.dragging(e); |
135 | | -// System.out.println("draggin"); |
136 | | - //e.sourceElement.style.top = currentLocation(e).y + "px"; |
137 | | - //caculateSelection(); |
138 | | - Event event = new Event (); |
139 | | - event.x = lastX; |
140 | | - event.y = lastY; |
141 | | - //event.widget = Slider.this; |
142 | | - //event.item = Slider.this; |
143 | | - event.detail = SWT.DRAG; |
144 | | - sendEvent (SWT.Selection, event); |
145 | | - return true; |
146 | | - } |
147 | | - |
148 | | - }); |
149 | | - dnd.bind(resizeHandle); |
150 | | - |
151 | | - } else if(resizeHandle != null){ |
152 | | - resizeHandle.style.display = "none"; |
153 | | - } |
| 94 | + }; |
| 95 | +// |
| 96 | +// this.handle.style.height = (OS.getStringPlainHeight("A")+ 2) + "px"; |
| 97 | +//// System.out.println("configuring table column " + this.handle.style.height); |
| 98 | +// if(resizeHandle != null){ |
| 99 | +// OS.destroyHandle(resizeHandle); |
| 100 | +// } |
| 101 | +// if(resizable){ |
| 102 | +// resizeHandle = document.createElement("DIV"); |
| 103 | +// resizeHandle.className = "table-column-resize"; |
| 104 | +// handle.appendChild(resizeHandle); |
| 105 | +// } |
| 106 | +// if(resizable){ |
| 107 | +// resizeHandle.style.display = "block"; |
| 108 | +// resizeHandle.style.height = Math.max(0, OS.getContainerHeight(this.handle)) + "px"; |
| 109 | +//// System.out.println(" height is " + resizeHandle.style.height); |
| 110 | +// int left = 0; |
| 111 | +// for(int i = 0; i <= parent.indexOf(this); i++){ |
| 112 | +// left += Math.max(0, parent.columns[i].getWidth() + 2); |
| 113 | +//// System.out.println(" at " + i + " left is "+ left); |
| 114 | +// } |
| 115 | +// resizeHandle.style.left = (left - 3)+ "px"; |
| 116 | +//// System.out.println("resize handle for " + this.text + " " + resizeHandle.style.left); |
| 117 | +// /* |
| 118 | +// * Resizing the columns |
| 119 | +// */ |
| 120 | +// DragAndDrop dnd = new DragAndDrop(); |
| 121 | +// dnd.addDragListener(new TableColumnDND() { |
| 122 | +// public boolean dragEnded(DragEvent e) { |
| 123 | +// super.dragEnded(e); |
| 124 | +// Event event = new Event (); |
| 125 | +// //Point location = getLocation(); |
| 126 | +//// event.x = ScaleDND.x;//location.x; |
| 127 | +//// event.y = ScaleDND.y;//location.y; |
| 128 | +// Point p = currentLocation(e); |
| 129 | +// event.x = Integer.parseInt(thumb.style.left);//p.x; //SashDND.x;//location.x; |
| 130 | +// if (event.doit) { |
| 131 | +// lastX = event.x; |
| 132 | +// } |
| 133 | +// int tempWidth = lastX - Integer.parseInt(resizeHandle.style.left) + getWidth(); |
| 134 | +//// System.out.println("drag ends" + lastX + " " + getWidth() + " " + tempWidth); |
| 135 | +// setWidth(Math.max(0, tempWidth)); |
| 136 | +// return true; |
| 137 | +// } |
| 138 | +// |
| 139 | +// public boolean dragging(DragEvent e) { |
| 140 | +// super.dragging(e); |
| 141 | +//// System.out.println("draggin"); |
| 142 | +// //e.sourceElement.style.top = currentLocation(e).y + "px"; |
| 143 | +// //caculateSelection(); |
| 144 | +// Event event = new Event (); |
| 145 | +// event.x = lastX; |
| 146 | +// event.y = lastY; |
| 147 | +// //event.widget = Slider.this; |
| 148 | +// //event.item = Slider.this; |
| 149 | +// event.detail = SWT.DRAG; |
| 150 | +// sendEvent (SWT.Selection, event); |
| 151 | +// return true; |
| 152 | +// } |
| 153 | +// |
| 154 | +// }); |
| 155 | +// dnd.bind(resizeHandle); |
| 156 | +// |
| 157 | +// } else if(resizeHandle != null){ |
| 158 | +// resizeHandle.style.display = "none"; |
| 159 | +// } |
154 | 160 |
|
155 | 161 | } |
156 | 162 |
|
@@ -191,7 +197,8 @@ public TableColumn (Table parent, int style, int index) { |
191 | 197 | super (parent, checkStyle (style)); |
192 | 198 | resizable = true; |
193 | 199 | this.parent = parent; |
194 | | - parent.createItem (this, index); |
| 200 | + parent.createItem (this, index); |
| 201 | + configureColumn(); |
195 | 202 | } |
196 | 203 |
|
197 | 204 | /** |
|
0 commit comments