Examples of IFilterAction


Examples of org.rssowl.core.persist.IFilterAction

    /* 6) Match All News - Enabled - Label News */
    filter = fFactory.createSearchFilter(null, null, "Filter 6");
    filter.setMatchAllNews(true);
    filter.setOrder(5);
    IFilterAction action = fFactory.createFilterAction(LabelNewsAction.ID);
    action.setData(fImportantLabel.getId());
    filter.addAction(action);
    DynamicDAO.save(filter);

    /* 7) Match All News - Enabled - Label News + Move News + Play Sound */
    filter = fFactory.createSearchFilter(null, null, "Filter 7");
    filter.setMatchAllNews(true);
    filter.setOrder(5);
    action = fFactory.createFilterAction(LabelNewsAction.ID);
    action.setData(fImportantLabel.getId());
    filter.addAction(action);

    action = fFactory.createFilterAction(MoveNewsAction.ID);
    action.setData(new Long[] { fNewsBin.getId() });
    filter.addAction(action);

    action = fFactory.createFilterAction("org.rssowl.ui.PlaySoundAction");
    action.setData("C:\\ProgramData\\Microsoft\\Windows & Help\\Start Menu");
    filter.addAction(action);

    DynamicDAO.save(filter);

    /* 8) Filter with Properties as Data */
    filter = fFactory.createSearchFilter(null, null, "Filter 8");
    filter.setMatchAllNews(true);
    filter.setOrder(5);

    action = fFactory.createFilterAction("org.rssowl.ui.PlaySoundAction");
    Properties props = new Properties();
    props.setProperty("foo", "bar");
    props.setProperty("hello world", " world hello ");
    props.setProperty("<some xml>tags</a>", "foo & bar");
    action.setData(props);
    filter.addAction(action);

    DynamicDAO.save(filter);
  }
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

  public List<IFilterAction> createActions() {
    List<IFilterAction> actions = new ArrayList<IFilterAction>(fItems.size());

    /* For each Item */
    for (NewsActionItem item : fItems) {
      IFilterAction action = item.createFilterAction(true);
      if (action != null)
        actions.add(action);
    }

    /* Delete Duplicate Actions */
    List<IFilterAction> duplicateActions = new ArrayList<IFilterAction>(0);
    for (IFilterAction action : actions) {

      /* Check if already Ignored */
      if (duplicateActions.contains(action))
        continue;

      /* Check for Actions to Ignore */
      for (IFilterAction otherAction : actions) {
        if (action == otherAction)
          continue;

        /* Same Action IDs */
        if (action.getActionId().equals(otherAction.getActionId())) {

          /* Ignore Action: Both Data is unspecified */
          if (action.getData() == null && otherAction.getData() == null)
            duplicateActions.add(otherAction);

          /* Ignore Action: Both Data is identical (Case: Object) */
          else if (action.getData() != null && action.getData().equals(otherAction.getData()))
            duplicateActions.add(otherAction);

          /* Ignore Action: Both Data is identical (Case: Arrays) */
          else if (action.getData() != null && action.getData() instanceof Object[]) {
            Object[] data = (Object[]) action.getData();
            if (otherAction.getData() instanceof Object[]) {
              Object[] otherData = (Object[]) otherAction.getData();
              if (Arrays.equals(data, otherData))
                duplicateActions.add(otherAction);
            }
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

      }
    });
  }

  void onAdd(NewsActionItem selectedItem) {
    IFilterAction filterAction = createAction(selectedItem.createFilterAction(false));
    addItem(filterAction, indexOf(selectedItem) + 1, true);
  }
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

    IFilterAction filterAction = createAction(selectedItem.createFilterAction(false));
    addItem(filterAction, indexOf(selectedItem) + 1, true);
  }

  void onAdd(NewsActionItem selectedItem, String actionId) {
    IFilterAction filterAction = Owl.getModelFactory().createFilterAction(actionId);
    addItem(filterAction, indexOf(selectedItem) + 1, true);
  }
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

      ISearchFilter filter = fTypesFactory.createSearchFilter(null, search, "Filter");
      filter.setEnabled(true);
      filter.setOrder(5);

      IFilterAction action = fTypesFactory.createFilterAction("org.rssowl.ActionId1");
      action.setData(100);
      filter.addAction(action);

      action = fTypesFactory.createFilterAction("org.rssowl.ActionId2");
      action.setData(new Long[] { 1l, 2l, 3l });
      filter.addAction(action);

      filter = DynamicDAO.save(filter);
      if (gc)
        System.gc();

      Collection<ISearchFilter> filters = DynamicDAO.loadAll(ISearchFilter.class);
      assertEquals(1, filters.size());
      ISearchFilter savedFilter = filters.iterator().next();
      assertEquals(filter.getName(), savedFilter.getName());
      assertEquals(filter.getOrder(), savedFilter.getOrder());
      assertEquals(filter.isEnabled(), savedFilter.isEnabled());

      List<IFilterAction> actions = savedFilter.getActions();
      assertEquals(2, actions.size());
      assertEquals("org.rssowl.ActionId1", actions.get(0).getActionId());
      assertEquals(100, actions.get(0).getData());
      assertEquals("org.rssowl.ActionId2", actions.get(1).getActionId());
      assertEquals(true, Arrays.equals((Object[]) actions.get(1).getData(), new Long[] { 1l, 2l, 3l }));

      ISearch savedSearch = savedFilter.getSearch();
      assertEquals(search.matchAllConditions(), savedSearch.matchAllConditions());
      List<ISearchCondition> savedConditions = savedSearch.getSearchConditions();
      assertEquals(2, savedConditions.size());

      assertEquals(true, ((SearchCondition) savedConditions.get(0)).isIdentical(condition1));
      assertEquals(true, ((SearchCondition) savedConditions.get(1)).isIdentical(condition2));
    }

    /* Update */
    {
      Collection<ISearchFilter> filters = DynamicDAO.loadAll(ISearchFilter.class);
      ISearchFilter savedFilter = filters.iterator().next();

      savedFilter.setName("Disabled Filter");
      savedFilter.setEnabled(false);
      savedFilter.setOrder(1);

      List<IFilterAction> actions = savedFilter.getActions();
      savedFilter.removeAction(actions.get(0));
      actions.get(1).setData(new Long[] { 3l, 2l, 1l });
      IFilterAction action = fTypesFactory.createFilterAction("org.rssowl.ActionId3");
      action.setData(200);
      savedFilter.addAction(action);

      ISearch savedSearch = savedFilter.getSearch();
      savedSearch.setMatchAllConditions(false);
      List<ISearchCondition> savedConditions = savedSearch.getSearchConditions();
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

    for (int i = 0; i < actions.size(); i++) {
      Element action = (Element) actions.get(i);
      String id = action.getAttributeValue(Attributes.ID.get());
      String data = action.getAttributeValue(Attributes.DATA.get());

      IFilterAction filterAction = factory.createFilterAction(id);
      if (data != null) {

        /* Special case Label Action */
        if (LabelNewsAction.ID.equals(id)) {
          Long labelId = Long.parseLong(data);
          filterAction.setData(labelId);
        }

        /* Special case Move/Copy Action */
        else if (MoveNewsAction.ID.equals(id) || CopyNewsAction.ID.equals(id)) {
          String[] binIds = data.split(OPMLConstants.SEPARATOR);
          Long[] binIdsLong = new Long[binIds.length];
          for (int j = 0; j < binIds.length; j++) {
            binIdsLong[j] = Long.parseLong(binIds[j]);
          }

          filterAction.setData(binIdsLong);
        }

        /* Any other Action */
        else {
          filterAction.setData(data);
        }
      }

      /* Look for Action Properties */
      else {
        List<?> actionProperties = action.getChildren(Tag.ACTION_PROPERTY.get(), RSSOWL_NS);
        if (!actionProperties.isEmpty()) {
          Properties properties = new Properties();
          for (Object actionProperty : actionProperties) {
            Element actionPropertyElement = (Element) actionProperty;
            String key = actionPropertyElement.getAttributeValue(Attributes.ID.get());
            String value = actionPropertyElement.getAttributeValue(Attributes.VALUE.get());

            properties.setProperty(key, value);
          }

          filterAction.setData(properties);
        }
      }

      filter.addAction(filterAction);
    }
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

    ISearchFilter filter = fFactory.createSearchFilter(null, null, "All News");
    filter.setMatchAllNews(true);
    filter.setEnabled(true);

    IFilterAction action = fFactory.createFilterAction(MARK_READ_ID);
    filter.addAction(action);

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, new NullProgressMonitor());
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

    ISearchFilter filter = fFactory.createSearchFilter(null, null, "All News");
    filter.setMatchAllNews(true);
    filter.setEnabled(true);

    IFilterAction action = fFactory.createFilterAction(MARK_UNREAD_ID);
    filter.addAction(action);

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, new NullProgressMonitor());
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

    ISearchFilter filter = fFactory.createSearchFilter(null, null, "All News");
    filter.setMatchAllNews(true);
    filter.setEnabled(true);

    IFilterAction action = fFactory.createFilterAction(MARK_STICKY_ID);
    filter.addAction(action);

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, new NullProgressMonitor());
View Full Code Here

Examples of org.rssowl.core.persist.IFilterAction

    ISearchFilter filter = fFactory.createSearchFilter(null, null, "All News");
    filter.setMatchAllNews(true);
    filter.setEnabled(true);

    IFilterAction action = fFactory.createFilterAction(LABEL_NEWS_ID);
    action.setData(label.getId());
    filter.addAction(action);

    DynamicDAO.save(filter);

    fAppService.handleFeedReload(bm, feed, null, false, new NullProgressMonitor());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.