Tabnine Logo
EventController.addListener
Code IndexAdd Tabnine to your IDE (free)

How to use
addListener
method
in
de.tsl2.nano.core.messaging.EventController

Best Java code snippets using de.tsl2.nano.core.messaging.EventController.addListener (Showing top 10 results out of 315)

origin: net.sf.tsl2nano/tsl2.nano.cursus

public EProcess() {
  prc.getEventController().addListener(this, Object.class);
}
 
origin: net.sf.tsl2nano/tsl2.nano.descriptor

  /**
   * a new listener will be created to set the new value of this bean to the given beanvalue.
   * 
   * @param anotherValue beanvalue to bind
   */
  public void bind(final BeanValue<T> anotherValue) {
//        if (!getType().equals(anotherValue.getType()))
//            ManagedException.implementationError("binding beanvalues must have the same type", anotherValue.getType());
    changeHandler().addListener(new IListener<ChangeEvent>() {
      @Override
      public void handleEvent(ChangeEvent changeEvent) {
        if (changeEvent.hasChanged) {
          anotherValue.setValue((T) changeEvent.newValue);
        }
      }
    });
  }
 
origin: net.sf.tsl2nano/tsl2.nano.vnet

/**
 * constructor
 * @param path for nodes to be notified
 * @param notification the notification content
 * @param response any node response
 * @param responseListener listeners to node responses
 */
public Notification(String path,
    Object notification,
    Map<String, Object> response,
    IListener<Notification> responseListener) {
  super();
  this.notification = notification;
  this.path = path;
  this.response = response;
  if (responseListener != null) {
    getResponseController().addListener(responseListener);
  }
}
origin: net.sf.tsl2nano/tsl2.nano.descriptor

private void createBinding() {
  firstValue.changeHandler().addListener(new IListener<ChangeEvent>() {
    @Override
    public void handleEvent(ChangeEvent changeEvent) {
      if (!updating && changeEvent.hasChanged) {
        try {
          updating = true;
          secondValue.setValue(converter.to((FIRST) changeEvent.newValue));
        } finally {
          updating = false;
        }
      }
    }
  });
  secondValue.changeHandler().addListener(new IListener<ChangeEvent>() {
    @Override
    public void handleEvent(ChangeEvent changeEvent) {
      if (!updating && changeEvent.hasChanged) {
        try {
          updating = true;
          firstValue.setValue(converter.from((SECOND) changeEvent.newValue));
        } finally {
          updating = false;
        }
      }
    }
  });
}
origin: net.sf.tsl2nano/tsl2.nano.descriptor

/**
 * constructor
 * 
 * @param ovalue orginal value to be bound to this wrapper instance. the value is holding an enum
 * @param enumValues enumeration values
 */
public OptionsWrapper(IValueAccess<E> ovalue, E[] enumValues) {
  super();
  assert enumValues.length <= ATTR_NAMES.length : "maximum count of "+ ATTR_NAMES.length + " enumeration values exceeded";
  this.enumerations = enumValues;
  this.ovalue = ovalue;
  /*
   * if the value was set from outside, we listen to it to refresh our wrapper and
   * perhaps other data-bound values
   */
  ovalue.changeHandler().addListener(new IListener<ChangeEvent>() {
    @SuppressWarnings("unchecked")
    @Override
    public void handleEvent(ChangeEvent event) {
      if (!changingValue) {
        Object value = event.getSource();
        BeanValue.getBeanValue(OptionsWrapper.this, ATTR_NAMES[indexOf((E) value)]).setValue(true);
      }
    }
  });
}
origin: net.sf.tsl2nano/tsl2.nano.descriptor

/**
 * convenience to observe an attribute
 * 
 * @param name attribute name
 * @param listener observer
 */
public void observe(String name, IListener listener) {
  getAttribute(name).changeHandler().addListener(listener);
}
origin: net.sf.tsl2nano/tsl2.nano.descriptor

/**
 * convenience method add a listener to all enumvalues.
 * 
 * @param wrapper wrapper instance to have an instance using booleans for each enum type that was selected.
 * @param listener user defined listener to act on selection changes.
 * @param enumConstants enum constants
 */
