# HG changeset patch # User Frank Benoit # Date 1213966152 -7200 # Node ID 31d465ea8ac5205b597bbb6d1ba7fa1de7768d54 # Parent 7ab2f0b1109605c7a64565b818979a2c379fbf89# Parent 56fea7e5f0f9b2f9d31db17942c6988360436d0a merge diff -r 56fea7e5f0f9 -r 31d465ea8ac5 dwtx/jface/layout/LayoutGenerator.d --- a/dwtx/jface/layout/LayoutGenerator.d Fri Jun 20 14:48:17 2008 +0200 +++ b/dwtx/jface/layout/LayoutGenerator.d Fri Jun 20 14:49:12 2008 +0200 @@ -28,6 +28,7 @@ import dwtx.jface.util.Geometry; import dwt.dwthelper.utils; +import tango.text.convert.Format; /* package */class LayoutGenerator { @@ -137,12 +138,12 @@ bool hScroll = hasStyle(control, DWT.H_SCROLL); bool vScroll = hasStyle(control, DWT.V_SCROLL); - bool containsText = hasMethod(control, "setText", [ ArrayWrapperString.classinfo ] ); //$NON-NLS-1$ + bool containsText = hasMethodSetText(control);//, "setText", [ ArrayWrapperString.classinfo ] ); //$NON-NLS-1$ // If the control has a setText method, an addModifyListener method, and // does not have // the DWT.READ_ONLY flag, assume it contains user-editable text. - bool userEditable = !hasStyle(control, DWT.READ_ONLY) && containsText && hasMethod(control, "addModifyListener", [ ModifyListener.classinfo ]); //$NON-NLS-1$ + bool userEditable = !hasStyle(control, DWT.READ_ONLY) && containsText && hasMethodAddModifyListener(control);//, "addModifyListener", [ ModifyListener.classinfo ]); //$NON-NLS-1$ // For controls containing user-editable text... if (userEditable) { @@ -195,17 +196,78 @@ return GridDataFactory.fillDefaults().grab(grabHorizontal, vScroll).align_(DWT.FILL, vAlign).hint(hHint, vScroll ? defaultSize.y : DWT.DEFAULT); } - private static bool hasMethod(Control control, String name, ClassInfo[] parameterTypes) { - ClassInfo c = control.classinfo; - implMissing(__FILE__,__LINE__); - pragma(msg, "FIXME dwtx.jface.layout.LayoutGenerator hasMethod reflection" ); - return true; -/+ try { - return c.getMethod(name, parameterTypes) !is null; - } catch (SecurityException e) { - return false; - } catch (NoSuchMethodException e) { - return false; - }+/ + struct ControlInfo { + char[] name; + bool hasSetText; + bool hasAddModifierListener; } + static ControlInfo[] controlInfo = [ + { "dwt.custom.CBanner.CBanner", false, false }, + { "dwt.custom.CCombo.CCombo", true, true }, + { "dwt.custom.CLabel.CLabel", true, false }, + { "dwt.custom.CTabFolder.CTabFolder", false, false }, + { "dwt.custom.SashForm.SashForm", false, false }, + { "dwt.custom.ScrolledComposite.ScrolledComposite", false, false }, + { "dwt.custom.StyledText.StyledText", true, true }, + { "dwt.custom.TableCursor.TableCursor", false, false }, + { "dwt.custom.TableTree.TableTree", false, false }, + { "dwt.custom.ViewForm.ViewForm", false, false }, + { "dwt.opengl.GLCanvas.GLCanvas", false, false }, + { "dwt.widgets.Button.Button", true, false }, + { "dwt.widgets.Canvas.Canvas", false, false }, + { "dwt.widgets.Combo.Combo", true, true }, + { "dwt.widgets.Composite.Composite", false, false }, + { "dwt.widgets.Control.Control", false, false }, + { "dwt.widgets.CoolBar.CoolBar", false, false }, + { "dwt.widgets.DateTime.DateTime", false, false }, + { "dwt.widgets.Decorations.Decorations", true, false }, + { "dwt.widgets.ExpandBar.ExpandBar", false, false }, + { "dwt.widgets.Group.Group", true, false }, + { "dwt.widgets.Label.Label", true, false }, + { "dwt.widgets.Link.Link", true, false }, + { "dwt.widgets.List.List", false, false }, + { "dwt.widgets.ProgressBar.ProgressBar", false, false }, + { "dwt.widgets.Sash.Sash", false, false }, + { "dwt.widgets.Scale.Scale", false, false }, + { "dwt.widgets.Scrollable.Scrollable", false, false }, + { "dwt.widgets.Shell.Shell", true, false }, + { "dwt.widgets.Slider.Slider", false, false }, + { "dwt.widgets.Spinner.Spinner", false, true }, + { "dwt.widgets.TabFolder.TabFolder", false, false }, + { "dwt.widgets.Table.Table", false, false }, + { "dwt.widgets.Text.Text", true, true }, + { "dwt.widgets.ToolBar.ToolBar", false, false }, + { "dwt.widgets.Tree.Tree", false, false }, + ]; + private static bool hasMethodSetText(Control control) { + char[] name = control.classinfo.name; + foreach( ci; controlInfo ){ + if( ci.name == name ){ + return ci.hasSetText; + } + } + throw new Exception( Format( "{}:{} Control was not found for reflection info: {}", __FILE__, __LINE__, name )); + } + private static bool hasMethodAddModifyListener(Control control) { + char[] name = control.classinfo.name; + foreach( ci; controlInfo ){ + if( ci.name == name ){ + return ci.hasAddModifierListener; + } + } + throw new Exception( Format( "{}:{} Control was not found for reflection info: {}", __FILE__, __LINE__, name )); + } +// private static bool hasMethod(Control control, String name, ClassInfo[] parameterTypes) { +// ClassInfo c = control.classinfo; +// implMissing(__FILE__,__LINE__); +// pragma(msg, "FIXME dwtx.jface.layout.LayoutGenerator hasMethod reflection" ); +// return true; +///+ try { +// return c.getMethod(name, parameterTypes) !is null; +// } catch (SecurityException e) { +// return false; +// } catch (NoSuchMethodException e) { +// return false; +// }+/ +// } }