Java Code Examples for com.intellij.ui.content.ContentFactory#createContent()

The following examples show how to use com.intellij.ui.content.ContentFactory#createContent() . 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: IMWindowFactory.java    From SmartIM4IntelliJ with Apache License 2.0 6 votes vote down vote up
private void createContents(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    File dir = new File(getWorkDir(), "SmartIM");
    if (dir.exists()) {
        dir.mkdirs();
    }
    System.setProperty("log.home", dir.getAbsolutePath());
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = null;

    WechatPanel wechatPanel = new WechatPanel(project, toolWindow);
    content = contentFactory.createContent(wechatPanel, "Wechat", false);
    toolWindow.getContentManager().addContent(content, 0);

    SmartQQPanel qqPanel = new SmartQQPanel(project, toolWindow);
    content = contentFactory.createContent(qqPanel, "SmartQQ", false);
    toolWindow.getContentManager().addContent(content, 1);

}
 
Example 2
Source File: DesktopToolWindowImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
@Override
protected void init(boolean canCloseContent, @Nullable Object component) {
  final ContentFactory contentFactory = ContentFactory.getInstance();
  myContentUI = new DesktopToolWindowContentUi(this);
  ContentManager contentManager = myContentManager = contentFactory.createContentManager(myContentUI, canCloseContent, myToolWindowManager.getProject());

  if (component != null) {
    final Content content = contentFactory.createContent((JComponent)component, "", false);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content, false);
  }

  myComponent = contentManager.getComponent();

  DesktopInternalDecorator.installFocusTraversalPolicy(myComponent, new LayoutFocusTraversalPolicy());

  UiNotifyConnector notifyConnector = new UiNotifyConnector(myComponent, new Activatable() {
    @Override
    public void showNotify() {
      myShowing.onReady();
    }
  });
  Disposer.register(contentManager, notifyConnector);
}
 
Example 3
Source File: ANTLRv4PluginController.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void createToolWindows() {
	LOG.info("createToolWindows "+project.getName());
	ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);

	previewPanel = new PreviewPanel(project);

	ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
	Content content = contentFactory.createContent(previewPanel, "", false);
	content.setCloseable(false);

	previewWindow = toolWindowManager.registerToolWindow(PREVIEW_WINDOW_ID, true, ToolWindowAnchor.BOTTOM);
	previewWindow.getContentManager().addContent(content);
	previewWindow.setIcon(Icons.getToolWindow());

	TextConsoleBuilderFactory factory = TextConsoleBuilderFactory.getInstance();
	TextConsoleBuilder consoleBuilder = factory.createBuilder(project);
	this.console = consoleBuilder.getConsole();

	JComponent consoleComponent = console.getComponent();
	content = contentFactory.createContent(consoleComponent, "", false);
	content.setCloseable(false);

	consoleWindow = toolWindowManager.registerToolWindow(CONSOLE_WINDOW_ID, true, ToolWindowAnchor.BOTTOM);
	consoleWindow.getContentManager().addContent(content);
	consoleWindow.setIcon(Icons.getToolWindow());
}
 
Example 4
Source File: DataSourcesView.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 6 votes vote down vote up
public void initToolWindow(Project project, ToolWindow toolWindow) {
    if (!initialized) {
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        Content content = contentFactory.createContent(toolWindowContent, "", false);
        toolWindow.getContentManager().addContent(content);

        component = project.getComponent(DataSourcesComponent.class);
        componentMetadata = project.getComponent(DataSourcesComponentMetadata.class);
        dataSourceMetadataUi = new DataSourceMetadataUi(componentMetadata);
        treeRoot = new PatchedDefaultMutableTreeNode(new RootTreeNodeModel());
        treeModel = new DefaultTreeModel(treeRoot, false);
        decorator = ToolbarDecorator.createDecorator(dataSourceTree);
        decorator.addExtraAction(new RefreshDataSourcesAction(this));

        configureDataSourceTree();
        decorateDataSourceTree();

        interactions = new DataSourceInteractions(project, this);

        replaceTreeWithDecorated();
        showDataSources();
        refreshDataSourcesMetadata();

        initialized = true;
    }
}
 
