com.intellij.openapi.ui.SimpleToolWindowPanel Java Examples

The following examples show how to use com.intellij.openapi.ui.SimpleToolWindowPanel. 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: DuneCompiler.java    From reasonml-idea-plugin with MIT License 6 votes vote down vote up
@Nullable
@Override
public ConsoleView getConsoleView() {
    ORToolWindowProvider windowProvider = ORToolWindowProvider.getInstance(project);
    ToolWindow duneToolWindow = windowProvider.getDuneToolWindow();
    Content windowContent = duneToolWindow.getContentManager().getContent(0);
    if (windowContent == null) {
        return null;
    }
    SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent();
    JComponent panelComponent = component.getComponent();
    if (panelComponent == null) {
        return null;
    }
    return (ConsoleView) panelComponent.getComponent(0);
}
 
Example #2
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
static FlutterConsole create(@NotNull Project project, @Nullable Module module) {
  final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  builder.setViewer(true);
  if (module != null) {
    builder.addFilter(new FlutterConsoleFilter(module));
  }
  final ConsoleView view = builder.getConsole();

  final SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
  panel.setContent(view.getComponent());

  final String title = module != null ? "[" + module.getName() + "] Flutter" : "Flutter";
  final Content content = ContentFactory.SERVICE.getInstance().createContent(panel.getComponent(), title, true);
  Disposer.register(content, view);

  return new FlutterConsole(view, content, project, module);
}
 
Example #3
Source File: FlutterConsole.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
static FlutterConsole create(@NotNull Project project, @Nullable Module module) {
  final TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
  builder.setViewer(true);
  if (module != null) {
    builder.addFilter(new FlutterConsoleFilter(module));
  }
  final ConsoleView view = builder.getConsole();

  final SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
  panel.setContent(view.getComponent());

  final String title = module != null ? "[" + module.getName() + "] Flutter" : "Flutter";
  final Content content = ContentFactory.SERVICE.getInstance().createContent(panel.getComponent(), title, true);
  Disposer.register(content, view);

  return new FlutterConsole(view, content, project, module);
}
 
Example #4
Source File: EsyCompiler.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Override
public ConsoleView getConsoleView() {
    ORToolWindowProvider windowProvider = ORToolWindowProvider.getInstance(m_project);
    ToolWindow esyToolWindow = windowProvider.getEsyToolWindow();
    Content windowContent = esyToolWindow.getContentManager().getContent(0);
    if (windowContent == null) {
        return null;
    }
    SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent();
    JComponent panelComponent = component.getComponent();
    if (panelComponent == null) {
        return null;
    }
    return (ConsoleView) panelComponent.getComponent(0);
}
 
Example #5
Source File: BsCompilerImpl.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
public ConsoleView getConsoleView() {
    ORToolWindowProvider windowProvider = ORToolWindowProvider.getInstance(m_project);
    ToolWindow bsToolWindow = windowProvider.getBsToolWindow();
    Content windowContent = bsToolWindow == null ? null : bsToolWindow.getContentManager().getContent(0);
    if (windowContent == null) {
        return null;
    }

    SimpleToolWindowPanel component = (SimpleToolWindowPanel) windowContent.getComponent();
    JComponent panelComponent = component.getComponent();
    return panelComponent == null ? null : (ConsoleView) panelComponent.getComponent(0);
}
 
Example #6
Source File: EventLogToolWindowFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
static void createContent(Project project, ToolWindow toolWindow, EventLogConsole console, String title) {
  // update default Event Log tab title
  ContentManager contentManager = toolWindow.getContentManager();
  Content generalContent = contentManager.getContent(0);
  if (generalContent != null && contentManager.getContentCount() == 1) {
    generalContent.setDisplayName("General");
  }

  final Editor editor = console.getConsoleEditor();

  SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
    @Override
    public Object getData(@Nonnull @NonNls Key dataId) {
      return PlatformDataKeys.HELP_ID == dataId ? EventLog.HELP_ID : super.getData(dataId);
    }
  };
  panel.setContent(editor.getComponent());
  panel.addAncestorListener(new LogShownTracker(project));

  ActionToolbar toolbar = createToolbar(project, editor, console);
  toolbar.setTargetComponent(editor.getContentComponent());
  panel.setToolbar(toolbar.getComponent());

  Content content = ContentFactory.getInstance().createContent(panel, title, false);
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);
}
 
