Пример #1
0
 private void removeWithParent(TreeItem toRemove) {
   TreeItem parent = treeStore.getParent(toRemove);
   treeStore.remove(toRemove);
   if (parent != null && !treeStore.hasChildren(parent)) {
     removeWithParent(parent);
   }
 }
    @Override
    public void onFilter(StoreFilterEvent<SelectionItem> event) {
      TreeStore<SelectionItem> treeStore = tree.getStore();

      for (SelectionItem ruleArg : treeStore.getAll()) {
        if (ruleArg.isDefault()) {
          tree.setChecked(ruleArg, CheckState.CHECKED);
        }
      }

      boolean filtered = treeStore.isFiltered();

      for (SelectionItem ruleArg : treeStore.getAll()) {
        // Ensure any groups with filtered-out children still display the group icon.
        if (ruleArg instanceof SelectionItemGroup) {
          tree.setLeaf(ruleArg, false);
          tree.refresh(ruleArg);
        }

        if (!filtered && ruleArg.isDefault()) {
          // Restore the tree's expanded state when the filter is cleared.
          tree.setExpanded(ruleArg, true);
        }
      }
    }
Пример #3
0
  public void removeTestInfo(TaskDataDto test) {

    String id = getTestItemId(test);
    TreeItem testItem = treeStore.findModelWithKey(id);
    if (testItem == null) {
      return;
    }
    TreeItem testInfo = treeStore.getFirstChild(testItem);
    if (testInfo != null && TEST_INFO.equals(testInfo.get(NAME))) removeWithParent(testInfo);
  }
Пример #4
0
  private void addItemToStore(TreeItem record, SummarySingleDto metricDto) {

    TreeItem taskItem = getTestItem(metricDto.getMetricName().getTest());
    for (TreeItem rec : treeStore.getChildren(taskItem)) {
      if (rec.getKey().equals(record.getKey())) {
        return;
      }
    }
    treeStore.add(taskItem, record);
  }
Пример #5
0
  public void addTestInfo(TaskDataDto test, Map<String, TestInfoDto> testInfoMap) {

    TreeItem testItem = getTestItem(test);

    String testInfoId = testItem.getKey() + TEST_INFO;
    if (treeStore.findModelWithKey(testInfoId) != null) {
      return;
    }

    String testItemName = getTestItemName(test);
    TreeItem testInfo = new TreeItem(testInfoId);
    testInfo.put(NAME, TEST_INFO);
    testInfo.put(TEST_DESCRIPTION, test.getDescription());
    testInfo.put(TEST_NAME, testItemName);
    treeStore.insert(testItem, 0, testInfo);

    TreeItem clock = new TreeItem(testItem.getKey() + "Clock");
    clock.put(NAME, "Clock");
    clock.put(TEST_DESCRIPTION, test.getDescription());
    clock.put(TEST_NAME, testItemName);
    clock.put(TEST_INFO, TEST_INFO);
    for (SessionDataDto session : chosenSessions) {
      if (testInfoMap.get(session.getSessionId()) != null)
        clock.put(
            SESSION_HEADER + session.getSessionId(),
            testInfoMap.get(session.getSessionId()).getClock());
    }
    treeStore.add(testInfo, clock);

    TreeItem termination = new TreeItem(testItem.getKey() + "Termination");
    termination.put(NAME, "Termination");
    termination.put(TEST_DESCRIPTION, test.getDescription());
    termination.put(TEST_NAME, testItemName);
    termination.put(TEST_INFO, TEST_INFO);
    for (SessionDataDto session : chosenSessions) {
      if (testInfoMap.get(session.getSessionId()) != null)
        termination.put(
            SESSION_HEADER + session.getSessionId(),
            testInfoMap.get(session.getSessionId()).getTermination());
    }
    treeStore.add(testInfo, termination);

    TreeItem startTime = new TreeItem(testItem.getKey() + "Start time");
    startTime.put(NAME, "Start time");
    startTime.put(TEST_DESCRIPTION, test.getDescription());
    startTime.put(TEST_NAME, testItemName);
    startTime.put(TEST_INFO, TEST_INFO);
    for (SessionDataDto session : chosenSessions) {
      if (testInfoMap.get(session.getSessionId()) != null) {
        Date date = testInfoMap.get(session.getSessionId()).getStartTime();
        startTime.put(SESSION_HEADER + session.getSessionId(), dateFormatter.format(date));
      }
    }
    treeStore.add(testInfo, startTime);
  }
