use of org.eclipse.ui.console.IConsoleListener in project sling by apache.
the class SlingConsoleEventListener method handleEvent.
@Override
public void handleEvent(Event event) {
synchronized (sync) {
initSlingConsole();
if (slingConsole != null) {
logEvent(event, slingConsole);
return;
}
delayedEvents.add(event);
final IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
if (listener == null) {
listener = new IConsoleListener() {
@Override
public void consolesRemoved(IConsole[] consoles) {
synchronized (sync) {
for (IConsole console : consoles) {
if (console.equals(slingConsole)) {
slingConsole = null;
}
}
}
}
@Override
public void consolesAdded(IConsole[] consoles) {
synchronized (sync) {
for (IConsole console : consoles) {
if (console.getType().equals(SlingConsoleFactory.CONSOLE_TYPE_SLING)) {
slingConsole = (MessageConsole) console;
synchronized (delayedEvents) {
for (Iterator<Event> it = delayedEvents.iterator(); it.hasNext(); ) {
logEvent(it.next(), slingConsole);
it.remove();
}
}
consoleManager.removeConsoleListener(listener);
listener = null;
break;
}
}
}
}
};
consoleManager.addConsoleListener(listener);
}
}
}
Aggregations