New tab in "Event Messages"

Hi,

I want to create a tool window to show log from an application inside the IDE, like inte the VCS Console or in the Event Message tool window. Is "Event Message" the good place to do this kind of things (I use websockets to recieve message from a web application) ? Or is their a particular behavior of this tool window ?

If you think it's the right place, how can I create easily a tab and how can I manipulate it's content easily ? I looked for the code and I saw that the initialization of its content is a little special (it appear that you use a particular instance of the editor).
If not, how can I add an editor to a tool window like the one in the "Event Message" tool window ?

And just a little remark : is it normal that the right margin appear in the VCS Console but it doesn't took into account ? Should not it be deleted?  

0
8 comments

There is no API to add new tabs to the Event Log toolwindow.

To add an editor to your own toolwindow, use the EditorTextField class.

0
Avatar
Permanently deleted user

Does it provide method as "Add Line/Delete line" ? As it's a log system, I recieve text in the socket and I just want to print it.

0

It is a regular editor. You can add and delete lines using Document.insertString() and Document.deleteString().

0
Avatar
Permanently deleted user

Hi,

I've some problems (cf attached screen) :

- the blue border arount the editor. I don't want it, I want an editor who look like the VCS console or the Event Window, not as a form field.
- secondly, how can I avoid that the user tip into the field ? As in the VCS Console.
- how can I add a scrollbar to the editor ? I add automatically logs to the document, so I want to have a scrollbar and the posibility of showing automatically the end of the file for the last logs and avoid to the user the necessity of scrolling.
- finally, how can I add a "toolbox" to the editor as on the left of the debugger or on the left of the event message tool window ? Is there a special way to do it or is it just a pannel + buttons ?

Thank you for your answers !



Attachment(s):
toolWindowEditor.png
0
Avatar
Permanently deleted user

Up

Edit :

I'm trying to initialize multiple tabs like this :

 
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
  ContentManager contentManager = toolWindow.getContentManager();
  
ProjectSettings projectSettings = ServiceManager.getService(project, ProjectSettings.class);
  
ArrayList<Application> applications = projectSettings.applications;

  for
(Application application : applications) {
    CcLogForm ccLogForm = new CcLogForm();
    
Content logs = contentManager.getFactory().createContent(ccLogForm.getEditor(), application.name, false);
    
contentManager.addContent(logs);
    
Editor editor = ccLogForm.getEditor().getEditor();
    assert
editor != null;

    
writeLogs(project, application, editor);
    
String oldLogs = CcApi.getInstance(project).logRequest(application);

    if
(oldLogs != null && !oldLogs.isEmpty()) {
      WebSocketCore.printSocket(editor, oldLogs);
    
}
    else if (oldLogs != null && oldLogs.isEmpty()) {
      WebSocketCore.printSocket(editor, "No logs available.\n");
    
}
  }
}


But during the second initialization, "editor" is null. How can I initialize multiple editors in a loop ?

Add problem about editor initialization.

0
Avatar
Permanently deleted user

Is there someone who can help me please ?

0
Avatar
Permanently deleted user

Hello! Try Console instead of Editor. Like this:

TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
ConsoleVeiw console = builder.getConsole();
console.print("Hello world!", ConsoleViewContentType.NORMAL_OUTPUT);


Does it help you?

0
Avatar
Permanently deleted user

Hi!

It's perfect! Everything works as expected. I'll publish the plugin soon, it was the last thing I wanted to improve.

I'll test it, do some code review and publish it soon.

Thank you for your help!

0

Please sign in to leave a comment.