Пример #6
0
 private TreeItem getTestDescriptionItem(String descriptionStr) {
   for (TreeItem item : treeStore.getRootItems()) {
     if (descriptionStr.equals(item.get(NAME))) {
       return item;
     }
   }
   TreeItem description = new TreeItem(descriptionStr);
   description.put(NAME, descriptionStr);
   treeStore.add(description);
   return description;
 }
Пример #7
0
  public void addSessionInfo() {
    TreeItem sessionInfo = new TreeItem(SESSION_INFO_ID);
    sessionInfo.put(NAME, "Session Info");
    treeStore.insert(0, sessionInfo);

    String tagsStr = "";
    TreeItem itemActiveKernels = new TreeItem(ACTIVE_KERNELS);
    TreeItem itemTaskExecuted = new TreeItem(TASKS_EXECUTED);
    TreeItem itemTaskFailed = new TreeItem(TASKS_FAILED);
    TreeItem itemDateStart = new TreeItem(START_DATE);
    TreeItem itemDateEnd = new TreeItem(END_DATE);
    TreeItem itemComment = new TreeItem(COMMENT);
    TreeItem itemUserComment = new TreeItem(USER_COMMENT);
    TreeItem itemTags = new TreeItem(SESSION_TAGS);

    itemActiveKernels.put(NAME, ACTIVE_KERNELS);
    itemTaskExecuted.put(NAME, TASKS_EXECUTED);
    itemTaskFailed.put(NAME, TASKS_FAILED);
    itemDateStart.put(NAME, START_DATE);
    itemDateEnd.put(NAME, END_DATE);
    itemComment.put(NAME, COMMENT);
    if (webClientProperties.isUserCommentStoreAvailable()) itemUserComment.put(NAME, USER_COMMENT);
    if (webClientProperties.isTagsStoreAvailable()) itemTags.put(NAME, SESSION_TAGS);

    for (SessionDataDto session : chosenSessions) {
      itemActiveKernels.put(
          SESSION_HEADER + session.getSessionId(), session.getActiveKernelsCount() + "");
      itemTaskExecuted.put(
          SESSION_HEADER + session.getSessionId(), session.getTasksExecuted() + "");
      itemTaskFailed.put(SESSION_HEADER + session.getSessionId(), session.getTasksFailed() + "");
      itemDateStart.put(
          SESSION_HEADER + session.getSessionId(), dateFormatter.format(session.getStartDate()));
      itemDateEnd.put(
          SESSION_HEADER + session.getSessionId(), dateFormatter.format(session.getEndDate()));
      itemComment.put(SESSION_HEADER + session.getSessionId(), session.getComment());
      if (webClientProperties.isUserCommentStoreAvailable()) {
        String userComment = session.getUserComment() == null ? "" : session.getUserComment();
        itemUserComment.put(SESSION_HEADER + session.getSessionId(), userComment);
      }
      if (webClientProperties.isTagsStoreAvailable()) {
        for (int i = 0; i < session.getTags().size(); i++) {
          if (i == session.getTags().size() - 1) tagsStr += session.getTags().get(i).getName();
          else tagsStr += session.getTags().get(i).getName() + ", ";
        }
        itemTags.put(SESSION_HEADER + session.getSessionId(), tagsStr);
        tagsStr = "";
      }
    }
    treeStore.add(sessionInfo, itemComment);
    if (webClientProperties.isUserCommentStoreAvailable())
      treeStore.add(sessionInfo, itemUserComment);
    if (webClientProperties.isTagsStoreAvailable()) treeStore.add(sessionInfo, itemTags);
    treeStore.add(sessionInfo, itemDateStart);
    treeStore.add(sessionInfo, itemDateEnd);

    treeStore.add(sessionInfo, itemActiveKernels);
    treeStore.add(sessionInfo, itemTaskExecuted);
    treeStore.add(sessionInfo, itemTaskFailed);
  }
  public TreeSelectionEditor(
      AppTemplateWizardAppearance appearance, SelectionItemProperties props) {
    TreeStore<SelectionItem> store = new TreeStore<SelectionItem>(props.id());

    tree = new SelectionItemTree(store, props.display());
    //        if (presenter.isEditingMode()) {
    //            /*
    //             * KLUDGE CORE-4653 JDS Set selection model to locked. This is to prevent the user
    // from
    //             * making any selections due to the issue described in CORE-4653.
    //             */
    //            tree.getSelectionModel().setLocked(true);
    //            tree.setCore4653Kludge();
    //        }
    tree.setHeight(appearance.getDefaultTreeSelectionHeight());

    tree.addValueChangeHandler(new TreeValueChangeHandler());
    selectionItemsEditor = new MyTreeStoreEditor(store, this);

    // This handler must be added after the store is added to the tree, since the tree adds its own
    // handlers that must trigger before this one.
    // Restore the tree's Checked state from each item's isDefault field after it's filtered.
    store.addStoreFilterHandler(new MyStoreFilterHandler());

    VerticalLayoutContainer vlc = new VerticalLayoutContainer();
    vlc.add(buildFilter(store), new VerticalLayoutData(1, -1));
    vlc.add(tree);

    argumentLabel = new FieldLabel(vlc);
    argumentLabel.setLabelAlign(TOP);
    argumentLabel.addDomHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            TreeSelectionEditor.this.fireEvent(new ArgumentSelectedEvent(model));
          }
        },
        ClickEvent.getType());

    labelLeafEditor = new LabelLeafEditor<String>(argumentLabel, this, appearance);
    idEditor = SimpleEditor.<String>of();
    typeEditor = SimpleEditor.<ArgumentType>of();
    requiredEditor = new LabelLeafEditor<Boolean>(argumentLabel, this, appearance);
    descriptionEditor = new LabelLeafEditor<String>(argumentLabel, this, appearance);

    initWidget(argumentLabel);
    visibilityEditor = new VisibilityEditor(this);
  }
