Differenze tra le versioni di "Programmazione:Java/Eclipse RCP/Documentazione Framework/Registrazione al gestore notifiche"
Da WikiSitech.
Vai alla navigazioneVai alla ricercaRiga 30: | Riga 30: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | [[Programmazione:Java/Eclipse_RCP/Documentazione_Framework|Back to Documentazione Framework]] |
Versione delle 10:15, 14 apr 2008
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
}
}
}