Example #7
Source File: ConsoleLogToolWindowFactory.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
static void createContent(Project project, ToolWindow toolWindow, ConsoleLogConsole console, String title) {
    // update default Event Log tab title
    ContentManager contentManager = toolWindow.getContentManager();
    Content generalContent = contentManager.getContent(0);
    if (generalContent != null && contentManager.getContentCount() == 1) {
        generalContent.setDisplayName("General");
    }

    final Editor editor = console.getConsoleEditor();

    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {
        @Override
        public Object getData(@NonNls String dataId) {
            return PlatformDataKeys.HELP_ID.is(dataId) ? ConsoleLog.HELP_ID : super.getData(dataId);
        }
    };
    panel.setContent(editor.getComponent());
    panel.addAncestorListener(new LogShownTracker(project));

    ActionToolbar toolbar = createToolbar(project, editor, console);
    toolbar.setTargetComponent(editor.getContentComponent());
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content);
}
 
Example #8
Source File: PreviewArea.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public PreviewArea(Project project, Set<FlutterOutline> outlinesWithWidgets, Disposable parent) {
  this.outlinesWithWidgets = outlinesWithWidgets;

  context = new WidgetEditingContext(
    project,
    FlutterDartAnalysisServer.getInstance(project),
    InspectorGroupManagerService.getInstance(project),
    EditorPositionService.getInstance(project)
  );

  inspectorClient = new InspectorGroupManagerService.Client(parent);
  context.inspectorGroupManagerService.addListener(inspectorClient, parent);
  preview = new PreviewViewController(new WidgetViewModelData(context), false, layeredPanel, parent);

  deviceMirrorPanel = new PreviewViewModelPanel(preview);

  windowToolbar = ActionManager.getInstance().createActionToolbar("PreviewArea", toolbarGroup, true);
  toolbarGroup.add(new TitleAction("Device Mirror"));

  window = new SimpleToolWindowPanel(true, true);
  window.setToolbar(windowToolbar.getComponent());

  deviceMirrorPanel.setLayout(new BorderLayout());

  // TODO(jacobr): reafactor to remove the layeredPanel as we aren't getting any benefit from it.
  window.setContent(layeredPanel);
  layeredPanel.add(deviceMirrorPanel, Integer.valueOf(0));

  // Layers should cover the whole root panel.
  layeredPanel.addComponentListener(new ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
      final Dimension renderSize = getRenderSize();
      preview.setScreenshotBounds(new Rectangle(0, 0, renderSize.width, renderSize.height));
    }
  });
}
 
Example #9
Source File: FreelineTerminal.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 创建Terminal panel
 *
 * @param terminalRunner
 * @param toolWindow
 * @return
 */
private Content createTerminalInContentPanel(@NotNull AbstractTerminalRunner terminalRunner, @NotNull final ToolWindow toolWindow) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);
    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", false);
    content.setCloseable(true);
    myTerminalWidget = terminalRunner.createTerminalWidget(content);
    panel.setContent(myTerminalWidget.getComponent());
    panel.addFocusListener(this);
    ActionToolbar toolbar = createToolbar(terminalRunner, myTerminalWidget, toolWindow);
    toolbar.setTargetComponent(panel);
    panel.setToolbar(toolbar.getComponent());
    content.setPreferredFocusableComponent(myTerminalWidget.getComponent());
    return content;
}
 
