Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 237846 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/swt/nebula/snippets/grid/GridSnippet2.java (+10 lines)
Lines 15-23 Link Here
15
import org.eclipse.nebula.widgets.grid.GridColumn;
15
import org.eclipse.nebula.widgets.grid.GridColumn;
16
import org.eclipse.nebula.widgets.grid.GridItem;
16
import org.eclipse.nebula.widgets.grid.GridItem;
17
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.custom.CCombo;
18
import org.eclipse.swt.layout.FillLayout;
19
import org.eclipse.swt.layout.FillLayout;
19
import org.eclipse.swt.widgets.Display;
20
import org.eclipse.swt.widgets.Display;
20
import org.eclipse.swt.widgets.Shell;
21
import org.eclipse.swt.widgets.Shell;
22
import org.eclipse.swt.widgets.Text;
21
23
22
/*
24
/*
23
 * Create a grid with an item that spans columns.
25
 * Create a grid with an item that spans columns.
Lines 34-45 Link Here
34
36
35
    Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
37
    Grid grid = new Grid(shell,SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
36
    grid.setHeaderVisible(true);
38
    grid.setHeaderVisible(true);
39
    
37
    GridColumn column = new GridColumn(grid,SWT.NONE);
40
    GridColumn column = new GridColumn(grid,SWT.NONE);
38
    column.setText("Column 1");
41
    column.setText("Column 1");
39
    column.setWidth(100);
42
    column.setWidth(100);
43
    column.setHeaderControl(new CCombo(grid,SWT.READ_ONLY|SWT.BORDER));
44
    column.setMoveable(true);
45
    
40
    GridColumn column2 = new GridColumn(grid,SWT.NONE);
46
    GridColumn column2 = new GridColumn(grid,SWT.NONE);
41
    column2.setText("Column 2");
47
    column2.setText("Column 2");
42
    column2.setWidth(100);
48
    column2.setWidth(100);
49
    column2.setMoveable(true);
50
    column2.setHeaderControl(new Text(grid,SWT.BORDER));
51
    
52
    
43
    GridItem item1 = new GridItem(grid,SWT.NONE);
53
    GridItem item1 = new GridItem(grid,SWT.NONE);
44
    item1.setText("First Item");
54
    item1.setText("First Item");
45
    item1.setText(1,"xxxxxxx");
55
    item1.setText(1,"xxxxxxx");
(-)src/org/eclipse/swt/nebula/snippets/cdatetime/CDTSnippet01.java (-1 / +17 lines)
Lines 3-12 Link Here
3
import org.eclipse.nebula.widgets.cdatetime.CDT;
3
import org.eclipse.nebula.widgets.cdatetime.CDT;
4
import org.eclipse.nebula.widgets.cdatetime.CDateTime;
4
import org.eclipse.nebula.widgets.cdatetime.CDateTime;
5
import org.eclipse.swt.SWT;
5
import org.eclipse.swt.SWT;
6
import org.eclipse.swt.events.SelectionAdapter;
7
import org.eclipse.swt.events.SelectionEvent;
6
import org.eclipse.swt.graphics.Point;
8
import org.eclipse.swt.graphics.Point;
7
import org.eclipse.swt.graphics.Rectangle;
9
import org.eclipse.swt.graphics.Rectangle;
8
import org.eclipse.swt.layout.GridData;
10
import org.eclipse.swt.layout.GridData;
9
import org.eclipse.swt.layout.GridLayout;
11
import org.eclipse.swt.layout.GridLayout;
12
import org.eclipse.swt.widgets.Button;
10
import org.eclipse.swt.widgets.Display;
13
import org.eclipse.swt.widgets.Display;
11
import org.eclipse.swt.widgets.Shell;
14
import org.eclipse.swt.widgets.Shell;
12
15
Lines 25-33 Link Here
25
		GridLayout layout = new GridLayout();
28
		GridLayout layout = new GridLayout();
26
		shell.setLayout(layout);
29
		shell.setLayout(layout);
27
30
28
		final CDateTime cdt = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN);
31
		final CDateTime cdt = new CDateTime(shell, CDT.BORDER | CDT.DROP_DOWN | CDT.DATE_LONG | CDT.TIME_SHORT );
29
		cdt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
32
		cdt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
30
33
34
		
35
		Button b = new Button(shell,SWT.PUSH);
36
		b.addSelectionListener(new SelectionAdapter() {
37
38
			@Override
39
			public void widgetSelected(SelectionEvent e) {
40
				System.err.println(cdt.getSelection());
41
			}
42
			
43
		});
44
		
31
		shell.pack();
45
		shell.pack();
32
		Point size = shell.getSize();
46
		Point size = shell.getSize();
33
		Rectangle screen = display.getMonitors()[0].getBounds();
47
		Rectangle screen = display.getMonitors()[0].getBounds();
Lines 37-42 Link Here
37
				size.x,
51
				size.x,
38
				size.y
52
				size.y
39
		);
53
		);
54
		
55
		
40
		shell.open();
56
		shell.open();
41
		while (!shell.isDisposed()) {
57
		while (!shell.isDisposed()) {
42
			if (!display.readAndDispatch())
58
			if (!display.readAndDispatch())
(-)META-INF/MANIFEST.MF (-6 / +3 lines)
Lines 9-22 Link Here
9
 org.eclipse.core.runtime,
9
 org.eclipse.core.runtime,
10
 org.eclipse.nebula.jface.gridviewer,
10
 org.eclipse.nebula.jface.gridviewer,
11
 org.eclipse.nebula.widgets.cdatetime,
11
 org.eclipse.nebula.widgets.cdatetime,
12
 org.eclipse.nebula.widgets.ctree,
13
 org.eclipse.nebula.widgets.datechooser,
14
 org.eclipse.nebula.widgets.formattedtext,
15
 org.eclipse.nebula.widgets.gallery,
16
 org.eclipse.nebula.widgets.grid,
12
 org.eclipse.nebula.widgets.grid,
17
 org.eclipse.nebula.widgets.pgroup,
18
 org.eclipse.nebula.widgets.pshelf,
13
 org.eclipse.nebula.widgets.pshelf,
19
 org.eclipse.nebula.widgets.compositetable
14
 org.eclipse.nebula.widgets.calendarcombo;bundle-version="1.0.0",
15
 org.eclipse.nebula.widgets.datechooser;bundle-version="1.0.0",
16
 org.eclipse.nebula.widgets.formattedtext;bundle-version="1.0.0"
20
Export-Package: org.eclipse.swt.nebula.snippets.ctree,
17
Export-Package: org.eclipse.swt.nebula.snippets.ctree,
21
 org.eclipse.swt.nebula.snippets.grid
18
 org.eclipse.swt.nebula.snippets.grid
22
Bundle-ClassPath: .
19
Bundle-ClassPath: .
(-).classpath (-1 / +1 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="output" path="bin"/>
6
	<classpathentry kind="output" path="bin"/>
7
</classpath>
7
</classpath>
(-)src/org/eclipse/nebula/snippets/gridviewer/Test.java (+223 lines)
Added Link Here
1
package org.eclipse.nebula.snippets.gridviewer;
2
3
import java.util.regex.Matcher;
4
import java.util.regex.Pattern;
5
6
import org.eclipse.jface.viewers.ArrayContentProvider;
7
import org.eclipse.jface.viewers.CellEditor;
8
import org.eclipse.jface.viewers.ColumnLabelProvider;
9
import org.eclipse.jface.viewers.ColumnViewerEditor;
10
import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent;
11
import org.eclipse.jface.viewers.ColumnViewerEditorActivationListener;
12
import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
13
import org.eclipse.jface.viewers.ColumnViewerEditorDeactivationEvent;
14
import org.eclipse.jface.viewers.ICellModifier;
15
import org.eclipse.jface.viewers.TextCellEditor;
16
import org.eclipse.nebula.jface.gridviewer.GridTableViewer;
17
import org.eclipse.nebula.jface.gridviewer.GridViewerColumn;
18
import org.eclipse.nebula.jface.gridviewer.GridViewerEditor;
19
import org.eclipse.nebula.widgets.grid.Grid;
20
import org.eclipse.nebula.widgets.grid.GridItem;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.layout.FillLayout;
23
import org.eclipse.swt.widgets.Display;
24
import org.eclipse.swt.widgets.Shell;
25
26
27
public class Test
28
{
29
    private Pattern m_IsValidPattern = null;
30
31
    public class MyModel
32
    {
33
        private String sCounter = "";
34
35
        public MyModel(){
36
        }
37
38
        public void setCounter(String sCounter)
39
        {
40
            this.sCounter = sCounter;
41
        }
42
43
        public String toString()
44
        {
45
            return sCounter;
46
        }
47
    }
48
49
    public class MyTextCellEditor extends TextCellEditor
50
    {
51
        /**
52
         * search pattern is Numeric character
53
         */
