如何在Intellij Idea工具窗口中将文本追加到现有内容?

时间:2018-09-01 06:49:31

标签: java intellij-plugin

我想在IntelliJ插件的工具窗口的现有内容下方打印一些字符串。目前,我只能覆盖它。 以下是我编写的在工具窗口上打印值的代码。

public class MyTypedHandler implements TypedActionHandler {
private TypedActionHandler myOriginalHandler;
String result = "";
public JLabel issue;

public MyTypedHandler(TypedActionHandler originalHandler){
    myOriginalHandler = originalHandler;
}
@Override
public void execute(@NotNull Editor editor, char c, @NotNull DataContext dataContext){
    myOriginalHandler.execute(editor, c, dataContext);
    final Document document = editor.getDocument();
    final Project project = editor.getProject();
    try {
        Guideline06_09 obj = new Guideline06_09();
        String result = obj.runalgorithm(document.getText());
        if(!result.isEmpty()){
            ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow("SCA_Tool");
            Component component = toolWindow.getComponent();
            component.getParent().add(new JLabel(result+"\n"));
        }
    }catch (Exception e){

    }
    Runnable runnable = new Runnable() {
        @Override
        public void run() {

        }
    };
    WriteCommandAction.runWriteCommandAction(project, runnable);
}

}

0 个答案:

没有答案