Example #10
Source File: FreelineTerminal.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public JBTabbedTerminalWidget getTerminalWidget(ToolWindow window) {
    window.show(null);
    if (myTerminalWidget == null) {
        JComponent parentPanel =  window.getContentManager().getContents()[0].getComponent();
        if (parentPanel instanceof SimpleToolWindowPanel) {
            SimpleToolWindowPanel panel = (SimpleToolWindowPanel) parentPanel;
            JPanel jPanel = (JPanel) panel.getComponents()[0];
            myTerminalWidget = (JBTabbedTerminalWidget) jPanel.getComponents()[0];
        } else {
            NotificationUtils.infoNotification("Wait for Freeline to initialize");
        }
    }
    return myTerminalWidget;
}
 
Example #11
Source File: PreviewArea.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public PreviewArea(Project project, Set<FlutterOutline> outlinesWithWidgets, Disposable parent) {
  this.outlinesWithWidgets = outlinesWithWidgets;

  context = new WidgetEditingContext(
    project,
    FlutterDartAnalysisServer.getInstance(project),
    InspectorGroupManagerService.getInstance(project),
    EditorPositionService.getInstance(project)
  );

  inspectorClient = new InspectorGroupManagerService.Client(parent);
  context.inspectorGroupManagerService.addListener(inspectorClient, parent);
  preview = new PreviewViewController(new WidgetViewModelData(context), false, layeredPanel, parent);

  deviceMirrorPanel = new PreviewViewModelPanel(preview);

  windowToolbar = ActionManager.getInstance().createActionToolbar("PreviewArea", toolbarGroup, true);
  toolbarGroup.add(new TitleAction("Device Mirror"));

  window = new SimpleToolWindowPanel(true, true);
  window.setToolbar(windowToolbar.getComponent());

  deviceMirrorPanel.setLayout(new BorderLayout());

  // TODO(jacobr): reafactor to remove the layeredPanel as we aren't getting any benefit from it.
  window.setContent(layeredPanel);
  layeredPanel.add(deviceMirrorPanel, Integer.valueOf(0));

  // Layers should cover the whole root panel.
  layeredPanel.addComponentListener(new ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
      final Dimension renderSize = getRenderSize();
      preview.setScreenshotBounds(new Rectangle(0, 0, renderSize.width, renderSize.height));
    }
  });
}
 
Example #12
Source File: ProjectViewImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void constructUi() {
  myViewContentPanel = new JPanel();
  myPanel = new SimpleToolWindowPanel(true).setProvideQuickActions(false);
  myPanel.setContent(myViewContentPanel);
}
 
