Examples of Favorite


Examples of com.adito.navigation.Favorite

       
        assertEquals("There should be no favorites", 0, SystemDatabaseFactory.getInstance().getFavorites(resource.getResourceType().getResourceTypeId(), user).size());
        SystemDatabaseFactory.getInstance().addFavorite(resource.getResourceType().getResourceTypeId(), resource.getResourceId(), user.getPrincipalName());
        assertEquals("There should now be one favorites", 1, SystemDatabaseFactory.getInstance().getFavorites(resource.getResourceType().getResourceTypeId(), user).size());
       
        Favorite favorite = SystemDatabaseFactory.getInstance().getFavorite(resource.getResourceType().getResourceTypeId(), user, resource.getResourceId());
        assertEquals("The favorite and resource id should match.", resource.getResourceId(), favorite.getFavoriteKey());
        assertEquals("The favorite username should match the users principle name.", user.getPrincipalName(), favorite.getUsername());
        assertEquals("The favorite type id and resource type id should match.", resource.getResourceType().getResourceTypeId(), favorite.getType());
       
        SystemDatabaseFactory.getInstance().removeFavorite(resource.getResourceType().getResourceTypeId(), resource.getResourceId(), user.getPrincipalName());
        assertEquals("There should be no favorites", 0, SystemDatabaseFactory.getInstance().getFavorites(resource.getResourceType().getResourceTypeId(), user).size());
       
        getPolicyService().revokePolicyFromPrincipal(policy, user);
View Full Code Here

Examples of com.adito.navigation.Favorite

        // form, this may then be used to determine if an item is a favorite
        List<Integer> l = new ArrayList<Integer>();
        List<Favorite> favorites = SystemDatabaseFactory.getInstance().getFavorites(getResourceType().getResourceTypeId(),
            getSessionInfo(request).getUser());
        for (Iterator i = favorites.iterator(); i.hasNext();) {
            Favorite f = (Favorite) i.next();
            l.add(new Integer(f.getFavoriteKey()));
        }
        ((AbstractResourcesForm) form).setUserFavorites(l);
        ((AbstractResourcesForm) form).setGlobalFavorites(ResourceUtil.filterResourceIdsForGlobalFavorites(PolicyDatabaseFactory.getInstance()
            .getGrantedResourcesOfType(getSessionInfo(request).getUser(), getResourceType()), getResourceType()));
        return super.unspecified(mapping, form, request, response);
View Full Code Here