Пример #9
0
  private TreeItem getTestItem(TaskDataDto tdd) {

    String key = getTestItemId(tdd);
    TreeItem taskItem = treeStore.findModelWithKey(key);
    if (taskItem != null) {
      return taskItem;
    }

    TreeItem description = getTestDescriptionItem(tdd.getDescription());

    taskItem = new TreeItem(key);
    taskItem.put(NAME, getTestItemName(tdd));
    taskItem.put(TEST_DESCRIPTION, tdd.getDescription());
    treeStore.add(description, taskItem);
    return taskItem;
  }
Пример #10
0
  // clear everything but Session Information
  public void clearTreeStore() {

    for (TreeItem root : treeStore.getRootItems()) {
      if (root.getKey().equals(SESSION_INFO_ID)) {
        continue;
      }
      for (TreeItem test : treeStore.getChildren(root)) {
        for (TreeItem item : treeStore.getChildren(test)) {
          if (TEST_INFO.equals(item.get(NAME))) {
            continue;
          }
          removeWithParent(item);
        }
      }
    }
  }
 private void processFolder(TreeStore<BaseDto> store, FolderDto folder) {
   for (BaseDto child : folder.getChildren()) {
     store.add(folder, child);
     if (child instanceof FolderDto) {
       processFolder(store, (FolderDto) child);
     }
   }
 }
Пример #12
0
  private void removeRecord(SummarySingleDto metric) {

    TreeItem testItem = getTestItem(metric.getMetricName().getTest());
    String key = testItem.getKey() + metric.getMetricName().getMetricName();

    for (TreeItem item : treeStore.getChildren(testItem)) {
      if (item.getKey().equals(key)) {
        removeWithParent(item);
        return;
      }
    }
  }
Пример #13
0
 public void removeSessionInfo() {
   TreeItem sessionInfo = treeStore.findModelWithKey(SESSION_INFO_ID);
   if (sessionInfo != null) treeStore.remove(sessionInfo);
 }
