Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.ILabel


    DynamicDAO.save(feed);

    assertNotNull(news.getDescription());

    ILabel label = fFactory.createLabel(null, "Label");
    DynamicDAO.save(label);

    news.addLabel(label);
    DynamicDAO.save(news);
View Full Code Here


        INews news = (INews) object;
        Set<ILabel> labels = CoreUtils.getSortedLabels(news);
        EntityGroup group = gDefault;

        if (!labels.isEmpty()) {
          ILabel label = labels.iterator().next();
          String name = label.getName();
          group = groupCache.get(name);
          if (group == null) {
            group = new EntityGroup(nextId++, GROUP_CATEGORY_ID, name, label.getOrder(), OwlUI.getRGB(label));
            groupCache.put(name, group);
          }
        }

        new EntityGroupItem(group, news);
View Full Code Here

    for (TreeItem item : items) {
      sortedLabels.add((ILabel) item.getData());
    }

    IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
    ILabel selectedLabel = (ILabel) selection.getFirstElement();
    int selectedLabelOrder = selectedLabel.getOrder();
    ILabel otherLabel = null;
    int index = sortedLabels.indexOf(selectedLabel);

    /* Move Up */
    if (up && index > 0) {
      otherLabel = sortedLabels.get(index - 1);
      selectedLabel.setOrder(otherLabel.getOrder());
      otherLabel.setOrder(selectedLabelOrder);
    }

    /* Move Down */
    else if (!up && index < sortedLabels.size() - 1) {
      otherLabel = sortedLabels.get(index + 1);
      selectedLabel.setOrder(otherLabel.getOrder());
      otherLabel.setOrder(selectedLabelOrder);
    }

    DynamicDAO.getDAO(ILabelDAO.class).saveAll(Arrays.asList(new ILabel[] { selectedLabel, otherLabel }));
    fViewer.refresh();
    fViewer.getTree().showSelection();
View Full Code Here

    LabelDialog dialog = new LabelDialog(getShell(), DialogMode.ADD, null);
    if (dialog.open() == IDialogConstants.OK_ID) {
      String name = dialog.getName();
      RGB color = dialog.getColor();

      ILabel newLabel = Owl.getModelFactory().createLabel(null, name);
      newLabel.setColor(OwlUI.toString(color));
      newLabel.setOrder(fViewer.getTree().getItemCount());
      DynamicDAO.save(newLabel);

      fViewer.refresh();
      fViewer.setSelection(new StructuredSelection(newLabel));
    }
View Full Code Here

  }

  private void onEdit() {
    IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection();
    if (!selection.isEmpty()) {
      ILabel label = (ILabel) selection.getFirstElement();
      LabelDialog dialog = new LabelDialog(getShell(), DialogMode.EDIT, label);
      if (dialog.open() == IDialogConstants.OK_ID) {
        boolean changed = false;
        String name = dialog.getName();
        RGB color = dialog.getColor();

        if (!label.getName().equals(name)) {
          label.setName(name);
          changed = true;
        }

        String colorStr = OwlUI.toString(color);
        if (!label.getColor().equals(colorStr)) {
          label.setColor(colorStr);
          changed = true;
        }

        /* Save Label */
        if (changed) {
View Full Code Here

    List<ILabel> labelsToSave = new ArrayList<ILabel>();

    TreeItem[] items = fViewer.getTree().getItems();
    for (int i = 0; i < items.length; i++) {
      TreeItem item = items[i];
      ILabel label = (ILabel) item.getData();
      label.setOrder(i);

      labelsToSave.add(label);
    }

    DynamicDAO.saveAll(labelsToSave);
View Full Code Here

    final RGB listBackground = fViewer.getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB();
    final RGB listSelectionBackground = fViewer.getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB();
    fViewer.setLabelProvider(new CellLabelProvider() {
      @Override
      public void update(ViewerCell cell) {
        ILabel label = (ILabel) cell.getElement();

        /* Text */
        cell.setText(label.getName());

        /* Color */
        if (!OwlUI.isHighContrast()) {
          RGB labelRGB = OwlUI.getRGB(label);
          if (!listBackground.equals(labelRGB) && !listSelectionBackground.equals(labelRGB))
View Full Code Here

  public void setUp() throws Exception {
    Owl.getPersistenceService().recreateSchema();
    fPluginLocation = FileLocator.toFileURL(Platform.getBundle("org.rssowl.core.tests").getEntry("/")).toURI();

    /* Label */
    ILabel label1 = fFactory.createLabel(null, "Label 0");
    ILabel label2 = fFactory.createLabel(null, "Label 1");
    label2.setColor("255,0,0");
    DynamicDAO.save(label1);
    DynamicDAO.save(label2);

    /* Feeds and News */
    List<IFeed> feeds = saveFeeds();
View Full Code Here

      }
    }

    assertNotNull(filter);

    ILabel label = null;
    for (IEntity element : elements) {
      if (element instanceof ILabel && "RSSOwl".equals(((ILabel) element).getName())) {
        label = (ILabel) element;
      }
    }

    assertNotNull(label);

    List<IFilterAction> actions = filter.getActions();
    assertEquals(2, actions.size());
    for (IFilterAction action : actions) {
      if (MoveNewsAction.ID.equals(action.getActionId())) {
        Object data = action.getData();
        assertTrue(data instanceof Long[]);
        assertEquals(binB.getId().longValue(), ((Long[]) data)[0].longValue());
      } else if (LabelNewsAction.ID.equals(action.getActionId())) {
        Object data = action.getData();
        assertEquals(label.getId().longValue(), ((Long) data).longValue());
      } else
        fail();
    }
  }
View Full Code Here

    assertEquals(5, count(Label.class.getName(), elements));

    ImportUtils.doImport(null, elements, false);

    for (IEntity entity : elements) {
      ILabel label = (ILabel) entity;
      if ("Later".equals(label.getName()))
        assertEquals(0, label.getOrder());
      else if ("Personal".equals(label.getName()))
        assertEquals(1, label.getOrder());
      else if ("Important".equals(label.getName()))
        assertEquals(2, label.getOrder());
      else if ("Work".equals(label.getName()))
        assertEquals(3, label.getOrder());
      else if ("To Do".equals(label.getName()))
        assertEquals(4, label.getOrder());
    }
  }
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.ILabel

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.