54
        private Pattern m_IsValidPattern = null;
55
56
        public MyTextCellEditor(Grid parent) {
57
            super(parent);
58
            m_IsValidPattern = Pattern.compile("[\\w+-\\.]");
59
        }
60
61
        @Override
62
        public void activate(ColumnViewerEditorActivationEvent activationEvent) {
63
64
            // set the activation character
65
            String s1 = String.valueOf( activationEvent.character );
66
            Matcher matcher = m_IsValidPattern.matcher( s1 );
67
            if (matcher.matches()) {
68
                doSetValue(s1);
69
            }
70
            super.activate(activationEvent);
71
        }
72
    }
73
74
75
    public Test(Shell shell)
76
    {
77
        /* allow numbers and characters */
78
        m_IsValidPattern = Pattern.compile("[\\w+-\\.]");
79
80
        final GridTableViewer v = new GridTableViewer(shell, SWT.BORDER
81
                | SWT.H_SCROLL | SWT.V_SCROLL);
82
83
84
        v.setCellEditors(new CellEditor[] {
85
                new MyTextCellEditor(v.getGrid()),
86
                new MyTextCellEditor(v.getGrid())
87
        });
88
89
        v.setCellModifier(new ICellModifier() {
90
91
            public boolean canModify(Object element, String property) {
92
                return true;
93
            }
94
95
            public Object getValue(Object element, String property) {
96
                return element.toString();
97
            }
98
99
            public void modify(Object element, String property, Object value) {
100
                if (element instanceof GridItem) {
101
                    GridItem item = (GridItem)element;
102
                    MyModel model = (MyModel)(item.getData());
103
                    model.setCounter(value.toString());
104
                    v.update(model, null);
105
                }
106
            }
107
        });
108
109
110
        ColumnViewerEditorActivationListener listener = new ColumnViewerEditorActivationListener() {
111
112
            public void afterEditorActivated(
113
                    ColumnViewerEditorActivationEvent event)
114
            {
115
            }
116
117
            public void afterEditorDeactivated(
118
                    ColumnViewerEditorDeactivationEvent event)
119
            {
120
            }
121
122
            public void beforeEditorActivated(
123
                    ColumnViewerEditorActivationEvent event)
124
            {
125
            }
126
127
            public void beforeEditorDeactivated(
128
                    ColumnViewerEditorDeactivationEvent event)
129
            {
130
            }
131
        };
132
133
        v.setContentProvider(new ArrayContentProvider());
134
        v.setColumnProperties(new String[] { "1", "2" });
135
        v.getGrid().setCellSelectionEnabled(true);
136
        v.getGrid().setLinesVisible(true);
137
        v.getGrid().setHeaderVisible(true);
138
139
        ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(
140
                v) {
141
            protected boolean isEditorActivationEvent(
142
                    ColumnViewerEditorActivationEvent event)
143
            {
144
                boolean result;
145
146
                String s1          = String.valueOf( event.character );
147
                Matcher matcher    = m_IsValidPattern.matcher( s1 );
148
                boolean bIsCharKey = matcher.matches();
149
150
                boolean bEnableKey =
151
                    (event.keyCode == SWT.CR) ||
152
                    (event.keyCode == SWT.KEYPAD_CR) ||
153
                    (event.keyCode == SWT.F2) ||
154
                    bIsCharKey;
155
156
                result = event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
157
                        || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
158
                        || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && bEnableKey)
159
                        || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
160
161
                return result;
162
            }
163
        };
