Exemplo n.º 1
0
 private void row(Grid grid, int row, String name, Widget field) {
   final CellFormatter fmt = grid.getCellFormatter();
   if (LocaleInfo.getCurrentLocale().isRTL()) {
     grid.setText(row, 1, name);
     grid.setWidget(row, 0, field);
     fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().header());
   } else {
     grid.setText(row, 0, name);
     grid.setWidget(row, 1, field);
     fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().header());
   }
 }
Exemplo n.º 2
0
  public void loadTable(final IncludedInDetail detail) {
    int row = 0;
    table.resizeRows(detail.getBranches().size() + 1);
    table.addStyleName(Gerrit.RESOURCES.css().changeTable());
    final CellFormatter fmt = table.getCellFormatter();
    fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().dataHeader());
    table.setText(row, 0, Util.C.includedInTableBranch());

    for (final String branch : detail.getBranches()) {
      fmt.addStyleName(++row, 0, Gerrit.RESOURCES.css().dataCell());
      fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().leftMostCell());
      table.setText(row, 0, branch);
    }

    if (!detail.getTags().isEmpty()) {
      table.resizeRows(table.getRowCount() + 2 + detail.getTags().size());
      row++;
      fmt.addStyleName(++row, 0, Gerrit.RESOURCES.css().dataHeader());
      table.setText(row, 0, Util.C.includedInTableTag());

      for (final String tag : detail.getTags()) {
        fmt.addStyleName(++row, 0, Gerrit.RESOURCES.css().dataCell());
        fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().leftMostCell());
        table.setText(row, 0, tag);
      }
    }

    table.setVisible(true);
    loaded = true;
  }
Exemplo n.º 3
0
  @Override
  protected void onInitUI() {
    super.onInitUI();

    tokenLabel = new CopyableLabel("");
    tokenLabel.addStyleName(Gerrit.RESOURCES.css().oauthToken());

    expiresLabel = new Label("");
    expiresLabel.addStyleName(Gerrit.RESOURCES.css().oauthExpires());

    grid = new Grid(2, 2);
    grid.setStyleName(Gerrit.RESOURCES.css().infoBlock());
    grid.addStyleName(Gerrit.RESOURCES.css().oauthInfoBlock());
    add(grid);

    expiredNote = new Label(Util.C.labelOAuthExpired());
    expiredNote.setVisible(false);
    add(expiredNote);

    row(grid, 0, Util.C.labelOAuthToken(), tokenLabel);
    row(grid, 1, Util.C.labelOAuthExpires(), expiresLabel);

    CellFormatter fmt = grid.getCellFormatter();
    fmt.addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
    fmt.addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
    fmt.addStyleName(1, 0, Gerrit.RESOURCES.css().bottomheader());

    flow = new FlowPanel();
    flow.setStyleName(Gerrit.RESOURCES.css().oauthPanel());
    add(flow);

    Label netrcLabel = new Label(Util.C.labelOAuthNetRCEntry());
    netrcLabel.setStyleName(Gerrit.RESOURCES.css().oauthPanelNetRCHeading());
    flow.add(netrcLabel);
    netrcValue = new CopyableLabel("");
    netrcValue.setStyleName(Gerrit.RESOURCES.css().oauthPanelNetRCEntry());
    flow.add(netrcValue);

    Label cookieLabel = new Label(Util.C.labelOAuthGitCookie());
    cookieLabel.setStyleName(Gerrit.RESOURCES.css().oauthPanelCookieHeading());
    flow.add(cookieLabel);
    cookieValue = new CopyableLabel("");
    cookieValue.setStyleName(Gerrit.RESOURCES.css().oauthPanelCookieEntry());
    flow.add(cookieValue);
  }
