private void removeAllContents(Project project, Content notRemove) { if (project.isDisposed()) { return; } final MessageView messageView = MessageView.SERVICE.getInstance(project); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { if (content.isPinned()) { continue; } if (content == notRemove) { continue; } boolean toRemove = CONTENT_ID_KEY.get(content) == myContentId; if (!toRemove) { final Object contentSessionId = SESSION_ID_KEY.get(content); toRemove = contentSessionId != null && contentSessionId != mySessionId; // the content was added by previous compilation } if (toRemove) { messageView.getContentManager().removeContent(content, true); } } }
private void close() { MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { if (content.getComponent() == this) { messageView.getContentManager().removeContent(content, true); return; } } }
public void showCompilerContent() { synchronized (myMessageViewLock) { if (myErrorTreeView != null) { final MessageView messageView = MessageView.SERVICE.getInstance(myProject); Content[] contents = messageView.getContentManager().getContents(); for (Content content : contents) { if (content.getUserData(myContentIdKey) != null) { messageView.getContentManager().setSelectedContent(content); return; } } } } }
// error tree view initialization must be invoked from event dispatch thread private void openMessageView() { if (isHeadlessMode()) { return; } if (myIndicator.isCanceled()) { return; } final JComponent component; synchronized (myMessageViewLock) { if (myErrorTreeView != null) { return; } myErrorTreeView = new CompilerErrorTreeView(myProject, myRestartWork); myErrorTreeView.setProcessController( new NewErrorTreeViewPanel.ProcessController() { @Override public void stopProcess() { cancel(); } @Override public boolean isProcessStopped() { return !myIndicator.isRunning(); } }); component = myErrorTreeView.getComponent(); } final MessageView messageView = MessageView.SERVICE.getInstance(myProject); final Content content = ContentFactory.SERVICE.getInstance().createContent(component, myContentName, true); CONTENT_ID_KEY.set(content, myContentId); SESSION_ID_KEY.set(content, mySessionId); messageView.getContentManager().addContent(content); myCloseListener.setContent(content, messageView.getContentManager()); removeAllContents(myProject, content); messageView.getContentManager().setSelectedContent(content); }
private void sendMsg(String msg) { isSendingMsg = true; final View view = MessageView.getInstance(this, 0, msg).view; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { view.setLayoutDirection(View.LAYOUT_DIRECTION_RTL); } ((LinearLayout) findViewById(R.id.layout_chatbox)).addView(view); (new Handler()) .post( new Runnable() { @Override public void run() { ((ScrollView) findViewById(R.id.scroll_chatbox)).fullScroll(ScrollView.FOCUS_DOWN); if (isBtmBarShowing) findViewById(R.id.btn_voice).requestFocus(); else findViewById(R.id.type_blank).requestFocus(); isSendingMsg = false; } }); SdkData.turingApiManager.requestTuringAPI(msg); ((EditText) findViewById(R.id.type_blank)).setText(""); }
/** @return can be null if user cancelled operation */ @Nullable public static AntBuildMessageView openBuildMessageView( Project project, AntBuildFileBase buildFile, String[] targets) { final VirtualFile antFile = buildFile.getVirtualFile(); if (!LOG.assertTrue(antFile != null)) { return null; } // check if there are running instances of the same build file MessageView ijMessageView = MessageView.SERVICE.getInstance(project); Content[] contents = ijMessageView.getContentManager().getContents(); for (Content content : contents) { if (content.isPinned()) { continue; } AntBuildMessageView buildMessageView = content.getUserData(KEY); if (buildMessageView == null) { continue; } if (!antFile.equals(buildMessageView.getBuildFile().getVirtualFile())) { continue; } if (buildMessageView.isStopped()) { ijMessageView.getContentManager().removeContent(content, true); continue; } int result = Messages.showYesNoCancelDialog( AntBundle.message("ant.is.active.terminate.confirmation.text"), AntBundle.message("starting.ant.build.dialog.title"), Messages.getQuestionIcon()); switch (result) { case 0: // yes buildMessageView.stopProcess(); ijMessageView.getContentManager().removeContent(content, true); continue; case 1: // no continue; default: // cancel return null; } } final AntBuildMessageView messageView = new AntBuildMessageView(project, buildFile, targets); String contentName = buildFile.getPresentableName(); contentName = BUILD_CONTENT_NAME + " (" + contentName + ")"; final Content content = ContentFactory.SERVICE .getInstance() .createContent(messageView.getComponent(), contentName, true); content.putUserData(KEY, messageView); ijMessageView.getContentManager().addContent(content); ijMessageView.getContentManager().setSelectedContent(content); content.setDisposer( new Disposable() { @Override public void dispose() { Disposer.dispose(messageView.myAlarm); } }); new CloseListener(content, ijMessageView.getContentManager(), project); // Do not inline next two variabled. Seeking for NPE. ToolWindow messageToolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); messageToolWindow.activate(null, false); return messageView; }