}
});
}
private void onCreateSavedSearch(boolean withQuickSearch) {
IModelFactory factory = Owl.getModelFactory();
List<ISearchCondition> conditions = new ArrayList<ISearchCondition>(2);
/* Create Condition from Location */
List<IFolderChild> searchScope = new ArrayList<IFolderChild>(1);
searchScope.add(((FeedViewInput) fFeedView.getEditorInput()).getMark());
ISearchField field = factory.createSearchField(INews.LOCATION, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.SCOPE, ModelUtils.toPrimitive(searchScope)));
/* Create Condition from Filter */
Type filterType = fFeedView.getFilter().getType();
switch (filterType) {
case SHOW_ALL:
if (!withQuickSearch) {
field = factory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, "")); //$NON-NLS-1$
}
break;
case SHOW_NEW:
field = factory.createSearchField(INews.STATE, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, EnumSet.of(INews.State.NEW)));
break;
case SHOW_RECENT:
field = factory.createSearchField(INews.AGE_IN_DAYS, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS_LESS_THAN, 2));
break;
case SHOW_LAST_5_DAYS:
field = factory.createSearchField(INews.AGE_IN_DAYS, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS_LESS_THAN, 6));
break;
case SHOW_STICKY:
field = factory.createSearchField(INews.IS_FLAGGED, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, true));
break;
case SHOW_LABELED:
field = factory.createSearchField(INews.LABEL, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, "*")); //$NON-NLS-1$
break;
case SHOW_UNREAD:
field = factory.createSearchField(INews.STATE, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, EnumSet.of(INews.State.NEW, INews.State.UNREAD, INews.State.UPDATED)));
break;
}
/* Also add Quick Search if required */
if (withQuickSearch) {
SearchTarget target = fFeedView.getFilter().getSearchTarget();
String text = fSearchInput.getText();
/* Convert to Wildcard Query */
if (StringUtils.supportsTrailingWildcards(text))
text = text + "*"; //$NON-NLS-1$
switch (target) {
case ALL:
field = factory.createSearchField(IEntity.ALL_FIELDS, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, text));
break;
case HEADLINE:
field = factory.createSearchField(INews.TITLE, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, text));
break;
case ATTACHMENTS:
field = factory.createSearchField(INews.ATTACHMENTS_CONTENT, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, text));
break;
case AUTHOR:
field = factory.createSearchField(INews.AUTHOR, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.CONTAINS_ALL, text));
break;
case CATEGORY:
field = factory.createSearchField(INews.CATEGORIES, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, text));
break;
case LABELS:
field = factory.createSearchField(INews.LABEL, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, text));
break;
case SOURCE:
field = factory.createSearchField(INews.SOURCE, INews.class.getName());
conditions.add(factory.createSearchCondition(field, SearchSpecifier.IS, text));
break;
}
}
/* Create and Show SM Dialog */