Example 5
Source File: ToolWindowFactory.java    From adc with Apache License 2.0 6 votes vote down vote up
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    JPanel framePanel = createPanel(project);
    disableAll();

    AndroidDebugBridge adb = AndroidSdkUtils.getDebugBridge(project);
    if (adb == null) {
        return;
    }

    if(adb.isConnected()){
        ToolWindowFactory.this.adBridge = adb;
        Logger.getInstance(ToolWindowFactory.class).info("Successfully obtained debug bridge");
        AndroidDebugBridge.addDeviceChangeListener(deviceChangeListener);
        updateDeviceComboBox();
    } else {
        Logger.getInstance(ToolWindowFactory.class).info("Unable to obtain debug bridge");
        String msg = MessageFormat.format(resourceBundle.getString("error.message.adb"), "");
        Messages.showErrorDialog(msg, resourceBundle.getString("error.title.adb"));
    }

    Content content = contentFactory.createContent(framePanel, "", false);
    toolWindow.getContentManager().addContent(content);
}
 
Example 6
Source File: OpenToolWindowAction.java    From tmc-intellij with MIT License 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    logger.info("Creating tool window content. @OpenToolWindowAction");
    ProjectListWindow window = new ProjectListWindow();
    ContentFactory cf = ContentFactory.SERVICE.getInstance();
    Content content = cf.createContent(window.getBasePanel(), "", true);
    toolWindow.getContentManager().addContent(content);
    ProjectListManagerHolder.get().addWindow(window);
}
 
Example 7
Source File: TestResultPanelFactory.java    From tmc-intellij with MIT License 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    logger.info("Creating tool window content for test results. " + "@TestResultPanelFactory");

    TestResultsPanel panel = new TestResultsPanel();
    ContentFactory cf = ContentFactory.SERVICE.getInstance();
    Content content = cf.createContent(panel, "", true);
    toolWindow.getContentManager().addContent(content);

    panels.add(panel);
}
 
Example 8
Source File: KeyPromoterToolWindowFactory.java    From IntelliJ-Key-Promoter-X with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
    KeyPromoterToolWindowPanel toolWindowBuilder = new KeyPromoterToolWindowPanel();
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    JBScrollPane toolWindowContent = new JBScrollPane(toolWindowBuilder.getContent());
    toolWindowContent.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    Content content = contentFactory.createContent(toolWindowContent, "", false);
    content.setPreferredFocusableComponent(toolWindowContent);
    content.setDisposer(toolWindowBuilder);
    toolWindow.getContentManager().addContent(content);
}
 
Example 9
Source File: ReferenceToolWindow.java    From intellij-reference-diagram with Apache License 2.0 5 votes vote down vote up
private void create(@NotNull ToolWindow toolWindow, ContentFactory contentFactory, ReferenceListToolWindow window) {
    Content content = contentFactory.createContent(window.getContent(), window.getName(), false);
    window.setUpdateTabNameCallback(newName -> {
        ApplicationManager.getApplication().invokeLater(
                () -> {
                    content.setDisplayName(newName);
                });
    });
    toolWindow.getContentManager().addContent(content);
}
 
Example 10
Source File: IMWindowFactory.java    From SmartIM4IntelliJ with Apache License 2.0 5 votes vote down vote up
private Content createContentPanel(Project project, ToolWindow toolWindow) {
    System.out.println("project:" + project);
    panel = new SmartQQPanel(project, toolWindow);
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(panel, "", false);
    return content;
}
 