164
165
        GridViewerEditor.create(v, actSupport,
166
                ColumnViewerEditor.TABBING_HORIZONTAL
167
                        | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
168
                        | ColumnViewerEditor.TABBING_VERTICAL
169
                        | ColumnViewerEditor.KEYBOARD_ACTIVATION);
170
171
        v.getColumnViewerEditor().addEditorActivationListener(listener);
172
173
        GridViewerColumn column = new GridViewerColumn(v, SWT.NONE);
174
        column.getColumn().setWidth(200);
175
        column.getColumn().setMoveable(true);
176
        column.getColumn().setText("Column 1");
177
        column.setLabelProvider(new ColumnLabelProvider());
178
179
        column = new GridViewerColumn(v, SWT.NONE);
180
        column.getColumn().setWidth(200);
181
        column.getColumn().setMoveable(true);
182
        column.getColumn().setText("Column 2");
183
        column.setLabelProvider(new ColumnLabelProvider());
184
185
        MyModel[] model = createModel();
186
187
        v.setInput(model);
188
    }
189
190
    private MyModel[] createModel() {
191
192
        MyModel[] elements = new MyModel[10];
193
194
        for (int i = 0; i < 10; i++)
195
        {
196
            elements[i] = new MyModel();
197
            if (i<3){
198
                Double h = Double.valueOf(i);
199
                elements[i].setCounter( h.toString() );
200
            }
201
        }
202
        return elements;
203
    }
204
205
    public static void main(String[] args)
206
    {
207
        Display display = new Display();
208
209
        Shell shell = new Shell(display);
210
        shell.setLayout(new FillLayout());
211
        new Test(shell);
212
        shell.open();
213
214
        while (!shell.isDisposed())
215
        {
216
            if (!display.readAndDispatch())
217
                display.sleep();
218
        }
219
220
        display.dispose();
221
222
    }
223
} 
(-)src/org/eclipse/nebula/widgets/grid/GridColumn.java (+27 lines)
Lines 18-23 Link Here
18
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.graphics.GC;
19
import org.eclipse.swt.graphics.Point;
19
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.swt.graphics.Rectangle;
21
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Event;
22
import org.eclipse.swt.widgets.Event;
22
import org.eclipse.swt.widgets.Item;
23
import org.eclipse.swt.widgets.Item;
23
import org.eclipse.swt.widgets.TypedListener;
24
import org.eclipse.swt.widgets.TypedListener;
Lines 40-45 Link Here
40
 */
41
 */
41
public class GridColumn extends Item
42
public class GridColumn extends Item
42
{
43
{
44
	private GridHeaderEditor controlEditor;
43
45
44
    /**
46
    /**
45
     * Default width of the column.
47
     * Default width of the column.
Lines 1086-1089 Link Here
1086
        cellRenderer.setWordWrap(wordWrap);
1088
        cellRenderer.setWordWrap(wordWrap);
1087
        parent.redraw();
1089
        parent.redraw();
1088
    }
1090
    }
1091
    
1092
    /**
1093
	 * Set a new editor at the top of the control. If there's an editor already
1094
	 * set it is disposed.
1095
	 * 
1096
	 * @param control
1097
	 *            the control to be displayed in the header
1098
	 */
1099
	public void setHeaderControl(Control control) {
1100
		if (this.controlEditor == null) {
1101
			this.controlEditor = new GridHeaderEditor(this);
1102
		}
1103
		this.controlEditor.setEditor(control);
1104
		getParent().recalculateHeader();
1105
	}
1106
	
1107
	/**
1108
	 * @return the current header control
1109
	 */
1110
	public Control getHeaderControl() {
1111
		if( this.controlEditor != null ) {
1112
			return this.controlEditor.getEditor();
1113
		}
1114
		return null;
1115
	}
1089
}
1116
}
(-)src/org/eclipse/nebula/widgets/grid/GridHeaderRenderer.java (-34 / +46 lines)
Lines 4-43 Link Here
4
4
5
/**
5
/**
6
 * <p>
6
 * <p>
7
 * NOTE:  THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT.  THIS IS A PRE-RELEASE ALPHA 
7
 * NOTE: THIS WIDGET AND ITS API ARE STILL UNDER DEVELOPMENT. THIS IS A
8
 * VERSION.  USERS SHOULD EXPECT API CHANGES IN FUTURE VERSIONS.
8
 * PRE-RELEASE ALPHA VERSION. USERS SHOULD EXPECT API CHANGES IN FUTURE
9
 * </p> 
9
 * VERSIONS.
10
 * The super class for all grid header renderers.  Contains the properties specific
10
 * </p>
11
 * to a grid header.
11
 * The super class for all grid header renderers. Contains the properties
12
 *
12
 * specific to a grid header.
13
 * 
13
 * @author chris.gross@us.ibm.com
14
 * @author chris.gross@us.ibm.com
14
 */
15
 */
