/** This is the entry point method. */
  public void onModuleLoad() {
    sendButton = new Button("Send");
    nameField = new TextBox();
    nameField.setText("GWT User");
    errorLabel = new Label();

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create the popup dialog box
    dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);
    closeButton = new Button("Close");
    // We can set the id of a widget by accessing its Element
    closeButton.getElement().setId("closeButton");
    textToServerLabel = new Label();
    serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.add(new HTML("<b>Sending name to the server:</b>"));
    dialogVPanel.add(textToServerLabel);
    dialogVPanel.add(new HTML("<br><b>Server replies:</b>"));
    dialogVPanel.add(serverResponseLabel);
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogBox.setWidget(dialogVPanel);

    // Add a handler to close the DialogBox
    final ClickHandler buttonClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            dialogBox.hide();
            sendButton.setEnabled(true);
            sendButton.setFocus(true);
          }
        };
    closeButton.addClickHandler(buttonClickHandler);

    // Add a handler to send the name to the server
    ChangeEventHandler handler = new ChangeEventHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);
  }
  @Override
  protected void onAttach() {
    super.onAttach();
    Image img =
        new Image(
            getBaseImageUrl()
                + "?merchant_id="
                + getMerchantId()
                + "&w="
                + getWidth()
                + "&h="
                + getHeight()
                + "&style="
                + getStyle()
                + "&variant="
                + getVariant()
                + "&loc="
                + getLoc());
    img.setTitle("Fast checkout through Google");

    PushButton pb = new PushButton(img);
    pb.addClickHandler(this);
    vpanel.clear();
    vpanel.add(pb);
  }
Beispiel #3
0
  private void setupSettingsPanel() {
    SplitLayoutPanel root = (SplitLayoutPanel) widget;
    root.setWidgetToggleDisplayAllowed(settingsPanel, true);
    testsMetricsPanel.showWidget(0);

    sessionPlotPanel = new SessionPlotPanel(plotPanel);
    sessionScopePlotList.add(sessionPlotPanel);
  }
Beispiel #4
0
  public void onModuleLoad() {
    // Create table for stock data.
    stocksFlexTable.setText(0, 0, "Symbol");
    stocksFlexTable.setText(0, 1, "Price");
    stocksFlexTable.setText(0, 2, "Change");
    stocksFlexTable.setText(0, 3, "Remove");

    // Assemble Add Stock panel.
    addPanel.add(newSymbolTextBox);
    addPanel.add(addStockButton);

    // Assemble Main panel.
    mainPanel.add(stocksFlexTable);
    mainPanel.add(addPanel);
    mainPanel.add(lastUpdateLabel);

    // Associate the Main panel with the HTML host page.
    RootPanel.get("stockList").add(mainPanel);

    // Move cursor focus to the input box.
    newSymbolTextBox.setFocus(true);

    initHandlers();
  }
  public DescriptionCellEditor() {
    super();

    ensureResources();
    setStyleName("");

    addCloseHandler(
        new CloseHandler<PopupPanel>() {
          @Override
          public void onClose(CloseEvent<PopupPanel> event) {
            if (event.isAutoClosed()) {
              commit();
              hide();
            }
          }
        });

    VerticalPanel verticalPanel = new VerticalPanel();

    textArea = new RichTextArea();
    textArea.setTabIndex(0);
    textArea.addStyleName(resources.style().bDescriptionCellEditor__editor());
    textArea.addKeyDownHandler(
        new KeyDownHandler() {
          @Override
          public void onKeyDown(KeyDownEvent event) {
            int keyCode = event.getNativeKeyCode();
            if (keyCode == KeyCodes.KEY_ESCAPE) {
              cancelButton.setFocus(true); // or grid did not get back focus
              hide();
            } else if (keyCode == KeyCodes.KEY_ENTER && event.isControlKeyDown()) {
              okButton.setFocus(true); // or grid did not get back focus
              okButton.click();
            }
          }
        });
    VerticalPanel textAreaPanel = new VerticalPanel();
    textAreaPanel.add(textArea);

    HorizontalPanel buttonPanel = new HorizontalPanel();

    okButton = new Button(strings.ok());
    okButton.addStyleName(resources.style().bDescriptionCellEditor__ok());
    okButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            commit();
            hide();
          }
        });
    buttonPanel.add(okButton);

    cancelButton = new Button(strings.cancel());
    cancelButton.addStyleName(resources.style().bDescriptionCellEditor__cancel());
    cancelButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            hide();
          }
        });
    buttonPanel.add(cancelButton);

    textAreaPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    textAreaPanel.add(buttonPanel);

    RichTextToolbar textToolbar = new RichTextToolbar(textArea);
    SimplePanel toolBarPanel = new SimplePanel(textToolbar);
    toolBarPanel.addStyleName(resources.style().bDescriptionCellEditor__toolbar());

    verticalPanel.add(toolBarPanel);
    verticalPanel.add(textAreaPanel);

    add(verticalPanel);
  }
