Package org.rssowl.core.persist.event

Examples of org.rssowl.core.persist.event.BookMarkEvent


        }

        public void entitiesUpdated(Set<BookMarkEvent> events) {
          bookMarkUpdateEventOccurred[0] = true;
          assertEquals(1, events.size());
          BookMarkEvent event = events.iterator().next();
          assertEquals(bookMark, event.getEntity());
          assertTrue("Expected this Event to be Root Event", event.isRoot());
          assertEquals(oldMarkParent, event.getOldParent());
          assertEquals(newMarkParent, event.getEntity().getParent());
        }
      };

      final boolean[] searchMarkUpdateEventOccurred = new boolean[1];
      searchMarkListener = new SearchMarkListener() {
        public void entitiesAdded(Set<SearchMarkEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesDeleted(Set<SearchMarkEvent> events) {
          fail("Unexpected event");
        }

        public void entitiesUpdated(Set<SearchMarkEvent> events) {
          searchMarkUpdateEventOccurred[0] = true;
          assertEquals(1, events.size());
          SearchMarkEvent event = events.iterator().next();
          assertEquals(searchMark, event.getEntity());
          assertTrue("Expected this Event to be Root Event", event.isRoot());
          assertEquals(oldMarkParent, event.getOldParent());
          assertEquals(newMarkParent, event.getEntity().getParent());
        }

        public void resultsChanged(Set<SearchMarkEvent> events) {
          fail("Unexpected event");
        }
View Full Code Here


      /* BookMarks got Added */
      public void entitiesAdded(Set<BookMarkEvent> events) {

        /* Reveal and Select if single Entity added */
        if (events.size() == 1) {
          final BookMarkEvent event = events.iterator().next();
          JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
            public void run() {
              expand(event.getEntity().getParent());
            }
          });
        }
      }
    };

    {
      /* SearchMark Listener */
      fSearchMarkListener = new SearchMarkListener() {

        /* SearchMarks got Updated */
        public void entitiesUpdated(final Set<SearchMarkEvent> events) {
          JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
            public void run() {
              Set<ISearchMark> updatedSearchMarks = null;
              Map<ISearchMark, IFolder> reparentedSearchMarks = null;

              /* Retrieve Updated SearchMarks */
              for (SearchMarkEvent event : events) {
                if (event.isRoot()) {

                  /* SearchMark got reparented */
                  if (event.getOldParent() != null) {
                    if (reparentedSearchMarks == null)
                      reparentedSearchMarks = new HashMap<ISearchMark, IFolder>();
                    reparentedSearchMarks.put(event.getEntity(), event.getOldParent());
                  }

                  /* Normal Update */
                  else {
                    if (updatedSearchMarks == null)
                      updatedSearchMarks = new HashSet<ISearchMark>();
                    updatedSearchMarks.add(event.getEntity());
                  }
                }
              }

              /* Event not interesting for us or we are disposed */
              if (updatedSearchMarks == null && reparentedSearchMarks == null)
                return;

              /* Ask Filter */
              if (fBookmarkFilter.needsRefresh(ISearchMark.class, events))
                fViewer.refresh(false);

              /* Ask Group */
              else if (fBookmarkGrouping.needsRefresh(ISearchMark.class))
                fViewer.refresh(false);

              /* Handle reparented SearchMarks */
              else if (reparentedSearchMarks != null) {
                Set<Entry<ISearchMark, IFolder>> entries = reparentedSearchMarks.entrySet();
                Set<IFolder> parentsToUpdate = new HashSet<IFolder>();
                try {
                  fViewer.getControl().getParent().setRedraw(false);
                  for (Entry<ISearchMark, IFolder> entry : entries) {
                    ISearchMark reparentedSearchMark = entry.getKey();
                    IFolder oldParent = entry.getValue();

                    /* Reparent while keeping the Selection */
                    ISelection selection = fViewer.getSelection();
                    fViewer.remove(oldParent, new Object[] { reparentedSearchMark });
                    fViewer.refresh(reparentedSearchMark.getParent(), false);
                    fViewer.setSelection(selection);

                    /* Remember to update parents */
                    parentsToUpdate.add(oldParent);
                    parentsToUpdate.add(reparentedSearchMark.getParent());
                  }
                } finally {
                  fViewer.getControl().getParent().setRedraw(true);
                }

                /* Update old Parents of Reparented Bookmarks */
                for (IFolder folder : parentsToUpdate)
                  updateFolderAndParents(folder);
              }

              /* Handle Updated Searchmarks */
              if (updatedSearchMarks != null)
                fViewer.update(updatedSearchMarks.toArray(), null);
            }
          });
        }

        /* SearchMarks got Deleted */
        public void entitiesDeleted(final Set<SearchMarkEvent> events) {
          JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
            public void run() {
              Set<ISearchMark> removedSearchMarks = null;

              /* Retrieve Removed SearchMarks */
              for (SearchMarkEvent event : events) {
                if (event.isRoot()) {
                  if (removedSearchMarks == null)
                    removedSearchMarks = new HashSet<ISearchMark>();
                  removedSearchMarks.add(event.getEntity());
                }
              }

              /* Event not interesting for us or we are disposed */
              if (removedSearchMarks == null || removedSearchMarks.size() == 0)
                return;

              /* Ask Filter */
              if (fBookmarkFilter.needsRefresh(ISearchMark.class, events))
                fViewer.refresh(false);

              /* Ask Group */
              else if (fBookmarkGrouping.needsRefresh(ISearchMark.class))
                fViewer.refresh(false);

              /* React normally then */
              else
                fViewer.remove(removedSearchMarks.toArray());
            }
          });
        }

        /* SearchMarks got Added */
        public void entitiesAdded(Set<SearchMarkEvent> events) {

          /* Reveal and Select if single Entity added */
          if (events.size() == 1) {
            final SearchMarkEvent event = events.iterator().next();
            JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
              public void run() {
                expand(event.getEntity().getParent());
              }
            });
          }
        }

        /* SearchMark result changed */
        public void resultsChanged(final Set<SearchMarkEvent> events) {
          JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
            public void run() {

              /* Ask Filter for a refresh */
              if (fBookmarkFilter.needsRefresh(ISearchMark.class, events))
                fViewer.refresh(false);

              /* Update SearchMarks */
              Set<ISearchMark> updatedSearchMarks = new HashSet<ISearchMark>(events.size());
              for (SearchMarkEvent event : events) {
                updatedSearchMarks.add(event.getEntity());
              }

              fViewer.update(updatedSearchMarks.toArray(), null);

              /* Update Parents */
 
View Full Code Here

      final boolean[] bookMarkAddedCalled = new boolean[] { false };
      final boolean[] bookMarkUpdatedCalled = new boolean[] { false };
      bookMarkListener = new BookMarkAdapter() {
        @Override
        public void entitiesAdded(Set<BookMarkEvent> events) {
          BookMarkEvent event = events.iterator().next();
          try {
            bookMarkAddedCalled[0] = true;
            BookMark dbBookMark = (BookMark) event.getEntity();
            initialBookMark.setId(dbBookMark.getId());
            assertTrue(initialBookMark.isIdentical(dbBookMark));
            dbBookMark.setName("Another name");
            updatedBookMark[0] = dbBookMark;
            DynamicDAO.save(dbBookMark);
          } catch (PersistenceException e) {
            fail(e.getMessage());
          }
        }

        @Override
        public void entitiesUpdated(Set<BookMarkEvent> events) {
          BookMarkEvent event = events.iterator().next();
          bookMarkUpdatedCalled[0] = true;
          BookMark dbBookMark = (BookMark) event.getEntity();
          assertTrue(updatedBookMark[0].isIdentical(dbBookMark));
        }
      };
      DynamicDAO.addEntityListener(IBookMark.class, bookMarkListener);
      DynamicDAO.save(initialBookMark);
View Full Code Here

            List<IMark> markList = Collections.singletonList(mark);
            newParent.reorderChildren(markList, newPosition, reparentInfo.isAfter().booleanValue());
          }
        }
        if (mark instanceof IBookMark)
          markEvent = new BookMarkEvent((IBookMark) mark, oldParent, true);
        else if (mark instanceof ISearchMark)
          markEvent = new SearchMarkEvent((ISearchMark) mark, oldParent, true);
        else if (mark instanceof INewsBin)
          markEvent = new NewsBinEvent((INewsBin) mark, oldParent, true);
        else