Example #13
Source File: ChangesViewManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
private JComponent createChangeViewComponent() {
  SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

  EmptyAction.registerWithShortcutSet("ChangesView.Refresh", CommonShortcuts.getRerun(), panel);
  EmptyAction.registerWithShortcutSet("ChangesView.NewChangeList", CommonShortcuts.getNew(), panel);
  EmptyAction.registerWithShortcutSet("ChangesView.RemoveChangeList", CommonShortcuts.getDelete(), panel);
  EmptyAction.registerWithShortcutSet(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST, CommonShortcuts.getMove(), panel);
  EmptyAction.registerWithShortcutSet("ChangesView.Rename", CommonShortcuts.getRename(), panel);
  EmptyAction.registerWithShortcutSet("ChangesView.SetDefault", new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_DOWN_MASK | ctrlMask())), panel);
  EmptyAction.registerWithShortcutSet("ChangesView.Diff", CommonShortcuts.getDiff(), panel);

  DefaultActionGroup group = (DefaultActionGroup)ActionManager.getInstance().getAction("ChangesViewToolbar");
  ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.CHANGES_VIEW_TOOLBAR, group, false);
  toolbar.setTargetComponent(myView);
  JComponent toolbarComponent = toolbar.getComponent();
  JPanel toolbarPanel = new JPanel(new BorderLayout());
  toolbarPanel.add(toolbarComponent, BorderLayout.WEST);

  DefaultActionGroup visualActionsGroup = new DefaultActionGroup();
  final Expander expander = new Expander();
  visualActionsGroup.add(CommonActionsManager.getInstance().createExpandAllAction(expander, panel));
  visualActionsGroup.add(CommonActionsManager.getInstance().createCollapseAllAction(expander, panel));

  ToggleShowFlattenAction showFlattenAction = new ToggleShowFlattenAction();
  showFlattenAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, ctrlMask())), panel);
  visualActionsGroup.add(showFlattenAction);
  visualActionsGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_COPY));
  visualActionsGroup.add(new ToggleShowIgnoredAction());
  visualActionsGroup.add(new IgnoredSettingsAction());
  visualActionsGroup.add(new ToggleDetailsAction());
  visualActionsGroup.add(new ContextHelpAction(ChangesListView.HELP_ID));
  toolbarPanel.add(ActionManager.getInstance().createActionToolbar(ActionPlaces.CHANGES_VIEW_TOOLBAR, visualActionsGroup, false).getComponent(), BorderLayout.CENTER);


  myView.setMenuActions((DefaultActionGroup)ActionManager.getInstance().getAction("ChangesViewPopupMenu"));

  myView.setShowFlatten(myState.myShowFlatten);

  myProgressLabel = new JPanel(new BorderLayout());

  panel.setToolbar(toolbarPanel);

  final JPanel content = new JPanel(new BorderLayout());
  mySplitter = new JBSplitter(false, "ChangesViewManager.DETAILS_SPLITTER_PROPORTION", 0.5f);
  mySplitter.setHonorComponentsMinimumSize(false);
  final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myView);
  final JPanel wrapper = new JPanel(new BorderLayout());
  wrapper.add(scrollPane, BorderLayout.CENTER);
  mySplitter.setFirstComponent(wrapper);
  content.add(mySplitter, BorderLayout.CENTER);
  content.add(myProgressLabel, BorderLayout.SOUTH);
  panel.setContent(content);

  ChangesDnDSupport.install(myProject, myView);
  myView.addTreeSelectionListener(myTsl);
  return panel;
}
 
Example #14
Source File: PreviewView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void updateOutline(@NotNull FlutterOutline outline) {
  currentOutline = outline;

  final DefaultMutableTreeNode rootNode = getRootNode();
  rootNode.removeAllChildren();

  outlinesWithWidgets.clear();
  outlineToNodeMap.clear();
  if (outline.getChildren() != null) {
    computeOutlinesWithWidgets(outline);
    updateOutlineImpl(rootNode, outline.getChildren());
  }

  getTreeModel().reload(rootNode);
  tree.expandAll();

  if (currentEditor != null) {
    final Caret caret = currentEditor.getCaretModel().getPrimaryCaret();
    applyEditorSelectionToTree(caret);
  }

  if (FlutterSettings.getInstance().isEnableHotUi() && propertyEditPanel == null) {
    propertyEditSplitter = new Splitter(false, 0.75f);
    propertyEditPanel = new PropertyEditorPanel(inspectorGroupManagerService, project, flutterAnalysisServer, false, false, project);
    propertyEditPanel.initalize(null, activeOutlines, currentFile);
    propertyEditToolbarGroup = new DefaultActionGroup();
    final ActionToolbar windowToolbar = ActionManager.getInstance().createActionToolbar("PropertyArea", propertyEditToolbarGroup, true);

    final SimpleToolWindowPanel window = new SimpleToolWindowPanel(true, true);
    window.setToolbar(windowToolbar.getComponent());
    final JScrollPane propertyScrollPane = ScrollPaneFactory.createScrollPane(propertyEditPanel);
    window.setContent(propertyScrollPane);
    propertyEditSplitter.setFirstComponent(window.getComponent());
    final InspectorGroupManagerService.Client inspectorStateServiceClient = new InspectorGroupManagerService.Client(project) {
      @Override
      public void onInspectorAvailabilityChanged() {
        super.onInspectorAvailabilityChanged();
        // Only show the screen mirror if there is a running device and
        // the inspector supports the neccessary apis.
        if (getInspectorService() != null && getInspectorService().isHotUiScreenMirrorSupported()) {
          // Wait to create the preview area until it is needed.
          if (previewArea == null) {
            previewArea = new PreviewArea(project, outlinesWithWidgets, project);
          }
          propertyEditSplitter.setSecondComponent(previewArea.getComponent());
        }
        else {
          propertyEditSplitter.setSecondComponent(null);
        }
      }
    };
    inspectorGroupManagerService.addListener(inspectorStateServiceClient, project);

    splitter.setSecondComponent(propertyEditSplitter);
  }

  // TODO(jacobr): this is the wrong spot.
  if (propertyEditToolbarGroup != null) {
    final TitleAction propertyTitleAction = new TitleAction("Properties");
    propertyEditToolbarGroup.removeAll();
    propertyEditToolbarGroup.add(propertyTitleAction);
  }
}
 
