View Javadoc

1   package org.robsite.extension.rss;
2   
3   import java.util.ArrayList;
4   
5   import oracle.ide.addin.AbstractCommand;
6   import oracle.ide.addin.Command;
7   
8   import org.robsite.extension.rss.model.Channel;
9   import org.robsite.extension.rss.model.Item;
10  
11  /***
12   * Command that marks one or more messages as read.
13   * 
14   * @author brian_duff@sourceforge.net
15   * @version $Revision: 1.1.1.1 $
16   */
17  public final class MarkAsReadCommand extends AbstractCommand
18  {
19    public MarkAsReadCommand()
20    {
21      super( Commands.id( Commands.MARK_AS_READ ), Command.NO_CHANGE );
22    }
23    
24    /***
25     * Actually invoke the command.
26     * 
27     * @return OK
28     */
29    public int doit()
30    {
31      Item[] items = (Item[]) getContext().getSelection();
32      NewsDockableWindow window = (NewsDockableWindow) getContext().getView();
33      Channel channel = window.getPanel().getSelectedChannel();
34      
35      ArrayList changedItems = new ArrayList();
36      
37      for ( int i=0; i < items.length; i++ )
38      {
39        if ( !items[i].isRead() )
40        {
41          items[i].setRead( true );
42          changedItems.add( items[i] );
43        }
44      }
45      
46      channel.fireItemsChanged( changedItems );
47      // Make sure the "read messages" count in the channel view is updated...
48      window.getPanel().getChannels().fireChannelUpdated( channel );
49      
50      return OK;
51    }
52    
53  }