15
public abstract class GridHeaderRenderer extends AbstractInternalWidget
16
public abstract class GridHeaderRenderer extends AbstractInternalWidget {
16
{
17
	
17
    /**
18
	/**
18
     * Returns the bounds of the text in the cell.  This is used when displaying in-place tooltips.
19
	 * Returns the bounds of the text in the cell. This is used when displaying
19
     * If <code>null</code> is returned here, in-place tooltips will not be displayed.  If the 
20
	 * in-place tooltips. If <code>null</code> is returned here, in-place
20
     * <code>preferred</code> argument is <code>true</code> then the returned bounds should be large
21
	 * tooltips will not be displayed. If the <code>preferred</code> argument is
21
     * enough to show the entire text.  If <code>preferred</code> is <code>false</code> then the 
22
	 * <code>true</code> then the returned bounds should be large enough to show
22
     * returned bounds should be be relative to the current bounds.
23
	 * the entire text. If <code>preferred</code> is <code>false</code> then the
23
     * 
24
	 * returned bounds should be be relative to the current bounds.
24
     * @param value the object being rendered.
25
	 * 
25
     * @param preferred true if the preferred width of the text should be returned.
26
	 * @param value
26
     * @return bounds of the text.
27
	 *            the object being rendered.
27
     */
28
	 * @param preferred
28
    public Rectangle getTextBounds(Object value, boolean preferred)
29
	 *            true if the preferred width of the text should be returned.
29
    {
30
	 * @return bounds of the text.
30
        return null;
31
	 */
31
    }
32
	public Rectangle getTextBounds(Object value, boolean preferred) {
32
    
33
		return null;
33
    /**
34
	}
34
     * Returns the bounds of the toggle within the header (typically only group headers have toggles)
35
35
     * or null.
36
	/**
36
     * 
37
	 * Returns the bounds of the toggle within the header (typically only group
37
     * @return toggle bounds or null if no toggle exists.
38
	 * headers have toggles) or null.
38
     */
39
	 * 
39
    public Rectangle getToggleBounds()
40
	 * @return toggle bounds or null if no toggle exists.
40
    {
41
	 */
41
        return null;
42
	public Rectangle getToggleBounds() {
42
    }
43
		return null;
44
	}
45
46
	/**
47
	 * Returns the bounds of the control to display
48
	 * 
49
	 * @return the bounds for the control or <code>null</code> if no control is
50
	 *         rendered
51
	 */
52
	protected Rectangle getControlBounds(Object value, boolean preferred) {
53
		return null;
54
	}
43
}
55
}
(-)src/org/eclipse/nebula/widgets/grid/Grid.java (-2 / +11 lines)
Lines 4100-4108 Link Here
4100
        for (Iterator columnsIterator = columns.iterator(); columnsIterator.hasNext(); )
4100
        for (Iterator columnsIterator = columns.iterator(); columnsIterator.hasNext(); )
4101
        {
4101
        {
4102
            GridColumn column = (GridColumn) columnsIterator.next();
4102
            GridColumn column = (GridColumn) columnsIterator.next();
4103
            int y = column.getHeaderRenderer().computeSize(gc, column.getWidth(), SWT.DEFAULT,
4104
                    column).y;
4105
            
4103
            colHeaderHeight = Math
4106
            colHeaderHeight = Math
4104
                .max(column.getHeaderRenderer().computeSize(gc, column.getWidth(), SWT.DEFAULT,
4107
                .max(y, colHeaderHeight);
4105
                                                            column).y, colHeaderHeight);
4108
            
4106
        }
4109
        }
4107
4110
4108
        int groupHeight = 0;
4111
        int groupHeight = 0;
Lines 7660-7665 Link Here
7660
        return columns.size() - 1;
7663
        return columns.size() - 1;
7661
    }
7664
    }
7662
7665
7666
    void recalculateHeader() {
7667
        computeHeaderHeight(sizingGC);
7668
        scrollValuesObsolete = true;
7669
        redraw();    	
7670
    }
7671
    
7663
    /**
7672
    /**
7664
     * Removes the given column from the table.
7673
     * Removes the given column from the table.
7665
     * 
7674
     * 
(-)src/org/eclipse/nebula/widgets/grid/internal/DefaultColumnHeaderRenderer.java (-279 / +279 lines)
Lines 7-13 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    chris.gross@us.ibm.com - initial API and implementation
9
 *    chris.gross@us.ibm.com - initial API and implementation
10
 *******************************************************************************/ 
10
 *******************************************************************************/
11
package org.eclipse.nebula.widgets.grid.internal;
11
package org.eclipse.nebula.widgets.grid.internal;
12
12
13
import org.eclipse.nebula.widgets.grid.GridColumn;
13
import org.eclipse.nebula.widgets.grid.GridColumn;
Lines 20-308 Link Here
20
20
21
/**
21
/**
22
 * The column header renderer.
22
 * The column header renderer.
23
 *
23
 * 
24
 * @author chris.gross@us.ibm.com
24
 * @author chris.gross@us.ibm.com
25
 * @since 2.0.0
25
 * @since 2.0.0
26
 */
26
 */
