private void passToView(final KeyEvent evt) { if (temp) view.removeToolBar(ActionBar.this); view.getTextArea().requestFocus(); SwingUtilities.invokeLater( new Runnable() { public void run() { view.getTextArea().requestFocus(); view.getInputHandler().setRepeatCount(repeatCount); view.getInputHandler().processKeyEvent(evt, View.ACTION_BAR, false); } }); }
// {{{ handlePluginUpdate() method @EBHandler public void handlePluginUpdate(PluginUpdate msg) { if (!queuedUpdate) { SwingUtilities.invokeLater( new Runnable() { public void run() { queuedUpdate = false; manager.update(); } }); queuedUpdate = true; } } // }}}
CompletionPopup(String[] actions) { super(view); setContentPane( new JPanel(new BorderLayout()) { public boolean isManagingFocus() { return false; } public boolean getFocusTraversalKeysEnabled() { return false; } }); list = new CompletionList(actions); list.setVisibleRowCount(8); list.addMouseListener(new MouseHandler()); list.setSelectedIndex(0); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scroller = new JScrollPane( list, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); getContentPane().add(scroller, BorderLayout.CENTER); GUIUtilities.requestFocus(this, list); pack(); Point p = new Point(0, -getHeight()); SwingUtilities.convertPointToScreen(p, action); setLocation(p); setVisible(true); KeyHandler keyHandler = new KeyHandler(); addKeyListener(keyHandler); list.addKeyListener(keyHandler); }
private void invoke() { String cmd; if (popup != null) cmd = popup.list.getSelectedValue().toString(); else { cmd = action.getText().trim(); int index = cmd.indexOf('='); if (index != -1) { action.addCurrentToHistory(); String propName = cmd.substring(0, index).trim(); String propValue = cmd.substring(index + 1).trim(); String code; if (propName.startsWith("buffer.")) { if (propName.equals("buffer.mode")) { code = "buffer.setMode(\"" + MiscUtilities.charsToEscapes(propValue) + "\");"; } else { code = "buffer.setStringProperty(\"" + MiscUtilities.charsToEscapes(propName.substring("buffer.".length())) + "\",\"" + MiscUtilities.charsToEscapes(propValue) + "\");"; } code += "\nbuffer.propertiesChanged();"; } else if (propName.startsWith("!buffer.")) { code = "jEdit.setProperty(\"" + MiscUtilities.charsToEscapes(propName.substring(1)) + "\",\"" + MiscUtilities.charsToEscapes(propValue) + "\");\n" + "jEdit.propertiesChanged();"; } else { code = "jEdit.setProperty(\"" + MiscUtilities.charsToEscapes(propName) + "\",\"" + MiscUtilities.charsToEscapes(propValue) + "\");\n" + "jEdit.propertiesChanged();"; } Macros.Recorder recorder = view.getMacroRecorder(); if (recorder != null) recorder.record(code); BeanShell.eval(view, namespace, code); cmd = null; } else if (cmd.length() != 0) { String[] completions = getCompletions(cmd); if (completions.length != 0) { cmd = completions[0]; } } else cmd = null; } if (popup != null) { popup.dispose(); popup = null; } final String finalCmd = cmd; final EditAction act = (finalCmd == null ? null : jEdit.getAction(finalCmd)); if (temp) view.removeToolBar(this); SwingUtilities.invokeLater( new Runnable() { public void run() { view.getTextArea().requestFocus(); if (act == null) { if (finalCmd != null) { view.getStatus() .setMessageAndClear(jEdit.getProperty("view.action.no-completions")); } } else { view.getInputHandler().setRepeatCount(repeatCount); view.getInputHandler().invokeAction(act); } } }); }