Programmazione:Java/Eclipse RCP/Documentazione Framework/Registrazione al gestore notifiche
Da WikiSitech.
(Reindirizzamento da Programmazione:Java/Documentazione Framework/Registrazione al gestore notifiche)
Vai alla navigazioneVai alla ricerca<< Back to Documentazione Framework
Questo è un'esempio di come una classe che necessita di notifiche deve registrarsi al Broker e deregistrarsi quando viene distrutta.
public class NotificationSampleClass extends Composite implements IFWKBrokerListener, Listener {
public static final String BROKER_NS = "NotificationSampleClass.BROKER_NS"; //$NON-NLS-1$
public static final String BROKER_CHANGE_FORM = "NotificationSampleClass.BROKER_CHANGE_FORM"; //$NON-NLS-1$
public NotificationSampleClass(Composite parent) {
super(parent);
IFWKBroker.instance.register(BROKER_NS, BROKER_CHANGE_FORM, this);
addListener(SWT.Dispose, this);
}
public void handleEvent(Event event) {
switch (event.type) {
case SWT.Dispose:
if (event.widget == frame) {
removeListener(SWT.Dispose, this);
IFWKBroker.instance.deregister(BROKER_NS, BROKER_CHANGE_FORM, this);
}
break;
}
}
public void handleNotify(IFWKBrokerProperty property) throws FWKException {
if (BROKER_NS.equals(property.getNamespace()) && BROKER_CHANGE_FORM.equals(property.getName())) {
// Gestione notifica
}
}
}