com.intellij.execution.ui.layout.PlaceInGrid Java Examples

The following examples show how to use com.intellij.execution.ui.layout.PlaceInGrid. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmbeddedLinuxJVMConsoleView.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Creats the tool window content
 * @param toolWindow
 */
public void createToolWindowContent(@NotNull ToolWindow toolWindow) {
    //Create runner UI layout
    RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(project);
    RunnerLayoutUi layoutUi = factory.create("", "", "session", project);

    // Adding actions
    DefaultActionGroup group = new DefaultActionGroup();
    layoutUi.getOptions().setLeftToolbar(group, ActionPlaces.UNKNOWN);

    Content console = layoutUi.createContent(EmbeddedLinuxJVMToolWindowFactory.ID, consoleView.getComponent(), "", null, null);
    AnAction[] consoleActions = consoleView.createConsoleActions();
    for (AnAction action : consoleActions) {
        if (!shouldIgnoreAction(action)) {
            group.add(action);
        }
    }
    layoutUi.addContent(console, 0, PlaceInGrid.right, false);

    JComponent layoutComponent = layoutUi.getComponent();
    myConsolePanel.add(layoutComponent, BorderLayout.CENTER);
    Content content = ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true);
    toolWindow.getContentManager().addContent(content);
}
 
Example #2
Source File: BuckToolWindowFactory.java    From Buck-IntelliJ-Plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void createToolWindowContent(
    @NotNull final Project project, @NotNull ToolWindow toolWindow) {
  toolWindow.setAvailable(true, null);
  toolWindow.setToHideOnEmptyContent(true);

  RunnerLayoutUi runnerLayoutUi = BuckUIManager.getInstance(project).getLayoutUi(project);
  Content consoleContent = createConsoleContent(runnerLayoutUi, project);

  runnerLayoutUi.addContent(consoleContent, 0, PlaceInGrid.center, false);
  runnerLayoutUi.getOptions().setLeftToolbar(
      getLeftToolbarActions(project), ActionPlaces.UNKNOWN);

  runnerLayoutUi.updateActionsNow();

  final ContentManager contentManager = toolWindow.getContentManager();
  Content content = contentManager.getFactory().createContent(
      runnerLayoutUi.getComponent(), "", true);
  contentManager.addContent(content);

  updateBuckToolWindowTitle(project);
}
 
Example #3
Source File: TabImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void setDetached(PlaceInGrid place, boolean detached) {
  switch (place) {
    case bottom:
      setBottomDetached(detached);
      break;
    case center:
      setCenterDetached(detached);
      break;
    case left:
      setLeftDetached(detached);
      break;
    case right:
      setRightDetached(detached);
      break;
  }
}
 
Example #4
Source File: XDebugSessionTab.java    From consulo with Apache License 2.0 6 votes vote down vote up
private XDebugSessionTab(@Nonnull XDebugSessionImpl session, @Nullable Image icon, @Nullable ExecutionEnvironment environment) {
  super(session.getProject(), "Debug", session.getSessionName(), GlobalSearchScope.allScope(session.getProject()));

  setSession(session, environment, icon);

  myUi.addContent(createFramesContent(), 0, PlaceInGrid.left, false);
  addVariablesAndWatches(session);

  attachToSession(session);

  DefaultActionGroup focus = new DefaultActionGroup();
  focus.add(ActionManager.getInstance().getAction(XDebuggerActions.FOCUS_ON_BREAKPOINT));
  myUi.getOptions().setAdditionalFocusActions(focus);

  myUi.addListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(ContentManagerEvent event) {
      Content content = event.getContent();
      if (mySession != null && content.isSelected() && getWatchesContentId().equals(ViewImpl.ID.get(content))) {
        myRebuildWatchesRunnable.run();
      }
    }
  }, myRunContentDescriptor);

  rebuildViews();
}
 
Example #5
Source File: RunContentBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void buildConsoleUiDefault(RunnerLayoutUi ui, final ExecutionConsole console) {
  final Content consoleContent = ui.createContent(ExecutionConsole.CONSOLE_CONTENT_ID, console.getComponent(), "Console",
                                                  AllIcons.Debugger.Console,
                                                  console.getPreferredFocusableComponent());

  consoleContent.setCloseable(false);
  addAdditionalConsoleEditorActions(console, consoleContent);
  ui.addContent(consoleContent, 0, PlaceInGrid.bottom, false);
}
 
Example #6
Source File: BuckToolWindowImpl.java    From buck with Apache License 2.0 5 votes vote down vote up
@Override
public void addPanel(BuckToolWindowPanel buckToolWindowPanel) {
  Content content =
      runnerLayoutUi.createContent(
          buckToolWindowPanel.getId(),
          buckToolWindowPanel.getComponent(),
          buckToolWindowPanel.getTitle(),
          null,
          null);
  content.setCloseable(false);
  content.setPinnable(false);
  runnerLayoutUi.addContent(content, 0, PlaceInGrid.center, false);
}
 