Example #15
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void addInspectorViewContent(FlutterApp app, @Nullable InspectorService inspectorService, ToolWindow toolWindow) {
  final ContentManager contentManager = toolWindow.getContentManager();
  final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(true);
  final JBRunnerTabs runnerTabs = new JBRunnerTabs(myProject, ActionManager.getInstance(), IdeFocusManager.getInstance(myProject), this);
  runnerTabs.setSelectionChangeHandler(this::onTabSelectionChange);
  final JPanel tabContainer = new JPanel(new BorderLayout());

  final String tabName;
  final FlutterDevice device = app.device();
  if (device == null) {
    tabName = app.getProject().getName();
  }
  else {
    final List<FlutterDevice> existingDevices = new ArrayList<>();
    for (FlutterApp otherApp : perAppViewState.keySet()) {
      existingDevices.add(otherApp.device());
    }
    tabName = device.getUniqueName(existingDevices);
  }

  final Content content = contentManager.getFactory().createContent(null, tabName, false);
  tabContainer.add(runnerTabs.getComponent(), BorderLayout.CENTER);
  content.setComponent(tabContainer);
  content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
  content.setIcon(FlutterIcons.Phone);
  contentManager.addContent(content);

  if (emptyContent != null) {
    contentManager.removeContent(emptyContent, true);
    emptyContent = null;
  }

  contentManager.setSelectedContent(content);

  final PerAppState state = getOrCreateStateForApp(app);
  assert (state.content == null);
  state.content = content;

  final DefaultActionGroup toolbarGroup = createToolbar(toolWindow, app, inspectorService);
  toolWindowPanel.setToolbar(ActionManager.getInstance().createActionToolbar("FlutterViewToolbar", toolbarGroup, true).getComponent());

  toolbarGroup.add(new OverflowAction(getOrCreateStateForApp(app), this, app));

  final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("InspectorToolbar", toolbarGroup, true);
  final JComponent toolbarComponent = toolbar.getComponent();
  toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
  tabContainer.add(toolbarComponent, BorderLayout.NORTH);

  final boolean debugConnectionAvailable = app.getLaunchMode().supportsDebugConnection();
  final boolean hasInspectorService = inspectorService != null;

  // If the inspector is available (non-release mode), then show it.
  if (debugConnectionAvailable) {
    if (hasInspectorService) {
      final boolean detailsSummaryViewSupported = inspectorService.isDetailsSummaryViewSupported();
      addInspectorPanel(WIDGET_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.widget, app, inspectorService, toolWindow,
                        toolbarGroup, true, detailsSummaryViewSupported);
      addInspectorPanel(RENDER_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.renderObject, app, inspectorService,
                        toolWindow, toolbarGroup, false, false);
    }
    else {
      // If in profile mode, add disabled tabs for the inspector.
      addDisabledTab(WIDGET_TAB_LABEL, runnerTabs, toolbarGroup);
      addDisabledTab(RENDER_TAB_LABEL, runnerTabs, toolbarGroup);
    }
  }
  else {
    // Add a message about the inspector not being available in release mode.
    final JBLabel label = new JBLabel("Inspector not available in release mode", SwingConstants.CENTER);
    label.setForeground(UIUtil.getLabelDisabledForeground());
    tabContainer.add(label, BorderLayout.CENTER);
  }
}
 
