com.intellij.ui.content.impl.ContentImpl Java Examples

The following examples show how to use com.intellij.ui.content.impl.ContentImpl. 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: FreelineUtil.java    From freeline with BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
private static void processConsole(Project project, ProcessHandler processHandler) {
    ConsoleView consoleView = FreeUIManager.getInstance(project).getConsoleView(project);
    consoleView.clear();
    consoleView.attachToProcess(processHandler);

    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow toolWindow;
    toolWindow = toolWindowManager.getToolWindow(TOOL_ID);

    // if already exist tool window then show it
    if (toolWindow != null) {
        toolWindow.show(null);
        return;
    }

    toolWindow = toolWindowManager.registerToolWindow(TOOL_ID, true, ToolWindowAnchor.BOTTOM);
    toolWindow.setTitle("free....");
    toolWindow.setStripeTitle("Free Console");
    toolWindow.setShowStripeButton(true);
    toolWindow.setIcon(PluginIcons.ICON_TOOL_WINDOW);
    toolWindow.getContentManager().addContent(new ContentImpl(consoleView.getComponent(), "Build", true));
    toolWindow.show(null);
}
 
Example #2
Source File: TestToolWindow.java    From intellij-reference-diagram with Apache License 2.0 6 votes vote down vote up
private static TestToolWindow createViewTab(Project project, PsiElement baseElement) {
    final ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
    ToolWindow toolWindow = toolWindowManager.getToolWindow(TOOL_WINDOW_ID);
    if (toolWindow == null) {
        toolWindow = toolWindowManager.registerToolWindow(TOOL_WINDOW_ID,
                true,
                ToolWindowAnchor.BOTTOM);
    }
    final TestToolWindow view = new TestToolWindow(project);
    ToolWindow finalToolWindow = toolWindow;
    toolWindow.activate(() -> {
        final String text = SymbolPresentationUtil.getSymbolPresentableText(baseElement);
        final ContentImpl content = new ContentImpl(view, "to " + text, true);
        finalToolWindow.getContentManager().addContent(content);
        finalToolWindow.getContentManager().setSelectedContent(content, true);
    });
    return view;
}
 
Example #3
Source File: JSGraphQLLanguageToolWindowManager.java    From js-graphql-intellij-plugin with MIT License 5 votes vote down vote up
private void createSchemasPanel() {
    ApplicationManager.getApplication().assertIsDispatchThread();
    if (mySchemasTree == null) {
        final Ref<Content> contentRef = new Ref<>();
        mySchemasTree = new GraphQLSchemasPanel(myProject);
        final ContentImpl schemasContent = new ContentImpl(mySchemasTree, "Schemas and Project Structure", false);
        schemasContent.setCloseable(false);
        contentRef.set(schemasContent);
        myToolWindow.getContentManager().addContent(contentRef.get(), 0);

    }
}
 
Example #4
Source File: RNUtil.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private static void processConsole(Project project, ProcessHandler processHandler) {
        ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
        consoleView.clear();
        consoleView.attachToProcess(processHandler);
        processHandler.startNotify();

        ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
        ToolWindow toolWindow;
        toolWindow = toolWindowManager.getToolWindow(TOOL_ID);

        // if already exist tool window then show it
        if (toolWindow != null) {
            toolWindow.show(null);// TODO add more tabs here?
            return;
        }

        toolWindow = toolWindowManager.registerToolWindow(TOOL_ID, true, ToolWindowAnchor.BOTTOM);
        toolWindow.setTitle("Android....");
        toolWindow.setStripeTitle("Android Console");
        toolWindow.setShowStripeButton(true);
        toolWindow.setIcon(PluginIcons.ICON_TOOL_WINDOW);

        JPanel panel = new JPanel((LayoutManager) new BorderLayout());
        panel.add((Component) consoleView.getComponent(), "Center");

        // Create toolbars
        DefaultActionGroup toolbarActions = new DefaultActionGroup();
        AnAction[]
                consoleActions = consoleView.createConsoleActions();// 必须在 consoleView.getComponent() 调用后组件真正初始化之后调用
        toolbarActions.addAll((AnAction[]) Arrays.copyOf(consoleActions, consoleActions.length));
        toolbarActions.add((AnAction) new StopProcessAction("Stop process", "Stop process", processHandler));
//        toolbarActions.add((AnAction) new CloseAction(defaultExecutor, runDescriptor, project));


        ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("unknown", (ActionGroup) toolbarActions, false);
        toolbar.setTargetComponent(consoleView.getComponent());
        panel.add((Component) toolbar.getComponent(), "West");

        ContentImpl consoleContent = new ContentImpl(panel, "Build", false);
        consoleContent.setManager(toolWindow.getContentManager());

        toolbarActions.add(new CloseTabAction(consoleContent));

//        addAdditionalConsoleEditorActions(consoleView, consoleContent);
//        consoleComponent.setActions();
        toolWindow.getContentManager().addContent(consoleContent);
        toolWindow.getContentManager().addContent(new ContentImpl(new JButton("Test"), "Build2", false));
        toolWindow.show(null);
    }
 
Example #5
Source File: JSGraphQLLanguageUIProjectService.java    From js-graphql-intellij-plugin with MIT License 4 votes vote down vote up
private void createToolWindowResultEditor(ToolWindow toolWindow) {

        final LightVirtualFile virtualFile = new LightVirtualFile("GraphQL.result.json", JsonFileType.INSTANCE, "");
        fileEditor = PsiAwareTextEditorProvider.getInstance().createEditor(myProject, virtualFile);

        if (fileEditor instanceof TextEditor) {
            final Editor editor = ((TextEditor) fileEditor).getEditor();
            final EditorEx editorEx = (EditorEx) editor;

            // set read-only mode
            editorEx.setViewer(true);
            editorEx.getSettings().setShowIntentionBulb(false);
            editor.getSettings().setAdditionalLinesCount(0);
            editor.getSettings().setCaretRowShown(false);
            editor.getSettings().setBlinkCaret(false);

            // query result header
            final JSGraphQLEditorHeaderComponent header = new JSGraphQLEditorHeaderComponent();

            querySuccessLabel = new JBLabel();
            querySuccessLabel.setVisible(false);
            querySuccessLabel.setIconTextGap(0);
            header.add(querySuccessLabel, BorderLayout.WEST);

            queryResultLabel = new JBLabel("", null, SwingConstants.LEFT);
            queryResultLabel.setBorder(new EmptyBorder(4, 6, 4, 6));
            queryResultLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            queryResultLabel.setVisible(false);
            queryResultLabel.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    final String fileUrl = (String) queryResultLabel.getClientProperty(FILE_URL_PROPERTY);
                    if (fileUrl != null) {
                        final VirtualFile queryFile = VirtualFileManager.getInstance().findFileByUrl(fileUrl);
                        if (queryFile != null) {
                            final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
                            fileEditorManager.openFile(queryFile, true, true);
                        }
                    }
                }
            });
            header.add(queryResultLabel, BorderLayout.CENTER);

            // finally set the header as permanent such that it's restored after searches
            editor.setHeaderComponent(header);
            editorEx.setPermanentHeaderComponent(header);
        }

        final ContentImpl content = new ContentImpl(fileEditor.getComponent(), "Query result", true);
        content.setCloseable(false);
        content.setShouldDisposeContent(false);
        toolWindow.getContentManager().addContent(content);
        Disposer.register(content, fileEditor);
    }
 
Example #6
Source File: ContentFactoryImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ContentImpl createContent(javax.swing.JComponent component, String displayName, boolean isLockable) {
  return new ContentImpl(component, displayName, isLockable);
}