diff options
author | dejan | 2006-05-04 15:58:15 +0000 |
---|---|---|
committer | dejan | 2006-05-04 15:58:15 +0000 |
commit | 7cc9dd70a168959bc5d5a2c96b4bf553a76cc638 (patch) | |
tree | 299cce2df228291294d2aa0c02a2f41094cb2d25 | |
parent | 95444075a5dfae69c3e97553f2a8643f8b99321e (diff) | |
download | eclipse.platform.ui-20060504.tar.gz eclipse.platform.ui-20060504.tar.xz eclipse.platform.ui-20060504.zip |
140084 FormText control tag should support width and height attributesv20060504
2 files changed, 31 insertions, 0 deletions
diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java index e93ca1543e4..29cd1393b73 100644 --- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java +++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ControlSegment.java @@ -21,6 +21,8 @@ import org.eclipse.swt.widgets.Control; public class ControlSegment extends ObjectSegment implements IFocusSelectable { private boolean fill; + private int width = SWT.DEFAULT; + private int height = SWT.DEFAULT; public ControlSegment() { } @@ -29,6 +31,14 @@ public class ControlSegment extends ObjectSegment implements IFocusSelectable { this.fill = fill; } + public void setWidth(int width) { + this.width = width; + } + + public void setHeight(int height) { + this.height = height; + } + public Control getControl(Hashtable resourceTable) { Object obj = resourceTable.get(getObjectId()); if (obj instanceof Control) { @@ -47,6 +57,10 @@ public class ControlSegment extends ObjectSegment implements IFocusSelectable { Point size = control.computeSize(realWhint, SWT.DEFAULT); if (wHint!=SWT.DEFAULT && fill) size.x = Math.max(size.x, wHint); + if (width !=SWT.DEFAULT) + size.x = width; + if (height != SWT.DEFAULT) + size.y = height; return size; } diff --git a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java index eab3219f47e..238a4181633 100644 --- a/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java +++ b/bundles/org.eclipse.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java @@ -293,6 +293,23 @@ public class FormTextModel { boolean doFill = value.equalsIgnoreCase("true"); //$NON-NLS-1$ segment.setFill(doFill); } + try { + Node width = control.getAttributes().getNamedItem("width"); //$NON-NLS-1$ + if (width!=null) { + String value = width.getNodeValue(); + int doWidth = Integer.parseInt(value); + segment.setWidth(doWidth); + } + Node height = control.getAttributes().getNamedItem("height"); //$NON-NLS-1$ + if (height!=null) { + String value = height.getNodeValue(); + int doHeight = Integer.parseInt(value); + segment.setHeight(doHeight); + } + } + catch (NumberFormatException e) { + // ignore invalid width or height + } return segment; } |