Пример #14
0
  private void init(Set<SessionDataDto> chosenSessions, int width) {

    int colWidth = calculateWidth(chosenSessions.size(), width);

    treeStore.clear();
    List<ColumnConfig<TreeItem, ?>> columns = new ArrayList<ColumnConfig<TreeItem, ?>>();

    // sort sessions by number sessionId
    SortedSet<SessionDataDto> sortedSet =
        new TreeSet<SessionDataDto>(
            new Comparator<SessionDataDto>() {
              @Override
              public int compare(SessionDataDto o, SessionDataDto o2) {
                return (Long.parseLong(o.getSessionId()) - Long.parseLong(o2.getSessionId())) > 0
                    ? 1
                    : -1;
              }
            });
    sortedSet.addAll(chosenSessions);

    ColumnConfig<TreeItem, String> nameColumn =
        new ColumnConfig<TreeItem, String>(
            new MapValueProvider(NAME), (int) (colWidth * METRIC_COLUMN_WIDTH_FACTOR));
    nameColumn.setHeader(METRIC);
    nameColumn.setSortable(false);
    nameColumn.setMenuDisabled(true);
    columns.add(nameColumn);

    for (SessionDataDto session : sortedSet) {
      ColumnConfig<TreeItem, String> column =
          new ColumnConfig<TreeItem, String>(
              new MapValueProvider(SESSION_HEADER + session.getSessionId()));
      column.setHeader(SESSION_HEADER + session.getSessionId());
      column.setWidth(colWidth);
      column.setSortable(false);
      column.setCell(
          new AbstractCell<String>() {
            @Override
            public void render(Context context, String value, SafeHtmlBuilder sb) {
              if (value != null) {
                sb.appendHtmlConstant(value);
              }
            }
          });
      column.setMenuDisabled(true);

      column.setColumnTextStyle(
          new SafeStyles() {
            @Override
            public String asString() {
              return WHITE_SPACE_NORMAL;
            }
          });

      columns.add(column);
    }

    ColumnModel<TreeItem> cm = new ColumnModel<TreeItem>(columns);

    treeGrid = new NoIconsTreeGrid(treeStore, cm, nameColumn);

    treeGrid.addBeforeCollapseHandler(
        new BeforeCollapseItemEvent.BeforeCollapseItemHandler<TreeItem>() {
          @Override
          public void onBeforeCollapse(BeforeCollapseItemEvent<TreeItem> event) {
            event.setCancelled(true);
          }
        });

    treeGrid.setAutoExpand(true);
    treeGrid.getView().setStripeRows(true);
    treeGrid.setMinColumnWidth(MIN_COLUMN_WIDTH);
    treeGrid.setAllowTextSelection(true);
    treeGrid.getView().setForceFit(true);

    treeStore.addStoreAddHandler(
        new StoreAddEvent.StoreAddHandler<TreeItem>() {
          @Override
          public void onAdd(StoreAddEvent<TreeItem> event) {
            for (TreeItem item : event.getItems()) {
              treeGrid.setExpanded(item, true);
            }
          }
        });

    if (webClientProperties.isUserCommentEditAvailable()) {
      treeGrid.addCellDoubleClickHandler(
          new CellDoubleClickEvent.CellDoubleClickHandler() {
            @Override
            public void onCellClick(CellDoubleClickEvent event) {
              TreeItem item =
                  treeGrid.findNode(treeGrid.getTreeView().getRow(event.getRowIndex())).getModel();
              if (item.getKey().equals(USER_COMMENT) && event.getCellIndex() > 0) {
                SessionDataDto currentSession = defineCurrentSession(event);
                userCommentBox.popUp(
                    currentSession, item.get(SESSION_HEADER + currentSession.getSessionId()), item);
              }
            }
          });
    }

    if (webClientProperties.isTagsAvailable()) {
      treeGrid.addCellDoubleClickHandler(
          new CellDoubleClickEvent.CellDoubleClickHandler() {
            @Override
            public void onCellClick(CellDoubleClickEvent event) {
              TreeItem item =
                  treeGrid.findNode(treeGrid.getTreeView().getRow(event.getRowIndex())).getModel();
              if (item.getKey().equals(SESSION_TAGS) && event.getCellIndex() > 0) {
                SessionDataDto currentSession = defineCurrentSession(event);
                if (allTagsLoadComplete) tagBox.popUpForEdit(currentSession, item, allTags);
              }
            }
          });
    }

    add(treeGrid);
  }
  @Override
  public Widget asWidget() {
    if (panel == null) {
      panel = new ContentPanel();
      panel.setHeadingText("Cell Action Tree");
      panel.setPixelSize(315, 400);
      panel.addStyleName("margin-10");

      VerticalLayoutContainer con = new VerticalLayoutContainer();
      panel.add(con);

      TreeStore<BaseDto> store = new TreeStore<BaseDto>(new KeyProvider());

      FolderDto root = TestData.getMusicRootFolder();
      for (BaseDto base : root.getChildren()) {
        store.add(base);
        if (base instanceof FolderDto) {
          processFolder(store, (FolderDto) base);
        }
      }

      SimpleSafeHtmlCell<String> cell =
          new SimpleSafeHtmlCell<String>(SimpleSafeHtmlRenderer.getInstance(), "click") {
            @Override
            public void onBrowserEvent(
                Context context,
                Element parent,
                String value,
                NativeEvent event,
                ValueUpdater<String> valueUpdater) {
              super.onBrowserEvent(context, parent, value, event, valueUpdater);
              if ("click".equals(event.getType())) {
                Info.display("Click", "You clicked \"" + value + "\"!");
              }
            }
          };

      final Tree<BaseDto, String> tree =
          new Tree<BaseDto, String>(
              store,
              new ValueProvider<BaseDto, String>() {

                @Override
                public String getValue(BaseDto object) {
                  return object.getName();
                }

                @Override
                public void setValue(BaseDto object, String value) {}

                @Override
                public String getPath() {
                  return "name";
                }
              });
      tree.setCell(cell);
      tree.setWidth(300);
      tree.getStyle().setLeafIcon(ExampleImages.INSTANCE.music());

      ToolBar buttonBar = new ToolBar();

      buttonBar.add(
          new TextButton(
              "Expand All",
              new SelectHandler() {

                @Override
                public void onSelect(SelectEvent event) {
                  tree.expandAll();
                }
              }));
      buttonBar.add(
          new TextButton(
              "Collapse All",
              new SelectHandler() {
                @Override
                public void onSelect(SelectEvent event) {
                  tree.collapseAll();
                }
              }));

      con.add(buttonBar, new VerticalLayoutData(1, -1));
      con.add(tree, new VerticalLayoutData(1, 1));
    }

    return panel;
  }
