Example #1
0
  /** Folder Tree */
  public FolderSelectTree() {
    tree = new Tree();
    rootItem.setStyleName("okm-TreeItem");
    rootItem.setUserObject(new GWTFolder());
    rootItem.setSelected(true);
    rootItem.setState(true);
    tree.setStyleName("okm-Tree");
    tree.addItem(rootItem);
    tree.addSelectionHandler(
        new SelectionHandler<TreeItem>() {

          @Override
          public void onSelection(SelectionEvent<TreeItem> event) {
            boolean refresh = true;
            TreeItem item = event.getSelectedItem();

            // Enables or disables move button ( evalues security to move to folder with permissions
            // )
            evaluateSecurityToAction(item);

            // Case that not refreshing tree and file browser ( right click )
            if (actualItem.equals(item)) {
              refresh = false;
            } else {
              // Disables actual item because on changing active node by
              // application this it's not changed automatically
              if (!actualItem.equals(item)) {
                actualItem.setSelected(false);
                actualItem = item;
              } else {
                refresh = false;
              }
            }

            if (refresh) {
              refresh(true);
            }
          }
        });
    actualItem = tree.getItem(0);
    initWidget(tree);
  }
Example #2
0
        public void onSuccess(List<GWTFolder> result) {
          boolean directAdd = true;

          // If has no childs directly add values is permited
          if (actualItem.getChildCount() > 0) {
            directAdd = false;
            // to prevent remote folder remove it disables all tree branch
            // items and after sequentially activate
            hideAllBranch(actualItem);
          }

          // On refreshing not refreshed the actual item values but must
          // ensure that has childs value is consistent
          if (result.isEmpty()) {
            ((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
          } else {
            ((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
          }

          // Ads folders childs if exists
          for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
            GWTFolder folder = it.next();
            TreeItem folderItem = new TreeItem(folder.getName());
            folderItem.setUserObject(folder);
            folderItem.setStyleName("okm-TreeItem");

            // If has no childs directly add values is permited, else
            // evalues each node to refresh, remove or add
            if (directAdd) {
              evaluesFolderIcon(folderItem);
              actualItem.addItem(folderItem);
            } else {
              // sequentially activate items and refreshes values
              addFolder(actualItem, folderItem);
            }
          }

          actualItem.setState(true);
          evaluesFolderIcon(actualItem);
        }
Example #3
0
  public TagMenuPopup(TaggerEditor vTagger, String lastSelectedColor) {
    super(true);
    getElement().addClassName("tagmenu-popup");
    this.setText("Annotations");
    this.vTagger = vTagger;
    this.lastSelectedColor = lastSelectedColor;
    root = new TreeItem("Available annotations");
    final Tree tree = new Tree();
    tree.addItem(root);
    root.setState(true);
    root.setStyleName("tagger_menu_root");

    final VerticalPanel vPanel = new VerticalPanel();

    if (vTagger.hasSelection()) {

      final VerticalPanel annotationCreationPanel = new VerticalPanel();
      annotationCreationPanel.setSpacing(5);
      annotationCreationPanel.setWidth("100%");
      final TextArea annotationBodyInput = new TextArea();
      annotationBodyInput.setWidth("90%");
      annotationCreationPanel.add(annotationBodyInput);
      final HorizontalPanel annotationCreationButtonPanel = new HorizontalPanel();
      annotationCreationButtonPanel.setSpacing(5);
      final Label colorLabel = new HTML("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
      final ColorPicker colorPicker =
          new ColorPicker() {
            @Override
            public void onChange(Widget sender) {
              super.onChange(sender);
              colorLabel
                  .getElement()
                  .setAttribute("style", "background:#" + this.getHexColor() + ";");
            }
          };
      try {
        if (lastSelectedColor != null) {
          colorPicker.setHex(lastSelectedColor);
        } else {
          int[] randomColor = getRandomColor();
          colorPicker.setRGB(randomColor[0], randomColor[1], randomColor[2]);
        }
      } catch (Exception e) {
        // well...
      }
      colorLabel
          .getElement()
          .setAttribute("style", "background:#" + colorPicker.getHexColor() + ";");

      HorizontalPanel colorPanel = new HorizontalPanel();
      colorPanel.setSpacing(5);
      PushButton colorButton = new PushButton("Change color...");
      colorPanel.add(colorButton);

      colorPanel.add(colorLabel);

      HandlerRegistration colorButtonReg =
          colorButton.addClickHandler(
              new ClickHandler() {

                public void onClick(ClickEvent event) {

                  annotationCreationPanel.insert(
                      colorPicker,
                      annotationCreationPanel.getWidgetIndex(annotationCreationButtonPanel));
                  TagMenuPopup.this.center();
                }
              });
      handlerRegistrations.add(colorButtonReg);
      annotationCreationPanel.add(colorPanel);

      PushButton saveButton = new PushButton("Save");
      // saveButton.setStylePrimaryName("tagger-pushButton");
      HandlerRegistration saveButtonReg =
          saveButton.addClickHandler(
              new ClickHandler() {

                public void onClick(ClickEvent event) {
                  //	TagMenuPopup.this.vTagger.createAndAddTagIntance(colorPicker.getHexColor());
                  TagMenuPopup.this.lastSelectedColor = colorPicker.getHexColor();
                  hide();
                }
              });
      handlerRegistrations.add(saveButtonReg);

      PushButton cancelButton = new PushButton("Cancel");
      // cancelButton.setStylePrimaryName("tagger-pushButton");

      annotationCreationButtonPanel.add(saveButton);
      annotationCreationButtonPanel.add(cancelButton);
      annotationCreationPanel.add(annotationCreationButtonPanel);

      PushButton addAnnotationButton = new PushButton("Add annotation...");
      // addAnnotationButton.setStylePrimaryName("tagger-pushButton");

      HandlerRegistration addAnnotationBtReg =
          addAnnotationButton.addClickHandler(
              new ClickHandler() {

                public void onClick(ClickEvent event) {
                  vPanel.insert(annotationCreationPanel, vPanel.getWidgetIndex(tree));
                }
              });
      handlerRegistrations.add(addAnnotationBtReg);
      vPanel.add(addAnnotationButton);

      HandlerRegistration cancelButtonReg =
          cancelButton.addClickHandler(
              new ClickHandler() {
                public void onClick(ClickEvent event) {
                  annotationBodyInput.setText("");
                  vPanel.remove(annotationCreationPanel);
                }
              });

      handlerRegistrations.add(cancelButtonReg);
    }

    vPanel.add(tree);
    vPanel.setStylePrimaryName("tagger_menu");
    setWidget(vPanel);
  }