package com.huangzj.protoplugin.devtools;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.openapi.wm.ex.ToolWindowEx;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NotNull;

public final class DevToolsToolWindowFactory implements ToolWindowFactory {

    public static final String TOOL_WINDOW_ID = "DevTools";

    public static final String TOOL_WINDOW_STRIPE_TITLE = "开发者工具";

    @Override
    public void init(@NotNull ToolWindow toolWindow) {
        if (toolWindow instanceof ToolWindowEx ex) {
            ex.setStripeTitle(TOOL_WINDOW_STRIPE_TITLE);
        }
    }

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        DevToolsPanel panel = new DevToolsPanel();
        var content = ContentFactory.getInstance().createContent(panel, TOOL_WINDOW_STRIPE_TITLE, false);
        toolWindow.getContentManager().addContent(content);
    }
}