public void update(final AnActionEvent e) { final EditorEx editor = myLanguageConsole.getConsoleEditor(); final Lookup lookup = LookupManager.getActiveLookup(editor); e.getPresentation() .setEnabled( !editor.isRendererMode() && !myProcessHandler.isProcessTerminated() && (lookup == null || !(lookup.isCompletion() && lookup.isFocused()))); }
private String constructConsoleTitle(final @NotNull String consoleTitle) { if (shouldAddNumberToTitle()) { List<RunContentDescriptor> consoles = ExecutionHelper.collectConsolesByDisplayName( myProject, new NotNullFunction<String, Boolean>() { @NotNull @Override public Boolean fun(String dom) { return dom.contains(consoleTitle); } }); int max = 0; for (RunContentDescriptor dsc : consoles) { ProcessHandler handler = dsc.getProcessHandler(); if (handler != null && !handler.isProcessTerminated()) { if (max == 0) { max = 1; } try { int num = Integer.parseInt( dsc.getDisplayName() .substring(consoleTitle.length() + 1, dsc.getDisplayName().length() - 1)); if (num > max) { max = num; } } catch (Exception e) { // skip } } } if (max >= 1) { return consoleTitle + "(" + (max + 1) + ")"; } } return consoleTitle; }