X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FBlogReader.java;h=9d68af170191e08bd3236ea66ad410b3be22f7ad;hb=90ae01c1c1504e0ae42817f78116f1d35b317c47;hp=25b5ea3caa816e819fc913ef9aefe492d303774c;hpb=87ea83af3e209a8c3a4b19f9530a9c05b4541148;p=jalview.git
diff --git a/src/jalview/gui/BlogReader.java b/src/jalview/gui/BlogReader.java
index 25b5ea3..9d68af1 100644
--- a/src/jalview/gui/BlogReader.java
+++ b/src/jalview/gui/BlogReader.java
@@ -1,19 +1,22 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
- * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.gui;
@@ -22,10 +25,10 @@ import jalview.util.MessageManager;
import java.awt.BorderLayout;
import java.awt.Component;
+import java.awt.Dialog.ModalExclusionType;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
-import java.awt.Dialog.ModalExclusionType;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
@@ -38,6 +41,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
+import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -195,7 +199,7 @@ public class BlogReader extends JPanel
{
if (parent != null)
{
- Cache.log.info("News window closed.");
+ Cache.log.debug("News window closed.");
jd = null;
parent.showNews(false);
}
@@ -243,16 +247,17 @@ public class BlogReader extends JPanel
public BlogReader(Desktop desktop)
{
- Cache.log.info("Constructing news reader.");
+ Cache.log.debug("Constructing news reader.");
parent = desktop;
_channelModel = new ChannelListModel();
// Construct our jalview news channel
Channel chan = new Channel();
- chan.setURL(jalview.bin.Cache.getDefault(
- "JALVIEW_NEWS_RSS",
- jalview.bin.Cache.getDefault("www.jalview.org",
- "http://www.jalview.org") + "/feeds/desktop/rss"));
+ chan.setURL(
+ jalview.bin.Cache.getDefault("JALVIEW_NEWS_RSS",
+ jalview.bin.Cache.getDefault("www.jalview.org",
+ "http://www.jalview.org")
+ + "/feeds/desktop/rss"));
loadLastM();
_channelModel.addChannel(chan);
updating = true;
@@ -272,16 +277,17 @@ public class BlogReader extends JPanel
if (setvisible)
{
- Cache.log.info("Will show jalview news automatically");
+ Cache.log.debug("Will show jalview news automatically");
showNews();
}
- Cache.log.info("Completed construction of reader.");
+ Cache.log.debug("Completed construction of reader.");
}
/**
* check if the news panel's container is visible
*/
+ @Override
public boolean isVisible()
{
if (parent == null)
@@ -309,14 +315,16 @@ public class BlogReader extends JPanel
xf.setContentPane(me);
xf.addWindowListener(new WindowAdapter()
{
+ @Override
public void windowClosing(WindowEvent e)
{
ActionEvent actionEvent = new ActionEvent(this,
- ActionEvent.ACTION_FIRST, (String) exitAction
- .getValue(Action.NAME));
+ ActionEvent.ACTION_FIRST,
+ (String) exitAction.getValue(Action.NAME));
exitAction.actionPerformed(actionEvent);
}
+ @Override
public void windowOpened(WindowEvent e)
{
}
@@ -328,10 +336,11 @@ public class BlogReader extends JPanel
{
createDialog();
bounds = new Rectangle(5, 5, 550, 350);
- jd.initDialogFrame(me, false, false, "News from www.jalview.org",
+ jd.initDialogFrame(me, false, false,
+ MessageManager.getString("label.news_from_jalview"),
bounds.width, bounds.height);
jd.frame.setModalExclusionType(ModalExclusionType.NO_EXCLUDE);
- Cache.log.info("Displaying news.");
+ Cache.log.debug("Displaying news.");
jd.waitForInput();
}
}
@@ -351,8 +360,8 @@ public class BlogReader extends JPanel
java.util.Date earliest = null;
try
{
- earliest = new SimpleDateFormat("YYYY-MM-DD").parse(chan
- .getHTTPLastModified());
+ earliest = new SimpleDateFormat("YYYY-MM-DD")
+ .parse(chan.getHTTPLastModified());
} catch (Exception x)
{
}
@@ -363,9 +372,9 @@ public class BlogReader extends JPanel
+ " and lastDate is " + lastDate);
for (Item i : (List- ) chan.getItems())
{
+ Date published = i.getPublishDate();
boolean isread = lastDate == null ? false
- : (i.getPublishDate() != null && !lastDate.before(i
- .getPublishDate()));
+ : (published != null && !lastDate.before(published));
if (!updating || updateItems)
{
@@ -375,11 +384,11 @@ public class BlogReader extends JPanel
{
i.setRead(isread);
}
- if (i.getPublishDate() != null && !i.isRead())
+ if (published != null && !i.isRead())
{
- if (earliest == null || earliest.after(i.getPublishDate()))
+ if (earliest == null || earliest.after(published))
{
- earliest = i.getPublishDate();
+ earliest = published;
}
}
}
@@ -416,11 +425,9 @@ public class BlogReader extends JPanel
}
if (lastDate != null)
{
- jalview.bin.Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED",
- lastDate);
- jalview.bin.Cache.log.info("Saved last read date as "
- + jalview.bin.Cache.date_format.format(lastDate));
-
+ String formatted = Cache
+ .setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED", lastDate);
+ Cache.log.debug("Saved last read date as " + formatted);
}
}
}
@@ -437,7 +444,9 @@ public class BlogReader extends JPanel
topBottomSplitPane.setBottomComponent(bottomPanel);
JScrollPane spTextDescription = new JScrollPane(textDescription);
textDescription.setText("");
- statusBar.setText(MessageManager.getString("label.status"));
+ statusBar.setText(new StringBuffer("[")
+ .append(MessageManager.getString("label.status")).append("]")
+ .toString());
buttonRefresh.addActionListener(new ActionListener()
{
@@ -466,6 +475,7 @@ public class BlogReader extends JPanel
listItems.addMouseListener(new java.awt.event.MouseAdapter()
{
+ @Override
public void mouseClicked(MouseEvent e)
{
listItems_mouseClicked(e);
@@ -491,6 +501,7 @@ public class BlogReader extends JPanel
}
textDescription.addHyperlinkListener(new HyperlinkListener()
{
+ @Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
@@ -502,6 +513,7 @@ public class BlogReader extends JPanel
listItems.addListSelectionListener(new ListSelectionListener()
{
+ @Override
public void valueChanged(ListSelectionEvent e)
{
if (e.getValueIsAdjusting() == false)
@@ -518,8 +530,8 @@ public class BlogReader extends JPanel
_itemsValueChanged(listItems);
}
- public class LaunchJvBrowserOnItem extends AbstractAction implements
- UpdatableAction
+ public class LaunchJvBrowserOnItem extends AbstractAction
+ implements UpdatableAction
{
JList _listItems = null;
@@ -531,6 +543,7 @@ public class BlogReader extends JPanel
_listItems = listItems;
}
+ @Override
public void actionPerformed(ActionEvent e)
{
Object o = _listItems.getSelectedValue();
@@ -544,6 +557,7 @@ public class BlogReader extends JPanel
}
}
+ @Override
public void update(Object o)
{
setEnabled(true);
@@ -572,7 +586,8 @@ public class BlogReader extends JPanel
private JPopupMenu _buildChannelsPopupMenu()
{
JPopupMenu popup = new JPopupMenu();
- popup.add(new JMenuItem(new MarkChannelAsRead(listChannels, listItems)));
+ popup.add(
+ new JMenuItem(new MarkChannelAsRead(listChannels, listItems)));
popup.add(new JMenuItem(
new MarkChannelAsUnread(listChannels, listItems)));
return popup;
@@ -596,8 +611,9 @@ public class BlogReader extends JPanel
}
DefaultListModel itemsModel = (DefaultListModel) listItems.getModel();
itemsModel.clear();
- Iterator iter = (channel.getItems() != null) ? channel.getItems()
- .iterator() : Collections.EMPTY_LIST.iterator();
+ Iterator iter = (channel.getItems() != null)
+ ? channel.getItems().iterator()
+ : Collections.EMPTY_LIST.iterator();
while (iter.hasNext())
{
itemsModel.addElement(iter.next());
@@ -693,8 +709,8 @@ public class BlogReader extends JPanel
button.setVerticalTextPosition(AbstractButton.BOTTOM);
button.setHorizontalTextPosition(AbstractButton.CENTER);
}
- else if (Boolean.toString(true).equals(
- general.get("radioTextRight")))
+ else if (Boolean.toString(true)
+ .equals(general.get("radioTextRight")))
{
button.setVerticalTextPosition(AbstractButton.CENTER);
button.setHorizontalTextPosition(AbstractButton.RIGHT);
@@ -743,28 +759,27 @@ public class BlogReader extends JPanel
jalview.bin.Cache.loadProperties(null);
jalview.bin.Cache.initLogger();
// test will advance read date each time
- Calendar today = Calendar.getInstance(), lastread = Calendar
- .getInstance();
+ Calendar today = Calendar.getInstance(),
+ lastread = Calendar.getInstance();
lastread.set(1983, 01, 01);
while (lastread.before(today))
{
- Cache.setDateProperty("JALVIEW_NEWS_RSS_LASTMODIFIED",
- lastread.getTime());
+ String formattedDate = Cache.setDateProperty(
+ "JALVIEW_NEWS_RSS_LASTMODIFIED", lastread.getTime());
BlogReader me = new BlogReader();
- System.out.println("Set last date to "
- + jalview.bin.Cache.date_format.format(lastread.getTime()));
+ System.out.println("Set last date to " + formattedDate);
if (me.isNewsNew())
{
- Cache.log.info("There is news to read.");
+ Cache.log.debug("There is news to read.");
}
else
{
- Cache.log.info("There is no new news.");
+ Cache.log.debug("There is no new news.");
me.xf.setTitle("Testing : Last read is " + me.lastDate);
me.showNews();
me.xf.toFront();
}
- Cache.log.info("Waiting for closure.");
+ Cache.log.debug("Waiting for closure.");
do
{
try
@@ -778,11 +793,11 @@ public class BlogReader extends JPanel
if (me.isNewsNew())
{
- Cache.log.info("Still new news after reader displayed.");
+ Cache.log.debug("Still new news after reader displayed.");
}
if (lastread.getTime().before(me.lastDate))
{
- Cache.log.info("The news was read.");
+ Cache.log.debug("The news was read.");
lastread.setTime(me.lastDate);
}
else
@@ -804,6 +819,7 @@ class ChannelsRenderer extends DefaultListCellRenderer
private final static Icon _icon = new ImageIcon(
Main.class.getResource("image/ComposeMail16.gif"));
+ @Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus)
{
@@ -813,7 +829,10 @@ class ChannelsRenderer extends DefaultListCellRenderer
if (value instanceof Channel)
{
Channel channel = (Channel) value;
- component.setText(MessageManager.formatMessage("label.channel_title_item_count", new String[]{channel.getTitle(),Integer.valueOf(channel.getUnreadItemCount()).toString()}));
+ component.setText(MessageManager
+ .formatMessage("label.channel_title_item_count", new String[]
+ { channel.getTitle(), Integer
+ .valueOf(channel.getUnreadItemCount()).toString() }));
component.setToolTipText(channel.getURL());
}
return component;
@@ -825,6 +844,7 @@ class ItemsRenderer extends DefaultListCellRenderer
private final static Icon _icon = new ImageIcon(
Main.class.getResource("image/ComposeMail16.gif"));
+ @Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus)
{
@@ -836,7 +856,13 @@ class ItemsRenderer extends DefaultListCellRenderer
Item item = (Item) value;
if (item.getPublishDate() != null)
{
- component.setText(MessageManager.formatMessage("label.blog_item_published_on_date", new String[]{DateFormat.getDateInstance().format(item.getPublishDate()).toString(),item.getTitle()}));
+ component.setText(MessageManager.formatMessage(
+ "label.blog_item_published_on_date", new String[]
+ { DateFormat
+ .getDateInstance(DateFormat.LONG,
+ MessageManager.getLocale())
+ .format(item.getPublishDate()).toString(),
+ item.getTitle() }));
}
component.setToolTipText(item.getLink());
if (!item.isRead())