Example 11
Source File: AbstractVcsHelperImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void openCommittedChangesTab(final CommittedChangesProvider provider,
                                    final RepositoryLocation location,
                                    final ChangeBrowserSettings settings,
                                    final int maxCount,
                                    String title) {
  DefaultActionGroup extraActions = new DefaultActionGroup();
  CommittedChangesPanel panel = new CommittedChangesPanel(myProject, provider, settings, location, extraActions);
  panel.setMaxCount(maxCount);
  panel.refreshChanges(false);
  final ContentFactory factory = ContentFactory.getInstance();
  if (title == null && location != null) {
    title = VcsBundle.message("browse.changes.content.title", location.toPresentableString());
  }
  final Content content = factory.createContent(panel, title, false);
  final ChangesViewContentI contentManager = ChangesViewContentManager.getInstance(myProject);
  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  extraActions.add(new CloseTabToolbarAction() {
    @Override
    public void actionPerformed(final AnActionEvent e) {
      contentManager.removeContent(content);
    }
  });

  ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(ChangesViewContentManager.TOOLWINDOW_ID);
  if (!window.isVisible()) {
    window.activate(null);
  }
}
 
Example 12
Source File: WindowFactory.java    From leetcode-editor with Apache License 2.0 5 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {

    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    JComponent navigatorPanel=  new NavigatorPanel(toolWindow,project);
    navigatorPanel.addAncestorListener(new UpdatePluginListener());
    Content content = contentFactory.createContent(navigatorPanel, "", false);
    toolWindow.getContentManager().addContent(content);

}
 
Example 13
Source File: PreviewView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void initToolWindow(@NotNull ToolWindow toolWindow) {
  final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
  final ContentManager contentManager = toolWindow.getContentManager();

  final Content content = contentFactory.createContent(null, null, false);
  content.setCloseable(false);

  windowPanel = new OutlineComponent(this);
  content.setComponent(windowPanel);

  windowPanel.setToolbar(widgetEditToolbar.getToolbar().getComponent());

  final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();

  tree = new OutlineTree(rootNode);
  tree.setCellRenderer(new OutlineTreeCellRenderer());
  tree.expandAll();

  initTreePopup();

  // Add collapse all, expand all, and show only widgets buttons.
  if (toolWindow instanceof ToolWindowEx) {
    final ToolWindowEx toolWindowEx = (ToolWindowEx)toolWindow;

    final CommonActionsManager actions = CommonActionsManager.getInstance();
    final TreeExpander expander = new DefaultTreeExpander(tree);

    final AnAction expandAllAction = actions.createExpandAllAction(expander, tree);
    expandAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Expandall);

    final AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree);
    collapseAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Collapseall);

    final ShowOnlyWidgetsAction showOnlyWidgetsAction = new ShowOnlyWidgetsAction();

    toolWindowEx.setTitleActions(expandAllAction, collapseAllAction, showOnlyWidgetsAction);
  }

  new TreeSpeedSearch(tree) {
    @Override
    protected String getElementText(Object element) {
      final TreePath path = (TreePath)element;
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
      final Object object = node.getUserObject();
      if (object instanceof OutlineObject) {
        return ((OutlineObject)object).getSpeedSearchString();
      }
      return null;
    }
  };

  tree.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() > 1) {
        final TreePath selectionPath = tree.getSelectionPath();
        if (selectionPath != null) {
          selectPath(selectionPath, true);
        }
      }
    }
  });

  tree.addTreeSelectionListener(treeSelectionListener);

  scrollPane = ScrollPaneFactory.createScrollPane(tree);
  content.setPreferredFocusableComponent(tree);

  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  splitter = new Splitter(true);
  setSplitterProportion(getState().getSplitterProportion());
  getState().addListener(e -> {
    final float newProportion = getState().getSplitterProportion();
    if (splitter.getProportion() != newProportion) {
      setSplitterProportion(newProportion);
    }
  });
  //noinspection Convert2Lambda
  splitter.addPropertyChangeListener("proportion", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if (!isSettingSplitterProportion) {
        getState().setSplitterProportion(splitter.getProportion());
      }
    }
  });
  scrollPane.setMinimumSize(new Dimension(1, 1));
  splitter.setFirstComponent(scrollPane);
  windowPanel.setContent(splitter);
}
 
