public boolean eventOccurred(UISWTViewEvent event) {
    if (listener == null) {
      UISWTViewEventListener eventListener = null;

      synchronized (UISWTViewEventListenerHolder.this) {
        int type = event.getType();
        if (type == UISWTViewEvent.TYPE_CREATE) {
          try {
            eventListener = cla.newInstance();
            UISWTView view = event.getView();
            if (eventListener instanceof UISWTViewCoreEventListener) {
              if (view instanceof UISWTViewCore) {
                UISWTViewCore coreView = (UISWTViewCore) view;
                coreView.setUseCoreDataSource(true);
              }
            }
            if (mapSWTViewToEventListener == null) {
              mapSWTViewToEventListener = new HashMap<UISWTView, UISWTViewEventListener>();
            }
            mapSWTViewToEventListener.put(view, eventListener);

            if (datasource != null) {
              if (view instanceof UISWTViewImpl) {
                UISWTViewImpl swtView = (UISWTViewImpl) view;
                swtView.triggerEventRaw(
                    UISWTViewEvent.TYPE_DATASOURCE_CHANGED,
                    PluginCoreUtils.convert(
                        datasource, ((UISWTViewImpl) view).useCoreDataSource()));
              } else {
                view.triggerEvent(UISWTViewEvent.TYPE_DATASOURCE_CHANGED, datasource);
              }
            }
          } catch (Exception e) {
            Debug.out(e);
            return false;
          }
        } else if (mapSWTViewToEventListener != null) {
          if (type == UISWTViewEvent.TYPE_DESTROY) {
            eventListener = mapSWTViewToEventListener.remove(event.getView());
          } else {
            eventListener = mapSWTViewToEventListener.get(event.getView());
          }
        }
      }

      if (eventListener == null) {
        return false;
      }

      return eventListener.eventOccurred(event);
    } else if (event.getType() == UISWTViewEvent.TYPE_CREATE
        && (listener instanceof UISWTViewCoreEventListener)) {
      if (event.getView() instanceof UISWTViewCore) {
        UISWTViewCore coreView = (UISWTViewCore) event.getView();
        coreView.setUseCoreDataSource(true);
      }
    }

    return (listener.eventOccurred(event));
  }
Пример #2
0
  public boolean eventOccurred(UISWTViewEvent event) {
    switch (event.getType()) {
      case UISWTViewEvent.TYPE_CREATE:
        swtView = event.getView();
        swtView.setTitle(MessageText.getString(MSGID_PREFIX + ".title.full"));
        break;

      case UISWTViewEvent.TYPE_DESTROY:
        delete();
        break;

      case UISWTViewEvent.TYPE_INITIALIZE:
        initialize((Composite) event.getData());
        break;

      case UISWTViewEvent.TYPE_LANGUAGEUPDATE:
        Messages.updateLanguageForControl(panel);
        break;

      case UISWTViewEvent.TYPE_DATASOURCE_CHANGED:
        break;

      case UISWTViewEvent.TYPE_FOCUSGAINED:
        refresh(true);
        break;

      case UISWTViewEvent.TYPE_REFRESH:
        refresh(false);
        break;

      case StatsView.EVENT_PERIODIC_UPDATE:
        periodicUpdate();
        break;
    }

    return true;
  }