/** * Default constructor. * * @param edit editable flag * @param win parent window */ public BaseXEditor(final boolean edit, final Window win) { super(win); setFocusable(true); setFocusTraversalKeysEnabled(!edit); addMouseMotionListener(this); addMouseWheelListener(this); addComponentListener(this); addMouseListener(this); addKeyListener(this); addFocusListener( new FocusAdapter() { @Override public void focusGained(final FocusEvent e) { if (isEnabled()) cursor(true); } @Override public void focusLost(final FocusEvent e) { cursor(false); rend.cursor(false); rend.repaint(); } }); layout(new BorderLayout(4, 0)); scroll = new BaseXBar(this); rend = new BaseXTextRenderer(text, scroll); add(rend, BorderLayout.CENTER); add(scroll, BorderLayout.EAST); Undo un = null; if (edit) { setBackground(Color.white); setBorder(new MatteBorder(1, 1, 0, 0, GUIConstants.color(6))); un = new Undo(); } else { mode(Fill.NONE); } undo = un; new BaseXPopup( this, edit ? new GUICommand[] { new UndoCmd(), new RedoCmd(), null, new CutCmd(), new CopyCmd(), new PasteCmd(), new DelCmd(), null, new AllCmd() } : new GUICommand[] {new CopyCmd(), null, new AllCmd()}); }