Dumb mode doesn't seem to work!

已回答

I'm using TextEditorProvider.getInstance().createEditor(project, lightVirtualFile) to create a text editor, which serves as the main interface for my SimpleToolWindowPanel. This panel is used for my tool window.

I've implemented the DumbAware interface for my tool window, meaning it shouldn't wait for indexing to complete.

However, I've noticed that the text editor doesn't load when the indexing hasn't finished. I'm wondering why this is happening.

 

TextEditor:

        LightVirtualFile lightVirtualFile = new LightVirtualFile("Dummy." + fileType.getDefaultExtension(), fileType, text);
        return (TextEditor) TextEditorProvider.getInstance().createEditor(project, lightVirtualFile);

 

Content:

    public JComponent createRootPanel() {
        TextEditor textEditor = createEditorComponent();
        this.editor = (EditorEx) textEditor.getEditor();

        JsonViewerPanel rootPanel = new JsonViewerPanel(new BorderLayout(), this.editor);
        JPanel centerPanel = new JPanel(new BorderLayout());
        centerPanel.add(textEditor.getComponent(), BorderLayout.CENTER);
        rootPanel.add(centerPanel, BorderLayout.CENTER);

        SimpleToolWindowPanel simpleToolWindowPanel = new SimpleToolWindowPanel(false, false);
        simpleToolWindowPanel.setContent(rootPanel);
        simpleToolWindowPanel.setToolbar(createToolbar(simpleToolWindowPanel));
        return simpleToolWindowPanel;
    }

 

 

ToolWindowFactory:

public class JsonViewerToolWindowFactory implements ToolWindowFactory, DumbAware {

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
        ContentManager contentManager = toolWindow.getContentManager();
        ToolWindowEx toolWindowEx = (ToolWindowEx) toolWindow;

        JsonViewerComponentProvider window = new JsonViewerComponentProvider(project, FileTypeHolder.JSON, true, true);

        AnAction[] tabActions = {new NewTabAction(contentFactory, toolWindowEx)};
        List<AnAction> titleActions = List.of(new JsonHistoryAction(toolWindowEx), new DonateAction(JsonAssistantBundle.messageOnSystem("action.donate.text")));
        SimpleActionGroup group = new SimpleActionGroup();
        group.add(Separator.create());
        group.add(new RenameTabAction());
        group.add(new MoveToEditorAction(toolWindowEx));
        group.add(new FloatingWindowAction(toolWindowEx));
        group.add(Separator.create());
        group.add(new EditInNewWindowAction(toolWindowEx));
        group.add(Separator.create());
        group.add(new ConfigureEditorOptionsAction(toolWindowEx));
        group.add(Separator.create());

        toolWindowEx.setTabActions(tabActions);
        toolWindowEx.setTitleActions(titleActions);
        toolWindowEx.setAdditionalGearActions(group);

        Content content = contentFactory.createContent(window.createRootPanel(), PluginConstant.JSON_VIEWER_TOOL_WINDOW_DISPLAY_NAME, false);
        content.setCloseable(false);
        contentManager.addContent(content, 0);
    }

}

 

0

> the text editor doesn't load

What exactly do you mean by that? Could you check by adding additional UI component into the tool window to make sure it affects only the Editor? What IDE version are you targeting?

0

请先登录再写评论。