Package org.damour.base.client.ui.buttons

Examples of org.damour.base.client.ui.buttons.Button


  private void initUI() {
    statsTable.setText(0, 0, "Loading...");
    statsTable.setBorderWidth(1);
    statsTable.setCellSpacing(5);
    add(statsTable);
    Button refreshButton = new Button("Refresh");
    refreshButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        fetchMemoryStats();
      }
    });
    Button gcButton = new Button("Request GC");
    gcButton.setTitle("Request Garbage Collection");
    gcButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        requestGarbageCollection();
      }
    });
View Full Code Here


    });
    principalListBox.setVisibleItemCount(6);
    principalListBox.setWidth("180px");

    VerticalPanel buttonPanel = new VerticalPanel();
    Button addButton = new Button("Add...");
    addButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        final VerticalPanel addPermissionPanel = new VerticalPanel();
        final ListBox addPrincipalListBox = new ListBox(true);
        addPrincipalListBox.setWidth("200px");
        addPrincipalListBox.setVisibleItemCount(12);
        addPermissionPanel.add(addPrincipalListBox);
        if (showUserPerms) {
          AsyncCallback<List<User>> getUsersCallback = new AsyncCallback<List<User>>() {
            public void onFailure(Throwable caught) {
              Window.alert(caught.getMessage());
            }

            public void onSuccess(List<User> users) {
              fetchedUsers.clear();
              for (User user : users) {
                addPrincipalListBox.addItem(user.getUsername());
                fetchedUsers.put(user.getUsername(), user);
              }
            }
          };
          BaseServiceCache.getService().getUsers(getUsersCallback);
        }
        if (showGroupPerms) {
          AsyncCallback<List<UserGroup>> getGroupsCallback = new AsyncCallback<List<UserGroup>>() {
            public void onFailure(Throwable caught) {
              Window.alert(caught.getMessage());
            }

            public void onSuccess(List<UserGroup> groups) {
              fetchedGroups.clear();
              for (UserGroup group : groups) {
                addPrincipalListBox.addItem(group.getName());
                fetchedGroups.put(group.getName(), group);
              }
            }
          };
          BaseServiceCache.getService().getGroups(AuthenticationHandler.getInstance().getUser(), getGroupsCallback);
        }

        PromptDialogBox dialog = new PromptDialogBox("Add New Permission", "OK", null, "Cancel", false, true);
        dialog.setContent(addPermissionPanel);
        dialog.setCallback(new IDialogCallback() {
          public void okPressed() {
            for (int i = 0; i < addPrincipalListBox.getItemCount(); i++) {
              if (addPrincipalListBox.isItemSelected(i)) {
                Permission newPerm = new Permission();
                newPerm.setPermissibleObject(permissibleObject);
                SecurityPrincipal principal = fetchedUsers.get(addPrincipalListBox.getItemText(i));
                if (principal == null) {
                  principal = fetchedGroups.get(addPrincipalListBox.getItemText(i));
                }
                newPerm.setSecurityPrincipal(principal);
                permissions.add(newPerm);
                dirty = true;
                populateUI();
                if (principalListBox.getItemCount() > 0) {
                  principalListBox.setSelectedIndex(principalListBox.getItemCount() - 1);
                }
                populatePermissionPanel();
              }
            }
          }

          public void cancelPressed() {
          }
        });
        dialog.center();
      }
    });

    Button removeButton = new Button("Remove...");
    removeButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        String principalName = principalListBox.getValue(principalListBox.getSelectedIndex());
        Permission permission = null;
        for (Permission mypermission : permissions) {
          if (showUserPerms && mypermission.getSecurityPrincipal() instanceof User) {
            User user = (User) mypermission.getSecurityPrincipal();
            if (principalName.equalsIgnoreCase(user.getUsername())) {
              permission = mypermission;
              break;
            }
          } else if (showGroupPerms && mypermission.getSecurityPrincipal() instanceof UserGroup) {
            UserGroup group = (UserGroup) mypermission.getSecurityPrincipal();
            if (principalName.equalsIgnoreCase(group.getName())) {
              permission = mypermission;
              break;
            }
          }
        }
        permissions.remove(permission);
        dirty = true;
        populateUI();
        if (principalListBox.getItemCount() > 0) {
          principalListBox.setSelectedIndex(principalListBox.getItemCount() - 1);
        }
        populatePermissionPanel();
      }
    });

    Button newButton = new Button("New...");
    newButton.setCommand(new CreateGroupCommand(AuthenticationHandler.getInstance().getUser(), new IGenericCallback<UserGroup>() {
      public void invoke(UserGroup group) {
        dirty = true;
        Permission newPerm = new Permission();
        newPerm.setPermissibleObject(permissibleObject);
        newPerm.setSecurityPrincipal(group);
View Full Code Here

    emailTextBox.setText(user.getEmail());
    validatedCheckBox.setValue(user.isValidated());
    administratorCheckBox.setValue(user.isAdministrator());
    birthdayPicker.setValue(birthday);

    Button applyButton = new Button("Apply");
    applyButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        user.setUsername(usernameTextBox.getText());
        user.setPasswordHint(passwordHintTextBox.getText());
        user.setFirstname(firstnameTextBox.getText());
        user.setLastname(lastnameTextBox.getText());
        user.setEmail(emailTextBox.getText());
        user.setBirthday(birthdayPicker.getValue().getTime());
        user.setAdministrator(administratorCheckBox.getValue());
        user.setValidated(validatedCheckBox.getValue());
        final AsyncCallback<User> loginCallback = new AsyncCallback<User>() {
          public void onFailure(Throwable caught) {
            MessageDialogBox dialog = new MessageDialogBox("Error", "Could not edit account.", true, true, true);
            dialog.center();
          }

          public void onSuccess(User user) {
            if (user == null) {
              MessageDialogBox dialog = new MessageDialogBox("Error", "Could not edit account.", true, true, true);
              dialog.center();
            } else {
              MessageDialogBox dialog = new MessageDialogBox("Success", "Account modified.", true, true, true);
              dialog.center();
              callback.invoke(user);
            }
          };
        };

        BaseServiceCache.getService().createOrEditAccount(user, passwordTextBox.getText(), null, loginCallback);
      }
    });
    applyButton.setTitle("Apply Changes");

    // build ui
    int row = 0;
    setWidget(row, 0, new Label("Username"));
    setWidget(row, 1, usernameTextBox);
View Full Code Here

    final ListBox choiceCombo = new ListBox(false);
    choiceCombo.addItem("Approve");
    choiceCombo.addItem("Deny");
    whatToDoPanel.add(choiceCombo);

    Button submitButton = new Button("Submit");
    submitButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        if (choiceCombo.getItemText(choiceCombo.getSelectedIndex()).equalsIgnoreCase("Approve")) {
          submitPendingGroupMembershipApproval(selectedPGMSet, true);
        } else {
          submitPendingGroupMembershipApproval(selectedPGMSet, false);
View Full Code Here

  final FlexTable dialogContent = new FlexTable();

  public PromptDialogBox(String title, String okText, Button customButton, String cancelText, boolean autoHide, boolean modal) {
    super(autoHide, modal);
    setText(title);
    Button ok = new Button(okText);
    ok.addClickHandler(new ClickHandler() {

      public void onClick(ClickEvent event) {
        if (validatorCallback == null || (validatorCallback != null && validatorCallback.validate())) {
          hide();
          if (callback != null) {
            callback.okPressed();
          }
        }
      }
    });
    final HorizontalPanel dialogButtonPanel = new HorizontalPanel();
    dialogButtonPanel.setSpacing(2);
    dialogButtonPanel.add(ok);
    if (customButton != null) {
      dialogButtonPanel.add(customButton);
    }
    if (cancelText != null) {
      Button cancel = new Button(cancelText);
      cancel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
          hide();
          if (callback != null) {
            callback.cancelPressed();
View Full Code Here

    queryResultTextBox.setWidth("1024px");
    queryTextBox.setVisibleLines(5);
    queryResultTextBox.setVisibleLines(20);
   
    add(queryTextBox);
    Button executeQueryButton = new Button("Execute");
    executeQueryButton.addClickHandler(new ClickHandler() {
     
      public void onClick(ClickEvent event) {
        executeQuery();
      }
    });
View Full Code Here

    }
    autoJoinCheckBox.setValue(group.isAutoJoin());
    lockGroupCheckBox.setValue(group.isLocked());
    visibleCheckBox.setValue(group.isVisible());

    Button applyButton = new Button("Apply");
    applyButton.addClickHandler(new ClickHandler() {
     
      public void onClick(ClickEvent event) {
        apply();
      }
    });
    applyButton.setTitle("Apply Changes");

    // build ui
    int row = 0;
    setWidget(row, 0, new Label("Name"));
    setWidget(row, 1, nameTextBox);
View Full Code Here

    setHeight("100%");
    setWidth("100%");

    VerticalPanel buttonPanel = new VerticalPanel();

    Button newGroupButton = new Button("New...");
    newGroupButton.setTitle("Create a New Group");
    newGroupButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        final UserGroup group = new UserGroup();
        group.setOwner(user);
        editGroupPanel = new EditGroupPanel(callback, EditGroupsPanel.this, users, group, false, true);
        final PromptDialogBox editGroupDialogBox = new PromptDialogBox("Create New Group", "OK", null, "Cancel", false, true);
        editGroupDialogBox.setContent(editGroupPanel);
        editGroupDialogBox.setCallback(new IDialogCallback() {
          public void okPressed() {
            if (!editGroupPanel.apply()) {
              editGroupDialogBox.center();
            } else {
              populateUI();
              if (callback != null) {
                callback.userGroupsFetched(groups);
              }
            }
          }

          public void cancelPressed() {
          }
        });
        editGroupDialogBox.center();
      }
    });

    deleteGroupButton.setTitle("Delete Group");
    deleteGroupButton.setEnabled(false);
    deleteGroupButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {

        if (groupsList.getSelectedIndex() < 0) {
          return;
        }

        final UserGroup group = groupMap.get(groupsList.getItemText(groupsList.getSelectedIndex()));

        final PromptDialogBox deleteGroupDialogBox = new PromptDialogBox("Confirm", "Yes", null, "No", false, true);
        deleteGroupDialogBox.setContent(new Label("Delete Group: " + group.getName() + "?"));
        deleteGroupDialogBox.setCallback(new IDialogCallback() {
          public void okPressed() {
            final AsyncCallback<Void> deleteGroupCallback = new AsyncCallback<Void>() {
              public void onFailure(Throwable caught) {
                MessageDialogBox dialog = new MessageDialogBox("Error", caught.getMessage(), true, true, true);
                dialog.center();
              }

              public void onSuccess(Void nothing) {
                groups.remove(group);
                lastListSelection = null;
                populateUI();
                if (callback != null) {
                  callback.userGroupsFetched(groups);
                }
              };
            };
            BaseServiceCache.getService().deleteGroup(group, deleteGroupCallback);

          }

          public void cancelPressed() {
          }
        });
        deleteGroupDialogBox.center();
      }
    });
    editGroupButton.setTitle("Edit Group Settings");
    editGroupButton.setEnabled(false);
    editGroupButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        if (groupsList.getSelectedIndex() < 0) {
          return;
        }
        final UserGroup group = groupMap.get(groupsList.getItemText(groupsList.getSelectedIndex()));
        editGroupPanel = new EditGroupPanel(callback, EditGroupsPanel.this, users, group, false, true);
        final PromptDialogBox editGroupDialogBox = new PromptDialogBox("Edit Group", "OK", null, "Cancel", false, true);
        editGroupDialogBox.setContent(editGroupPanel);
        editGroupDialogBox.setCallback(new IDialogCallback() {
          public void okPressed() {
            if (!editGroupPanel.apply()) {
              editGroupDialogBox.center();
            } else {
              if (callback != null) {
                callback.userGroupsFetched(groups);
              }
            }
          }

          public void cancelPressed() {
          }
        });
        editGroupDialogBox.center();
      }
    });
    buttonPanel.add(newGroupButton);
    buttonPanel.add(editGroupButton);
    buttonPanel.add(deleteGroupButton);

    Button refreshButton = new Button("Refresh");
    refreshButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        groupsList.clear();
        groupsList.addItem("Loading...");
        setWidget(0, 1, new Label());
        fetchGroups();
View Full Code Here

TOP

Related Classes of org.damour.base.client.ui.buttons.Button

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.