Search in sources :

Example 51 with Content

use of com.intellij.ui.content.Content in project android by JetBrains.

the class DefaultGradleConsoleView method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
    //Create runner UI layout
    RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(myProject);
    RunnerLayoutUi layoutUi = factory.create("", "", "session", myProject);
    JComponent layoutComponent = layoutUi.getComponent();
    // Adding actions
    DefaultActionGroup group = new DefaultActionGroup();
    layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN);
    Content console = layoutUi.createContent(GradleConsoleToolWindowFactory.ID, myConsoleView.getComponent(), "", null, null);
    AnAction[] consoleActions = myConsoleView.createConsoleActions();
    for (AnAction action : consoleActions) {
        if (!shouldIgnoreAction(action)) {
            group.add(action);
        }
    }
    layoutUi.addContent(console, 0, PlaceInGrid.right, false);
    myConsolePanel.add(layoutComponent, BorderLayout.CENTER);
    //noinspection ConstantConditions
    Content content = ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true);
    toolWindow.getContentManager().addContent(content);
}
Also used : RunnerLayoutUi(com.intellij.execution.ui.RunnerLayoutUi) Content(com.intellij.ui.content.Content) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 52 with Content

use of com.intellij.ui.content.Content in project android by JetBrains.

the class AndroidToolWindowFactory method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
    // In order to use the runner layout ui, the runner infrastructure needs to be initialized.
    // Otherwise it is not possible to for example drag one of the tabs out of the tool window.
    // The object that needs to be created is the content manager of the execution manager for this project.
    ExecutionManager.getInstance(project).getContentManager();
    RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("Android", TOOL_WINDOW_ID, "Profiling Tools", project);
    toolWindow.setIcon(AndroidIcons.AndroidToolWindow);
    toolWindow.setAvailable(true, null);
    toolWindow.setToHideOnEmptyContent(true);
    toolWindow.setTitle(TOOL_WINDOW_ID);
    DeviceContext deviceContext = new DeviceContext();
    // TODO Remove global handlers. These handlers are global, but are set per project.
    // if there are two projects opened, things go very wrong.
    ClientData.setMethodProfilingHandler(new OpenVmTraceHandler(project));
    Content logcatContent = createLogcatContent(layoutUi, project, deviceContext);
    final AndroidLogcatView logcatView = logcatContent.getUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY);
    assert logcatView != null;
    logcatContent.setSearchComponent(logcatView.createSearchComponent());
    layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false);
    MonitorContentFactory.createMonitorContent(project, deviceContext, layoutUi);
    layoutUi.getOptions().setLeftToolbar(getToolbarActions(project, deviceContext), ActionPlaces.UNKNOWN);
    layoutUi.addListener(new ContentManagerAdapter() {

        @Override
        public void selectionChanged(ContentManagerEvent event) {
            Content selectedContent = event.getContent();
            BaseMonitorView view = selectedContent.getUserData(BaseMonitorView.MONITOR_VIEW_KEY);
            if (view != null && event.getOperation() == ContentManagerEvent.ContentOperation.add) {
                UsageTracker.getInstance().log(AndroidStudioEvent.newBuilder().setCategory(AndroidStudioEvent.EventCategory.PROFILING).setKind(AndroidStudioEvent.EventKind.MONITOR_RUNNING).setMonitorType(view.getMonitorType()));
            }
        }
    }, project);
    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project);
    DevicePanel devicePanel = new DevicePanel(project, deviceContext);
    JPanel panel = devicePanel.getComponent();
    panel.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
    loadingPanel.add(panel, BorderLayout.NORTH);
    loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER);
    final ContentManager contentManager = toolWindow.getContentManager();
    Content c = contentManager.getFactory().createContent(loadingPanel, "", true);
    // Store references to the logcat & device panel views, so that these views can be retrieved directly from
    // the DDMS tool window. (e.g. to clear logcat before a launch, select a particular device, etc)
    c.putUserData(AndroidLogcatView.ANDROID_LOGCAT_VIEW_KEY, logcatView);
    c.putUserData(DEVICES_PANEL_KEY, devicePanel);
    contentManager.addContent(c);
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            logcatView.activate();
            final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(TOOL_WINDOW_ID);
            if (window != null && window.isVisible()) {
                ConsoleView console = logcatView.getLogConsole().getConsole();
                if (console != null) {
                    checkFacetAndSdk(project, console);
                }
            }
        }
    }, project.getDisposed());
    final File adb = AndroidSdkUtils.getAdb(project);
    if (adb == null) {
        return;
    }
    loadingPanel.setLoadingText("Initializing ADB");
    loadingPanel.startLoading();
    ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb);
    Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() {

        @Override
        public void onSuccess(@Nullable AndroidDebugBridge bridge) {
            Logger.getInstance(AndroidToolWindowFactory.class).info("Successfully obtained debug bridge");
            loadingPanel.stopLoading();
        }

        @Override
        public void onFailure(@NotNull Throwable t) {
            loadingPanel.stopLoading();
            // If we cannot connect to ADB in a reasonable amount of time (10 seconds timeout in AdbService), then something is seriously
            // wrong. The only identified reason so far is that some machines have incompatible versions of adb that were already running.
            // e.g. Genymotion, some HTC flashing software, Ubuntu's adb package may all conflict with the version of adb in the SDK.
            Logger.getInstance(AndroidToolWindowFactory.class).info("Unable to obtain debug bridge", t);
            String msg;
            if (t.getMessage() != null) {
                msg = t.getMessage();
            } else {
                msg = String.format("Unable to establish a connection to adb.\n\n" + "Check the Event Log for possible issues.\n" + "This can happen if you have an incompatible version of adb running already.\n" + "Try re-opening %1$s after killing any existing adb daemons.\n\n" + "If this happens repeatedly, please file a bug at http://b.android.com including the following:\n" + "  1. Output of the command: '%2$s devices'\n" + "  2. Your idea.log file (Help | Show Log in Explorer)\n", ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath());
            }
            Messages.showErrorDialog(msg, "ADB Connection Error");
        }
    }, EdtExecutor.INSTANCE);
}
Also used : ConsoleView(com.intellij.execution.ui.ConsoleView) ContentManager(com.intellij.ui.content.ContentManager) ContentManagerAdapter(com.intellij.ui.content.ContentManagerAdapter) AndroidLogcatView(com.android.tools.idea.logcat.AndroidLogcatView) ToolWindow(com.intellij.openapi.wm.ToolWindow) RunnerLayoutUi(com.intellij.execution.ui.RunnerLayoutUi) DeviceContext(com.android.tools.idea.ddms.DeviceContext) Content(com.intellij.ui.content.Content) DevicePanel(com.android.tools.idea.ddms.DevicePanel) OpenVmTraceHandler(com.android.tools.idea.ddms.OpenVmTraceHandler) JBLoadingPanel(com.intellij.ui.components.JBLoadingPanel) File(java.io.File) ContentManagerEvent(com.intellij.ui.content.ContentManagerEvent) AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge)

