Listener to capture project run event

Answered

Hello guys,

I'm developing a tool window plugin to monitor and display log entries from a master log file. Is there any way i can capture a project execution event? I need to start monitoring the log file once a project is run, and stop monitoring once completed. My current implementation contains an infinite while loop that continuously monitors the log file. This takes a hit on the performance so I need to make improvements.

0
3 comments

Nevermind found a solution but I don't completely understand the code. Can someone explain what triggers the contentSelected and contentRemoved methods?

public class Loader implements  RunContentWithExecutorListener {
public void someMethod(Project project){      project.getMessageBus().connect().subscribe(RunContentManager.TOPIC, this);
} @Override public void contentSelected(RunContentDescriptor runContentDescriptor, @NotNull Executor executor) {
}
 
@Override
public void contentRemoved(RunContentDescriptor runContentDescriptor, @NotNull Executor executor) {
 
}
 
}
1

Finally! I found something that works but Intellij says the addRunContentListener method is deprecated. grrrr...Is there any workaround?

EDIT: found this suggestion in the previous source code @deprecated Use {@link RunContentManager#TOPIC} instead. I don't get it though

public class Loader implements  RunContentListener {

public void someMethod(Project project){

     ExecutionManager.getInstance(project).getContentManager().addRunContentListener(this);

}

@Override
public void contentSelected(RunContentDescriptor runContentDescriptor) {
     //RUN event is captured here! yeay!
}

@Override
public void contentRemoved(RunContentDescriptor runContentDescriptor) {

}

}

0

@...
I want to show text of Run  window in a DialogMessage

How to achieve that pleaase ?

0

Please sign in to leave a comment.