package es.java.otro.command;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.browser.IWebBrowser;
import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
import org.eclipse.ui.handlers.HandlerUtil;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
import es.java.otro.model.Entry;
import es.java.otro.model.Feed;
import es.java.otro.model.Root;
import es.java.otro.util.RssUtil;
import es.java.otro.view.UrlDialog;
public class NewFeedHandler extends AbstractHandler implements IHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
IWorkbenchBrowserSupport support =
PlatformUI.getWorkbench().getBrowserSupport();
IWebBrowser browser = support.createBrowser("otro.browser");
// browser.openURL(new URL("http://www.eclipse.org"));
UrlDialog url = new UrlDialog(HandlerUtil.getActiveShell(event));
url.open();
String feedUrl = url.getUrl();
Feed f = RssUtil.createFeed(feedUrl);
Root.getInstance().addFeed(f);
} catch ( Exception e) {
e.printStackTrace();
}
return null;
}
}