Examples of com.adito.navigation.Favorite

                if (rt instanceof FavoriteResourceType) {
                    FavoriteResourceType frt = (FavoriteResourceType) rt;
                    try {
                        List fl = SystemDatabaseFactory.getInstance().getFavorites(frt.getResourceTypeId(), user);
                        for (Iterator j = fl.iterator(); j.hasNext();) {
                            Favorite f = (Favorite) j.next();
                            try {
                                WrappedFavoriteItem wfi = frt.createWrappedFavoriteItem(f.getFavoriteKey(), request,
                                                AbstractFavoriteItem.USER_FAVORITE);
                                if (wfi == null) {
                                    SystemDatabaseFactory.getInstance().removeFavorite(f.getType(), f.getFavoriteKey(),
                                                    f.getUsername());
                                }
                                try {
                                    ResourceUtil.checkResourceAccessRights(wfi.getFavoriteItem().getResource(), info);
                                    getModel().addItem(wfi);
                                } catch (NoPermissionException npe) {
                                    // Skip
                                }
                            } catch (Exception e) {
                                log.error("Failed to add user favorite " + f.getFavoriteKey() + ".", e);
                            }
                        }
                    } catch (Exception e) {
                        log.error("Failed to create user favorites for resource type " + frt.getResourceTypeId());
                    }
View Full Code Here

Examples of com.cxy.redisclient.domain.Favorite

  public void testListById() throws IOException {
    FavoriteService service = new FavoriteService();
    int fid = service.add(1,"key", "local 2.6.12:db0:key:");

    Favorite favorite = service.listById(fid);
    assertTrue(favorite.getFavorite().equals("local 2.6.12:db0:key:"));
  }
View Full Code Here

Examples of com.cxy.redisclient.domain.Favorite

    }
  }

  public Favorite listById(int fid) {
    try {
      Favorite favorite = null;
      if (ConfigFile.read(ConfigFile.FAVORITE + fid) != null)
        favorite = new Favorite(fid, Integer.parseInt(ConfigFile
            .read(ConfigFile.FAVORITE_SERVER + fid)),
            ConfigFile.read(ConfigFile.FAVORITE_NAME + fid),
            ConfigFile.read(ConfigFile.FAVORITE + fid));

      return favorite;
View Full Code Here

Examples of com.cxy.redisclient.domain.Favorite

    try {
      int amount = Integer.parseInt(ConfigFile
          .readMaxId(ConfigFile.FAVORITE_MAXID));
      List<Favorite> favorites = new ArrayList<Favorite>();
      for (int i = 1; i <= amount; i++) {
        Favorite favorite = listById(i);
        if (favorite != null)
          favorites.add(favorite);
      }

      return favorites;
View Full Code Here

Examples of com.cxy.redisclient.domain.Favorite

  }

  public void updateList(List<Favorite> favorites) {
    List<Favorite> allFavorite = listAll();
    for (Favorite favorite : allFavorite) {
      Favorite newFavorite = find(favorite.getFid(), favorites);
      if (newFavorite == null)
        delete(favorite.getFid());
      else {
        if (!favorite.getName().equals(newFavorite.getName()))
          updateName(favorite.getFid(), newFavorite.getName());
      }
    }
  }
View Full Code Here

Examples of com.cxy.redisclient.domain.Favorite

        menuItem.setText(favorite.getName());
        menuItem.setData(FAVORITE, favorite);
        menuItem.addSelectionListener(new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Favorite favorite = (Favorite) menuItem
                .getData(FAVORITE);
            int sid = favorite.getServerID();

            String[] containers = favorite.getFavorite().split(":");

            String container = "";
            for (int i = 2; i < containers.length; i++) {
              container += containers[i] + ":";
            }
            TreeItem selected = gotoDBContainer(sid, Integer
                .parseInt(containers[1].replaceFirst(DB_PREFIX,
                    "")), container, favorite.isData(),
                false);
            history.add(selected);
            btnBackward.setEnabled(true);
            btnForward.setEnabled(false);
          }
View Full Code Here

Examples of com.cxy.redisclient.domain.Favorite

    btnRenameButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    btnRenameButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        TableItem[] items = table.getSelection();
        Favorite favorite = (Favorite) items[0].getData();
        RenameFavoriteDialog dialog = new RenameFavoriteDialog(shell, image, favorite);
        String name =  (String) dialog.open();
        if(name != null) {
          items[0].setText(new String[] { name, favorite.getFavorite() });
          favorite.setName(name);
          items[0].setData(favorite);
        }
      }
    });
    btnRenameButton.setEnabled(false);
    btnRenameButton.setText(RedisClient.i18nFile.getText(I18nFile.RENAME));
   
   
    btnRemoveButton = new Button(grpFavorites, SWT.NONE);
    btnRemoveButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    btnRemoveButton.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        TableItem[] items = table.getSelection();
        for(TableItem item : items){
          item.dispose();
        }
        tableItemSelected();
      }
    });
    btnRemoveButton.setEnabled(false);
    btnRemoveButton.setText(RedisClient.i18nFile.getText(I18nFile.REMOVE));
       
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new FillLayout(SWT.HORIZONTAL));
    composite.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
   
    Button btnOk = new Button(composite, SWT.NONE);
    btnOk.addSelectionListener(new SelectionAdapter() {
      @SuppressWarnings("unchecked")
      @Override
      public void widgetSelected(SelectionEvent e) {
        TableItem[] items = table.getItems();
       
        for(TableItem item : items){
          ((ArrayList<Favorite>) result).add((Favorite) item.getData());
        }
       
        shell.dispose();
      }
    });
    btnOk.setText(RedisClient.i18nFile.getText(I18nFile.OK));
   
    Button btnCancel = new Button(composite, SWT.NONE);
    btnCancel.addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        result = null;
        shell.dispose();
      }
    });
    btnCancel.setText(RedisClient.i18nFile.getText(I18nFile.CANCEL));
   
   
    List<Favorite> favorites = service.listAll();
    for(Favorite favorite: favorites){
      TableItem item = new TableItem(table, SWT.NONE);
      item.setText(new String[] { favorite.getName(),
        favorite.getFavorite() });
      item.setData(favorite);
    }
   
    super.createContents();
  }
View Full Code Here

Examples of tvbrowser.extras.favoritesplugin.core.Favorite

    });
    return result;
  }

  public Object createDataObject(Object obj) {
    Favorite fav = (Favorite)obj;
    fav.setRemindAfterDownload(mCheckOnUpdateCb.isSelected());
    if (mReminderCb.isSelected()) {
      fav.getReminderConfiguration().setReminderServices(new String[]{ReminderConfiguration.REMINDER_DEFAULT});
    }
    else {
      fav.getReminderConfiguration().setReminderServices(new String[]{});
    }
    return fav;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.