Esempio n. 1
0
  @Inject
  public LeftMenuView(LeftMenuUiBinder binder) {

    initWidget(binder.createAndBindUi(this));

    // set visibility of menu per roles

    if (PerunSession.getInstance().isPerunAdmin()) {
      perunManager.setVisible(true);
      perunManagerMenu.setIn(true);
    }
    if (PerunSession.getInstance().isVoAdmin() || PerunSession.getInstance().isVoObserver()) {
      voManager.setVisible(true);
      groupManager.setVisible(true);
      if (!PerunSession.getInstance().isPerunAdmin()) {
        voManagerMenu.setIn(true);
      }
    }
    if (PerunSession.getInstance().isGroupAdmin()) {
      groupManager.setVisible(true);
      if (!PerunSession.getInstance().isVoAdmin() && !PerunSession.getInstance().isVoObserver()) {
        groupManagerMenu.setIn(true);
      }
    }
    if (PerunSession.getInstance().isFacilityAdmin()) {
      facilityManager.setVisible(true);
      if (!PerunSession.getInstance().isVoAdmin() && !PerunSession.getInstance().isVoObserver()) {
        // if only group admin, prefer facility admin menu
        facilityManagerMenu.setIn(true);
      }
    }
  }
  private void createAnnotationAccordionGroup(
      final Annotation annotation, final AnnotationSource annotationSource) {

    final Panel container = new Panel();
    final PanelHeader header = new PanelHeader();
    final PanelCollapse collapse = new PanelCollapse();
    final PanelBody body = new PanelBody();

    container.add(header);
    collapse.add(body);
    container.add(collapse);

    final Button remove = new Button();
    remove.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(final ClickEvent clickEvent) {
            presenter.onDeleteAnnotation(annotation);
          }
        });
    remove.setPull(Pull.RIGHT);
    remove.setIcon(IconType.TRASH);
    remove.setType(ButtonType.DANGER);
    remove.setSize(ButtonSize.SMALL);
    remove.getElement().getStyle().setMarginTop(-4, Style.Unit.PX);
    header.add(remove);

    final Heading heading = new Heading(HeadingSize.H4);
    final Anchor anchor = new Anchor();
    anchor.setText(accordionHeading(annotation));
    anchor.setDataToggle(Toggle.COLLAPSE);
    anchor.setDataParent(accordionsContainer.getId());
    anchor.setDataTargetWidget(collapse);
    anchor.addStyleName("collapsed");
    heading.add(anchor);
    header.add(heading);

    accordionsContainer.add(container);

    if (annotation.getAnnotationDefinition() != null
        && annotation.getAnnotationDefinition().getValuePairs() != null) {
      for (AnnotationValuePairDefinition valuePairDefinition :
          annotation.getAnnotationDefinition().getValuePairs()) {
        body.add(createValuePairItem(annotation, valuePairDefinition, annotationSource));
      }
    }
  }