Exemplo n.º 4
0
 @Override
 protected void setup() {
   // Set up backwards.
   backwards = new PushButton();
   backwards.addClickHandler(
       new ClickHandler() {
         @Override
         public void onClick(ClickEvent event) {
           addMonths(-1);
         }
       });
   backwards.getUpFace().setHTML("‹");
   backwards.setStyleName(BASE_NAME + "PreviousButton");
   forwards = new PushButton();
   forwards.getUpFace().setHTML("›");
   forwards.setStyleName(BASE_NAME + "NextButton");
   forwards.addClickHandler(
       new ClickHandler() {
         @Override
         public void onClick(ClickEvent event) {
           addMonths(+1);
         }
       });
   // Set up backwards year
   backwardsYear = new PushButton();
   backwardsYear.addClickHandler(
       new ClickHandler() {
         @Override
         public void onClick(ClickEvent event) {
           addMonths(-12);
         }
       });
   backwardsYear.getUpFace().setHTML("«");
   backwardsYear.setStyleName(BASE_NAME + "PreviousButton");
   forwardsYear = new PushButton();
   forwardsYear.getUpFace().setHTML("»");
   forwardsYear.setStyleName(BASE_NAME + "NextButton");
   forwardsYear.addClickHandler(
       new ClickHandler() {
         @Override
         public void onClick(ClickEvent event) {
           addMonths(+12);
         }
       });
   // Set up grid.
   grid = new Grid(1, 5);
   grid.setWidget(0, previousYearColumn, backwardsYear);
   grid.setWidget(0, previousMonthColumn, backwards);
   grid.setWidget(0, nextMonthColumn, forwards);
   grid.setWidget(0, nextYearColumn, forwardsYear);
   CellFormatter formatter = grid.getCellFormatter();
   formatter.setStyleName(0, monthColumn, BASE_NAME + "Month");
   formatter.setWidth(0, previousYearColumn, "1");
   formatter.setWidth(0, previousMonthColumn, "1");
   formatter.setWidth(0, monthColumn, "100%");
   formatter.setWidth(0, nextMonthColumn, "1");
   formatter.setWidth(0, nextYearColumn, "1");
   grid.setStyleName(BASE_NAME + "MonthSelector");
   initWidget(grid);
 }
