/** * Activates the participants for the given console, if any. * * @param console the console */ private void activateParticipants(IConsole console) { // activate if (console != null && fActive) { final ListenerList<IConsolePageParticipant> listeners = getParticipants(console); if (listeners != null) { for (IConsolePageParticipant iConsolePageParticipant : listeners) { final IConsolePageParticipant participant = iConsolePageParticipant; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { participant.activated(); } @Override public void handleException(Throwable exception) { ConsolePlugin.log(exception); listeners.remove(participant); } }); } } } }
/** * Deactivates participants for the given console, if any. * * @param console console to deactivate */ private void deactivateParticipants(IConsole console) { // deactivate if (console != null) { final ListenerList<IConsolePageParticipant> listeners = getParticipants(console); if (listeners != null) { for (IConsolePageParticipant iConsolePageParticipant : listeners) { final IConsolePageParticipant participant = iConsolePageParticipant; SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { participant.deactivated(); } @Override public void handleException(Throwable exception) { ConsolePlugin.log(exception); listeners.remove(participant); } }); } } } }
/** * Activates the participants for the given console, if any. * * @param console */ private void activateParticipants(IConsole console) { // activate if (console != null && fActive) { final ListenerList listeners = getParticipants(console); if (listeners != null) { Object[] participants = listeners.getListeners(); for (int i = 0; i < participants.length; i++) { final IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; SafeRunner.run(new ISafeRunnable() { public void run() throws Exception { participant.activated(); } public void handleException(Throwable exception) { ConsolePlugin.log(exception); listeners.remove(participant); } }); } } } }
/** * Deactivates participants for the given console, if any. * * @param console console to deactivate */ private void deactivateParticipants(IConsole console) { // deactivate if (console != null) { final ListenerList listeners = getParticipants(console); if (listeners != null) { Object[] participants = listeners.getListeners(); for (int i = 0; i < participants.length; i++) { final IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; SafeRunner.run(new ISafeRunnable() { public void run() throws Exception { participant.deactivated(); } public void handleException(Throwable exception) { ConsolePlugin.log(exception); listeners.remove(participant); } }); } } } }
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> key) { Object adpater = super.getAdapter(key); if (adpater == null) { IConsole console = getConsole(); if (console != null) { ListenerList<IConsolePageParticipant> listeners = getParticipants(console); // an adapter can be asked for before the console participants are created if (listeners != null) { for (IConsolePageParticipant iConsolePageParticipant : listeners) { IConsolePageParticipant participant = iConsolePageParticipant; adpater = participant.getAdapter(key); if (adpater != null) { return (T) adpater; } } } } } return (T) adpater; }
public Object getAdapter(Class key) { Object adpater = super.getAdapter(key); if (adpater == null) { IConsole console = getConsole(); if (console != null) { ListenerList listeners = getParticipants(console); // an adapter can be asked for before the console participants are created if (listeners != null) { Object[] participants = listeners.getListeners(); for (int i = 0; i < participants.length; i++) { IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; adpater = participant.getAdapter(key); if (adpater != null) { return adpater; } } } } } return adpater; }