return null;
}
private void initialize() {
cores = new Stack<Core>();
Core core = new Core(new ResourceLoaderFactory(), this);
cores.push(core);
core.registerService(ValueConvertorRegister.class,
new ValueConvertorRegister());
core.registerMetaclassManager(IConstants.XWT_NAMESPACE,
new MetaclassManager(null, null, this));
core.registerMetaclass(new BindingMetaclass(this),
IConstants.XWT_NAMESPACE);
core.registerMetaclass(new BindingMetaclass(MultiBinding.class, this),
IConstants.XWT_NAMESPACE);
core.registerMetaclass(new TableEditorMetaclass(core.getMetaclass(
ControlEditor.class, IConstants.XWT_NAMESPACE), this),
IConstants.XWT_NAMESPACE);
registerConvertor(ObjectToString.instance);
registerConvertor(DateToString.instance);
registerConvertor(EnumToString.instance);
registerConvertor(StringToInteger.instance);
// It is not supported by eclipse 3.4.1
registerConvertor(StringToNumberConverter.class, "toBigDecimal");
registerConvertor(StringToNumberConverter.class, "toByte", false);
registerConvertor(StringToNumberConverter.toLong(false));
// It is not supported by eclipse 3.4.1
registerConvertor(StringToNumberConverter.class, "toShort", false);
registerConvertor(StringToNumberConverter.toFloat(false));
registerConvertor(StringToNumberConverter.toDouble(false));
registerConvertor(NumberToStringConverter.fromInteger(false));
// It is not supported by eclipse 3.4.1
registerConvertor(NumberToStringConverter.class, "fromBigDecimal");
registerConvertor(NumberToStringConverter.class, "fromByte", false);
registerConvertor(NumberToStringConverter.fromLong(false));
// It is not supported by eclipse 3.4.1
registerConvertor(NumberToStringConverter.class, "fromShort", false);
registerConvertor(NumberToStringConverter.fromFloat(false));
registerConvertor(NumberToStringConverter.fromDouble(false));
registerConvertor(StringToBoolean.instance);
registerConvertor(ObjectToBoolean.instance);
registerConvertor(SelectionToBoolean.instance);
registerConvertor(CollectionToBoolean.instance);
registerConvertor(CollectionToInteger.instance);
registerConvertor(StringToIntArray.instance);
registerConvertor(BindingToObject.instance);
registerConvertor(StringToColor.instance);
registerConvertor(StringToFont.instance);
registerConvertor(StringToImage.instance);
registerConvertor(StringToPoint.instance);
registerConvertor(StringToRectangle.instance);
registerConvertor(StringToURL.instance);
registerConvertor(StringToType.instance);
registerConvertor(StringToFormAttachment.instance);
registerConvertor(StringToIValidationRule.instance);
registerConvertor(StringToIValueConverter.instance);
registerConvertor(ListToIObservableCollection.instance);
registerConvertor(SetToIObservableCollection.instance);
registerConvertor(ObjectToISelection.instance);
registerConvertor(ListToSet.instance);
registerConvertor(IStatusToString.instance);
registerConvertor(IStatusToBoolean.instance);
ValueConvertorRegister convertorRegister = (ValueConvertorRegister) core
.getService(ValueConvertorRegister.class);
convertorRegister.register(String.class, float.class,
StringToNumberConverter.toFloat(true));
convertorRegister.register(String.class, int.class,
StringToInteger.instance);
// It is not supported by eclipse 3.4.1
// convertorRegister.register(String.class, short.class,
// StringToNumberConverter.toShort(true));
registerConvertor(convertorRegister, String.class, short.class,
StringToNumberConverter.class, "toShort", true);
convertorRegister.register(String.class, long.class,
StringToNumberConverter.toLong(true));
// It is not supported by eclipse 3.4.1
// convertorRegister.register(String.class, byte.class,
// StringToNumberConverter.toByte(true));
registerConvertor(convertorRegister, String.class, byte.class,
StringToNumberConverter.class, "toByte", true);
convertorRegister.register(String.class, boolean.class,
StringToBoolean.instance);
convertorRegister.register(String.class, double.class,
StringToNumberConverter.toDouble(true));
convertorRegister.register(float.class, String.class,
NumberToStringConverter.fromFloat(true));
convertorRegister.register(int.class, String.class,
NumberToStringConverter.fromInteger(true));
// It is not supported by eclipse 3.4.1
// convertorRegister.register(short.class, String.class,
// NumberToStringConverter.fromShort(true));
registerConvertor(convertorRegister, short.class, String.class,
NumberToStringConverter.class, "fromShort", true);
convertorRegister.register(long.class, String.class,
NumberToStringConverter.fromLong(true));
// It is not supported by eclipse 3.4.1
// convertorRegister.register(byte.class, String.class,
// NumberToStringConverter.fromByte(true));
registerConvertor(convertorRegister, byte.class, String.class,
NumberToStringConverter.class, "fromByte", true);
convertorRegister.register(double.class, String.class,
NumberToStringConverter.fromDouble(true));
Class<?> type = org.eclipse.swt.browser.Browser.class;
IMetaclass browserMetaclass = (IMetaclass) registerMetaclass(type);
browserMetaclass.addProperty(new DynamicProperty(type, String.class,
PropertiesConstants.PROPERTY_URL));
IMetaclass buttonMetaclass = (IMetaclass) registerMetaclass(Button.class);
buttonMetaclass.addProperty(new DataProperty(IConstants.XAML_COMMAND,
IUserDataConstants.XWT_COMMAND_KEY, ICommand.class));
registerMetaclass(org.eclipse.swt.widgets.Canvas.class);
registerMetaclass(org.eclipse.swt.widgets.Caret.class);
registerMetaclass(org.eclipse.swt.widgets.Combo.class);
registerMetaclass(org.eclipse.swt.widgets.Composite.class);
registerMetaclass(org.eclipse.swt.widgets.CoolBar.class);
registerMetaclass(org.eclipse.swt.widgets.CoolItem.class);
registerMetaclass(org.eclipse.swt.widgets.DateTime.class);
registerMetaclass(org.eclipse.swt.widgets.Decorations.class);
registerMetaclass(org.eclipse.swt.widgets.ExpandBar.class);
IMetaclass expandItemMetaclass = registerMetaclass(ExpandItem.class);
expandItemMetaclass.findProperty("control").addSetPostAction(
new ExpandItemHeightAction());
registerMetaclass(Group.class);
registerMetaclass(IME.class);
registerMetaclass(Label.class);
registerMetaclass(Link.class);
registerMetaclass(Listener.class);
registerMetaclass(List.class);
registerMetaclass(Menu.class);
IMetaclass menuItemMetaclass = (IMetaclass) registerMetaclass(MenuItem.class);
menuItemMetaclass.addProperty(new DataProperty(IConstants.XAML_COMMAND,
IUserDataConstants.XWT_COMMAND_KEY, ICommand.class));
registerMetaclass(org.eclipse.swt.widgets.MessageBox.class);
registerMetaclass(org.eclipse.swt.widgets.ProgressBar.class);
registerMetaclass(org.eclipse.swt.widgets.Sash.class);
registerMetaclass(org.eclipse.swt.widgets.Scale.class);
registerMetaclass(org.eclipse.swt.widgets.ScrollBar.class);
registerMetaclass(org.eclipse.swt.widgets.Shell.class);
registerMetaclass(org.eclipse.swt.widgets.Slider.class);
registerMetaclass(org.eclipse.swt.widgets.Spinner.class);
registerMetaclass(org.eclipse.swt.widgets.TabFolder.class);
registerMetaclass(org.eclipse.swt.widgets.TabItem.class);
registerMetaclass(org.eclipse.swt.widgets.Table.class);
type = org.eclipse.swt.widgets.TableItem.class;
IMetaclass metaclass = (IMetaclass) registerMetaclass(type);
metaclass.addProperty(new TableItemProperty());
metaclass.addProperty(new TableItemEditorProperty());
metaclass.addProperty(new DynamicBeanProperty(TableItem.class,
String[].class, PropertiesConstants.PROPERTY_TEXTS,
PropertiesConstants.PROPERTY_TEXT));
registerMetaclass(TableItemProperty.Cell.class);
registerMetaclass(ControlEditor.class);
registerMetaclass(TableEditor.class);
IMetaclass TableEditorMetaclass = core.getMetaclass(TableEditor.class,
IConstants.XWT_NAMESPACE);
TableEditorMetaclass.addProperty(new TableEditorDynamicProperty());
type = org.eclipse.swt.widgets.TableColumn.class;
metaclass = (IMetaclass) registerMetaclass(type);
metaclass.addProperty(new TableColumnEditorProperty());
registerMetaclass(org.eclipse.swt.widgets.Text.class);
registerMetaclass(org.eclipse.swt.widgets.ToolBar.class);
registerMetaclass(org.eclipse.swt.widgets.ToolItem.class);
registerMetaclass(org.eclipse.swt.widgets.ToolTip.class);
registerMetaclass(org.eclipse.swt.widgets.Tracker.class);
registerMetaclass(org.eclipse.swt.widgets.Tray.class);
registerMetaclass(org.eclipse.swt.widgets.Tree.class);
registerMetaclass(org.eclipse.swt.widgets.TreeColumn.class);
registerMetaclass(org.eclipse.swt.widgets.TreeItem.class);
type = org.eclipse.swt.widgets.TreeItem.class;
metaclass = (IMetaclass) registerMetaclass(type);
metaclass.addProperty(new DynamicBeanProperty(TreeItem.class,
String[].class, PropertiesConstants.PROPERTY_TEXTS,
PropertiesConstants.PROPERTY_TEXT));
// registerMetaclass(org.eclipse.swt.layout.FillData.class);
registerMetaclass(org.eclipse.swt.layout.FillLayout.class);
registerMetaclass(org.eclipse.swt.layout.FormAttachment.class);
registerMetaclass(org.eclipse.swt.layout.FormData.class);
registerMetaclass(org.eclipse.swt.layout.FormLayout.class);
registerMetaclass(org.eclipse.swt.layout.GridData.class);
registerMetaclass(org.eclipse.swt.layout.GridLayout.class);
registerMetaclass(org.eclipse.swt.layout.RowData.class);
registerMetaclass(org.eclipse.swt.layout.RowLayout.class);
registerMetaclass(org.eclipse.swt.custom.StackLayout.class);
registerMetaclass(org.eclipse.swt.custom.CLabel.class);
registerMetaclass(org.eclipse.swt.custom.CCombo.class);
registerMetaclass(org.eclipse.swt.custom.CTabFolder.class);
registerMetaclass(org.eclipse.swt.custom.CTabItem.class);
registerMetaclass(org.eclipse.swt.custom.SashForm.class);
registerMetaclass(org.eclipse.swt.custom.StyledText.class);
registerMetaclass(org.eclipse.swt.custom.ScrolledComposite.class);
registerMetaclass(org.eclipse.swt.custom.TableTree.class);
registerMetaclass(org.eclipse.swt.custom.ViewForm.class);
registerMetaclass(org.eclipse.swt.custom.CBanner.class);
registerMetaclass(org.eclipse.swt.custom.TableCursor.class);
type = org.eclipse.swt.widgets.Widget.class;
metaclass = (IMetaclass) registerMetaclass(type);
metaclass.addProperty(new DataProperty(IConstants.XAML_DATA_CONTEXT,
IUserDataConstants.XWT_DATACONTEXT_KEY));
metaclass.addProperty(new DataProperty(IConstants.XAML_BINDING_CONTEXT,
IUserDataConstants.XWT_BINDING_CONTEXT_KEY));
metaclass.addProperty(new DataProperty(IConstants.XAML_TRIGGERS,
IUserDataConstants.XWT_TRIGGERS_KEY, TriggerBase[].class));
metaclass.addProperty(new StyleProperty());
registerEventGroup(type, new RadioEventGroup(IEventConstants.KEY_GROUP));
registerEventGroup(type, new RadioEventGroup(
IEventConstants.MOUSE_GROUP));
registerEventGroup(type, new RadioEventGroup(
IEventConstants.MOUSE_MOVING_GROUP));
registerEventGroup(type, new RadioEventGroup(
IEventConstants.FOCUS_GROUP));
registerEventGroup(type, new RadioEventGroup(
IEventConstants.EXPAND_GROUP));
registerEventGroup(type, new RadioEventGroup(
IEventConstants.WINDOW_GROUP));
registerEventGroup(type, new RadioEventGroup(
IEventConstants.ACTIVATION_GROUP));
registerEventGroup(type, new RadioEventGroup(IEventConstants.HARD_KEY));
type = org.eclipse.jface.viewers.Viewer.class;
metaclass = (IMetaclass) core.getMetaclass(type,
IConstants.XWT_NAMESPACE);
if (metaclass != null) {
IProperty property = metaclass.findProperty("Input");
metaclass.addProperty(new InputBeanProperty(property));
metaclass.addProperty(new DataProperty(
IConstants.XAML_DATA_CONTEXT,
IUserDataConstants.XWT_DATACONTEXT_KEY));
metaclass.removeProperty("selection");
metaclass.addProperty(new DataProperty(
PropertiesConstants.PROPERTY_BINDING_PATH,
IUserDataConstants.XWT_PROPERTY_DATA_KEY, String.class));
metaclass.addProperty(new DataProperty(
PropertiesConstants.PROPERTY_ITEM_TEXT,
IUserDataConstants.XWT_PROPERTY_ITEM_TEXT_KEY,
IBinding.class));
metaclass.addProperty(new DataProperty(
PropertiesConstants.PROPERTY_ITEM_IMAGE,
IUserDataConstants.XWT_PROPERTY_ITEM_IMAGE_KEY,
IBinding.class));
metaclass.addProperty(new SingleSelectionBeanProperty(
PropertiesConstants.PROPERTY_SINGLE_SELECTION));
metaclass.addProperty(new MultiSelectionBeanProperty(
PropertiesConstants.PROPERTY_MULTI_SELECTION));
}
type = org.eclipse.jface.viewers.AbstractListViewer.class;
metaclass = (IMetaclass) core.getMetaclass(type,
IConstants.XWT_NAMESPACE);
if (metaclass != null) {
metaclass.addInitializer(new JFaceInitializer());
}
type = org.eclipse.jface.viewers.ColumnViewer.class;
metaclass = (IMetaclass) core.getMetaclass(type,
IConstants.XWT_NAMESPACE);
if (metaclass != null) {
metaclass.addProperty(new DynamicBeanProperty(type, String[].class,
PropertiesConstants.PROPERTY_COLUMN_PROPERTIES));
metaclass.addProperty(new ColumnViewerColumnsProperty());
metaclass.addInitializer(new JFaceInitializer());
}
for (Class<?> cls : JFacesHelper.getSupportedElements()) {
registerMetaclass(cls);
}
type = org.eclipse.jface.viewers.TableViewer.class;
metaclass = (IMetaclass) core.getMetaclass(type,
IConstants.XWT_NAMESPACE);
IProperty property = metaclass.findProperty("table");
if (property instanceof AbstractProperty) {
AbstractProperty abstractProperty = (AbstractProperty) property;
abstractProperty.setValueAsParent(true);
}
core.registerMetaclass(new ComboBoxCellEditorMetaclass(core
.getMetaclass(ComboBoxCellEditor.class.getSuperclass(),
IConstants.XWT_NAMESPACE), this),
IConstants.XWT_NAMESPACE);
type = org.eclipse.jface.viewers.TableViewerColumn.class;
core.registerMetaclass(new TableViewerColumnMetaClass(core
.getMetaclass(type.getSuperclass(), IConstants.XWT_NAMESPACE),
this), IConstants.XWT_NAMESPACE);
metaclass = (IMetaclass) core.getMetaclass(type,
IConstants.XWT_NAMESPACE);
//
// PROPERTY_DATA_KEY
//
metaclass.addProperty(new TableViewerColumnWidthProperty());