Ejemplo n.º 1
0
  /** {@inheritDoc} */
  @SuppressWarnings("unchecked")
  @Subscribe
  public void update(final Object eventObject) {
    if (eventObject == null || !(eventObject instanceof BaralgaEvent)) {
      return;
    }

    final BaralgaEvent event = (BaralgaEvent) eventObject;
    ProjectActivity activity;

    switch (event.getType()) {
      case BaralgaEvent.PROJECT_ACTIVITY_ADDED:
        applyFilter();
        break;

      case BaralgaEvent.PROJECT_ACTIVITY_CHANGED:
        {
          activity = (ProjectActivity) event.getData();
          final boolean matchesFilter = model.getFilter().matchesCriteria(activity);

          if (entriesByActivity.containsKey(activity)) {
            // If activity matches the current filter it is updated
            // if not the activity is removed
            if (matchesFilter) {
              entriesByActivity.get(activity).update();
            } else {
              final DescriptionPanelEntry entryPanel = entriesByActivity.get(activity);
              this.container.remove(entryPanel);
            }
          }

          break;
        }

      case BaralgaEvent.PROJECT_ACTIVITY_REMOVED:
        final Collection<ProjectActivity> projectActivities =
            (Collection<ProjectActivity>) event.getData();
        for (ProjectActivity projectActivity : projectActivities) {
          if (entriesByActivity.containsKey(projectActivity)) {
            final DescriptionPanelEntry entryPanel = entriesByActivity.get(projectActivity);
            this.container.remove(entryPanel);
          }
        }
        break;

      case BaralgaEvent.PROJECT_CHANGED:
        for (Entry<ProjectActivity, DescriptionPanelEntry> entry : entriesByActivity.entrySet()) {
          entry.getValue().update();
        }
        break;

      case BaralgaEvent.FILTER_CHANGED:
        final Filter newFilter = (Filter) event.getData();
        setFilter(newFilter);
        break;

      case BaralgaEvent.DATA_CHANGED:
        applyFilter();
        break;
    }
  }
 private void resetInactivity() {
   model.resetUserInactivityState();
   setVisible(false);
 }