Example #7
Source File: XDebugTabLayouter.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Registers tab for the given {@code console}.
 *
 * @param console {@code ExecutionConsole} instance
 * @param ui {@code RunnerLayoutUi} instance
 * @return registered {@code Content} instance
 */
@Nonnull
public Content registerConsoleContent(@Nonnull RunnerLayoutUi ui, @Nonnull ExecutionConsole console) {
  Content content = ui.createContent(DebuggerContentInfo.CONSOLE_CONTENT, console.getComponent(),
                                     XDebuggerBundle.message("debugger.session.tab.console.content.name"),
                                     AllIcons.Debugger.Console,
                                     console.getPreferredFocusableComponent());
  content.setCloseable(false);
  ui.addContent(content, 1, PlaceInGrid.bottom, false);
  return content;
}
 
Example #8
Source File: TabImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isDetached(PlaceInGrid place) {
  switch (place) {
    case bottom:
      return isBottomDetached();
    case center:
      return isCenterDetached();
    case left:
      return isLeftDetached();
    case right:
      return isRightDetached();
  }

  return false;
}
 
Example #9
Source File: RunnerLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private ViewImpl.Default getOrCreateDefault(@Nonnull String id) {
  if (myDefaultViews.containsKey(id)) {
    return myDefaultViews.get(id);
  }
  return setDefault(id, Integer.MAX_VALUE, PlaceInGrid.bottom, false);
}
 
Example #10
Source File: RunnerLayoutUiImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public Content addContent(@Nonnull Content content, boolean applyDefaults, int defaultTabId, @Nonnull PlaceInGrid defaultPlace, boolean defaultIsMinimized) {
  final String id = content.getUserData(CONTENT_TYPE);

  assert id != null : "Content id is missing, use RunnerLayoutUi to create content instances";

  if (applyDefaults) {
    getLayout().setDefault(id, defaultTabId, defaultPlace, defaultIsMinimized);
  }

  getContentManager().addContent(content);
  return content;
}
 
Example #11
Source File: ViewImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ViewImpl(String id, TabImpl tab, final PlaceInGrid placeInGrid, boolean minimizedInGrid, int window) {
  myID = id;
  myTab = tab;
  myPlaceInGrid = placeInGrid;
  myMinimizedInGrid = minimizedInGrid;
  myWindow = window;
}
 
Example #12
Source File: RunnerLayout.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public PlaceInGrid getDefaultGridPlace(@Nonnull Content content) {
  return getOrCreateDefault(getOrCreateContentId(content)).getPlaceInGrid();
}
 
Example #13
Source File: RunnerLayoutUiImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public Content addContent(@Nonnull Content content, int defaultTabId, @Nonnull PlaceInGrid defaultPlace, boolean defaultIsMinimized) {
  return addContent(content, true, defaultTabId, defaultPlace, defaultIsMinimized);
}
 
Example #14
Source File: RunnerLayoutUiImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public Content addContent(@Nonnull Content content) {
  return addContent(content, false, -1, PlaceInGrid.center, false);
}
 
Example #15
Source File: ViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PlaceInGrid getPlaceInGrid() {
  return myPlaceInGrid;
}
 
Example #16
Source File: ViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public Default(final String ID, final int tabID, final PlaceInGrid placeInGrid, final boolean minimizedInGrid) {
  myID = ID;
  myTabID = tabID;
  myPlaceInGrid = placeInGrid;
  myMinimizedInGrid = minimizedInGrid;
}
 
Example #17
Source File: ViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void setPlaceInGrid(PlaceInGrid placeInGrid) {
  myPlaceInGrid = placeInGrid;
}
 
Example #18
Source File: ViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public PlaceInGrid getPlaceInGrid() {
  return myPlaceInGrid;
}
 
