我想在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);
}
}