/** * Convert buffer name to editor object before call back to command executable * * @see * com.mulgasoft.emacsplus.minibuffer.WithMinibuffer#executeResult(org.eclipse.ui.texteditor.ITextEditor, * java.lang.Object) */ @Override protected boolean executeResult(ITextEditor editor, Object minibufferResult) { String bufferName = (String) minibufferResult; IEditorReference result = null; if (bufferName != null && bufferName.length() > 0) { // get the editor reference by name result = getBufferList().get(bufferName); if (result == null) { try { // Attempt auto-completion if name fetch failed SortedMap<String, IEditorReference> viewTree = getBuffers(bufferName, false, false); if (viewTree.size() == 1) { bufferName = viewTree.firstKey(); result = viewTree.get(bufferName); } } catch (Exception e) { // Could be a java.util.regex.PatternSyntaxException on weird input // when looking for a match; just ignore and command will abort } } } else if (defaultFile != null) { result = defaultFile; } if (result != null) { addToHistory(result.getName()); setExecuting(true); // remember the executable as getEditor(true), if it has to restore the editor, // will automatically give it focus, which results in a call to out focusLost.... IMinibufferExecutable ex = getExecutable(); super.executeResult(editor, ex, result.getEditor(true)); } else { beep(); } return true; }
protected void leave(boolean closeDialog) { try { super.leave(closeDialog); } finally { this.bufferList = null; this.defaultFile = null; } }
protected void resetSearch() { setMBString(EMPTY_STR); super.resetSearch(); }