Пример #16
0
  @Override
  public Widget asWidget() {
    final Window complex = new Window();
    complex.setMaximizable(true);
    complex.setHeadingText("Accordion Window");
    complex.setWidth(200);
    complex.setHeight(350);

    AccordionLayoutContainer con = new AccordionLayoutContainer();
    con.setExpandMode(ExpandMode.SINGLE_FILL);
    complex.add(con);

    AccordionLayoutAppearance appearance =
        GWT.<AccordionLayoutAppearance>create(AccordionLayoutAppearance.class);

    ContentPanel cp = new ContentPanel(appearance);
    cp.setAnimCollapse(false);
    cp.setHeadingText("Online Users");
    cp.getHeader().addStyleName(ThemeStyles.getStyle().borderTop());
    con.add(cp);
    con.setActiveWidget(cp);

    TreeStore<NameImageModel> store = new TreeStore<NameImageModel>(NameImageModel.KP);

    Tree<NameImageModel, String> tree =
        new Tree<NameImageModel, String>(
            store,
            new ValueProvider<NameImageModel, String>() {

              @Override
              public String getValue(NameImageModel object) {
                return object.getName();
              }

              @Override
              public void setValue(NameImageModel object, String value) {}

              @Override
              public String getPath() {
                return "name";
              }
            });

    tree.setIconProvider(
        new IconProvider<NameImageModel>() {
          public ImageResource getIcon(NameImageModel model) {
            if (null == model.getImage()) {
              return null;
            } else if ("user-girl" == model.getImage()) {
              return ExampleImages.INSTANCE.userFemale();
            } else if ("user-kid" == model.getImage()) {
              return ExampleImages.INSTANCE.userKid();
            } else {
              return ExampleImages.INSTANCE.user();
            }
          }
        });

    NameImageModel m = newItem("Family", null);
    store.add(m);

    store.add(m, newItem("Darrell", "user"));
    store.add(m, newItem("Maro", "user-girl"));
    store.add(m, newItem("Lia", "user-kid"));
    store.add(m, newItem("Alec", "user-kid"));
    store.add(m, newItem("Andrew", "user-kid"));

    tree.setExpanded(m, true);

    m = newItem("Friends", null);
    store.add(m);

    store.add(m, newItem("Bob", "user"));
    store.add(m, newItem("Mary", "user-girl"));
    store.add(m, newItem("Sally", "user-girl"));
    store.add(m, newItem("Jack", "user"));

    tree.setExpanded(m, true);

    cp.add(tree);

    cp = new ContentPanel(appearance);
    cp.setAnimCollapse(false);
    cp.setBodyStyleName("pad-text");
    cp.setHeadingText("Settings");
    cp.add(new Label(TestData.DUMMY_TEXT_SHORT));
    con.add(cp);

    cp = new ContentPanel(appearance);
    cp.setAnimCollapse(false);
    cp.setBodyStyleName("pad-text");
    cp.setHeadingText("Stuff");
    cp.add(new Label(TestData.DUMMY_TEXT_SHORT));
    con.add(cp);

    cp = new ContentPanel(appearance);
    cp.setAnimCollapse(false);
    cp.setBodyStyleName("pad-text");
    cp.setHeadingText("More Stuff");
    cp.add(new Label(TestData.DUMMY_TEXT_SHORT));
    con.add(cp);

    TextButton b = new TextButton("Open");
    b.addSelectHandler(
        new SelectHandler() {

          @Override
          public void onSelect(SelectEvent event) {
            complex.show();
          }
        });

    VerticalPanel vp = new VerticalPanel();
    vp.setSpacing(10);
    vp.add(b);
    return vp;
  }
