Пример #1
0
  private static void refreshTree() {
    final List<String> openedNodes = new ArrayList<String>();
    TreeNode[] allNodes = inputQueueTree.getData().getAllNodes();
    for (int i = 0; i < allNodes.length; i++) {
      if (inputQueueTree.getData().isOpen(allNodes[i])) {
        openedNodes.add(allNodes[i].getAttributeAsString("path"));
      }
    }
    final ListGridRecord selectedRecord = inputQueueTree.getSelectedRecord();
    inputQueueTree.fetchData(
        null,
        new DSCallback() {

          @Override
          public void execute(DSResponse response, Object rawData, DSRequest request) {
            inputQueueTree.openSubfolders(openedNodes, null, selectedRecord);
          }
        });
  }
Пример #2
0
  public static void setInputTreeToSection(
      final DispatchAsync dispatcher,
      final LangConstants lang,
      final EventBus eventBus,
      SectionStack sectionStack,
      final PlaceManager placeManager,
      final MessageBus messageBus,
      boolean force) {

    SectionStackSection section1 = new SectionStackSection();
    section1.setTitle(lang.inputQueue());
    String isInputSection = sectionStack.getSection(0).getAttribute(Constants.SECTION_INPUT_ID);
    boolean notContains = isInputSection == null || !"yes".equals(isInputSection);
    if (notContains || force) {
      if (!notContains) {
        sectionStack.collapseSection(0);
        sectionStack.removeSection(0);
      }
      if (inputQueueTree == null) {
        inputQueueTree = new InputQueueTree(dispatcher, lang, eventBus);
        inputQueueTree
            .getCreateMenuItem()
            .addClickHandler(
                new com.smartgwt.client.widgets.menu.events.ClickHandler() {

                  @Override
                  public void onClick(final MenuItemClickEvent event) {
                    String msg = event.getMenu().getEmptyMessage();
                    String model = msg.substring(0, msg.indexOf("/"));
                    String path = msg.substring(msg.indexOf("/") + 1);
                    String id = path;
                    if (path.contains("/")) {
                      id = path.substring(0, path.indexOf("/"));
                    }

                    placeManager.revealRelativePlace(
                        new PlaceRequest(NameTokens.FIND_METADATA)
                            .with(Constants.ATTR_MODEL, model)
                            .with(Constants.URL_PARAM_SYSNO, id)
                            .with(Constants.URL_PARAM_PATH, path));
                  }
                });

        messageBus.subscribe(
            "InputQueueBroadcastReceiver",
            new MessageCallback() {
              @Override
              public void callback(Message message) {
                String inputItem = message.get(String.class, "ingested");
                for (ListGridRecord record : inputQueueTree.getRecords()) {
                  if (record.getAttribute(Constants.ATTR_ID).equals(inputItem)) {
                    record.setAttribute(Constants.ATTR_INGEST_INFO, true);
                    inputQueueTree.redraw();
                  }
                }
              }
            });
      }

      section1.setItems(inputQueueTree);
      section1.setControls(getRefreshButton(lang, eventBus, dispatcher));
      section1.setResizeable(true);
      section1.setExpanded(true);
      sectionStack.addSection(section1, 0);
      section1.setAttribute(Constants.SECTION_INPUT_ID, "yes");
    }
  }