27
public class DefaultColumnHeaderRenderer extends GridHeaderRenderer
27
public class DefaultColumnHeaderRenderer extends GridHeaderRenderer {
28
{
29
28
30
    int leftMargin = 6;
29
	int leftMargin = 6;
31
30
32
    int rightMargin = 6;
31
	int rightMargin = 6;
33
32
34
    int topMargin = 3;
33
	int topMargin = 3;
35
34
36
    int bottomMargin = 3;
35
	int bottomMargin = 3;
37
36
38
    int arrowMargin = 6;
37
	int arrowMargin = 6;
39
38
40
    int imageSpacing = 3;
39
	int imageSpacing = 3;
41
40
42
    private SortArrowRenderer arrowRenderer = new SortArrowRenderer();
41
	private SortArrowRenderer arrowRenderer = new SortArrowRenderer();
43
42
44
    /** 
43
	/**
45
     * {@inheritDoc}
44
	 * {@inheritDoc}
46
     */
45
	 */
47
    public Point computeSize(GC gc, int wHint, int hHint, Object value)
46
	public Point computeSize(GC gc, int wHint, int hHint, Object value) {
48
    {
47
		GridColumn column = (GridColumn) value;
49
        GridColumn column = (GridColumn)value;
48
50
49
		int x = 0;
51
        int x = 0;
50
52
51
		x += leftMargin;
53
        x += leftMargin;
52
54
53
		x += gc.stringExtent(column.getText()).x + rightMargin;
55
        x += gc.stringExtent(column.getText()).x + rightMargin;
54
56
55
		int y = 0;
57
        int y = 0;
56
58
57
		y += topMargin;
59
        y += topMargin;
58
60
59
		y += gc.getFontMetrics().getHeight();
61
        y += gc.getFontMetrics().getHeight();
60
62
61
		y += bottomMargin;
63
        y += bottomMargin;
62
64
63
		if (column.getImage() != null) {
65
        if (column.getImage() != null)
64
			x += column.getImage().getBounds().width + imageSpacing;
66
        {
65
67
            x += column.getImage().getBounds().width + imageSpacing;
66
			y = Math.max(y, topMargin + column.getImage().getBounds().height
68
67
					+ bottomMargin);
69
            y = Math.max(y, topMargin + column.getImage().getBounds().height + bottomMargin);
68
		}
70
        }
69
		
71
70
		y += computeControlSize(column).y;
72
        return new Point(x, y);
71
73
    }
72
		System.err.println("Height:" + y); 
74
73
		
75
    /** 
74
		return new Point(x, y);
76
     * {@inheritDoc}
75
	}
77
     */
76
78
    public void paint(GC gc, Object value)
77
	/**
79
    {
78
	 * {@inheritDoc}
80
        GridColumn column = (GridColumn)value;
79
	 */
81
80
	public void paint(GC gc, Object value) {
82
        boolean flat = (column.getParent().getCellSelectionEnabled() && !column.getMoveable());
81
		GridColumn column = (GridColumn) value;
83
        
82
84
        boolean drawSelected = ((isMouseDown() && isHover()));
83
		boolean flat = (column.getParent().getCellSelectionEnabled() && !column
85
84
				.getMoveable());
86
        gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
85
87
86
		boolean drawSelected = ((isMouseDown() && isHover()));
88
        if (flat && isSelected())
87
89
        {
88
		gc.setBackground(getDisplay().getSystemColor(
90
            gc.setBackground(column.getParent().getCellHeaderSelectionBackground());
89
				SWT.COLOR_WIDGET_BACKGROUND));
91
        }
90
92
        
91
		if (flat && isSelected()) {
93
        gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width,
92
			gc.setBackground(column.getParent()
94
                         getBounds().height);
93
					.getCellHeaderSelectionBackground());
95
94
		}
96
        int pushedDrawingOffset = 0;
95
97
        if (drawSelected)
96
		gc.fillRectangle(getBounds().x, getBounds().y, getBounds().width,
98
        {
97
				getBounds().height);
99
            pushedDrawingOffset = 1;
98
100
        }
99
		int pushedDrawingOffset = 0;
101
100
		if (drawSelected) {
102
        int x = leftMargin;
101
			pushedDrawingOffset = 1;
103
102
		}
104
        if (column.getImage() != null)
103
105
        {
104
		int x = leftMargin;
106
                gc.drawImage(column.getImage(), getBounds().x + x + pushedDrawingOffset,
105
107
                        getBounds().y + pushedDrawingOffset + getBounds().height - bottomMargin - column.getImage().getBounds().height);        		
106
		if (column.getImage() != null) {
108
            x += column.getImage().getBounds().width + imageSpacing;
107
			gc.drawImage(column.getImage(), getBounds().x + x
109
        }
108
					+ pushedDrawingOffset, getBounds().y + pushedDrawingOffset
110
109
					+ getBounds().height - bottomMargin
111
        int width = getBounds().width - x;
110
					- column.getImage().getBounds().height);
112
111
			x += column.getImage().getBounds().width + imageSpacing;
113
        if (column.getSort() == SWT.NONE)
112
		}
114
        {
113
115
            width -= rightMargin;
114
		int width = getBounds().width - x;
116
        }
115
117
        else
116
		if (column.getSort() == SWT.NONE) {
118
        {
117
			width -= rightMargin;
119
            width -= arrowMargin + arrowRenderer.getSize().x + arrowMargin;
118
		} else {
120
        }
119
			width -= arrowMargin + arrowRenderer.getSize().x + arrowMargin;
121
120
		}
122
        gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
121
123
122
		gc.setForeground(getDisplay().getSystemColor(
124
        int y = getBounds().y + getBounds().height - bottomMargin - gc.getFontMetrics().getHeight();
123
				SWT.COLOR_WIDGET_FOREGROUND));
125
124
126
        String text = TextUtils.getShortString(gc, column.getText(), width);
125
		int y = bottomMargin;
127
        
126
		
128
        if (column.getAlignment() == SWT.RIGHT)
127
		if( column.getHeaderControl() == null ) {
129
        {
128
			y = getBounds().y + getBounds().height - bottomMargin
130
            int len = gc.stringExtent(text).x;
129
			- gc.getFontMetrics().getHeight();			
131
            if (len < width)
130
		}
132
            {
131
133
                x += width - len;
132
		String text = TextUtils.getShortString(gc, column.getText(), width);
134
            }
133
135
        }
134
		if (column.getAlignment() == SWT.RIGHT) {
136
        else if (column.getAlignment() == SWT.CENTER)
135
			int len = gc.stringExtent(text).x;
137
        {
136
			if (len < width) {
138
            int len = gc.stringExtent(text).x;
137
				x += width - len;
139
            if (len < width)
138
			}
140
            {
139
		} else if (column.getAlignment() == SWT.CENTER) {
141
                x += (width - len) / 2;
140
			int len = gc.stringExtent(text).x;
142
            }
141
			if (len < width) {
143
        }
142
				x += (width - len) / 2;
144
        
143
			}
145
        
144
		}
146
        gc.drawString(text, getBounds().x + x + pushedDrawingOffset,
145
147
                      y + pushedDrawingOffset,true);
146
		gc.drawString(text, getBounds().x + x + pushedDrawingOffset, y
148
147
				+ pushedDrawingOffset, true);
149
        if (column.getSort() != SWT.NONE)
148
150
        {
149
		if (column.getSort() != SWT.NONE) {
151
            arrowRenderer.setSelected(column.getSort() == SWT.UP);
150
			arrowRenderer.setSelected(column.getSort() == SWT.UP);
152
            if (drawSelected)
151
			if (drawSelected) {
153
            {
152
				arrowRenderer.setLocation(getBounds().x + getBounds().width
154
                arrowRenderer
153
						- arrowMargin - arrowRenderer.getBounds().width + 1,
155
                    .setLocation(
154
						getBounds().y
156
                                 getBounds().x + getBounds().width - arrowMargin
155
								+ ((getBounds().height - arrowRenderer
157
                                     - arrowRenderer.getBounds().width + 1,
156
										.getBounds().height) / 2) + 1);
158
                                 getBounds().y
157
			} else {
159
                                     + ((getBounds().height - arrowRenderer.getBounds().height) / 2)
158
				arrowRenderer.setLocation(getBounds().x + getBounds().width
160
                                     + 1);
159
						- arrowMargin - arrowRenderer.getBounds().width,
161
            }
160
						getBounds().y
162
            else
161
								+ ((getBounds().height - arrowRenderer
163
            {
162
										.getBounds().height) / 2));
164
                arrowRenderer
163
			}
165
                    .setLocation(
164
			arrowRenderer.paint(gc, null);
166
                                 getBounds().x + getBounds().width - arrowMargin
165
		}
167
                                     - arrowRenderer.getBounds().width,
166
168
                                 getBounds().y
167
		if (!flat) {
169
                                     + ((getBounds().height - arrowRenderer.getBounds().height) / 2));
168
170
            }
169
			if (drawSelected) {
171
            arrowRenderer.paint(gc, null);
170
				gc.setForeground(getDisplay().getSystemColor(
172
        }
171
						SWT.COLOR_WIDGET_NORMAL_SHADOW));
173
172
			} else {
174
        if (!flat)
173
				gc.setForeground(getDisplay().getSystemColor(
175
        {
174
						SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
176
              
175
			}
177
            if (drawSelected)
176
178
            {
177
			gc.drawLine(getBounds().x, getBounds().y, getBounds().x
179
                gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
178
					+ getBounds().width - 1, getBounds().y);
180
            }
179
			gc.drawLine(getBounds().x, getBounds().y, getBounds().x,
181
            else
180
					getBounds().y + getBounds().height - 1);
182
            {
181
183
                gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
182
			if (!drawSelected) {
184
            }
183
				gc.setForeground(getDisplay().getSystemColor(
185
    
184
						SWT.COLOR_WIDGET_LIGHT_SHADOW));
186
            gc.drawLine(getBounds().x, getBounds().y, getBounds().x + getBounds().width - 1,
185
				gc.drawLine(getBounds().x + 1, getBounds().y + 1, getBounds().x
187
                        getBounds().y);
186
						+ getBounds().width - 2, getBounds().y + 1);
188
            gc.drawLine(getBounds().x, getBounds().y, getBounds().x, getBounds().y + getBounds().height
187
				gc.drawLine(getBounds().x + 1, getBounds().y + 1,
189
                                                                     - 1);
188
						getBounds().x + 1, getBounds().y + getBounds().height
190
    
189
								- 2);
191
            if (!drawSelected)
190
			}
192
            {
191
193
                gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
192
			if (drawSelected) {
194
                gc.drawLine(getBounds().x + 1, getBounds().y + 1,
193
				gc.setForeground(getDisplay().getSystemColor(
195
                            getBounds().x + getBounds().width - 2, getBounds().y + 1);
194
						SWT.COLOR_WIDGET_NORMAL_SHADOW));
196
                gc.drawLine(getBounds().x + 1, getBounds().y + 1, getBounds().x + 1,
195
			} else {
197
                            getBounds().y + getBounds().height - 2);
196
				gc.setForeground(getDisplay().getSystemColor(
198
            }
197
						SWT.COLOR_WIDGET_DARK_SHADOW));
199
    
198
			}
200
            if (drawSelected)
199
			gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y,
201
            {
200
					getBounds().x + getBounds().width - 1, getBounds().y
202
                gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
201
							+ getBounds().height - 1);
203
            }
202
			gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1,
204
            else
203
					getBounds().x + getBounds().width - 1, getBounds().y
205
            {
204
							+ getBounds().height - 1);
206
                gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
205
207
            }
206
			if (!drawSelected) {
208
            gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y, getBounds().x
207
				gc.setForeground(getDisplay().getSystemColor(
209
                                                                              + getBounds().width - 1,
208
						SWT.COLOR_WIDGET_NORMAL_SHADOW));
210
                        getBounds().y + getBounds().height - 1);
209
				gc.drawLine(getBounds().x + getBounds().width - 2,
211
            gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1, getBounds().x
210
						getBounds().y + 1, getBounds().x + getBounds().width
212
                                                                               + getBounds().width - 1,
211
								- 2, getBounds().y + getBounds().height - 2);
213
                        getBounds().y + getBounds().height - 1);
212
				gc.drawLine(getBounds().x + 1, getBounds().y
214
            
213
						+ getBounds().height - 2, getBounds().x
215
            if (!drawSelected)
214
						+ getBounds().width - 2, getBounds().y
216
            {
215
						+ getBounds().height - 2);
217
                gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
216
			}
218
                gc.drawLine(getBounds().x + getBounds().width - 2, getBounds().y + 1,
217
219
                            getBounds().x + getBounds().width - 2, getBounds().y + getBounds().height
218
		} else {
220
                                                                   - 2);
219
			gc.setForeground(getDisplay().getSystemColor(
221
                gc.drawLine(getBounds().x + 1, getBounds().y + getBounds().height - 2,
220
					SWT.COLOR_WIDGET_DARK_SHADOW));
222
                            getBounds().x + getBounds().width - 2, getBounds().y + getBounds().height
221
223
                                                                   - 2);
222
			gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y,
224
            }
223
					getBounds().x + getBounds().width - 1, getBounds().y
225
            
224
							+ getBounds().height - 1);
226
        }
225
			gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1,
227
        else
226
					getBounds().x + getBounds().width - 1, getBounds().y
228
        {
227
							+ getBounds().height - 1);
229
            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
228
		}