Example #19
Source File: LogviewFactory.java    From logviewer with Apache License 2.0 4 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {

    final File adb = AndroidSdkUtils.getAdb(project);
    ExecutionManager.getInstance(project).getContentManager();

    RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("LogViewer", TOOL_WINDOW_ID, "Logview Tools", project);

    toolWindow.setIcon(LogviewerPluginIcons.TOOL_ICON);
    toolWindow.setAvailable(true, null);
    toolWindow.setToHideOnEmptyContent(true);
    toolWindow.setTitle(TOOL_WINDOW_ID);


    DeviceContext deviceContext = new DeviceContext();

    Content logcatContent = createLogcatContent(layoutUi, project, deviceContext);
    final LogView logcatView = logcatContent.getUserData(LOG_VIEW_KEY);
    layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false);

    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project);
    loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER);

    final ContentManager contentManager = toolWindow.getContentManager();
    Content c = contentManager.getFactory().createContent(loadingPanel, "", true);
    c.putUserData(LOG_VIEW_KEY, logcatView);
    contentManager.addContent(c);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            logcatView.activate();
        }
    }, project.getDisposed());


    if (adb != null) {
        loadingPanel.setLoadingText("Initializing ADB");
        loadingPanel.startLoading();

        //ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb);
        ListenableFuture<AndroidDebugBridge> future = AdbBridgeFactory.getAdb(adb);
        Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() {
            @Override
            public void onSuccess(@Nullable AndroidDebugBridge bridge) {
                Logger.getInstance(LogviewFactory.class).info("Successfully obtained debug bridge");
                loadingPanel.stopLoading();
            }

            @Override
            public void onFailure(@NotNull Throwable t) {
                loadingPanel.stopLoading();
                Logger.getInstance(LogviewFactory.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",
                            ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath());
                }
                Messages.showErrorDialog(msg, "ADB Connection Error");
            }
        }, EdtExecutor.INSTANCE);
    } else {
        logcatView.showHint("No adb connection!.\n\nDrag and drop log files to view them.");
    }
}
 
Example #20
Source File: RunnerLayout.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public ViewImpl.Default setDefault(@Nonnull String id, int tabIndex, @Nonnull PlaceInGrid placeInGrid, boolean isMinimized) {
  final ViewImpl.Default view = new ViewImpl.Default(id, tabIndex, placeInGrid, isMinimized);
  myDefaultViews.put(id, view);
  return view;
}
 
Example #21
Source File: XDebugSessionTab.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void addVariablesAndWatches(@Nonnull XDebugSessionImpl session) {
  myUi.addContent(createVariablesContent(session), 0, PlaceInGrid.center, false);
  if (!myWatchesInVariables) {
    myUi.addContent(createWatchesContent(session), 0, PlaceInGrid.right, false);
  }
}
 
Example #22
Source File: RunnerLayoutUi.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
Content addContent(@Nonnull Content content, int defaultTabId, @Nonnull PlaceInGrid defaultPlace, boolean defaultIsMinimized);
 
Example #23
Source File: BlazeConsoleView.java    From intellij with Apache License 2.0 4 votes vote down vote up
void createToolWindowContent(ToolWindow toolWindow) {
  // Create runner UI layout
  RunnerLayoutUi.Factory factory = RunnerLayoutUi.Factory.getInstance(project);
  RunnerLayoutUi layoutUi = factory.create("", "", "session", project);
  layoutUi.getOptions().setMoveToGridActionEnabled(false).setMinimizeActionEnabled(false);

  Content console =
      layoutUi.createContent(
          BlazeConsoleToolWindowFactory.ID, consoleView.getComponent(), "", null, null);
  console.setCloseable(false);
  layoutUi.addContent(console, 0, PlaceInGrid.right, false);

  // Adding actions
  DefaultActionGroup group = new DefaultActionGroup();
  layoutUi.getOptions().setLeftToolbar(group, TOOLBAR_ACTION_PLACE);

  // Initializing prev and next occurrences actions
  OccurenceNavigator navigator = fromConsoleView(consoleView);
  CommonActionsManager actionsManager = CommonActionsManager.getInstance();
  AnAction prevAction = actionsManager.createPrevOccurenceAction(navigator);
  prevAction.getTemplatePresentation().setText(navigator.getPreviousOccurenceActionName());
  AnAction nextAction = actionsManager.createNextOccurenceAction(navigator);
  nextAction.getTemplatePresentation().setText(navigator.getNextOccurenceActionName());

  group.addAll(prevAction, nextAction);

  AnAction[] consoleActions = consoleView.createConsoleActions();
  for (AnAction action : consoleActions) {
    if (!shouldIgnoreAction(action)) {
      group.add(action);
    }
  }
  group.add(new StopAction());

  JComponent layoutComponent = layoutUi.getComponent();

  layoutComponent.setFocusTraversalPolicyProvider(true);
  layoutComponent.setFocusTraversalPolicy(
      new LayoutFocusTraversalPolicy() {
        @Override
        public Component getDefaultComponent(Container container) {
          if (container.equals(layoutComponent)) {
            return consoleView.getPreferredFocusableComponent();
          }
          return super.getDefaultComponent(container);
        }
      });

  Content content =
      ContentFactory.SERVICE.getInstance().createContent(layoutComponent, null, true);
  content.setCloseable(false);
  toolWindow.getContentManager().addContent(content);
}