Example 14
Source File: PreviewView.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void initToolWindow(@NotNull ToolWindow toolWindow) {
  final ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
  final ContentManager contentManager = toolWindow.getContentManager();

  final Content content = contentFactory.createContent(null, null, false);
  content.setCloseable(false);

  windowPanel = new OutlineComponent(this);
  content.setComponent(windowPanel);

  windowPanel.setToolbar(widgetEditToolbar.getToolbar().getComponent());

  final DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();

  tree = new OutlineTree(rootNode);
  tree.setCellRenderer(new OutlineTreeCellRenderer());
  tree.expandAll();

  initTreePopup();

  // Add collapse all, expand all, and show only widgets buttons.
  if (toolWindow instanceof ToolWindowEx) {
    final ToolWindowEx toolWindowEx = (ToolWindowEx)toolWindow;

    final CommonActionsManager actions = CommonActionsManager.getInstance();
    final TreeExpander expander = new DefaultTreeExpander(tree);

    final AnAction expandAllAction = actions.createExpandAllAction(expander, tree);
    expandAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Expandall);

    final AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree);
    collapseAllAction.getTemplatePresentation().setIcon(AllIcons.Actions.Collapseall);

    final ShowOnlyWidgetsAction showOnlyWidgetsAction = new ShowOnlyWidgetsAction();

    toolWindowEx.setTitleActions(expandAllAction, collapseAllAction, showOnlyWidgetsAction);
  }

  new TreeSpeedSearch(tree) {
    @Override
    protected String getElementText(Object element) {
      final TreePath path = (TreePath)element;
      final DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
      final Object object = node.getUserObject();
      if (object instanceof OutlineObject) {
        return ((OutlineObject)object).getSpeedSearchString();
      }
      return null;
    }
  };

  tree.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() > 1) {
        final TreePath selectionPath = tree.getSelectionPath();
        if (selectionPath != null) {
          selectPath(selectionPath, true);
        }
      }
    }
  });

  tree.addTreeSelectionListener(treeSelectionListener);

  scrollPane = ScrollPaneFactory.createScrollPane(tree);
  content.setPreferredFocusableComponent(tree);

  contentManager.addContent(content);
  contentManager.setSelectedContent(content);

  splitter = new Splitter(true);
  setSplitterProportion(getState().getSplitterProportion());
  getState().addListener(e -> {
    final float newProportion = getState().getSplitterProportion();
    if (splitter.getProportion() != newProportion) {
      setSplitterProportion(newProportion);
    }
  });
  //noinspection Convert2Lambda
  splitter.addPropertyChangeListener("proportion", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if (!isSettingSplitterProportion) {
        getState().setSplitterProportion(splitter.getProportion());
      }
    }
  });
  scrollPane.setMinimumSize(new Dimension(1, 1));
  splitter.setFirstComponent(scrollPane);
  windowPanel.setContent(splitter);
}
 
Example 15
Source File: RootWindow.java    From WIFIADB with Apache License 2.0 4 votes vote down vote up
private void attach2ToolWindow(ToolWindow toolWindow){
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(mRoot, Config.TITLE, false);
    toolWindow.getContentManager().addContent(content);
}
 
