public View create(final Element elem) { if (elem == null) { return null; } Document doc = elem.getDocument(); Boolean i18n = (Boolean)doc.getProperty(StringConstants.BIDI_PROPERTY); if (i18n.booleanValue()) { return (View)AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { Class cls = Class.forName(FIELD_VIEW_I18N_CLASS); Constructor constructor = cls.getConstructor(new Class[] {Element.class}); constructor.setAccessible(true); return constructor.newInstance(new Object[] {elem}); } catch (Exception e) { return null; } } }); } return new FieldView(elem); }
public void testCreateElement() { Element element = jtf.getDocument().getDefaultRootElement(); View view = ui.create(element); assertTrue(view instanceof FieldView); element = element.getElement(0); view = ui.create(element); assertTrue(view instanceof FieldView); /* no view support for bidi text ui = (BasicTextFieldUI)jtfBidi.getUI(); element = jtfBidi.getDocument().getDefaultRootElement(); view = ui.create(element); assertFalse(view instanceof FieldView); */ }
public View create(Element elem) { return new FieldView(elem); }