Пример #17
0
  public Widget asWidget() {
    FlowLayoutContainer con = new FlowLayoutContainer();
    con.addStyleName("margin-10");

    TreeStore<BaseDto> store = new TreeStore<BaseDto>(new KeyProvider());

    FolderDto root = TestData.getMusicRootFolder();
    for (BaseDto base : root.getChildren()) {
      store.add(base);
      if (base instanceof FolderDto) {
        processFolder(store, (FolderDto) base);
      }
    }

    StoreFilterField<BaseDto> filter =
        new StoreFilterField<BaseDto>() {

          @Override
          protected boolean doSelect(
              Store<BaseDto> store, BaseDto parent, BaseDto item, String filter) {
            if (item instanceof FolderDto) {
              return false;
            }

            String name = item.getName();
            name = name.toLowerCase();
            if (name.startsWith(filter.toLowerCase())) {
              return true;
            }
            return false;
          }
        };
    filter.bind(store);

    final Tree<BaseDto, String> tree =
        new Tree<BaseDto, String>(
            store,
            new ValueProvider<BaseDto, String>() {

              @Override
              public String getValue(BaseDto object) {
                return object.getName();
              }

              @Override
              public void setValue(BaseDto object, String value) {}

              @Override
              public String getPath() {
                return "name";
              }
            });
    tree.setWidth(300);
    tree.getStyle().setLeafIcon(ExampleImages.INSTANCE.music());
    ButtonBar buttonBar = new ButtonBar();

    buttonBar.add(
        new TextButton(
            "Expand All",
            new SelectHandler() {

              @Override
              public void onSelect(SelectEvent event) {
                tree.expandAll();
              }
            }));
    buttonBar.add(
        new TextButton(
            "Collapse All",
            new SelectHandler() {
              @Override
              public void onSelect(SelectEvent event) {
                tree.collapseAll();
              }
            }));

    buttonBar.setLayoutData(new MarginData(4));
    con.add(filter);
    con.add(buttonBar);
    con.add(tree);
    return con;
  }