Package org.osgi.service.event

Examples of org.osgi.service.event.EventHandler


    public void handleChildRemove(M parent, C element);
  }

  public static <C extends MUIElement, M extends MElementContainer<C>, R extends BaseRenderer<M, ?> & ChildrenHandler<M, C>> void attachChildProcessor(IEventBroker eventBroker, final R renderer) {
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, new EventHandler() {

      @SuppressWarnings("unchecked")
      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
View Full Code Here


      }
    });
  }

  public static <M extends MUIElement, R extends BaseRenderer<M, ?>> void attachVisibleProcessor(IEventBroker eventBroker, final R renderer) {
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, new EventHandler() {

      @SuppressWarnings("unchecked")
      @Override
      public void handleEvent(Event event) {
        MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
View Full Code Here

    registerEventListener(eventBroker, UIEvents.Window.TOPIC_WIDTH);
    registerEventListener(eventBroker, UIEvents.Window.TOPIC_HEIGHT);
    registerEventListener(eventBroker, UIEvents.UILabel.TOPIC_LABEL);
    registerEventListener(eventBroker, UIEvents.UILabel.TOPIC_TOOLTIP);
    registerEventListener(eventBroker, UIEvents.UIElement.TOPIC_VISIBLE);
    eventBroker.subscribe(UIEvents.Window.TOPIC_WINDOWS, new EventHandler() {
     
      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if( changedObj instanceof MPerspective ) {
View Full Code Here

 
  boolean inLazyInit;
 
  @PostConstruct
  void init(IEventBroker eventBroker) {
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj instanceof MPartStack) {
          MPartStack parent = (MPartStack) changedObj;
          if (BaseStackRenderer.this == parent.getRenderer()) {
            String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
           
            if (UIEvents.EventTypes.ADD.equals(eventType)) {
              MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
              handleChildAddition(parent, (MStackElement) element);
            } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
              MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
              handleChildRemove(parent, (MStackElement) element);
            }
          }
        }
      }
    });
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj instanceof MPartStack) {
          MPartStack parent = (MPartStack) changedObj;
          if (BaseStackRenderer.this == parent.getRenderer()) {
            String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
            if (UIEvents.EventTypes.SET.equals(eventType)) {
              MUIElement newValue = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
              MUIElement oldValue = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
              handleSelectedElement(parent, (MStackElement) oldValue, (MStackElement) newValue);
            }
          }
        }
      }
    });
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, new EventHandler() {
     
      @Override
      public void handleEvent(Event event) {
        MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
        if( changedObj.isToBeRendered() ) {
View Full Code Here

      context.set(ATTRIBUTE_localizedTooltip, l.getLocalizedTooltip());
    }
  }
 
  protected void registerEventListener(IEventBroker broker, String topic) {
    broker.subscribe(topic, new EventHandler() {
     
      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if( ! (changedObj instanceof MUIElement) ) {
View Full Code Here

  boolean inLazyInit;

  @PostConstruct
  void init(IEventBroker eventBroker) {
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj instanceof MPerspectiveStack) {
          MPerspectiveStack parent = (MPerspectiveStack) changedObj;
          if (BasePerspectiveStackRenderer.this == parent.getRenderer()) {
            String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);

            if (UIEvents.EventTypes.ADD.equals(eventType)) {
              MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
              handleChildAddition(parent, (MPerspective) element);
            } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
              MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
              handleChildRemove(parent, (MPerspective) element);
            }
          }
        }
      }
    });
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj instanceof MPerspectiveStack) {
          MPerspectiveStack parent = (MPerspectiveStack) changedObj;
          if (BasePerspectiveStackRenderer.this == parent.getRenderer()) {
            String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
            if (UIEvents.EventTypes.SET.equals(eventType)) {
              MUIElement newValue = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
              MUIElement oldValue = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
              handleSelectedElement(parent, (MPerspective) oldValue, (MPerspective) newValue);
            }
          }
        }
      }
    });
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj.isToBeRendered()) {
View Full Code Here

  @Inject
  RendererFactory factory;

  @PostConstruct
  void init(IEventBroker eventBroker) {
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj instanceof MPartSashContainer) {
          MPartSashContainer parent = (MPartSashContainer) changedObj;
          if (BaseSashRenderer.this == parent.getRenderer()) {
            String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
           
            if (UIEvents.EventTypes.ADD.equals(eventType)) {
              MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
              handleChildAddition(parent, (MPartSashContainerElement) element);
            } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
              MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
              handleChildRemove(parent, (MPartSashContainerElement) element);
            }
          }
        }
      }
    });
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj instanceof MPartSashContainer) {
          MPartSashContainer parent = (MPartSashContainer) changedObj;
          if (BaseSashRenderer.this == parent.getRenderer()) {
            String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
            if (UIEvents.EventTypes.SET.equals(eventType)) {
              MUIElement newValue = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
              MUIElement oldValue = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
              handleSelectedElement(parent, (MPartSashContainerElement) oldValue, (MPartSashContainerElement) newValue);
            }
          }
        }
      }
    });
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj.isToBeRendered()) {
View Full Code Here

  @Log
  Logger logger;
 
  @PostConstruct
  void init(IEventBroker eventBroker) {
    eventBroker.subscribe(UIEvents.Perspective.TOPIC_WINDOWS, new EventHandler() {
     
      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if( changedObj instanceof MPerspective ) {
View Full Code Here

  @Inject
  RendererFactory factory;

  @PostConstruct
  void init(IEventBroker eventBroker) {
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj instanceof MArea) {
          MArea parent = (MArea) changedObj;
          if (BaseAreaRenderer.this == parent.getRenderer()) {
            String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
           
            if (UIEvents.EventTypes.ADD.equals(eventType)) {
              MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
              handleChildAddition(parent, (MPartSashContainerElement) element);
            } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
              MUIElement element = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
              handleChildRemove(parent, (MPartSashContainerElement) element);
            }
          }
        }
      }
    });
    eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj instanceof MArea) {
          MArea parent = (MArea) changedObj;
          if (BaseAreaRenderer.this == parent.getRenderer()) {
            String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
            if (UIEvents.EventTypes.SET.equals(eventType)) {
              MUIElement newValue = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);
              MUIElement oldValue = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
              handleSelectedElement(parent, (MPartSashContainerElement) oldValue, (MPartSashContainerElement) newValue);
            }
          }
        }
      }
    });
    eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE, new EventHandler() {

      @Override
      public void handleEvent(Event event) {
        MUIElement changedObj = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
        if (changedObj.isToBeRendered()) {
View Full Code Here

  public void dispose() {
    unregsiterModelListeners();
  }

  private void registerModelListeners() {
    additionHandler = new EventHandler() {
      public void handleEvent(Event event) {
        Object elementObj = event
            .getProperty(UIEvents.EventTags.ELEMENT);
        if (elementObj instanceof MApplication) {
          Object newObj = event
              .getProperty(UIEvents.EventTags.NEW_VALUE);
          if (UIEvents.EventTypes.ADD.equals(event
              .getProperty(UIEvents.EventTags.TYPE))
              && newObj instanceof MBindingTable) {
            MBindingTable bt = (MBindingTable) newObj;
            final Context bindingContext = contextManager
                .getContext(bt.getBindingContext()
                    .getElementId());
            final BindingTable table = new BindingTable(
                bindingContext);
            bindingTables.addTable(table);
            List<MKeyBinding> bindings = bt.getBindings();
            for (MKeyBinding binding : bindings) {
              Binding keyBinding = createBinding(bindingContext,
                  binding.getCommand(),
                  binding.getParameters(),
                  binding.getKeySequence(), binding);
              if (keyBinding != null) {
                table.addBinding(keyBinding);
              }
            }
          }
        } else if (elementObj instanceof MBindingTable) {
          Object newObj = event
              .getProperty(UIEvents.EventTags.NEW_VALUE);
          Object oldObj = event
              .getProperty(UIEvents.EventTags.OLD_VALUE);

          // adding a binding
          if (UIEvents.EventTypes.ADD.equals(event
              .getProperty(UIEvents.EventTags.TYPE))
              && newObj instanceof MKeyBinding) {

            MKeyBinding binding = (MKeyBinding) newObj;
            updateBinding(binding, true, elementObj);
          }
          // removing a binding
          else if (UIEvents.EventTypes.REMOVE.equals(event
              .getProperty(UIEvents.EventTags.TYPE))
              && oldObj instanceof MKeyBinding) {

            MKeyBinding binding = (MKeyBinding) oldObj;
            updateBinding(binding, false, elementObj);
          }
        } else if (elementObj instanceof MKeyBinding) {
          MKeyBinding binding = (MKeyBinding) elementObj;

          String attrName = (String) event
              .getProperty(UIEvents.EventTags.ATTNAME);

          if (UIEvents.EventTypes.SET.equals(event
              .getProperty(UIEvents.EventTags.TYPE))) {
            Object oldObj = event
                .getProperty(UIEvents.EventTags.OLD_VALUE);
            if (UIEvents.KeyBinding.COMMAND.equals(attrName)) {
              MKeyBinding oldBinding = (MKeyBinding) EcoreUtil
                  .copy((EObject) binding);
              oldBinding.setCommand((MCommand) oldObj);
              updateBinding(oldBinding, false,
                  ((EObject) binding).eContainer());
              updateBinding(binding, true, null);
            } else if (UIEvents.KeySequence.KEYSEQUENCE
                .equals(attrName)) {
              MKeyBinding oldBinding = (MKeyBinding) EcoreUtil
                  .copy((EObject) binding);
              oldBinding.setKeySequence((String) oldObj);
              updateBinding(oldBinding, false,
                  ((EObject) binding).eContainer());
              updateBinding(binding, true, null);
            }
          } else if (UIEvents.KeyBinding.PARAMETERS.equals(attrName)) {
            if (UIEvents.EventTypes.ADD.equals(event
                .getProperty(UIEvents.EventTags.TYPE))) {
              Object newObj = event
                  .getProperty(UIEvents.EventTags.NEW_VALUE);
              MKeyBinding oldBinding = (MKeyBinding) EcoreUtil
                  .copy((EObject) binding);
              oldBinding.getParameters().remove(newObj);
              updateBinding(oldBinding, false,
                  ((EObject) binding).eContainer());
              updateBinding(binding, true, null);
            } else if (UIEvents.EventTypes.REMOVE.equals(event
                .getProperty(UIEvents.EventTags.TYPE))) {
              Object oldObj = event
                  .getProperty(UIEvents.EventTags.OLD_VALUE);
              MKeyBinding oldBinding = (MKeyBinding) EcoreUtil
                  .copy((EObject) binding);
              oldBinding.getParameters().add((MParameter) oldObj);
              updateBinding(oldBinding, false,
                  ((EObject) binding).eContainer());
              updateBinding(binding, true, null);
            }
          }
          // if we've updated the tags for an MKeyBinding
          else if (UIEvents.ApplicationElement.TAGS.equals(attrName)) {
            List<String> tags = binding.getTags();
            // if we added a deleted tag to the MKeyBinding, then
            // remove it from the runtime binding tables
            if (tags.contains(EBindingService.DELETED_BINDING_TAG)) {
              updateBinding(binding, false, elementObj);
            }
            // else we're adding the binding to the runtime tables
            else {
              updateBinding(binding, true, elementObj);
            }
          }
        }
      }
    };
    broker.subscribe(UIEvents.BindingTableContainer.TOPIC_BINDINGTABLES,
        additionHandler);
    broker.subscribe(UIEvents.BindingTable.TOPIC_BINDINGS, additionHandler);
    broker.subscribe(UIEvents.KeyBinding.TOPIC_COMMAND, additionHandler);
    broker.subscribe(UIEvents.KeyBinding.TOPIC_PARAMETERS, additionHandler);
    broker.subscribe(UIEvents.KeySequence.TOPIC_KEYSEQUENCE,
        additionHandler);
    broker.subscribe(UIEvents.ApplicationElement.TOPIC_TAGS,
        additionHandler);

    contextHandler = new EventHandler() {
      public void handleEvent(Event event) {
        Object elementObj = event
            .getProperty(UIEvents.EventTags.ELEMENT);
        Object newObj = event.getProperty(UIEvents.EventTags.NEW_VALUE);
        if (UIEvents.EventTypes.SET.equals(event
View Full Code Here

TOP

Related Classes of org.osgi.service.event.EventHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.