Example 16
Source File: GraphConsoleView.java    From jetbrains-plugin-graph-database-support with Apache License 2.0 4 votes vote down vote up
public void initToolWindow(Project project, ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(consoleToolWindowContent, "", false);
    toolWindow.getContentManager().addContent(content);

    if (!initialized) {
        updateLookAndFeel();
        initializeWidgets(project);
        initializeUiComponents(project);

        // Hide standard tabs
        defaultTabContainer.setVisible(false);

        // Tabs
        consoleTabs.setFirstTabOffset(0);
        consoleTabs.addTab(new TabInfo(logTab)
            .setText(Tabs.LOG));
        consoleTabs.addTab(new TabInfo(graphTab)
            .setText(Tabs.GRAPH));
        consoleTabs.addTab(new TabInfo(tableScrollPane)
            .setText(Tabs.TABLE));
        consoleTabs.addTab(new TabInfo(parametersTab)
            .setText(Tabs.PARAMETERS));
        consoleTabs.setSelectionChangeHandler((info, requestFocus, doChangeSelection) -> {
            Analytics.event("console", "openTab[" + info.getText() + "]");
            ActionCallback callback = doChangeSelection.run();
            graphPanel.resetPan();
            return callback;
        });

        project.getMessageBus().connect().subscribe(OpenTabEvent.OPEN_TAB_TOPIC, this::selectTab);

        AtomicInteger tabId = new AtomicInteger(0);
        project.getMessageBus().connect().subscribe(QueryPlanEvent.QUERY_PLAN_EVENT,
                (query, result) -> createNewQueryPlanTab(query, result, tabId.incrementAndGet()));

        // Actions
        final ActionGroup consoleActionGroup = (ActionGroup)
                ActionManager.getInstance().getAction(GraphConstants.Actions.CONSOLE_ACTIONS);
        ActionToolbar consoleToolbar = ActionManager.getInstance()
                .createActionToolbar(GraphConstants.ToolWindow.CONSOLE_TOOL_WINDOW, consoleActionGroup, false);
        consoleToolbarPanel.add(consoleToolbar.getComponent(), BorderLayout.CENTER);
        consoleToolbarPanel.setBorder(new CustomLineBorder(0, 0, 0, 1));
        consoleToolbarPanel.validate();
        initialized = true;
    }
}
 
Example 17
Source File: AndroidWiFiADBWindow.java    From AndroidWiFiADB with Apache License 2.0 4 votes vote down vote up
private void createToolWindowContent(ToolWindow toolWindow) {
  ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
  Content content = contentFactory.createContent(toolWindowContent, "", false);
  toolWindow.getContentManager().addContent(content);
}
 
Example 18
Source File: MyToolWindowFactory.java    From intellij-sdk-docs with Apache License 2.0 4 votes vote down vote up
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
  MyToolWindow myToolWindow = new MyToolWindow(toolWindow);
  ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
  Content content = contentFactory.createContent(myToolWindow.getContent(), "", false);
  toolWindow.getContentManager().addContent(content);
}
 
Example 19
Source File: MigrationsToolWindow.java    From yiistorm with MIT License 4 votes vote down vote up
@Override
public void createToolWindowContent(Project project, ToolWindow toolWindow) {

    _project = project;
    toolw = this;
    yiic = new Yiic();

    PropertiesComponent properties = PropertiesComponent.getInstance(getProject());
    yiiFile = properties.getValue("yiicFile");
    useMigrations = properties.getBoolean("useYiiMigrations", false);
    setMigrateLogText("");

    contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());

    scrollpane = new JBScrollPane();
    migrateLog = new JTextArea("Yii migrations");
    //migrateLog.setLineWrap(true);
    migrateLog.setEditable(false);
    migrateLog.setEnabled(true);
    scrollpane.setLayout(new ScrollPaneLayout());
    scrollpane.getViewport().add(migrateLog);
    contentPane.add(scrollpane, BorderLayout.CENTER);

    FlowLayout layout = new FlowLayout();
    layout.setAlignment(FlowLayout.LEFT);
    buttonsPanel.setLayout(layout);
    actionMenuBar = new JMenuBar();
    actionMenuBar.setBackground(new Color(0, 0, 0, 0));
    actionMenuBar.setLayout(layout);
    actionMenuBar.setBorderPainted(false);
    buttonsPanel.add(actionMenuBar);


    contentPane.add(buttonsPanel, BorderLayout.NORTH);


    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    Content content = contentFactory.createContent(contentPane, "", false);
    toolWindow.getContentManager().addContent(content);
    if (yiiFile != null && yiic.yiicIsRunnable(yiiFile)) {
        yiiProtected = yiiFile.replaceAll("yiic.(bat|php)$", "");
        runBackgroundTask(this.ADD_MENUS_BACKGROUND_ACTION, project);
    } else {
        setMigrateLogText("Set path to yiic in project settings -> YiiStorm");
    }

}