+
+ private FormData formData(Object top, Object bottom, Object left, Object right) {
+ return formData(top, bottom, left, right, null);
+ }
+
+ private FormData formData(Object top, Object bottom, Object left, Object right, Integer height) {
+ FormData d = new FormData();
+ d.top = formAttachment(top);
+ d.bottom = formAttachment(bottom);
+ d.left = formAttachment(left);
+ d.right = formAttachment(right);
+ d.height = height != null ? (Integer) height : SWT.DEFAULT;
+ return d;
+ }
+
+ private FormAttachment formAttachment(Object o) {
+ if (o == null)
+ return null;
+ if (o instanceof Control)
+ return new FormAttachment((Control) o);
+ if (o instanceof Integer)
+ return new FormAttachment((Integer) o);
+ if (o instanceof Tuple2) {
+ Tuple2 t = (Tuple2) o;
+ return new FormAttachment((Integer) t.c0, (Integer) t.c1);
+ }
+ throw new IllegalArgumentException("argument not supported: " + o);
+ }
+