View Full Code Here

    return createSaveEventTemplate(entity);
  }

  @Override
  protected final BookMarkEvent createSaveEventTemplate(IBookMark entity) {
    return new BookMarkEvent(entity, null, true);
  }
View Full Code Here

    return createSaveEventTemplate(entity);
  }

  @Override
  protected final BookMarkEvent createSaveEventTemplate(IBookMark entity) {
    return new BookMarkEvent(entity, null, true);
  }
View Full Code Here

      /* BookMarks got Added */
      public void entitiesAdded(Set<BookMarkEvent> events) {

        /* Reveal and Select if single Entity added */
        if (events.size() == 1) {
          final BookMarkEvent event = events.iterator().next();
          JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
            public void run() {
              expand(event.getEntity().getParent());
            }
          });
        }
      }
    };

    {
      /* SearchMark Listener */
      fSearchMarkListener = new SearchMarkListener() {

        /* SearchMarks got Updated */
        public void entitiesUpdated(final Set<SearchMarkEvent> events) {
          JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
            public void run() {
              Set<ISearchMark> updatedSearchMarks = null;
              Map<ISearchMark, IFolder> reparentedSearchMarks = null;

              /* Retrieve Updated SearchMarks */
              for (SearchMarkEvent event : events) {
                if (event.isRoot()) {

                  /* SearchMark got reparented */
                  if (event.getOldParent() != null) {
                    if (reparentedSearchMarks == null)
                      reparentedSearchMarks = new HashMap<ISearchMark, IFolder>();
                    reparentedSearchMarks.put(event.getEntity(), event.getOldParent());
                  }

                  /* Normal Update */
                  else {
                    if (updatedSearchMarks == null)
                      updatedSearchMarks = new HashSet<ISearchMark>();
                    updatedSearchMarks.add(event.getEntity());
                  }
                }
              }

              /* Event not interesting for us or we are disposed */
              if (updatedSearchMarks == null && reparentedSearchMarks == null)
                return;

              /* Ask Filter */
              if (fBookmarkFilter.needsRefresh(ISearchMark.class, events))
                fViewer.refresh(false);

              /* Ask Group */
              else if (fBookmarkGrouping.needsRefresh(ISearchMark.class))
                fViewer.refresh(false);

              /* Handle reparented Folders */
              else if (reparentedSearchMarks != null) {
                Set<Entry<ISearchMark, IFolder>> entries = reparentedSearchMarks.entrySet();
                try {
                  fViewer.getControl().getParent().setRedraw(false);
                  for (Entry<ISearchMark, IFolder> entry : entries) {
                    ISearchMark reparentedSearchMark = entry.getKey();
                    IFolder oldParent = entry.getValue();

                    /* Reparent while keeping the Selection */
                    ISelection selection = fViewer.getSelection();
                    fViewer.remove(oldParent, new Object[] { reparentedSearchMark });
                    fViewer.refresh(reparentedSearchMark.getParent(), false);
                    fViewer.setSelection(selection);
                  }
                } finally {
                  fViewer.getControl().getParent().setRedraw(true);
                }
              }

              /* Handle Updated Searchmarks */
              if (updatedSearchMarks != null)
                fViewer.update(updatedSearchMarks.toArray(), null);
            }
          });
        }

        /* SearchMarks got Deleted */
        public void entitiesDeleted(final Set<SearchMarkEvent> events) {
          JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
            public void run() {
              Set<ISearchMark> removedSearchMarks = null;

              /* Retrieve Removed SearchMarks */
              for (SearchMarkEvent event : events) {
                if (event.isRoot()) {
                  if (removedSearchMarks == null)
                    removedSearchMarks = new HashSet<ISearchMark>();
                  removedSearchMarks.add(event.getEntity());
                }
              }

              /* Event not interesting for us or we are disposed */
              if (removedSearchMarks == null || removedSearchMarks.size() == 0)
                return;

              /* Ask Filter */
              if (fBookmarkFilter.needsRefresh(ISearchMark.class, events))
                fViewer.refresh(false);

              /* Ask Group */
              else if (fBookmarkGrouping.needsRefresh(ISearchMark.class))
                fViewer.refresh(false);

              /* React normally then */
              else
                fViewer.remove(removedSearchMarks.toArray());
            }
          });
        }

        /* SearchMarks got Added */
        public void entitiesAdded(Set<SearchMarkEvent> events) {

          /* Reveal and Select if single Entity added */
          if (events.size() == 1) {
            final SearchMarkEvent event = events.iterator().next();
            JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
              public void run() {
                expand(event.getEntity().getParent());
              }
            });
          }
        }

        /* SearchMark result changed */
        public void resultsChanged(final Set<SearchMarkEvent> events) {
          JobRunner.runInUIThread(fViewer.getControl(), new Runnable() {
            public void run() {

              /* Ask Filter for a refresh */
              if (fBookmarkFilter.needsRefresh(ISearchMark.class, events))
                fViewer.refresh(false);

              /* Update SearchMarks */
              Set<ISearchMark> updatedSearchMarks = new HashSet<ISearchMark>(events.size());
              for (SearchMarkEvent event : events) {
                updatedSearchMarks.add(event.getEntity());
              }

              fViewer.update(updatedSearchMarks.toArray(), null);
            }
          });
View Full Code Here

      final boolean[] bookMarkAddedCalled = new boolean[] { false };
      final boolean[] bookMarkUpdatedCalled = new boolean[] { false };
      bookMarkListener = new BookMarkAdapter() {
        @Override
        public void entitiesAdded(Set<BookMarkEvent> events) {
          BookMarkEvent event = events.iterator().next();
          try {
            bookMarkAddedCalled[0] = true;
            BookMark dbBookMark = (BookMark) event.getEntity();
            initialBookMark.setId(dbBookMark.getId());
            assertTrue(initialBookMark.isIdentical(dbBookMark));
            dbBookMark.setName("Another name");
            updatedBookMark[0] = dbBookMark;
            DynamicDAO.save(dbBookMark);
          } catch (PersistenceException e) {
            fail(e.getMessage());
          }
        }

        @Override
        public void entitiesUpdated(Set<BookMarkEvent> events) {
          BookMarkEvent event = events.iterator().next();
          bookMarkUpdatedCalled[0] = true;
          BookMark dbBookMark = (BookMark) event.getEntity();
          assertTrue(updatedBookMark[0].isIdentical(dbBookMark));
        }
      };
      DynamicDAO.addEntityListener(IBookMark.class, bookMarkListener);
      DynamicDAO.save(initialBookMark);
View Full Code Here

      IPerson person = (IPerson) entity;
      modelEvent = new PersonEvent(person, root);
    }
    else if (entity instanceof IBookMark) {
      IBookMark mark = (IBookMark) entity;
      BookMarkEvent eventTemplate = (BookMarkEvent) template;
      IFolder oldParent = eventTemplate == null ? null : eventTemplate.getOldParent();
      modelEvent = new BookMarkEvent(mark, oldParent, root);
    }
    else if (entity instanceof ISearchMark) {
      ISearchMark mark = (ISearchMark) entity;
      SearchMarkEvent eventTemplate = (SearchMarkEvent) template;
      IFolder oldParent = eventTemplate == null ? null : eventTemplate.getOldParent();
      modelEvent = new SearchMarkEvent(mark, oldParent, root);
    }
    else if (entity instanceof IFolder) {
      IFolder folder = (IFolder) entity;
      FolderEvent eventTemplate = (FolderEvent) template;
      IFolder oldParent = eventTemplate == null ? null : eventTemplate.getOldParent();
      modelEvent = new FolderEvent(folder, oldParent, root);
    }
    else if (entity instanceof ILabel) {
      ILabel label = (ILabel) entity;
      modelEvent = new LabelEvent(label, root);
View Full Code Here

            List<IMark> markList = Collections.singletonList(mark);
            newParent.reorderChildren(markList, newPosition, reparentInfo.isAfter().booleanValue());
          }
        }
        if (mark instanceof IBookMark) {
          BookMarkEvent event = new BookMarkEvent((IBookMark) mark, oldParent, true);
          bookMarkEvents.add(event);
          DBHelper.putEventTemplate(event);
        } else if (mark instanceof ISearchMark) {
          SearchMarkEvent event = new SearchMarkEvent((ISearchMark) mark, oldParent, true);
          searchMarkEvents.add(event);
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.event.BookMarkEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.