230
229
231
            gc.drawLine(getBounds().x + getBounds().width - 1, getBounds().y, getBounds().x
230
	}
232
                                                                              + getBounds().width - 1,
231
233
                        getBounds().y + getBounds().height - 1);
232
	/**
234
            gc.drawLine(getBounds().x, getBounds().y + getBounds().height - 1, getBounds().x
233
	 * {@inheritDoc}
235
                                                                               + getBounds().width - 1,
234
	 */
236
                        getBounds().y + getBounds().height - 1);
235
	public void setDisplay(Display display) {
237
        }
236
		super.setDisplay(display);
238
        
237
		arrowRenderer.setDisplay(display);
239
238
	}
240
    }
239
241
240
	/**
242
    /**
241
	 * {@inheritDoc}
243
     * {@inheritDoc}
242
	 */
244
     */
243
	public boolean notify(int event, Point point, Object value) {
245
    public void setDisplay(Display display)
244
		return false;
246
    {
245
	}
247
        super.setDisplay(display);
246
248
        arrowRenderer.setDisplay(display);
247
	/**
249
    }
248
	 * {@inheritDoc}
250
249
	 */
251
    /** 
250
	public Rectangle getTextBounds(Object value, boolean preferred) {
252
     * {@inheritDoc}
251
		GridColumn column = (GridColumn) value;
253
     */
252
254
    public boolean notify(int event, Point point, Object value)
253
		int x = leftMargin;
255
    {
254
256
        return false;
255
		if (column.getImage() != null) {
257
    }
256
			x += column.getImage().getBounds().width + imageSpacing;
258
257
		}
259
    /** 
258
260
     * {@inheritDoc}
259
		GC gc = new GC(column.getParent());
261
     */
260
		gc.setFont(column.getParent().getFont());
262
    public Rectangle getTextBounds(Object value, boolean preferred)
261
		int y = bottomMargin;
263
    {
262
		
264
        GridColumn column = (GridColumn)value;
263
		if( column.getHeaderControl() != null ) {
265
        
264
			y = getBounds().height - bottomMargin
266
        int x = leftMargin;
265
			- gc.getFontMetrics().getHeight();			
267
266
		}
268
        if (column.getImage() != null)
267
269
        {
268
		Rectangle bounds = new Rectangle(x, y, 0, 0);
270
            x += column.getImage().getBounds().width + imageSpacing;
269
271
        }
270
		Point p = gc.stringExtent(column.getText());
272
271
273
272
		bounds.height = p.y;
274
273
275
        GC gc = new GC(column.getParent());
274
		if (preferred) {
276
        gc.setFont(column.getParent().getFont());
275
			bounds.width = p.x;
277
        int y = getBounds().height - bottomMargin - gc.getFontMetrics().getHeight();
276
		} else {
278
        
277
			int width = getBounds().width - x;
279
        Rectangle bounds = new Rectangle(x,y,0,0);
278
			if (column.getSort() == SWT.NONE) {
280
        
279
				width -= rightMargin;
281
        Point p = gc.stringExtent(column.getText());
280
			} else {
282
        
281
				width -= arrowMargin + arrowRenderer.getSize().x + arrowMargin;
283
        bounds.height = p.y;
282
			}
284
        
283
			bounds.width = width;
285
        if (preferred)
284
		}
286
        {
285
287
            bounds.width = p.x;
286
		gc.dispose();
288
        }
287
289
        else
288
		return bounds;
290
        {
289
	}
291
            int width = getBounds().width - x;
290
292
            if (column.getSort() == SWT.NONE)
291
	/**
293
            {
292
	 * @return the bounds reserved for the control
294
                width -= rightMargin;
293
	 */
295
            }
294
	protected Rectangle getControlBounds(Object value, boolean preferred) {
296
            else
295
		Rectangle bounds = getBounds();
297
            {
296
		GridColumn column = (GridColumn) value;
298
                width -= arrowMargin + arrowRenderer.getSize().x + arrowMargin;
297
		Point controlSize = computeControlSize(column);
299
            }
298
//		System.err.println(column.getHeaderControl() + ": " + controlSize); 
300
            bounds.width = width;
299
		return new Rectangle(bounds.x+3,bounds.height-bottomMargin-controlSize.y,bounds.width-6,controlSize.y);
301
        }
300
	}
