Top Description Fields Constructors Methods
org.eclipse.swt.custom

public Class ControlEditor

extends Object
Class Inheritance
Known Direct Subclasses
org.eclipse.swt.custom.TableEditor, org.eclipse.swt.custom.TreeEditor
Imports
org.eclipse.swt.*, org.eclipse.swt.graphics.*, org.eclipse.swt.widgets.*

A ControlEditor is a manager for a Control that appears above a composite and tracks with the moving and resizing of that composite. It can be used to display one control above another control. This could be used when editing a control that does not have editing capabilities by using a text editor or for launching a dialog by placing a button above a control.

Here is an example of using a ControlEditor:


Canvas canvas = new Canvas(shell, SWT.BORDER);
canvas.setBounds(10, 10, 300, 300);
Color color = new Color(null, 255, 0, 0);
canvas.setBackground(color);
ControlEditor editor = new ControlEditor (canvas);
// The editor will be a button in the bottom right corner of the canvas.
// When selected, it will launch a Color dialog that will change the background
// of the canvas.
Button button = new Button(canvas, SWT.PUSH);
button.setText("Select Color...");
button.addSelectionListener (new SelectionAdapter() {
	public void widgetSelected(SelectionEvent e) {
		ColorDialog dialog = new ColorDialog(shell);
		dialog.open();
		RGB rgb = dialog.getRGB();
		if (rgb != null) {
			if (color != null) color.dispose();
			color = new Color(null, rgb);
			canvas.setBackground(color);
		}

	}
});

editor.horizontalAlignment = SWT.RIGHT;
editor.verticalAlignment = SWT.BOTTOM;
editor.grabHorizontal = false;
editor.grabVertical = false;
Point size = button.computeSize(SWT.DEFAULT, SWT.DEFAULT);
editor.minimumWidth = size.x;
editor.minimumHeight = size.y;
editor.setEditor (button);
See Also
Sample code and further information

Field Summary

Modifier and TypeField and Description
private Listener
pack-priv Control
private static final int[]
public boolean
grabHorizontal

Specifies whether the editor should be sized to use the entire width of the control.

public boolean
grabVertical

Specifies whether the editor should be sized to use the entire height of the control.

private boolean
public int
horizontalAlignment

Specifies how the editor should be aligned relative to the control.

public int
minimumHeight

Specifies the minimum height the editor can have.

public int
minimumWidth

Specifies the minimum width the editor can have.

pack-priv Composite
private Listener
public int
verticalAlignment

Specifies how the editor should be aligned relative to the control.

Constructor Summary

AccessConstructor and Description
public
ControlEditor(Composite
the Composite above which this editor will be displayed
parent
)

Creates a ControlEditor for the specified Composite.

Method Summary

Modifier and TypeMethod and Description
pack-priv Rectangle
public void
dispose()

Removes all associations between the Editor and the underlying composite.

public Control

Returns:

the Control that is displayed above the composite being edited
getEditor
()

Returns the Control that is displayed above the composite being edited.

public void
layout()

Lays out the control within the underlying composite.

pack-priv void
public void
setEditor(Control
the Control that is displayed above the composite being edited
editor
)

Specify the Control that is to be displayed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

controlListenerback to summary
private Listener controlListener
editorback to summary
pack-priv Control editor
EVENTSback to summary
private static final int[] EVENTS
grabHorizontalback to summary
public boolean grabHorizontal

Specifies whether the editor should be sized to use the entire width of the control. True means resize the editor to the same width as the cell. False means do not adjust the width of the editor. The default value is false.

grabVerticalback to summary
public boolean grabVertical

Specifies whether the editor should be sized to use the entire height of the control. True means resize the editor to the same height as the underlying control. False means do not adjust the height of the editor. The default value is false.

hadFocusback to summary
private boolean hadFocus
horizontalAlignmentback to summary
public int horizontalAlignment

Specifies how the editor should be aligned relative to the control. Allowed values are SWT.LEFT, SWT.RIGHT and SWT.CENTER. The default value is SWT.CENTER.

minimumHeightback to summary
public int minimumHeight

Specifies the minimum height the editor can have. This is used in association with a true value of grabVertical. If the control becomes smaller than the minimumHeight, the editor will not made smaller than the minimum height value. The default value is 0.

minimumWidthback to summary
public int minimumWidth

Specifies the minimum width the editor can have. This is used in association with a true value of grabHorizontal. If the cell becomes smaller than the minimumWidth, the editor will not made smaller than the minimum width value. The default value is 0.

parentback to summary
pack-priv Composite parent
scrollbarListenerback to summary
private Listener scrollbarListener
verticalAlignmentback to summary
public int verticalAlignment

Specifies how the editor should be aligned relative to the control. Allowed values are SWT.TOP, SWT.BOTTOM and SWT.CENTER. The default value is SWT.CENTER.

Constructor Detail

ControlEditorback to summary
public ControlEditor(Composite parent)

Creates a ControlEditor for the specified Composite.

Parameters
parent:Composite

the Composite above which this editor will be displayed

Method Detail

computeBoundsback to summary
pack-priv Rectangle computeBounds()
disposeback to summary
public void dispose()

Removes all associations between the Editor and the underlying composite. The composite and the editor Control are not disposed.

getEditorback to summary
public Control getEditor()

Returns the Control that is displayed above the composite being edited.

Returns:Control

the Control that is displayed above the composite being edited

layoutback to summary
public void layout()

Lays out the control within the underlying composite. This method should be called after changing one or more fields to force the Editor to resize.

Since
2.1
scrollback to summary
pack-priv void scroll(Event e)
setEditorback to summary
public void setEditor(Control editor)

Specify the Control that is to be displayed.

Note

The Control provided as the editor must be created with its parent being the Composite specified in the ControlEditor constructor.

Parameters
editor:Control

the Control that is displayed above the composite being edited