Example 53 with Content

use of com.intellij.ui.content.Content in project android by JetBrains.

the class AndroidMonitorToolWindowFactory method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    AndroidMonitorToolWindow view = new AndroidMonitorToolWindow(project);
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(view.getComponent(), "", false);
    toolWindow.getContentManager().addContent(content);
}
Also used : Content(com.intellij.ui.content.Content) ContentFactory(com.intellij.ui.content.ContentFactory)

Example 54 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class GitShowCommitInLogAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
    final Project project = event.getRequiredData(CommonDataKeys.PROJECT);
    final VcsRevisionNumber revision = getRevisionNumber(event);
    if (revision == null) {
        return;
    }
    boolean logReady = findLog(project) != null;
    final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
    ContentManager cm = window.getContentManager();
    Content[] contents = cm.getContents();
    for (Content content : contents) {
        if (VcsLogContentProvider.TAB_NAME.equals(content.getDisplayName())) {
            cm.setSelectedContent(content);
            break;
        }
    }
    final VcsLog log = findLog(project);
    if (log == null) {
        showLogNotReadyMessage(project);
        return;
    }
    Runnable selectAndOpenLog = new Runnable() {

        @Override
        public void run() {
            Runnable selectCommit = new Runnable() {

                @Override
                public void run() {
                    jumpToRevisionUnderProgress(project, log, revision);
                }
            };
            if (!window.isVisible()) {
                window.activate(selectCommit, true);
            } else {
                selectCommit.run();
            }
        }
    };
    if (logReady) {
        selectAndOpenLog.run();
        return;
    }
    VcsProjectLog projectLog = VcsProjectLog.getInstance(project);
    if (projectLog == null) {
        showLogNotReadyMessage(project);
        return;
    }
    VcsLogUiImpl logUi = projectLog.getMainLogUi();
    if (logUi == null) {
        showLogNotReadyMessage(project);
        return;
    }
    logUi.invokeOnChange(selectAndOpenLog);
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) VcsLog(com.intellij.vcs.log.VcsLog) VcsRevisionNumber(com.intellij.openapi.vcs.history.VcsRevisionNumber) ChangesViewContentManager(com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager) ContentManager(com.intellij.ui.content.ContentManager) VcsProjectLog(com.intellij.vcs.log.impl.VcsProjectLog) VcsLogUiImpl(com.intellij.vcs.log.ui.VcsLogUiImpl)

Example 55 with Content

use of com.intellij.ui.content.Content in project intellij-community by JetBrains.

the class LogConsoleManagerBase method removeAdditionalTabComponent.

@Override
public void removeAdditionalTabComponent(@NotNull AdditionalTabComponent component) {
    Disposer.dispose(component);
    final Content content = myAdditionalContent.remove(component);
    if (!getUi().isDisposed()) {
        getUi().removeContent(content, true);
    }
}
Also used : Content(com.intellij.ui.content.Content)

Aggregations

Content (com.intellij.ui.content.Content)157 ContentManager (com.intellij.ui.content.ContentManager)42 ToolWindow (com.intellij.openapi.wm.ToolWindow)37 NotNull (org.jetbrains.annotations.NotNull)19 ContentFactory (com.intellij.ui.content.ContentFactory)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)13 MessageView (com.intellij.ui.content.MessageView)10 Disposable (com.intellij.openapi.Disposable)8 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)8 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)7 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)7 ConsoleView (com.intellij.execution.ui.ConsoleView)6 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)6 TabbedContent (com.intellij.ui.content.TabbedContent)6 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)5 Ref (com.intellij.openapi.util.Ref)5 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)4 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)4 Assert.assertNotNull (junit.framework.Assert.assertNotNull)4