Exemplo n.º 5
0
  /**
   * Inits the widget SortableTable, by Parvinder Thapa
   *
   * @link<http://psthapar.googlepages.com/simplesortabletable>
   */
  private void initSortableTable() {
    // sortableTable = new SortableTable();

    table = new FlexTable();

    table.setWidth(500 + "px");
    table.setStyleName("sortableTable");
    table.setBorderWidth(1);
    table.setCellPadding(4);
    table.setCellSpacing(1);

    // sortableTable.setWidth(500 + "px");
    // sortableTable.setStyleName("sortableTable");
    // sortableTable.setBorderWidth(1);
    // sortableTable.setCellPadding(4);
    // sortableTable.setCellSpacing(1);

    // header
    table.setHTML(0, FILE_NAME_COLUMN, FILE_NAME_TEXT);
    table.setHTML(0, STATUS_COLUMN, STATUS_TEXT);
    table.setHTML(0, DATE_COLUMN, DATE_TEXT);
    table.setHTML(0, DOWNLOAD_COLUMN, DOWNLOAD_TEXT);
    // sortableTable.addColumnHeader(FILE_NAME_TEXT, FILE_NAME_COLUMN);
    // sortableTable.addColumnHeader(STATUS_TEXT, STATUS_COLUMN);
    // sortableTable.addColumnHeader(DATE_TEXT, DATE_COLUMN);
    // sortableTable.addColumnHeader(DOWNLOAD_TEXT, DOWNLOAD_COLUMN);

    // COSMETIC PART OF THE WIDGET
    // Set Style Name for the header
    // RowFormatter rowFormatter = sortableTable.getRowFormatter();
    RowFormatter rowFormatter = table.getRowFormatter();
    rowFormatter.setStyleName(0, "tableHeader");

    // Set the Styles for the Data Rows and Columns
    // CellFormatter cellFormatter = sortableTable.getCellFormatter();
    CellFormatter cellFormatter = table.getCellFormatter();
    // Set the styles for the headers
    for (int colIndex = 0; colIndex < 4; colIndex++) {
      cellFormatter.setStyleName(0, colIndex, "headerStyle");
      cellFormatter.setAlignment(
          0, colIndex, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
    }

    for (int rowIndex = 1; rowIndex < 21; rowIndex++) {
      if (rowIndex % 2 == 0) {
        rowFormatter.setStyleName(rowIndex, "customRowStyle");
      } else {
        rowFormatter.setStyleName(rowIndex, "tableRow");
      }
      for (int colIndex = 0; colIndex < 4; colIndex++) {
        cellFormatter.setStyleName(rowIndex, colIndex, "customFont");
        if (colIndex == 1 || colIndex == 3) {
          cellFormatter.setAlignment(
              rowIndex,
              colIndex,
              HasHorizontalAlignment.ALIGN_RIGHT,
              HasVerticalAlignment.ALIGN_MIDDLE);
        } else if (colIndex == 0) {
          cellFormatter.setAlignment(
              rowIndex,
              colIndex,
              HasHorizontalAlignment.ALIGN_LEFT,
              HasVerticalAlignment.ALIGN_MIDDLE);
        }
        if (colIndex == 2) {
          cellFormatter.setAlignment(
              rowIndex,
              colIndex,
              HasHorizontalAlignment.ALIGN_CENTER,
              HasVerticalAlignment.ALIGN_MIDDLE);
        }
      }
    }
    // add(sortableTable);
    add(table);
  }
Exemplo n.º 6
0
 public void formatCell(int row, O o, CellFormatter cellFormatter) {
   String color = getColor(o);
   if (color != null) {
     cellFormatter.getElement(row, index).getStyle().setColor(color);
   }
 }
Exemplo n.º 7
0
 private void updateCellStyle(int row, ExtLevel level, boolean isTraceLine) {
   rowFormatter.getElement(row).getStyle().setColor(LogParser.getColor(level));
   rowFormatter.setStyleName(row, level == null ? "" : level.getName());
   rowFormatter.setVisible(row, level == null ? true : showNames.contains(level.getName()));
   cellFormatter.getElement(row, 0).getStyle().setPaddingLeft(isTraceLine ? 20 : 2, Unit.PX);
 }
Exemplo n.º 8
0
  public EventEditor(final Admin admin, JSEventTemplate et) {
    this.admin = admin;
    this.et = et;

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

    final Label errmsg = new Label();
    errmsg.addStyleName(errmsg.getStylePrimaryName() + "-error");
    errmsg.addStyleName(errmsg.getStylePrimaryName() + "-bottom");

    FlexTable grid = new FlexTable();
    grid.setWidth("100%");

    CellFormatter cf = grid.getCellFormatter();
    // right align field labels
    cf.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(5, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    cf.setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    grid.setText(0, 0, "Event Name:");
    grid.setText(1, 0, "Raid Size:");
    grid.setText(2, 0, "Minimum Level:");
    grid.setText(3, 0, "Instance:");
    grid.setText(4, 0, "Bosses:");
    grid.setText(5, 0, "Roles:");
    grid.setText(7, 0, "Badges:");

    size.setVisibleLength(2);
    minlevel.setVisibleLength(2);

    size.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              int sizen = Integer.parseInt(size.getText());
              if (sizen < 0) {
                size.setText("0");
              }
            } catch (NumberFormatException e) {
              size.setText("25");
            }

            updateRoleTotals();
          }
        });

    minlevel.addChangeHandler(
        new ChangeHandler() {
          public void onChange(ChangeEvent event) {
            try {
              int minleveln = Integer.parseInt(minlevel.getText());
              if (minleveln < 0) {
                size.setText("0");
              }
            } catch (NumberFormatException e) {
              size.setText(MAX_LEVEL);
            }
          }
        });

    instances.setWidth("100%");
    instances.setVisibleItemCount(1);

    roles.setWidth("100%");
    roles.setVisibleItemCount(1);

    badges.setWidth("100%");
    badges.setVisibleItemCount(1);

    grid.setWidget(0, 1, name);
    grid.setWidget(1, 1, size);
    grid.setWidget(2, 1, minlevel);

    grid.setWidget(3, 1, instances);

    GoteFarm.goteService.getInstances(
        admin.current_guild.key,
        new AsyncCallback<List<JSInstance>>() {
          public void onSuccess(List<JSInstance> results) {
            int sel = 0;

            for (JSInstance i : results) {
              instances.addItem(i.name, i.key);
              if (EventEditor.this.et != null && i.key.equals(EventEditor.this.et.instance_key)) {
                sel = instances.getItemCount() - 1;
              }
            }

            instances.setSelectedIndex(sel);

            updateBosses();
          }

          public void onFailure(Throwable caught) {}
        });

    instances.addChangeHandler(this);
    roles.addChangeHandler(this);
    badges.addChangeHandler(this);

    grid.setWidget(3, 2, newinst);

    newinst.setText(NEW_INSTANCE);

    newinst.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
              final String inst = newinst.getText();

              boolean found = false;

              for (int i = 0; i < instances.getItemCount(); ++i) {
                if (instances.getItemText(i).equals(inst)) {
                  instances.setSelectedIndex(i);
                  focusBoss();
                  found = true;
                  break;
                }
              }

              if (!found) {
                GoteFarm.goteService.addInstance(
                    admin.current_guild.key,
                    inst,
                    new AsyncCallback<JSInstance>() {
                      public void onSuccess(JSInstance result) {
                        instances.addItem(result.name, result.key);
                        instances.setSelectedIndex(instances.getItemCount() - 1);
                        bosses.clear();

                        focusBoss();
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            }
          }
        });

    grid.setWidget(4, 1, bosses);
    grid.setWidget(4, 2, newboss);

    bosses.setWidth("100%");
    bosses.setVisibleItemCount(10);

    newboss.setText(NEW_BOSS);

    newboss.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
              int selinst = instances.getSelectedIndex();
              if (selinst == -1) {
                errmsg.setText("You need to select and instance to " + "add a boss.");
                return;
              }

              final String boss = newboss.getText();

              boolean found = false;

              for (int i = 0; i < bosses.getItemCount(); ++i) {
                if (bosses.getItemText(i).equals(boss)) {
                  bosses.setItemSelected(i, true);
                  focusBoss();
                  found = true;
                  break;
                }
              }

              if (!found) {
                GoteFarm.goteService.addBoss(
                    instances.getValue(selinst),
                    boss,
                    new AsyncCallback<JSBoss>() {

                      public void onSuccess(JSBoss result) {
                        bosses.addItem(result.name, result.key);
                        bosses.setItemSelected(bosses.getItemCount() - 1, true);

                        focusBoss();
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            }
          }
        });

    grid.setWidget(5, 1, roles);

    roles.addItem(SELECT_A_ROLE);

    GoteFarm.goteService.getRoles(
        admin.current_guild.key,
        new AsyncCallback<List<JSRole>>() {
          public void onSuccess(List<JSRole> results) {
            for (JSRole i : results) {
              roles.addItem(i.name, i.key);
            }
          }

          public void onFailure(Throwable caught) {}
        });

    grid.setWidget(5, 2, newrole);

    newrole.setText(NEW_ROLE);

    newrole.addKeyPressHandler(
        new KeyPressHandler() {
          private void focusRole() {
            newrole.setFocus(true);
            newrole.setText(NEW_ROLE);
            newrole.setSelectionRange(0, NEW_ROLE.length());
          }

          public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
              final String role = newrole.getText();

              boolean found = false;

              for (int i = 0; i < roles.getItemCount(); ++i) {
                if (roles.getItemText(i).equals(role)) {
                  roles.setSelectedIndex(i);
                  addRole(role);
                  focusRole();
                  found = true;
                  break;
                }
              }

              if (!found) {
                GoteFarm.goteService.addRole(
                    admin.current_guild.key,
                    role,
                    true,
                    new AsyncCallback<JSRole>() {
                      public void onSuccess(JSRole result) {
                        roles.addItem(role, result.key);
                        roles.setSelectedIndex(roles.getItemCount() - 1);

                        addRole(role);
                        focusRole();
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            }
          }
        });

    roleft.setWidth("100%");
    roleft.setCellSpacing(0);
    roleft.setCellPadding(5);
    roleft.setText(0, 0, "Role");
    roleft.setText(0, 1, "Min");
    roleft.setText(0, 2, "Max");
    roleft.setText(1, 0, "Totals");

    FlexTable.FlexCellFormatter rcf = roleft.getFlexCellFormatter();
    rcf.addStyleName(0, 0, "header");
    rcf.addStyleName(0, 1, "header");
    rcf.addStyleName(0, 2, "header");
    rcf.addStyleName(0, 3, "header");
    rcf.addStyleName(1, 0, "footer");
    rcf.addStyleName(1, 1, "footer");
    rcf.addStyleName(1, 2, "footer");
    rcf.addStyleName(1, 3, "footer");

    FlexTable.FlexCellFormatter gcf = grid.getFlexCellFormatter();

    grid.setWidget(6, 0, roleft);
    gcf.setColSpan(6, 0, 3);

    grid.setWidget(7, 1, badges);

    badges.addItem(SELECT_A_BADGE);

    GoteFarm.goteService.getBadges(
        admin.current_guild.key,
        new AsyncCallback<List<JSBadge>>() {
          public void onSuccess(List<JSBadge> results) {
            for (JSBadge badge : results) {
              badges.addItem(badge.name, badge.key);
            }
          }

          public void onFailure(Throwable caught) {}
        });

    grid.setWidget(7, 2, newbadge);

    newbadge.setText(NEW_BADGE);

    newbadge.addKeyPressHandler(
        new KeyPressHandler() {
          private void focusBadge() {
            newbadge.setFocus(true);
            newbadge.setText(NEW_BADGE);
            newbadge.setSelectionRange(0, NEW_BADGE.length());
          }

          public void onKeyPress(KeyPressEvent event) {
            if (event.getCharCode() == KeyCodes.KEY_ENTER) {
              final String badge = newbadge.getText();

              boolean found = false;

              for (int i = 0; i < badges.getItemCount(); ++i) {
                if (badges.getItemText(i).equals(badge)) {
                  addBadge(badge);
                  focusBadge();
                  found = true;
                  break;
                }
              }

              if (!found) {
                GoteFarm.goteService.addBadge(
                    admin.current_guild.key,
                    badge,
                    0,
                    new AsyncCallback<JSBadge>() {
                      public void onSuccess(JSBadge result) {
                        badges.addItem(badge, result.key);
                        badges.setSelectedIndex(badges.getItemCount() - 1);

                        addBadge(badge);
                        focusBadge();
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            }
          }
        });

    badgeft.setWidth("100%");
    badgeft.setCellSpacing(0);
    badgeft.setCellPadding(5);
    badgeft.setText(0, 0, "Badge");
    badgeft.setText(0, 1, "Require For Sign Up");
    badgeft.setText(0, 2, "Apply To Role");
    badgeft.setText(0, 3, "Num Role Slots");
    badgeft.setText(0, 4, "Early Signup (Hours)");

    FlexTable.FlexCellFormatter bcf = badgeft.getFlexCellFormatter();
    bcf.addStyleName(0, 0, "header");
    bcf.addStyleName(0, 1, "header");
    bcf.addStyleName(0, 2, "header");
    bcf.addStyleName(0, 3, "header");
    bcf.addStyleName(0, 4, "header");
    bcf.addStyleName(0, 5, "header");

    grid.setWidget(8, 0, badgeft);
    gcf.setColSpan(8, 0, 3);

    vpanel.add(grid);

    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.setWidth("100%");

    final CheckBox modify = new CheckBox("Modify published events (can change signups)");
    modify.setValue(true);
    modify.addStyleName(modify.getStylePrimaryName() + "-bottom");
    modify.addStyleName(modify.getStylePrimaryName() + "-left");

    Button save =
        new Button(
            "Save",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                // clear error message
                errmsg.setText("");

                final JSEventTemplate t = new JSEventTemplate();

                if (EventEditor.this.et != null) {
                  t.key = EventEditor.this.et.key;
                } else {
                  t.key = null;
                }

                t.name = name.getText();
                t.size = getRaidSize();
                t.minimumLevel = Integer.parseInt(minlevel.getText());
                int index = instances.getSelectedIndex();
                if (index < 0) {
                  errmsg.setText("Please select an instance for this event.");
                  return;
                }
                t.instance_key = instances.getValue(index);

                t.boss_keys = new ArrayList<String>();
                for (int i = 0; i < bosses.getItemCount(); ++i) {
                  if (bosses.isItemSelected(i)) {
                    t.boss_keys.add(bosses.getValue(i));
                  }
                }

                t.roles = new ArrayList<JSEventRole>();
                for (int i = 0; i < roleft.getRowCount() - 2; ++i) {
                  JSEventRole er = new JSEventRole();
                  er.name = roleft.getText(i + 1, 0);
                  er.role_key = getRoleKey(er.name);
                  TextBox minmax;
                  minmax = (TextBox) roleft.getWidget(i + 1, 1);
                  er.min = Integer.parseInt(minmax.getText());
                  minmax = (TextBox) roleft.getWidget(i + 1, 2);
                  er.max = Integer.parseInt(minmax.getText());
                  t.roles.add(er);
                }

                t.badges = new ArrayList<JSEventBadge>();
                for (int i = 0; i < badgeft.getRowCount() - 1; ++i) {
                  JSEventBadge eb = new JSEventBadge();
                  eb.name = badgeft.getText(i + 1, 0);
                  eb.badge_key = getBadgeKey(eb.name);
                  CheckBox cb = (CheckBox) badgeft.getWidget(i + 1, 1);
                  eb.requireForSignup = cb.getValue();
                  ListBox lb = (ListBox) badgeft.getWidget(i + 1, 2);
                  String role = lb.getItemText(lb.getSelectedIndex());
                  if (!role.equals(ALL_ROLES)) {
                    eb.applyToRole = role;
                  }
                  TextBox tb;
                  tb = (TextBox) badgeft.getWidget(i + 1, 3);
                  eb.numSlots = Integer.parseInt(tb.getText());
                  tb = (TextBox) badgeft.getWidget(i + 1, 4);
                  eb.earlySignup = Integer.parseInt(tb.getText());
                  t.badges.add(eb);
                }

                t.modifyEvents = modify.getValue();

                GoteFarm.goteService.saveEventTemplate(
                    admin.current_guild.key,
                    t,
                    new AsyncCallback<JSEventTemplate>() {
                      public void onSuccess(JSEventTemplate result) {
                        EventEditor.this.admin.eventAdded();
                        EventEditor.this.admin.setCenterWidget(null);
                        if (t.key != null && t.modifyEvents) {
                          admin.fireAdminChange(AdminChange.getEventsChanged());
                        }
                      }

                      public void onFailure(Throwable caught) {
                        errmsg.setText(caught.getMessage());
                      }
                    });
              }
            });

    save.addStyleName(save.getStylePrimaryName() + "-bottom");
    save.addStyleName(save.getStylePrimaryName() + "-left");

    Button cancel =
        new Button(
            "Cancel",
            new ClickHandler() {
              public void onClick(ClickEvent event) {
                EventEditor.this.admin.setCenterWidget(null);
              }
            });

    cancel.addStyleName(cancel.getStylePrimaryName() + "-bottom");
    cancel.addStyleName(cancel.getStylePrimaryName() + "-right");

    hpanel.add(save);
    // Editing an existing event?
    if (EventEditor.this.et != null) {
      hpanel.add(modify);
    }
    hpanel.add(errmsg);
    hpanel.add(cancel);

    vpanel.add(hpanel);

    if (et != null) {
      for (JSEventRole ev : et.roles) {
        addRole(ev.name, ev.min, ev.max);
      }

      for (JSEventBadge eb : et.badges) {
        addBadge(eb.name, eb.requireForSignup, eb.applyToRole, eb.numSlots, eb.earlySignup);
      }
    }

    if (et == null) {
      name.setText(NEW_EVENT);

      DeferredCommand.addCommand(
          new Command() {
            public void execute() {
              name.setFocus(true);
              name.setSelectionRange(0, NEW_EVENT.length());
            }
          });

      size.setText("25");
      minlevel.setText(MAX_LEVEL);
    } else {
      name.setText(et.name);
      size.setText("" + et.size);
      minlevel.setText("" + et.minimumLevel);
    }

    updateRoleTotals();

    initWidget(vpanel);

    setStyleName("Admin-EventEditor");
  }