302
        
301
303
        
302
	private Point computeControlSize(GridColumn column) {
304
        gc.dispose();
303
		if( column.getHeaderControl() != null ) {
305
        
304
			return column.getHeaderControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
306
        return bounds;        
305
		}
307
    }    
306
		return new Point(0,0);
307
	}
308
}
308
}
(-)src/org/eclipse/nebula/widgets/grid/GridHeaderEditor.java (+225 lines)
Added Link Here
1
package org.eclipse.nebula.widgets.grid;
2
3
import org.eclipse.swt.SWT;
4
import org.eclipse.swt.custom.ControlEditor;
5
import org.eclipse.swt.events.ControlEvent;
6
import org.eclipse.swt.events.ControlListener;
7
import org.eclipse.swt.events.SelectionEvent;
8
import org.eclipse.swt.events.SelectionListener;
9
import org.eclipse.swt.graphics.Rectangle;
10
import org.eclipse.swt.widgets.Event;
11
import org.eclipse.swt.widgets.Listener;
12
13
/**
14
 * Manager for a Control that appears below the grid column header.
15
 * Based on {@link GridEditor}. 
16
 */
17
class GridHeaderEditor extends ControlEditor {
18
19
  private Grid table;
20
21
  private GridColumn column;
22
  
23
  ControlListener columnListener;
24
  
25
  Listener resizeListener;
26
27
  private final Listener columnVisibleListener;
28
29
  private final Listener columnGroupListener;
30
31
  private final SelectionListener scrollListener;
32
  
33
  /**
34
   * Creates a TableEditor for the specified Table.
35
   * 
36
   * @param column the Table Control above which this editor will be displayed
37
   */
38
  GridHeaderEditor(final GridColumn column)
39
  {
40
      super(column.getParent());
41
      
42
      this.table = column.getParent();
43
      this.column = column;
44
      
45
      
46
      columnListener = new ControlListener()
47
      {
48
          public void controlMoved(ControlEvent e)
49
          {
50
              table.getDisplay().asyncExec(new Runnable() {
51
52
				public void run() {
53
					layout();
54
				}
55
            	  
56
              });
57
          }
58
59
          public void controlResized(ControlEvent e)
60
          {
61
              layout();
62
          }
63
      };
64
      
65
      columnVisibleListener = new Listener()
66
      {
67
        public void handleEvent(Event event)
68
          {
69
            getEditor().setVisible(((GridColumn)event.widget).isVisible());
70
            if (getEditor().isVisible()) layout();
71
          }  
72
      };
73
      
74
      resizeListener = new Listener()
75
      {
76
       public void handleEvent(Event event)
77
          {
78
              layout();
79
          }   
80
      };
81
      
82
      scrollListener = new SelectionListener()
83
      {
84
          public void widgetSelected(SelectionEvent e)
85
          {
86
              layout();
87
          }
88
          public void widgetDefaultSelected(SelectionEvent e)
89
          {
90
          }        
91
      };
92
      
93
      columnGroupListener = new Listener()
94
      {
95
          public void handleEvent(Event event)
96
          {
97
              if (getEditor() == null || getEditor().isDisposed()) return;
98
              getEditor().setVisible(column.isVisible());
99
              if (getEditor().isVisible()) layout();
100
          }
101
      };
102
103
      // The following three listeners are workarounds for
104
      // Eclipse bug 105764
105
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=105764
106
      table.addListener(SWT.Resize, resizeListener);
107
      
108
      if (table.getVerticalScrollBarProxy() != null)
109
      {
110
          table.getVerticalScrollBarProxy().addSelectionListener(scrollListener);
111
      }
112
      if (table.getHorizontalScrollBarProxy() != null)
113
      {
114
          table.getHorizontalScrollBarProxy().addSelectionListener(scrollListener);
115
      }
116
117
      // To be consistent with older versions of SWT, grabVertical defaults to
118
      // true
119
      grabVertical = true;
120
      
121
      initColumn();
122
  }
123
124
  /**
125
   * Returns the bounds of the editor.
126
   * @return bounds of the editor.
127
   */
128
  protected Rectangle internalComputeBounds()
129
  {
130
	return column.getHeaderRenderer().getControlBounds(column,true);
131
  }
132
133
  /**
134
   * Removes all associations between the TableEditor and the cell in the
135
   * table. The Table and the editor Control are <b>not</b> disposed.
136
   */
137
  public void dispose()
138
  {
139
      if (!table.isDisposed() && !column.isDisposed() )
140
      {
141
    	  column.removeControlListener(columnListener);
142
          if (column.getColumnGroup() != null){
143
        	  column.getColumnGroup().removeListener(SWT.Expand, columnGroupListener);
144
        	  column.getColumnGroup().removeListener(SWT.Collapse, columnGroupListener);
145
          }
146
      }
147
      
148
      if (!table.isDisposed())
149
      {
150
          table.removeListener(SWT.Resize, resizeListener);
151
          
152
          if (table.getVerticalScrollBarProxy() != null)
153
              table.getVerticalScrollBarProxy().removeSelectionListener(scrollListener);
154
          
155
          if (table.getHorizontalScrollBarProxy() != null)
156
              table.getHorizontalScrollBarProxy().removeSelectionListener(scrollListener);
157
      }
158
      
159
      columnListener = null;
160
      resizeListener = null;
161
      table = null;
162
      super.dispose();
163
  }
164
165
  /**
166
   * Sets the zero based index of the column of the cell being tracked by this
167
   * editor.
168
   * 
169
   * @param column the zero based index of the column of the cell being
170
   * tracked by this editor
171
   */
172
  void initColumn()
173
  {
174
175
	  column.addControlListener(columnListener);
176
	  column.addListener(SWT.Show, columnVisibleListener);
177
	  column.addListener(SWT.Hide, columnVisibleListener);
178
	  
179
      if (column.getColumnGroup() != null){
180
    	  column.getColumnGroup().addListener(SWT.Expand, columnGroupListener);
181
    	  column.getColumnGroup().addListener(SWT.Collapse, columnGroupListener);
182
      }
183
      layout();
184
  }
185
  
186
  /** 
187
   * {@inheritDoc}
188
   */
189
  public void layout()
190
  {
191
      if (table.isDisposed())
192
          return;
193
      table.getDisplay().asyncExec(new Runnable() {
194
195
		public void run() {
196
		      boolean hadFocus = false;
197
198
		      if (getEditor() == null || getEditor().isDisposed()) {
199
		          return;
200
		      }
201
		      
202
		      if (getEditor().getVisible())
203
		      {
204
		          hadFocus = getEditor().isFocusControl();
205
		      }
206
			Rectangle rect = internalComputeBounds();
207
		      if( rect == null ) {
208
		    	  getEditor().setVisible(false);
209
		    	  return;
210
		      }
211
		      getEditor().setBounds(rect);
212
		      
213
		      if (hadFocus)
214
		      {
215
		          if (getEditor() == null || getEditor().isDisposed())
216
		              return;
217
		          getEditor().setFocus();
218
		      }
219
		}
220
    	  
221
      });
222
223
  }
224
225
}

Return to bug 237846