Beispiel #6
0
  private void renderPlots(
      HTMLPanel panel,
      List<PlotSeriesDto> plotSeriesDtoList,
      String id,
      double yMinimum,
      boolean isMetric) {
    panel.add(loadIndicator);

    SimplePlot redrawingPlot = null;

    VerticalPanel plotGroupPanel = new VerticalPanel();
    plotGroupPanel.setWidth("100%");
    plotGroupPanel.getElement().setId(id);

    for (PlotSeriesDto plotSeriesDto : plotSeriesDtoList) {
      Markings markings = null;
      if (plotSeriesDto.getMarkingSeries() != null) {
        markings = new Markings();
        for (MarkingDto plotDatasetDto : plotSeriesDto.getMarkingSeries()) {
          double x = plotDatasetDto.getValue();
          markings.addMarking(
              new Marking()
                  .setX(new Range(x, x))
                  .setLineWidth(1)
                  .setColor(plotDatasetDto.getColor()));
        }

        markingsMap.put(id, new TreeSet<MarkingDto>(plotSeriesDto.getMarkingSeries()));
      }

      final SimplePlot plot =
          createPlot(id, markings, plotSeriesDto.getXAxisLabel(), yMinimum, isMetric);
      redrawingPlot = plot;
      PlotModel plotModel = plot.getModel();

      for (PlotDatasetDto plotDatasetDto : plotSeriesDto.getPlotSeries()) {
        SeriesHandler handler =
            plotModel.addSeries(plotDatasetDto.getLegend(), plotDatasetDto.getColor());

        // Populate plot with data
        for (PointDto pointDto : plotDatasetDto.getPlotData()) {
          handler.add(new DataPoint(pointDto.getX(), pointDto.getY()));
        }
      }

      // Add X axis label
      Label xLabel = new Label(plotSeriesDto.getXAxisLabel());
      xLabel.addStyleName(getResources().css().xAxisLabel());

      Label plotHeader = new Label(plotSeriesDto.getPlotHeader());
      plotHeader.addStyleName(getResources().css().plotHeader());

      Label plotLegend = new Label("PLOT LEGEND");
      plotLegend.addStyleName(getResources().css().plotLegend());

      VerticalPanel vp = new VerticalPanel();
      vp.setWidth("100%");

      Label panLeftLabel = new Label();
      panLeftLabel.addStyleName(getResources().css().panLabel());
      panLeftLabel.getElement().appendChild(new Image(getResources().getArrowLeft()).getElement());
      panLeftLabel.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              plot.pan(new Pan().setLeft(-100));
            }
          });

      Label panRightLabel = new Label();
      panRightLabel.addStyleName(getResources().css().panLabel());
      panRightLabel
          .getElement()
          .appendChild(new Image(getResources().getArrowRight()).getElement());
      panRightLabel.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              plot.pan(new Pan().setLeft(100));
            }
          });

      Label zoomInLabel = new Label("Zoom In");
      zoomInLabel.addStyleName(getResources().css().zoomLabel());
      zoomInLabel.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              plot.zoom();
            }
          });

      Label zoomOutLabel = new Label("Zoom Out");
      zoomOutLabel.addStyleName(getResources().css().zoomLabel());
      zoomOutLabel.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              plot.zoomOut();
            }
          });

      FlowPanel zoomPanel = new FlowPanel();
      zoomPanel.addStyleName(getResources().css().zoomPanel());
      zoomPanel.add(panLeftLabel);
      zoomPanel.add(panRightLabel);
      zoomPanel.add(zoomInLabel);
      zoomPanel.add(zoomOutLabel);

      vp.add(plotHeader);
      vp.add(zoomPanel);
      vp.add(plot);
      vp.add(xLabel);
      // Will be added if there is need it
      // vp.add(plotLegend);

      plotGroupPanel.add(vp);
    }
    int loadingId = panel.getWidgetCount() - 1;
    panel.remove(loadingId);
    panel.add(plotGroupPanel);

    // Redraw plot
    if (redrawingPlot != null) {
      redrawingPlot.redraw();
    }
  }
 private void addParameter(String key, String value) {
   parametersPanel.add(buildParameterEntry(key, value));
 }
