Java Code Examples for com.intellij.openapi.ui.SimpleToolWindowPanel#setContent()

The following examples show how to use com.intellij.openapi.ui.SimpleToolWindowPanel#setContent() . 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: 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 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: 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 4
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 5
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 6
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 7
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 8
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);
}
 
Example 9
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 10
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 11
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 12
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 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;
}