Package com.cxy.redisclient.domain

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


    }
  }

  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

    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

  }

  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

        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

    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

TOP

Related Classes of com.cxy.redisclient.domain.Favorite

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.