{
if (GlobalController.SINGLETON.checkForNewSubscription()) return;
GlobalController controller = GlobalController.SINGLETON;
MainFrame mainFrame = controller.getMainFrame();
AddSmartFeedDialog dialog = new AddSmartFeedDialog(mainFrame);
dialog.open(DataFeed.getGlobalPurgeLimit());
if (!dialog.hasBeenCanceled())
{
IFeed feed;
String title = dialog.getFeedTitle();
int purgeLimit = dialog.getFeedArticlesLimit();
int from = dialog.getDedupFrom();
int to = dialog.getDedupTo();
boolean isDedup = dialog.isDedupEnabled();
if (dialog.isQueryFeed())
{
int queryType = dialog.getFeedQueryType();
String parameter = dialog.getFeedParameter();
QueryFeed qfeed = controller.createQueryFeed(null, title, queryType, parameter, purgeLimit);
if (qfeed != null) qfeed.setDedupProperties(isDedup, from, to);
feed = qfeed;
} else
{
Query searchQuery = dialog.getFeedSearchQuery();
SearchFeed sfeed = controller.createSearchFeed(null, title, searchQuery, purgeLimit);
if (sfeed != null) sfeed.setDedupProperties(isDedup, from, to, false);
controller.updateSearchFeed(sfeed);
feed = sfeed;
}
if (feed != null)
{
feed.setType(dialog.getFeedType());
feed.setCustomViewModeEnabled(dialog.isCustomViewModeEnabled());
feed.setCustomViewMode(dialog.getViewMode());
dialog.commitAutoSaveProperties(feed);
controller.selectFeed(feed, true);
}
}
}