Example #16
Source File: PreviewView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void updateOutline(@NotNull FlutterOutline outline) {
  currentOutline = outline;

  final DefaultMutableTreeNode rootNode = getRootNode();
  rootNode.removeAllChildren();

  outlinesWithWidgets.clear();
  outlineToNodeMap.clear();
  if (outline.getChildren() != null) {
    computeOutlinesWithWidgets(outline);
    updateOutlineImpl(rootNode, outline.getChildren());
  }

  getTreeModel().reload(rootNode);
  tree.expandAll();

  if (currentEditor != null) {
    final Caret caret = currentEditor.getCaretModel().getPrimaryCaret();
    applyEditorSelectionToTree(caret);
  }

  if (FlutterSettings.getInstance().isEnableHotUi() && propertyEditPanel == null) {
    propertyEditSplitter = new Splitter(false, 0.75f);
    propertyEditPanel = new PropertyEditorPanel(inspectorGroupManagerService, project, flutterAnalysisServer, false, false, project);
    propertyEditPanel.initalize(null, activeOutlines, currentFile);
    propertyEditToolbarGroup = new DefaultActionGroup();
    final ActionToolbar windowToolbar = ActionManager.getInstance().createActionToolbar("PropertyArea", propertyEditToolbarGroup, true);

    final SimpleToolWindowPanel window = new SimpleToolWindowPanel(true, true);
    window.setToolbar(windowToolbar.getComponent());
    final JScrollPane propertyScrollPane = ScrollPaneFactory.createScrollPane(propertyEditPanel);
    window.setContent(propertyScrollPane);
    propertyEditSplitter.setFirstComponent(window.getComponent());
    final InspectorGroupManagerService.Client inspectorStateServiceClient = new InspectorGroupManagerService.Client(project) {
      @Override
      public void onInspectorAvailabilityChanged() {
        super.onInspectorAvailabilityChanged();
        // Only show the screen mirror if there is a running device and
        // the inspector supports the neccessary apis.
        if (getInspectorService() != null && getInspectorService().isHotUiScreenMirrorSupported()) {
          // Wait to create the preview area until it is needed.
          if (previewArea == null) {
            previewArea = new PreviewArea(project, outlinesWithWidgets, project);
          }
          propertyEditSplitter.setSecondComponent(previewArea.getComponent());
        }
        else {
          propertyEditSplitter.setSecondComponent(null);
        }
      }
    };
    inspectorGroupManagerService.addListener(inspectorStateServiceClient, project);

    splitter.setSecondComponent(propertyEditSplitter);
  }

  // TODO(jacobr): this is the wrong spot.
  if (propertyEditToolbarGroup != null) {
    final TitleAction propertyTitleAction = new TitleAction("Properties");
    propertyEditToolbarGroup.removeAll();
    propertyEditToolbarGroup.add(propertyTitleAction);
  }
}
 