protected void setEnumBooleanListener(OptionsWrapper<?> wrapper,
    IListener<ChangeEvent> listener,
    Enum[] enumConstants) {
  for (int i = 0; i < enumConstants.length; i++) {
    LOG.debug("adding valuechange-listener for attribute: " + OptionsWrapper.ATTR_NAMES[i]);
    BeanValue.getBeanValue(wrapper, OptionsWrapper.ATTR_NAMES[i]).changeHandler().addListener(listener);
    //TODO: listener bei dispose evtl. wieder abbauen!
  }
}
origin: net.sf.tsl2nano/tsl2.nano.vnet

/**
 * constructor
 * 
 * @param core {@link #core}
 * @param connections {@link #connections}
 */
@SuppressWarnings("rawtypes")
public Node(T core, List<IConnection<T, D>> connections) {
  super();
  controller = Net.createEventController();
  statistics = new NodeStatistics();
  this.core = core;
  if (connections != null) {
    this.connections = connections;
    for (IConnection<T, D> connection : connections) {
      controller.addListener((IListener) connection);
    }
  } else {
    this.connections = new LinkedList<IConnection<T, D>>();
  }
}
origin: net.sf.tsl2nano/tsl2.nano.descriptor

/**
 * connect the attribute by the given attribute-name to another attribute through listening to value changes. if the
 * other attribute is changing, the own attribute will fire a value change, too (without changing the value!) to
 * inform other listeners, that a dependent attribute was changed. maybe useful for refreshings. the connect 'other'
 * attribute is accessible though {@link #getConnection(String)}.
 * 
 * @param attrName the beans attribute name to be connected. the attribute has to be at least of type
 *            {@link IValueAccess}! check it through {@link #getAttribute(String)}.
 * @param valueToConnect foreign attribute to listen for changes.
 * @param callback method to be called, if foreign attribute changes.
 */
public void connect(final String attrName,
    IValueAccess<?> valueToConnect,
    final IAction<?> callback,
    boolean afterChanging) {
  valueToConnect.changeHandler().addListener(
    new ValueConnection(this, attrName, valueToConnect, callback, afterChanging), ChangeEvent.class);
  isconnected = true;
}
origin: net.sf.tsl2nano/tsl2.nano.descriptor

/**
 * uses the information of {@link #attributeID} to inject the real {@link AttributeDefinition} into registered
 * change listeners
 * 
 * @throws CloneNotSupportedException
 */
void injectAttributeOnChangeListeners(BeanDefinition beandef) {
  //provide dependency listeners their attribute-definition
  if (hasListeners()) {
    Collection<IListener> listener = changeHandler().getListeners(null);
    boolean isBean = beandef instanceof Bean;
    for (IListener l : listener) {
      if (l instanceof AbstractDependencyListener) {
        AbstractDependencyListener<?, ?> dl = (AbstractDependencyListener<?, ?>) l;
        if (isBean) {//create a specific listener instance for the given bean!
          LOG.debug(beandef.getId() + ": re-assigning dependency-listener-clone " + dl);
          dl = (AbstractDependencyListener<?, ?>) dl.clone();
          Class eventType = changeHandler().getEventType(l);
          changeHandler().removeListener(l);
          changeHandler().addListener(dl, eventType);
        }
        if (dl.attributeID != null) {
          String name = StringUtil.substring(dl.attributeID, ".", null);
          LOG.debug(beandef.getId() + ": resetting value of attribute " + name);
          dl.setAttribute((AttributeDefinition) beandef.getAttribute(name));
        }
      }
    }
  }
}
de.tsl2.nano.core.messagingEventControlleraddListener

Popular methods of EventController

  • fireEvent
  • <init>
  • fireValueChange
  • getEventType
  • getListeners
  • handle
  • hasListeners
  • removeListener
  • reset

Popular in Java

  • Running tasks concurrently on multiple threads
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (Timer)
  • onCreateOptionsMenu (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Menu (java.awt)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Cipher (javax.crypto)
    This class provides access to implementations of cryptographic ciphers for encryption and decryption
  • ImageIO (javax.imageio)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now