예제 #1
0
 /**
  * gets the parent folder of the selected item in the tree.
  *
  * @return Folder
  * @throws NoItemSelectedException if no item in the tree is selected, of if the selected item has
  *     no parent (Subcribed Feeds folder, outbox or trash)
  */
 public Folder getParentOfSelected() throws NoItemSelectedException {
   if (treeViewer.getSelection() instanceof IStructuredSelection) {
     IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
     Object o = selection.getFirstElement();
     // if the item selected in the tree is a folder, then traverses the tree to find its parent
     // folder
     // throws an exception if the item is a root item
     if (o instanceof Folder) {
       Folder f = (Folder) o;
       try {
         if (f.getId() != control.getSubscribedFeeds().getId())
           return (Folder) treeViewer.getTree().getSelection()[0].getParentItem().getData();
         else throw new NoItemSelectedException("Top level folder has no parent");
       } catch (ControlException e) {
         throw new NoItemSelectedException("No Item Selected");
       }
     }
     // if the item selected in the tree is a feed, then traverses the tree to
     // find its parent, but throws an exception if its a top-level item(outbox or trash).
     if (o instanceof Feed) {
       Feed f = (Feed) o;
       try {
         if (f.getId() != control.getTrash().getId() && f.getId() != control.getOutbox().getId())
           return (Folder) treeViewer.getTree().getSelection()[0].getParentItem().getData();
         else throw new NoItemSelectedException("Top level feed has no parent");
       } catch (ControlException e) {
         throw new NoItemSelectedException("No Item Selected");
       }
     }
   }
   throw new NoItemSelectedException("No Item Selected");
 }
예제 #2
0
 /** Updates the view of the trash in the tree */
 public void updateTrash() {
   treeViewer.refresh(((TreeItem) treeViewer.getTree().getItem(2)).getData());
   try {
     Feed trash = control.getTrash();
     if (mostRecentFeed != null && mostRecentFeed.getId() == trash.getId()) {
       updateArticles(trash);
     }
   } catch (ControlException e) {
   }
 }
예제 #3
0
 /**
  * Gets the currently selected folder in the view. If no folder is selected, gets the folder that
  * is the parent of the first selected item. If nothing is selected, then throws an exception.
  *
  * @return Folder selected folder.
  * @throws NoItemSelectedException If no folder is currently selected.
  */
 public Folder getSelectedFolder() throws NoItemSelectedException {
   if (treeViewer.getSelection() instanceof IStructuredSelection) {
     // System.out.println("selected item is istructuredselection");
     IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
     Object o = selection.getFirstElement();
     if (o instanceof Folder) {
       // if selection is a folder, just return it
       Folder f = (Folder) o;
       return f;
     }
     if (o instanceof Feed) {
       Feed f = (Feed) o;
       // if its a feed thats not the trash/outbox, then return its parent
       try {
         if (f.getId() != control.getTrash().getId()
             && f.getId() != control.getOutbox().getId()) // FOLDER MAGIC
         return (Folder) treeViewer.getTree().getSelection()[0].getParentItem().getData();
       } catch (ControlException e) {
       }
     }
   }
   throw new NoItemSelectedException("No Folder Selected");
 }