Example #17
Source File: FlutterView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void addInspectorViewContent(FlutterApp app, @Nullable InspectorService inspectorService, ToolWindow toolWindow) {
  final ContentManager contentManager = toolWindow.getContentManager();
  final SimpleToolWindowPanel toolWindowPanel = new SimpleToolWindowPanel(true);
  final JBRunnerTabs runnerTabs = new JBRunnerTabs(myProject, ActionManager.getInstance(), IdeFocusManager.getInstance(myProject), this);
  runnerTabs.setSelectionChangeHandler(this::onTabSelectionChange);
  final JPanel tabContainer = new JPanel(new BorderLayout());

  final String tabName;
  final FlutterDevice device = app.device();
  if (device == null) {
    tabName = app.getProject().getName();
  }
  else {
    final List<FlutterDevice> existingDevices = new ArrayList<>();
    for (FlutterApp otherApp : perAppViewState.keySet()) {
      existingDevices.add(otherApp.device());
    }
    tabName = device.getUniqueName(existingDevices);
  }

  final Content content = contentManager.getFactory().createContent(null, tabName, false);
  tabContainer.add(runnerTabs.getComponent(), BorderLayout.CENTER);
  content.setComponent(tabContainer);
  content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE);
  content.setIcon(FlutterIcons.Phone);
  contentManager.addContent(content);

  if (emptyContent != null) {
    contentManager.removeContent(emptyContent, true);
    emptyContent = null;
  }

  contentManager.setSelectedContent(content);

  final PerAppState state = getOrCreateStateForApp(app);
  assert (state.content == null);
  state.content = content;

  final DefaultActionGroup toolbarGroup = createToolbar(toolWindow, app, inspectorService);
  toolWindowPanel.setToolbar(ActionManager.getInstance().createActionToolbar("FlutterViewToolbar", toolbarGroup, true).getComponent());

  toolbarGroup.add(new OverflowAction(getOrCreateStateForApp(app), this, app));

  final ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("InspectorToolbar", toolbarGroup, true);
  final JComponent toolbarComponent = toolbar.getComponent();
  toolbarComponent.setBorder(IdeBorderFactory.createBorder(SideBorder.BOTTOM));
  tabContainer.add(toolbarComponent, BorderLayout.NORTH);

  final boolean debugConnectionAvailable = app.getLaunchMode().supportsDebugConnection();
  final boolean hasInspectorService = inspectorService != null;

  // If the inspector is available (non-release mode), then show it.
  if (debugConnectionAvailable) {
    if (hasInspectorService) {
      final boolean detailsSummaryViewSupported = inspectorService.isDetailsSummaryViewSupported();
      addInspectorPanel(WIDGET_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.widget, app, inspectorService, toolWindow,
                        toolbarGroup, true, detailsSummaryViewSupported);
      addInspectorPanel(RENDER_TAB_LABEL, runnerTabs, state, InspectorService.FlutterTreeType.renderObject, app, inspectorService,
                        toolWindow, toolbarGroup, false, false);
    }
    else {
      // If in profile mode, add disabled tabs for the inspector.
      addDisabledTab(WIDGET_TAB_LABEL, runnerTabs, toolbarGroup);
      addDisabledTab(RENDER_TAB_LABEL, runnerTabs, toolbarGroup);
    }
  }
  else {
    // Add a message about the inspector not being available in release mode.
    final JBLabel label = new JBLabel("Inspector not available in release mode", SwingConstants.CENTER);
    label.setForeground(UIUtil.getLabelDisabledForeground());
    tabContainer.add(label, BorderLayout.CENTER);
  }
}
 
Example #18
Source File: EsyToolWindowFactory.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow window) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    BsConsole console = new BsConsole(project);
    panel.setContent(console.getComponent());

    ActionToolbar toolbar = createToolbar(console);
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true);

    window.getContentManager().addContent(content);

    Disposer.register(project, console);
}
 
Example #19
Source File: DuneToolWindowFactory.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow window) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    BsConsole console = new BsConsole(project);
    panel.setContent(console.getComponent());

    ActionToolbar toolbar = createToolbar(console);
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true);

    window.getContentManager().addContent(content);

    Disposer.register(project, console);
}
 
Example #20
Source File: BsToolWindowFactory.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull ToolWindow window) {
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true);

    BsConsole console = new BsConsole(project);
    panel.setContent(console.getComponent());

    ActionToolbar toolbar = createToolbar(console);
    panel.setToolbar(toolbar.getComponent());

    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, "", true);

    window.getContentManager().addContent(content);

    Disposer.register(project, console);
}