/** * This method inserts a default value for the standard java types, else it inserts the text name * of the expected class type. It acts to give a clue as to the input type. */ public static String getDefaultValue(String type) { if (numericalTypes.contains(type) || extraNumericalTypes.contains(type)) { return "0"; } if (booleanTypes.contains(type)) { return "true"; } type = getReadableClassName(type); int i = type.lastIndexOf('.'); if (i > 0) { return type.substring(i + 1, type.length()); } else { return type; } }
static { // compute primitives/primitiveMap/primitiveToWrapper for (Class<?> c : primitiveWrappers) { try { Field f = c.getField("TYPE"); Class<?> p = (Class<?>) f.get(null); primitives.add(p); primitiveMap.put(p.getName(), p); primitiveToWrapper.put(p.getName(), c); } catch (Exception e) { throw new AssertionError(e); } } // compute editableTypes for (Class<?> c : primitives) { editableTypes.add(c.getName()); } for (Class<?> c : primitiveWrappers) { editableTypes.add(c.getName()); } for (Class<?> c : extraEditableClasses) { editableTypes.add(c.getName()); } // compute numericalTypes for (Class<?> c : primitives) { String name = c.getName(); if (!name.equals(Boolean.TYPE.getName())) { numericalTypes.add(name); } } for (Class<?> c : primitiveWrappers) { String name = c.getName(); if (!name.equals(Boolean.class.getName())) { numericalTypes.add(name); } } }
@Override public void keyPressed(KeyEvent e) { // Accept "copy" key strokes KeyStroke ks = KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()); JComponent comp = (JComponent) e.getSource(); for (int i = 0; i < 3; i++) { InputMap im = comp.getInputMap(i); Object key = im.get(ks); if (defaultEditorKitCopyActionName.equals(key) || transferHandlerCopyActionName.equals(key)) { return; } } // Accept JTable navigation key strokes if (!tableNavigationKeys.contains(e.getKeyCode())) { e.consume(); } }
/** This method tells whether the type is editable (means can be created with a String or not) */ public static boolean isEditableType(String type) { return editableTypes.contains(type); }
// Here's where the font is set on the editor pane, and we also keep // track of the panes in use for future font updates. public void install(JEditorPane pane) { if (Settings.debug) System.err.println("Installing kit into pane"); delegate.install(pane); panes.add(pane); pane.setFont(Settings.font); }
public void deinstall(JEditorPane pane) { if (Settings.debug) System.err.println("Deinstalling kit from pane"); panes.remove(pane); delegate.deinstall(pane); }