Beispiel #8
0
  private void loadModule() {

    // basic settings
    session.setUiElements(new UiElements(null));

    // Get web page's BODY
    RootLayoutPanel body = RootLayoutPanel.get();

    // check RPC url
    if (session.getRpcUrl().isEmpty()) {
      VerticalPanel bodyContents = new VerticalPanel();
      bodyContents.setSize("100%", "300px");
      bodyContents.add(
          new HTML(new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>RPC SERVER NOT FOUND!</h2>"));
      bodyContents.setCellHorizontalAlignment(
          bodyContents.getWidget(0), HasHorizontalAlignment.ALIGN_CENTER);
      bodyContents.setCellVerticalAlignment(
          bodyContents.getWidget(0), HasVerticalAlignment.ALIGN_BOTTOM);
      body.add(bodyContents);
      return;
    }

    // WEB PAGE SPLITTER
    bodySplitter.getElement().setId("appFormGUI");
    body.add(bodySplitter);

    // left menu
    leftMenu = new ApplicationFormLeftMenu();

    // show loading box
    loadingBox = session.getUiElements().perunLoadingBox();
    loadingBox.show();

    // switch menu event
    JsonCallbackEvents events =
        new JsonCallbackEvents() {
          @Override
          public void onFinished(JavaScriptObject jso) {

            bodySplitter.clear();
            bodySplitter.addSouth(getFooter(), 23);
            ArrayList<Application> apps = JsonUtils.jsoAsList(jso);
            if (apps != null && !apps.isEmpty()) {
              // show menu
              bodySplitter.addWest(leftMenu, 280);
            }
            // else don't show menu
            // MAIN CONTENT
            contentPanel.setSize("100%", "100%");
            contentPanel.add(leftMenu.getContent());
            bodySplitter.add(contentPanel);

            // Append more GUI elements from UiElements class which are not part of splitted design
            // WE DON'T WANT TO CONFUSE USER WITH STATUS MESSAGES
            // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status

            // starts loading
            isUserMemberOfVo();

            // hides the loading box
            loadingBox.hide();
          }

          @Override
          public void onError(PerunError error) {
            // MAIN CONTENT

            bodySplitter.clear();
            bodySplitter.addSouth(getFooter(), 23);
            contentPanel.clear();
            contentPanel.setSize("100%", "100%");
            contentPanel.add(leftMenu.getContent());
            bodySplitter.add(contentPanel);

            // Append more GUI elements from UiElements class which are not part of splitted design
            // bodySplitter.getElement().appendChild(session.getUiElements().getStatus().getElement()); // status

            // starts loading
            isUserMemberOfVo();

            // hides the loading box
            loadingBox.hide();
          }
        };

    // load VO to check if exists
    loadVo(events);
  }
  public Widget draw() {

    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": settings");

    // Main panel
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");

    final TabMenu menu = new TabMenu();

    // Adds menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");

    // IDS
    final Map<String, Integer> ids = new HashMap<String, Integer>();
    ids.put("group", groupId);

    // define GET ATTRIBUTES callback
    final GetAttributesV2 jsonCallback = new GetAttributesV2();
    jsonCallback.setIds(ids);
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
      jsonCallback.setCheckable(false);
    final CellTable<Attribute> table = jsonCallback.getEmptyTable();
    table.setWidth("100%");
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    vp.add(sp);

    // define GET RES. REQ ATTRIBUTES callback
    final GetResourceRequiredAttributesV2 reqAttrs =
        new GetResourceRequiredAttributesV2(
            null, JsonCallbackEvents.passDataToAnotherCallback(jsonCallback));

    // GROUP RESOURCES LISTBOX
    final ListBoxWithObjects<Resource> resourceDropDown = new ListBoxWithObjects<Resource>();
    resourceDropDown.setTitle(
        "By selecting a resource you will switch to either group-resource or member-resource setting (you must pick member too)");

    // fill table with group attributes on page load
    if (lastSelectedMemberId == 0 && lastSelectedResourceId == 0) {
      jsonCallback.retrieveData();
    } else {
      // load attrs by listbox selection after calls are done
      Scheduler.get()
          .scheduleFixedPeriod(
              new Scheduler.RepeatingCommand() {
                @Override
                public boolean execute() {
                  // load proper table if something was selected
                  if (resCallDone && memCallDone) {
                    // trigger change event
                    DomEvent.fireNativeEvent(Document.get().createChangeEvent(), resourceDropDown);
                    return false;
                  }
                  return true;
                }
              },
              200);
    }

    // fill resources listbox
    if (resources == null) {
      // get assigned resources
      GetAssignedResources resources =
          new GetAssignedResources(
              groupId,
              PerunEntity.GROUP,
              new JsonCallbackEvents() {
                public void onFinished(JavaScriptObject jso) {
                  ArrayList<Resource> resources = JsonUtils.jsoAsList(jso);
                  resourceDropDown.clear();
                  if (resources != null && !resources.isEmpty()) {
                    resources = new TableSorter<Resource>().sortByName(resources);
                    resourceDropDown.addNotSelectedOption();
                    for (int i = 0; i < resources.size(); i++) {
                      resourceDropDown.addItem(resources.get(i));
                      if (lastSelectedResourceId == resources.get(i).getId()) {
                        resourceDropDown.setSelected(resources.get(i), true);
                      }
                    }
                  } else {
                    resourceDropDown.addItem("No resources available");
                  }
                  resCallDone = true;
                }

                public void onError(PerunError error) {
                  resourceDropDown.clear();
                  resourceDropDown.addItem("Error while loading");
                  resCallDone = true;
                }

                public void onLoadingStart() {
                  resCallDone = false;
                  resourceDropDown.clear();
                  resourceDropDown.addItem("Loading...");
                }
              });
      resources.retrieveData();

    } else {
      // use predefined resources
      resourceDropDown.addNotSelectedOption();
      resources = new TableSorter<Resource>().sortByName(resources);
      resourceDropDown.addAllItems(resources);
    }

    // GROUP MEMBERS LISTBOX
    final ListBoxWithObjects<RichMember> membersDropDown = new ListBoxWithObjects<RichMember>();
    membersDropDown.setTitle(
        "By selecting a member you will switch to either member or member-resource settings (you must pick resource too)");

    // fill members listbox
    GetGroupRichMembers members =
        new GetGroupRichMembers(
            groupId,
            new JsonCallbackEvents() {
              public void onFinished(JavaScriptObject jso) {
                ArrayList<RichMember> mems = JsonUtils.jsoAsList(jso);
                membersDropDown.clear();
                if (mems != null && !mems.isEmpty()) {
                  mems = new TableSorter<RichMember>().sortByName(mems);
                  membersDropDown.addNotSelectedOption();
                  for (int i = 0; i < mems.size(); i++) {
                    membersDropDown.addItem(mems.get(i));
                    if (mems.get(i).getId() == lastSelectedMemberId) {
                      membersDropDown.setSelected(mems.get(i), true);
                    }
                  }
                } else {
                  membersDropDown.addItem("No members available");
                }
                memCallDone = true;
              }

              public void onError(PerunError error) {
                membersDropDown.clear();
                membersDropDown.addItem("Error while loading");
                memCallDone = true;
              }

              public void onLoadingStart() {
                memCallDone = false;
                membersDropDown.clear();
                membersDropDown.addItem("Loading...");
              }
            });
    members.retrieveData();

    // CHECKBOXES "FOR ALL MEMBERS"
    final CheckBox memChb = new CheckBox();
    memChb.setText("To all members");
    memChb.setVisible(false);
    memChb.setTitle("Uses this setting for all members of this group.");
    memChb.setValue(false);

    // SAVE CHANGES BUTTON
    final CustomButton saveChangesButton =
        TabMenu.getPredefinedButton(
            ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
      saveChangesButton.setEnabled(false);

    // click handler to save group and member-user attributes
    final ClickHandler saveAttrsClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<Attribute> list = jsonCallback.getTableSelectedList();

            if (UiElements.cantSaveEmptyListDialogBox(list)) {

              // refresh table and disable button a event for GetAttributes
              final JsonCallbackEvents events =
                  JsonCallbackEvents.disableButtonEvents(
                      saveChangesButton, JsonCallbackEvents.refreshTableEvents(jsonCallback));

              if (memChb.getValue() == true) {
                // to all members selected
                UiElements.generateInfo(
                    WidgetTranslation.INSTANCE.saveConfirmTitle(),
                    "Same value(s) for selected attribute(s) will be set to ALL members of group.",
                    new ClickHandler() {
                      public void onClick(ClickEvent event) {
                        ArrayList<RichMember> memList = membersDropDown.getAllObjects();
                        for (int i = 0; i < memList.size(); i++) {
                          SetAttributes request = new SetAttributes();
                          if (i == memList.size() - 1) {
                            request.setEvents(events);
                          } else {
                            request.setEvents(
                                JsonCallbackEvents.disableButtonEvents(saveChangesButton));
                          }
                          Map<String, Integer> ids = new HashMap<String, Integer>();
                          ids.put("member", memList.get(i).getId());
                          ids.put("workWithUserAttributes", 1);
                          request.setAttributes(ids, list);
                        }
                      }
                    });
              } else {
                // just one group / memeber
                SetAttributes request = new SetAttributes(events);
                request.setAttributes(jsonCallback.getIds(), list);
              }
            }
          }
        };

    // click handler to save required attributes
    final ClickHandler saveReqAttrsClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<Attribute> list = jsonCallback.getTableSelectedList();
            // check if not empty
            if (UiElements.cantSaveEmptyListDialogBox(list)) {

              // refresh table and disable button a event for GetResourceRequiredAttributes
              final JsonCallbackEvents events =
                  JsonCallbackEvents.disableButtonEvents(
                      saveChangesButton,
                      new JsonCallbackEvents() {
                        public void onFinished(JavaScriptObject jso) {
                          jsonCallback.clearTable();
                          // set back resourceToGetServicesFrom
                          Map<String, Integer> ids = reqAttrs.getIds();
                          if (ids.containsKey("resource")) {
                            ids.put("resourceToGetServicesFrom", ids.get("resource"));
                          }
                          if (ids.containsKey("user")) {
                            ids.put("workWithUserAttributes", 1);
                          }
                          if (ids.containsKey("resource") && ids.containsKey("group")) {
                            ids.put("workWithGroupAttributes", 1);
                          }
                          reqAttrs.setIds(ids);
                          reqAttrs.retrieveData();
                        }
                      });

              final SetAttributes request = new SetAttributes();

              if (memChb.getValue() == true) {
                // to all members selected
                UiElements.generateInfo(
                    WidgetTranslation.INSTANCE.saveConfirmTitle(),
                    "Same value(s) for selected attribute(s) will be set to ALL members of group.",
                    new ClickHandler() {
                      public void onClick(ClickEvent event) {
                        ArrayList<RichMember> memList = membersDropDown.getAllObjects();
                        for (int i = 0; i < memList.size(); i++) {
                          if (i == 0) {
                            events.onLoadingStart();
                          } // trigger disable button if first
                          Map<String, Integer> ids = new HashMap<String, Integer>();
                          ids.put("member", memList.get(i).getId());
                          ids.put("user", memList.get(i).getUserId());
                          ids.put("resource", resourceDropDown.getSelectedObject().getId());
                          ids.put("facility", resourceDropDown.getSelectedObject().getFacilityId());
                          if (i == memList.size() - 1) {
                            request.setEvents(events);
                          } // set events to last to get refresh and button enable
                          request.setAttributes(ids, list);
                        }
                      }
                    });
              } else {
                // group or member
                request.setEvents(events); // disable button events
                request.setAttributes(reqAttrs.getIds(), list);
              }
            }
          }
        };

    // REMOVE BUTTON
    final CustomButton removeButton =
        TabMenu.getPredefinedButton(
            ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeAttributes());
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
      removeButton.setEnabled(false);

    // click handler to remove group and member-user attributes
    final ClickHandler removeAttrsClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<Attribute> list = jsonCallback.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {

              // refresh table and disable button a event for GetAttributes
              final JsonCallbackEvents events =
                  JsonCallbackEvents.disableButtonEvents(
                      removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback));

              final RemoveAttributes request = new RemoveAttributes();

              if (memChb.getValue() == true) {
                // to all members selected
                UiElements.generateInfo(
                    WidgetTranslation.INSTANCE.deleteConfirmTitle(),
                    "Selected attribute(s) will be removed from ALL members of group.",
                    new ClickHandler() {
                      public void onClick(ClickEvent event) {
                        ArrayList<RichMember> memList = membersDropDown.getAllObjects();
                        for (int i = 0; i < memList.size(); i++) {
                          if (i == 0) {
                            events.onLoadingStart();
                          } // trigger disable button if first
                          Map<String, Integer> ids = new HashMap<String, Integer>();
                          ids.put("member", memList.get(i).getId());
                          ids.put("workWithUserAttributes", 1);
                          if (i == memList.size() - 1) {
                            request.setEvents(events);
                          } // set events to last to get refresh and button enable
                          request.removeAttributes(ids, list);
                        }
                      }
                    });
              } else {
                // just one group / memeber
                request.setEvents(events); // disable button events
                request.removeAttributes(jsonCallback.getIds(), list);
              }
            }
          }
        };

    // click handler to remove ResourceRequiredAttributes
    final ClickHandler removeReqAttrsClickHandler =
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            final ArrayList<Attribute> list = jsonCallback.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {

              // refresh table and disable button a event for GetAttributes
              final JsonCallbackEvents events =
                  JsonCallbackEvents.disableButtonEvents(
                      removeButton,
                      new JsonCallbackEvents() {
                        public void onFinished(JavaScriptObject jso) {
                          jsonCallback.clearTable();
                          // set back resourceToGetServicesFrom
                          Map<String, Integer> ids = reqAttrs.getIds();
                          if (ids.containsKey("resource")) {
                            ids.put("resourceToGetServicesFrom", ids.get("resource"));
                          }
                          if (ids.containsKey("user")) {
                            ids.put("workWithUserAttributes", 1);
                          }
                          if (ids.containsKey("resource") && ids.containsKey("group")) {
                            ids.put("workWithGroupAttributes", 1);
                          }
                          reqAttrs.setIds(ids);
                          reqAttrs.retrieveData();
                        }
                      });

              final RemoveAttributes request = new RemoveAttributes();

              if (memChb.getValue() == true) {
                // to all members selected
                UiElements.generateInfo(
                    WidgetTranslation.INSTANCE.deleteConfirmTitle(),
                    "Selected attribute(s) will be removed from ALL members of group.",
                    new ClickHandler() {
                      @Override
                      public void onClick(ClickEvent event) {
                        ArrayList<RichMember> memList = membersDropDown.getAllObjects();
                        for (int i = 0; i < memList.size(); i++) {
                          if (i == 0) {
                            events.onLoadingStart();
                          } // trigger disable button if first
                          Map<String, Integer> ids = new HashMap<String, Integer>();
                          ids.put("member", memList.get(i).getId());
                          ids.put("user", memList.get(i).getUserId());
                          ids.put("resource", resourceDropDown.getSelectedObject().getId());
                          ids.put("facility", resourceDropDown.getSelectedObject().getFacilityId());
                          if (i == memList.size() - 1) {
                            request.setEvents(events);
                          } // set events to last to get refresh and button enable
                          request.removeAttributes(ids, list);
                        }
                      }
                    });
              } else {
                // just one group / member
                request.setEvents(events); // disable button events
                request.removeAttributes(reqAttrs.getIds(), list);
              }
            }
          }
        };

    // SET NEW ATTR BUTTON
    final CustomButton setNewAttributeButton =
        TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.setNewAttributes());
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
      setNewAttributeButton.setEnabled(false);
    // click handler
    setNewAttributeButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            ids.clear();
            if (resourceDropDown.getSelectedIndex() > 0) {
              if (membersDropDown.getSelectedIndex() > 0) {
                ids.put("member", membersDropDown.getSelectedObject().getId());
                ids.put("user", membersDropDown.getSelectedObject().getUserId());
                ids.put("resource", resourceDropDown.getSelectedObject().getId());
                ids.put("facility", resourceDropDown.getSelectedObject().getFacilityId());
              } else {
                ids.put("resource", resourceDropDown.getSelectedObject().getId());
                ids.put("group", groupId);
                ids.put("workWithGroupAttributes", 1);
              }
            } else {
              if (membersDropDown.getSelectedIndex() > 0) {
                ids.put("member", membersDropDown.getSelectedObject().getId());
                ids.put("user", membersDropDown.getSelectedObject().getUserId());
              } else {
                ids.put("group", groupId);
              }
            }
            session
                .getTabManager()
                .addTabToCurrentTab(new SetNewAttributeTabItem(ids, jsonCallback.getList()), true);
          }
        });

    // ClickHandlersRegistration - save onClicks for GetAttributes
    final ArrayList<HandlerRegistration> clickHandlers = new ArrayList<HandlerRegistration>();
    clickHandlers.add(saveChangesButton.addClickHandler(saveAttrsClickHandler));
    clickHandlers.add(removeButton.addClickHandler(removeAttrsClickHandler));

    // DEFINE CHANGE HANDLER FOR ALL DROP DOWNS
    ChangeHandler changeHandler =
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {

            int resIndex = resourceDropDown.getSelectedIndex();
            int memIndex = membersDropDown.getSelectedIndex();

            // no resource or member selected
            if (resIndex == 0 && memIndex == 0) {
              lastSelectedMemberId = 0;
              lastSelectedResourceId = 0;
              memChb.setValue(false);
              memChb.setVisible(false);
              jsonCallback.clearTable();
              ids.clear();
              ids.put("group", groupId);
              jsonCallback.setIds(ids);
              jsonCallback.retrieveData();
              for (HandlerRegistration handler : clickHandlers) {
                if (handler != null) {
                  handler.removeHandler();
                }
              }
              clickHandlers.add(saveChangesButton.addClickHandler(saveAttrsClickHandler));
              clickHandlers.add(removeButton.addClickHandler(removeAttrsClickHandler));
            }
            // no resource but member selected
            if (resIndex == 0 && memIndex > 0) {
              lastSelectedMemberId = membersDropDown.getSelectedObject().getId();
              lastSelectedResourceId = 0;
              memChb.setValue(false);
              memChb.setVisible(true);
              jsonCallback.clearTable();
              ids.clear();
              ids.put("member", membersDropDown.getSelectedObject().getId());
              ids.put("workWithUserAttributes", 1);
              jsonCallback.setIds(ids);
              jsonCallback.retrieveData();
              for (HandlerRegistration handler : clickHandlers) {
                if (handler != null) {
                  handler.removeHandler();
                }
              }
              clickHandlers.add(saveChangesButton.addClickHandler(saveAttrsClickHandler));
              clickHandlers.add(removeButton.addClickHandler(removeAttrsClickHandler));
            }
            // resource and no member selected
            if (resIndex > 0 && memIndex == 0) {
              lastSelectedMemberId = 0;
              lastSelectedResourceId = resourceDropDown.getSelectedObject().getId();
              memChb.setValue(false);
              memChb.setVisible(false);
              jsonCallback.clearTable();
              ids.clear();
              ids.put("group", groupId);
              ids.put("resource", resourceDropDown.getSelectedObject().getId());
              ids.put("resourceToGetServicesFrom", ids.get("resource"));
              ids.put("workWithGroupAttributes", 1);
              reqAttrs.setIds(ids);
              reqAttrs.retrieveData();
              // set ids back to make saveChanges work
              ids.remove("resourceToGetServicesFrom");
              reqAttrs.setIds(ids);
              for (HandlerRegistration handler : clickHandlers) {
                if (handler != null) {
                  handler.removeHandler();
                }
              }
              clickHandlers.add(saveChangesButton.addClickHandler(saveReqAttrsClickHandler));
              clickHandlers.add(removeButton.addClickHandler(removeReqAttrsClickHandler));
            }
            // resource and member selected
            if (resIndex > 0 && memIndex > 0) {
              lastSelectedMemberId = membersDropDown.getSelectedObject().getId();
              lastSelectedResourceId = resourceDropDown.getSelectedObject().getId();
              memChb.setValue(false);
              memChb.setVisible(true);
              jsonCallback.clearTable();
              ids.clear();
              ids.put("resource", resourceDropDown.getSelectedObject().getId());
              ids.put("resourceToGetServicesFrom", ids.get("resource"));
              ids.put("member", membersDropDown.getSelectedObject().getId());
              ids.put("workWithUserAttributes", 1);
              reqAttrs.setIds(ids);
              reqAttrs.retrieveData();
              // set ids back to make saveChanges work
              ids.clear();
              ids.put("member", membersDropDown.getSelectedObject().getId());
              ids.put("user", membersDropDown.getSelectedObject().getUser().getId());
              ids.put("facility", resourceDropDown.getSelectedObject().getFacilityId());
              ids.put("resource", resourceDropDown.getSelectedObject().getId());
              reqAttrs.setIds(ids);
              for (HandlerRegistration handler : clickHandlers) {
                if (handler != null) {
                  handler.removeHandler();
                }
              }
              clickHandlers.add(saveChangesButton.addClickHandler(saveReqAttrsClickHandler));
              clickHandlers.add(removeButton.addClickHandler(removeReqAttrsClickHandler));
            }
          }
        };

    // ADD CHANGE HANDLERS TO DROP-DOWN MENUS
    resourceDropDown.addChangeHandler(changeHandler);
    membersDropDown.addChangeHandler(changeHandler);

    // PUT ELEMENTS IN MENU
    menu.addWidget(saveChangesButton);
    // menu.addWidget(resChb);
    menu.addWidget(memChb);
    menu.addWidget(setNewAttributeButton);
    menu.addWidget(removeButton);
    menu.addWidget(new HTML("<strong>Resources:</strong>"));
    menu.addWidget(resourceDropDown);
    menu.addWidget(new HTML("<strong>Members:</strong>"));
    menu.addWidget(membersDropDown);

    this.contentWidget.setWidget(vp);

    return getWidget();
  }