public void setDataType(DataType dataType) { if (dataType == null) { dataTypeCombo.setSelection(null); } else { // TODO : check what happens if dataType not in combo try { dataTypeCombo.setSelection( new StructuredSelection(registry.getDataTypeInfo(dataType.getClass()))); } catch (IllegalArgumentException e) { // "DataTypeInfo not found in registry: " + dataType.getClass() DroolsEclipsePlugin.log(e); } } }
public void setDataType(DataType type) { ((Composite) editor).dispose(); if (type == null) { editor = new EmptyEditor(this); } else { Class editorClass = null; try { editorClass = registry.getDataTypeInfo(type.getClass()).getValueEditorClass(); editor = (Editor) editorClass .getConstructor(new Class[] {Composite.class}) .newInstance(new Object[] {this}); } catch (IllegalArgumentException e) { // "Could not find data type info for type " + type.getClass() DroolsEclipsePlugin.log(e); editor = new EmptyEditor(this); } catch (InstantiationException e) { // "Could not create editor for editor " + editorClass DroolsEclipsePlugin.log(e); editor = new EmptyEditor(this); } catch (NoSuchMethodException e) { // "Could not create editor for editor " + editorClass DroolsEclipsePlugin.log(e); editor = new EmptyEditor(this); } catch (InvocationTargetException e) { // "Could not create editor for editor " + editorClass DroolsEclipsePlugin.log(e); editor = new EmptyEditor(this); } catch (IllegalAccessException e) { // "Could not create editor for editor " + editorClass DroolsEclipsePlugin.log(e); editor = new EmptyEditor(this); } editor.setDataType(type); layout(); } }