3 comments
Comment actions Permalink

Please show your code in full and explain the problem in more detail.

0
Comment actions Permalink

Yann Cebron

The MessageDialog doesn't appear when i run my project .
I  need the to show the text of run operation .


public class ConsoleReader extends AnAction implements AnActionListener {

public ConsoleReader () {}


public void beforeActionPerformed(@NotNull AnAction action, @NotNull DataContext dataContext, @NotNull AnActionEvent event) {


dataContext = DataManager.getInstance().getDataContext();
Project prj = (Project) dataContext.getData(DataConstants.PROJECT);
ActionManager actionManager = ActionManager.getInstance();


String actionId = actionManager.getId(action);


if (actionId != null) {

if (actionId.equals(IdeActions.ACTION_DEFAULT_RUNNER)) {

prj.getMessageBus().connect().subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionListener() {
@Override
public void processStarted(@NotNull String executorId, @NotNull ExecutionEnvironment env, @NotNull ProcessHandler handler) {

handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {

String text = event.getText();
if (text != null )
Messages.showMessageDialog(prj, text, "Console output", Messages.getInformationIcon());
}
});
}
});

}

}

}

public void update(AnActionEvent e) {
// Set the availability based on whether a project is open
Project project = e.getProject();
e.getPresentation().setEnabledAndVisible(project != null);

}

@Override
public void actionPerformed(@NotNull AnActionEvent anActionEvent) {

}

}

 

 

0

Please sign in to leave a comment.