/** * Sets a mnemomic for the specified button. * * @param b button * @param mnem mnemonics that have already been assigned */ public static void setMnemonic(final AbstractButton b, final StringBuilder mnem) { // do not set mnemonics for Mac! Alt+key used for special characters. if (Prop.MAC) return; // find and assign unused mnemomic final String label = b.getText(); final int ll = label.length(); for (int l = 0; l < ll; l++) { final char ch = Character.toLowerCase(label.charAt(l)); if (!letter(ch) || mnem.indexOf(Character.toString(ch)) != -1) continue; b.setMnemonic(ch); mnem.append(ch); break; } }
/** * Sets the output text. * * @param out cached output */ public void setText(final ArrayOutput out) { final byte[] buf = out.buffer(); final int size = (int) out.size(); final byte[] chop = token(DOTS); if (out.finished() && size >= chop.length) { System.arraycopy(chop, 0, buf, size - chop.length, chop.length); } text.setText(buf, size); header.setText((out.finished() ? CHOPPED : "") + RESULT); home.setEnabled(gui.context.data() != null); }
/** * Default constructor. * * @param man view manager */ public TextView(final ViewNotifier man) { super(TEXTVIEW, man); border(5).layout(new BorderLayout(0, 5)); header = new BaseXHeader(RESULT); home = BaseXButton.command(GUIMenuCmd.C_HOME, gui); home.setEnabled(false); text = new TextPanel(false, gui); text.setSyntax(new SyntaxXML()); search = new SearchEditor(gui, text); final AbstractButton save = BaseXButton.get("c_save", SAVE, false, gui); final AbstractButton find = search.button(FIND); final BaseXBack buttons = new BaseXBack(false); buttons.layout(new TableLayout(1, 3, 1, 0)).border(0, 0, 4, 0); buttons.add(save); buttons.add(home); buttons.add(find); final BaseXBack b = new BaseXBack(false).layout(new BorderLayout()); b.add(buttons, BorderLayout.WEST); b.add(header, BorderLayout.EAST); add(b, BorderLayout.NORTH); add(search, BorderLayout.CENTER); save.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { save(); } }); refreshLayout(); }
/** * Serializes the specified nodes. * * @param n nodes to display */ private void setText(final DBNodes n) { if (visible()) { try { final ArrayOutput ao = new ArrayOutput(); ao.setLimit(gui.gopts.get(GUIOptions.MAXTEXT)); if (n != null) n.serialize(Serializer.get(ao)); setText(ao); cmd = null; ns = ao.finished() ? n : null; } catch (final IOException ex) { Util.debug(ex); } } else { home.setEnabled(gui.context.data() != null); } }