Ejemplo n.º 1
0
  public void setCategories(AccessChecker accessChecker, String[] categories) {
    tree.removeAll();
    if (categories == null) return;
    if (accessChecker == null) {
      for (String category : categories) {
        lookCategoryItem(category);
      }
      return;
    }

    group = creator.getSelectedGroupName();

    StringBuilder builder = new StringBuilder();
    for (String category : categories) {
      if (!accessChecker.isPermitAccess(group + "." + category, true)) continue;
      lookCategoryItem(category);
      if (builder.length() > 0) builder.append('\n');
      builder.append(category);
    }

    File file = new File(ClientConnector2.getCacheFolder("sources/type"), "group." + group);
    try {
      byte[] bytes = builder.toString().getBytes(Application.CHARSET);
      RWData.getInstance().save(file, bytes);
    } catch (Exception e) {
      file.delete();
    }
  }
Ejemplo n.º 2
0
  public void setSelectedSources(Worker[] plugins, String... sources) {
    TreeItem[] items = tree.getSelection();
    if (items.length < 1) return;
    TreeItem selectedItem = items[0];

    items = selectedItem.getItems();
    if (items == null || items.length < 1) return;

    for (int i = 0; i < items.length; i++) {
      for (String source : sources) {
        if (!items[i].getText().equals(source)) continue;
        tree.setSelection(new TreeItem[] {selectedItem, items[i]});
        creator.setSource(plugins, getSelectedCategory(), source, false);
        int topIndex = i;
        int visibleCount = tree.getSize().y / 48;
        if (topIndex - visibleCount < 0) return;
        topIndex -= visibleCount;
        tree.setTopItem(items[topIndex]);
        break;
      }
    }
  }