From 769bda330f3fa8160284d98fc4263b86c1bfb6f0 Mon Sep 17 00:00:00 2001 From: axelcl Date: Sun, 20 Feb 2005 17:38:21 +0000 Subject: [PATCH] misc --- .../net/sourceforge/phpeclipse/news/Channel.java | 5 +- .../sourceforge/phpeclipse/news/IconManager.java | 6 +- .../src/net/sourceforge/phpeclipse/news/Item.java | 12 ++- .../net/sourceforge/phpeclipse/news/Messages.java | 8 +- .../sourceforge/phpeclipse/news/RssListener.java | 4 +- .../phpeclipse/news/dialogs/NewChannelDialog.java | 89 ++++++++++++++++++++ .../phpeclipse/news/pref/ChannelStore.java | 4 +- .../phpeclipse/news/pref/ListEncoder.java | 2 +- .../phpeclipse/news/pref/SiteListEditor.java | 2 +- .../phpeclipse/news/view/ExplorerView.java | 34 +++++--- .../phpeclipse/news/view/HeadlineView.java | 4 +- .../news/view/NewsTreeViewerProvider.java | 4 +- 12 files changed, 138 insertions(+), 36 deletions(-) create mode 100644 archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/dialogs/NewChannelDialog.java diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Channel.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Channel.java index 8b22c55..3339e8d 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Channel.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Channel.java @@ -4,7 +4,6 @@ import java.io.InputStream; import java.io.PushbackInputStream; import java.net.URL; import java.net.URLConnection; -import java.net.UnknownHostException; import java.util.ArrayList; import java.util.HashSet; @@ -20,7 +19,7 @@ import org.xml.sax.InputSource; /** * @author jnegre - http://www.jnegre.org/ * - * (c)Copyright 2002 Jérôme Nègre + * (c)Copyright 2002 J�r�me N�gre * */ public class Channel { @@ -101,8 +100,6 @@ public class Channel { } this.readUids = null; - } catch(UnknownHostException e) { - // no connection to internet } catch(Exception e) { newErrorMessage = e.toString(); Plugin.logInfo("Error in channel update",e); diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/IconManager.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/IconManager.java index 2294108..40133e8 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/IconManager.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/IconManager.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004 Jérôme Nègre. + * Copyright (c) 2004 J�r�me N�gre. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.jnegre.org/cpl1_0.html * * Contributors: - * Jérôme Nègre - initial API and implementation + * J�r�me N�gre - initial API and implementation *******************************************************************************/ /* @@ -21,7 +21,7 @@ import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; /** - * @author Jérôme Nègre + * @author J�r�me N�gre */ public class IconManager { //the root folder containing the icons diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Item.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Item.java index bce05ec..9073b48 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Item.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Item.java @@ -18,7 +18,7 @@ import org.w3c.dom.Text; /** * @author jnegre - http://www.jnegre.org/ * - * (c)Copyright 2002 Jérôme Nègre + * (c)Copyright 2002 J�r�me N�gre * */ public class Item { @@ -45,7 +45,11 @@ public class Item { this.channel = channel; this.title = readValue("title", itemElement, 0); this.link = readValue("link", itemElement, 0); - this.description = readValue("description", itemElement, 0); + + String simpleDescription = readValue("description", itemElement, 0); + String contentEncoded = readValue("content:encoded", itemElement, 0); + this.description = contentEncoded!=null?contentEncoded:simpleDescription; + this.author = readValue("author", itemElement, 0); this.guid = readValue("guid", itemElement, 1); String pubDate = readValue("pubDate", itemElement, 0); @@ -188,7 +192,7 @@ public class Item { if(string.charAt(position) == 'Z') { calendar.set(Calendar.ZONE_OFFSET,0); if(length != position +1) { - //trop de caractères + //trop de caract�res throw new Exception("Invalid format of dc:date (extra tokens)"); } } else if(string.charAt(position) == '+' || string.charAt(position) == '-') { @@ -198,7 +202,7 @@ public class Item { int minute = readInt(string,position+4,2); calendar.set(Calendar.ZONE_OFFSET,sign*(hour*60*60*1000+minute*60*1000)); if(length != position +6) { - //trop de caractères + //trop de caract�res throw new Exception("Invalid format of dc:date (extra tokens)"); } } else { diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Messages.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Messages.java index 023315b..dd10f17 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Messages.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/Messages.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2004 Jérôme Nègre. + * Copyright (c) 2004 J�r�me N�gre. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.jnegre.org/cpl1_0.html * * Contributors: - * Jérôme Nègre - initial API and implementation + * J�r�me N�gre - initial API and implementation *******************************************************************************/ /* @@ -18,10 +18,10 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; /** - * @author Jérôme Nègre + * @author J�r�me N�gre */ public class Messages { - private static final String BUNDLE_NAME = "net.sourceforge.phpeclipse.news.messages";//$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.jnegre.allthenews.messages";//$NON-NLS-1$ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle .getBundle(BUNDLE_NAME); diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/RssListener.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/RssListener.java index 5e36f4b..bf05472 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/RssListener.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/RssListener.java @@ -1,13 +1,13 @@ /* * Created on 15 mai 2004 - * Copyright 2004 Jérôme Nègre + * Copyright 2004 J�r�me N�gre */ package net.sourceforge.phpeclipse.news; import java.util.ArrayList; /** - * @author Jérôme Nègre + * @author J�r�me N�gre */ public interface RssListener { diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/dialogs/NewChannelDialog.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/dialogs/NewChannelDialog.java new file mode 100644 index 0000000..63e36b0 --- /dev/null +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/dialogs/NewChannelDialog.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2004 J�r�me N�gre. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.jnegre.org/cpl1_0.html + * + * Contributors: + * J�r�me N�gre - initial API and implementation + *******************************************************************************/ + +/* + * Created on 19 d�c. 2004 + */ +package net.sourceforge.phpeclipse.news.dialogs; + +import java.util.ArrayList; + +import net.sourceforge.phpeclipse.news.Channel; +import net.sourceforge.phpeclipse.news.Plugin; +import net.sourceforge.phpeclipse.news.pref.ChannelStore; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +/** + * @author J�r�me N�gre + */ +public class NewChannelDialog extends Dialog { + + private Text titleText; + private Text urlText; + + /** + * @param parentShell + */ + public NewChannelDialog(Shell parentShell) { + super(parentShell); + setShellStyle(SWT.DIALOG_TRIM|SWT.RESIZE); + } + + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite)super.createDialogArea(parent); + GridLayout layout = new GridLayout(2,false); + composite.setLayout(layout); + //composite.setBackground(composite.getDisplay().getSystemColor(SWT.COLOR_CYAN)); + + Label label = new Label(composite, SWT.NONE); + label.setText("Title: "); + titleText = new Text(composite, SWT.BORDER); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + titleText.setLayoutData(gd); + + label = new Label(composite, SWT.NONE); + label.setText("Url: "); + urlText = new Text(composite, SWT.BORDER); + gd = new GridData(GridData.FILL_HORIZONTAL); + urlText.setLayoutData(gd); + + return composite; + } + + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText("Add New Channel"); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() { + Channel channel = new Channel(titleText.getText(), urlText.getText()); + ArrayList channels = Plugin.getDefault().getChannelList(); + ChannelStore.saveReadStatus(channels); + channels.add(channel); + ChannelStore.setChannels(channels); + Plugin.getDefault().updateChannelList(); + Plugin.getDefault().update(); + this.close(); + } + +} diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/ChannelStore.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/ChannelStore.java index f48c494..6f8a0a1 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/ChannelStore.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/ChannelStore.java @@ -1,6 +1,6 @@ /* * Created on 9 juin 2004 - * Copyright 2004 Jérôme Nègre + * Copyright 2004 J�r�me N�gre */ package net.sourceforge.phpeclipse.news.pref; @@ -18,7 +18,7 @@ import net.sourceforge.phpeclipse.news.Plugin; import org.eclipse.jface.dialogs.IDialogSettings; /** - * @author Jérôme Nègre + * @author J�r�me N�gre */ public class ChannelStore { diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/ListEncoder.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/ListEncoder.java index a83e409..24bde24 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/ListEncoder.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/ListEncoder.java @@ -1,6 +1,6 @@ /* * Created on 14 juil. 2003 - * (c)2003 Jérôme Nègre - http://www.jnegre.org/ + * (c)2003 J�r�me N�gre - http://www.jnegre.org/ * */ package net.sourceforge.phpeclipse.news.pref; diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/SiteListEditor.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/SiteListEditor.java index afcd485..085108d 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/SiteListEditor.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/pref/SiteListEditor.java @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Jérôme Nègre - adaptation of ListEditor to add the search button + * J�r�me N�gre - adaptation of ListEditor to add the search button *******************************************************************************/ package net.sourceforge.phpeclipse.news.pref; diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/ExplorerView.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/ExplorerView.java index e1faf8d..f427565 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/ExplorerView.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/ExplorerView.java @@ -1,6 +1,6 @@ /* * Created on 15 mai 2004 - * Copyright 2004 Jérôme Nègre + * Copyright 2004 J�r�me N�gre */ package net.sourceforge.phpeclipse.news.view; @@ -11,9 +11,11 @@ import net.sourceforge.phpeclipse.news.IconManager; import net.sourceforge.phpeclipse.news.Item; import net.sourceforge.phpeclipse.news.Plugin; import net.sourceforge.phpeclipse.news.RssListener; +import net.sourceforge.phpeclipse.news.dialogs.NewChannelDialog; import net.sourceforge.phpeclipse.webbrowser.views.BrowserView; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; @@ -26,7 +28,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.part.ViewPart; /** - * @author Jérôme Nègre + * @author J�r�me N�gre */ public class ExplorerView extends ViewPart implements RssListener { @@ -36,6 +38,8 @@ public class ExplorerView extends ViewPart implements RssListener { private Action refreshAction; + private Action newChannelAction; + public ExplorerView() { super(); } @@ -107,11 +111,19 @@ public class ExplorerView extends ViewPart implements RssListener { } }; refreshAction.setToolTipText("Refresh"); + + // newChannel + newChannelAction = new Action("Add New Channel") { + public void run() { + NewChannelDialog ncd = new NewChannelDialog(ExplorerView.this.getViewSite().getShell()); + ncd.open(); + } + }; } private void createMenu() { - //IMenuManager mgr = getViewSite().getActionBars().getMenuManager(); - //mgr.add(clearAction); + IMenuManager mgr = getViewSite().getActionBars().getMenuManager(); + mgr.add(newChannelAction); } private void createToolBar() { @@ -138,13 +150,13 @@ public class ExplorerView extends ViewPart implements RssListener { // } public void onItemSelected(Item item) { if (item != null) { // && uiReady && linkAction.isChecked()) { - // if(showDescritionAction.isChecked()) { - // String desc = item.getDescription(); - // if(desc == null) - // desc = HTML_NO_DESCRIPTION; - // browser.setText(MessageFormat.format(HTML,new String[]{desc, encodeNewLine(desc), item.getUsableLink(), - // item.getUsableTitle()})); - // } else { + // if(showDescritionAction.isChecked()) { + // String desc = item.getDescription(); + // if(desc == null) + // desc = HTML_NO_DESCRIPTION; + // browser.setText(MessageFormat.format(HTML,new String[]{desc, encodeNewLine(desc), item.getUsableLink(), + // item.getUsableTitle()})); + // } else { setUrl(item.getUsableLink()); // } //XXX this is a hack, should be done otherwise diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/HeadlineView.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/HeadlineView.java index e87ef3e..bcd30cd 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/HeadlineView.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/HeadlineView.java @@ -1,6 +1,6 @@ /* * Created on 15 mai 2004 - * Copyright 2004 Jérôme Nègre + * Copyright 2004 J�r�me N�gre */ package net.sourceforge.phpeclipse.news.view; @@ -23,7 +23,7 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.part.ViewPart; /** - * @author Jérôme Nègre + * @author J�r�me N�gre */ public class HeadlineView extends ViewPart implements RssListener { diff --git a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/NewsTreeViewerProvider.java b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/NewsTreeViewerProvider.java index 8b225b3..70a833e 100644 --- a/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/NewsTreeViewerProvider.java +++ b/archive/net.sourceforge.phpeclipse.news/src/net/sourceforge/phpeclipse/news/view/NewsTreeViewerProvider.java @@ -1,6 +1,6 @@ /* * Created on 16 mai 2004 - * Copyright 2004 Jérôme Nègre + * Copyright 2004 J�r�me N�gre */ package net.sourceforge.phpeclipse.news.view; @@ -16,7 +16,7 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.graphics.Image; /** - * @author Jérôme Nègre + * @author J�r�me N�gre */ public class NewsTreeViewerProvider implements -- 1.7.1