All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bushe.swing.event.annotation.VetoTopicPatternSubscriber Maven / Gradle / Ivy

Go to download

Nifty GUI is a Java Library that supports the building of interactive user interfaces for games or similar applications. It utilizes OpenGL for rendering and it can be easily integrated into many rendering systems. The configuration of the GUI is stored in xml files with little supporting Java code. In short Nifty helps you to layout stuff, display it in a cool way and interact with it :)

There is a newer version: 1.4.3
Show newest version
package org.bushe.swing.event.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.bushe.swing.event.EventService;
import org.bushe.swing.event.EventServiceLocator;
import org.bushe.swing.event.ThreadSafeEventService;

/**
 * An Annotation for adding VetoTopicPatternListener subscriptions to EventService Events.
 * 

* This annotation simplifies much of the repetitive boilerplate used for adding veto topic pattern listeners * (which in EventBus 2.0 will be called VetoTopicPatternSubscribers, thus this annotation name difference) * to EventService Events. Example: *

*

 * public class MyAppController {
 *   public MyAppController {
 *       AnnotationProcessor.process(this);//this line can be avoided with a compile-time tool or an Aspect
 *   }
 *   @EvenTopicSubscriber(topic="App.Close.*")
 *   public void onAppClosingEvent(String topic, Object payload) {
 *      //close connections, close windows
 *   }
 * }
 *
 * public class MyDocumentController {
 *   @VetoTopicSubscriber(topic="App.Close.*")
 *   public boolean ensureDocumentIsSaved(String topic, Object payload) {
 *      if (docHasUnsavedChanges()) {
 *         boolean answer = MyModalDialog.show("Are you sure you want to close and lose your changes?");
 *         if (answer == StandardButtonValues.Cancel) {
 *            //stop processing this event
 *            return true;
 *         }
 *      }
 *      //It's OK to close
 *      return false;
 *   }
 * }
 * 
*/ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface VetoTopicPatternSubscriber { /** The topic to subscribe to */ public abstract String topicPattern(); /** Determines the order in which this veto subscriber is called, default is FIFO.*/ public abstract int priority() default 0; /** Whether to subscribe weakly or strongly. */ public abstract ReferenceStrength referenceStrength() default ReferenceStrength.WEAK; /** The event service to subscribe to, default to the EventServiceLocator.SERVICE_NAME_EVENT_BUS. */ public abstract String eventServiceName() default EventServiceLocator.SERVICE_NAME_EVENT_BUS; /** * Whether or not to autocreate the event service if it doesn't exist on subscription, default is true. If the * service needs to be created, it must have a default constructor. */ public abstract Class autoCreateEventServiceClass() default ThreadSafeEventService.class; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy