public WeeklyRecurrenceEditor() {
      setStyleName("weeklyRecurrencePanel"); // $NON-NLS-1$

      Label l = new Label(Messages.getString("schedule.recurEveryWeek"));
      everyWeekOnLabel = new ErrorLabel(l);
      l.setStyleName("startLabel"); // $NON-NLS-1$
      add(everyWeekOnLabel);

      FlexTable gp = new FlexTable();
      gp.setCellPadding(0);
      gp.setCellSpacing(0);
      // add Sun - Wed
      final int ITEMS_IN_ROW = 4;
      for (int ii = 0; ii < ITEMS_IN_ROW; ++ii) {
        DayOfWeek day = DayOfWeek.get(ii);
        CheckBox cb = new CheckBox(Messages.getString(day.toString()));
        cb.setStylePrimaryName(DOW_CHECKBOX);
        gp.setWidget(0, ii, cb);
        dayToCheckBox.put(day, cb);
      }
      // Add Thur - Sat
      for (int ii = ITEMS_IN_ROW; ii < DayOfWeek.length(); ++ii) {
        DayOfWeek day = DayOfWeek.get(ii);
        CheckBox cb = new CheckBox(Messages.getString(day.toString()));
        cb.setStylePrimaryName(DOW_CHECKBOX);
        gp.setWidget(1, ii - 4, cb);
        dayToCheckBox.put(day, cb);
      }
      add(gp);
      configureOnChangeHandler();
    }
示例#2
0
  public SubGoalDialogBox(
      final Command riksPane,
      List<GwtSubGoal> allSubGoals,
      List<GwtSubGoal> curretSelectedSubGoals) {

    // Set the dialog box's caption.
    setText(messages.associateGoals());

    this.allSubGoals = allSubGoals;
    this.oldSelectedSubGoals = curretSelectedSubGoals;

    final VerticalPanel checkBoxContainer = new VerticalPanel();
    checkBoxContainer.setSpacing(10);
    for (GwtSubGoal a : allSubGoals) {

      SubGoalCheckBox checkBox = new SubGoalCheckBox();
      checkBox.setText(a.getDescription());
      checkBox.setSubGoalID(a.getId());
      if (isCurrentSubGoalSelected(a.getId())) {
        checkBox.setValue(true);
      }
      checkBoxContainer.add(checkBox);
    }

    Button ok = new Button(messages.ok());
    Button cancel = new Button(messages.cancel());
    cancel.setWidth("60px");
    ok.setWidth("60px");

    FlexTable buttonsTable = new FlexTable();
    buttonsTable.setWidth("100%");
    buttonsTable.setCellPadding(3);
    buttonsTable.setWidget(0, 0, ok);
    buttonsTable.setWidget(0, 1, cancel);
    buttonsTable
        .getCellFormatter()
        .setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    buttonsTable.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);

    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            loadSelectedSubGoals(checkBoxContainer);
            riksPane.execute();
            SubGoalDialogBox.this.hide();
          }
        });

    cancel.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {

            SubGoalDialogBox.this.hide();
          }
        });

    checkBoxContainer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    checkBoxContainer.add(buttonsTable);
    setWidget(checkBoxContainer);
  }
示例#3
0
 public FlexTable createTable() {
   if (!currentRow.cells.isEmpty()) nextRow();
   FlexTable table = new FlexTable();
   table.setStyleName(styleName);
   table.setCellSpacing(cellSpacing);
   table.setCellPadding(cellPadding);
   if (centered) table.getElement().setAttribute("align", "center");
   String widthAsString = width == null ? "" : width;
   table.setWidth(widthAsString);
   table.getElement().setAttribute("width", widthAsString);
   if (columnWidths != null) {
     ColumnFormatter columnFormatter = table.getColumnFormatter();
     for (int i = 0; i < columnWidths.length; i++) {
       columnFormatter.setWidth(i, columnWidths[i]);
     }
   }
   int rowIndex = 0;
   for (Row row : rows) {
     int colIndex = 0;
     for (Cell cell : row.cells) {
       table.setWidget(rowIndex, colIndex, cell.widget);
       if (cell.colspan > 1)
         table.getFlexCellFormatter().setColSpan(rowIndex, colIndex, cell.colspan);
       if (cell.align != null) {
         table.getCellFormatter().setHorizontalAlignment(rowIndex, colIndex, cell.align);
       }
       colIndex += cell.colspan;
     }
     rowIndex++;
   }
   return table;
 }
示例#4
0
  public WeaponsView() {
    DecoratorPanel contentTableDecorator = new DecoratorPanel();
    initWidget(contentTableDecorator);
    contentTableDecorator.setWidth("100%");
    contentTableDecorator.setWidth("15em");

    contentTable = new FlexTable();
    contentTable.setWidth("100%");
    contentTable.getCellFormatter().addStyleName(0, 0, "contacts-ListContainer");
    contentTable.getCellFormatter().setWidth(0, 0, "100%");
    contentTable.getFlexCellFormatter().setVerticalAlignment(0, 0, DockPanel.ALIGN_TOP);

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.setBorderWidth(0);
    hPanel.setSpacing(0);
    hPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
    addButton = new Button("增加");
    hPanel.add(addButton);
    deleteButton = new Button("删除");
    hPanel.add(deleteButton);
    contentTable.getCellFormatter().addStyleName(0, 0, "contacts-ListMenu");
    contentTable.setWidget(0, 0, hPanel);

    contactsTable = new FlexTable();
    contactsTable.setCellSpacing(0);
    contactsTable.setCellPadding(0);
    contactsTable.setWidth("100%");
    contactsTable.addStyleName("contacts-ListContents");
    contactsTable.getColumnFormatter().setWidth(0, "15px");
    contentTable.setWidget(1, 0, contactsTable);

    contentTableDecorator.add(contentTable);
  }
示例#5
0
 private void addStylesToElementsInStockList() {
   stocksFlexTable.getRowFormatter().addStyleName(0, "watchListHeader");
   stocksFlexTable.addStyleName("watchList");
   stocksFlexTable.getCellFormatter().addStyleName(0, 1, "watchListNumericColumn");
   stocksFlexTable.getCellFormatter().addStyleName(0, 2, "watchListNumericColumn");
   stocksFlexTable.getCellFormatter().addStyleName(0, 3, "watchListRemoveColumn");
   stocksFlexTable.setCellPadding(6);
 }
示例#6
0
  private void BuildList(String Filter) {

    Iterator<Entry<String, pojoMethod>> it = this.methodList.entrySet().iterator();

    int i = 0;
    this._MenuStack.clear();
    this._MenuStack.removeAllRows();

    // this._MenuStack.setHeight(height)
    // We need to set Height of the parent panel dynamically based on the number of items
    // We need to add a hidden field with a unique id
    while (it.hasNext()) {
      // Use of final to allow access to it in the clickHandlers
      final int index = i; // This keeps track of which item we are looking at
      Entry<String, pojoMethod> tmpEntry = it.next();
      final pojoMethod tmpMethod = tmpEntry.getValue();
      //
      String comp1 = tmpMethod.getMethodName().toLowerCase();
      String comp2 = Filter.toLowerCase();
      if (comp1.contains(comp2)) {
        final Label titleLabel = new Label();
        titleLabel.setText(tmpMethod.getMethodName());
        titleLabel.addStyleName("menuMethodName");
        final int _i = i;
        // _edit.setStyleName("btnEditMethod");
        titleLabel.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent event) {

                // set selected style/should shuffle as well
                setActiveMenu(tmpMethod.getMethodID());
                eventBus.fireEvent(
                    new DragEvent(titleLabel.getText(), "EditMethod", index, (IPojo) tmpMethod));
              }
            });

        // this._MenuStack.setWidget(i,0,tmpItem.asWidget());
        this._MenuStack.setWidget(i, 0, titleLabel);
        // this._MenuStack.setWidget(i,1,_edit);
        Hidden tmpHidden = new Hidden();
        tmpHidden.setValue(tmpMethod.getMethodID());
        this._MenuStack.setWidget(i, 1, tmpHidden);
        _MenuStack.getFlexCellFormatter()
            .getElement(i, 0)
            .setAttribute("style", "border-right:Solid 1px #ccc;");
        // _MenuStack.getFlexCellFormatter().getElement(i, 1).setAttribute("style",
        // "padding-left:5px;");
        i++;
      }
    }

    _MenuStack.setCellPadding(0);
    _MenuStack.setCellSpacing(0);
    int newHeight = _MenuStack.getRowCount() * 30;
    this._MenuStack.setHeight(newHeight + "px");
  }
示例#7
0
 EventsView() {
   initWidget(eventsFormTable);
   eventsFormTable.setWidth("32em");
   eventsFormTable.setCellSpacing(5);
   eventsFormTable.setCellPadding(3);
   cellFormatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
   eventsFormTable.getFlexCellFormatter().setColSpan(1, 0, 2);
   eventsFormTable.setWidget(2, 0, new HTML("Events List"));
 }
  public FilesListPanel() {
    super();
    // Create the toolbar
    toolbar = new FilesToolbar(this);
    SimplePanel toolbarWrapper = new SimplePanel();
    toolbarWrapper.add(toolbar);
    toolbarWrapper.setStyleName("files-toolbar"); // $NON-NLS-1$
    add(toolbarWrapper);

    SimplePanel filesListWrapper = new SimplePanel();
    FocusPanel fp =
        new FocusPanel(filesList) {
          public void onBrowserEvent(Event event) {
            if ((DOM.eventGetType(event) & Event.ONKEYDOWN) == Event.ONKEYDOWN) {
              if (event.getKeyCode() == KeyCodes.KEY_UP) {
                selectPreviousItem(selectedFileItem);
              } else if (event.getKeyCode() == KeyCodes.KEY_DOWN) {
                selectNextItem(selectedFileItem);
              } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) {
                SolutionBrowserPerspective sbp = SolutionBrowserPerspective.getInstance();
                FilesListPanel flp = sbp.getFilesListPanel();
                sbp.openFile(
                    "/"
                        + flp.getSelectedFileItem().getSolution()
                        + flp.getSelectedFileItem().getPath(),
                    flp.getSelectedFileItem().getName(),
                    flp.getSelectedFileItem().getLocalizedName(),
                    COMMAND.RUN);
              }
            }
            super.onBrowserEvent(event);
          }
        };
    filesList.setCellPadding(1);
    filesList.setWidth("100%");
    AbsolutePanel bounderyPanel = new AbsolutePanel();
    bounderyPanel.add(fp);

    fp.sinkEvents(Event.KEYEVENTS);

    filesListWrapper.add(bounderyPanel);
    fp.getElement()
        .getStyle()
        .setProperty("margin", "29px 0px 10px 0px"); // $NON-NLS-1$ //$NON-NLS-2$
    filesListWrapper.setStyleName("files-list-panel"); // $NON-NLS-1$
    add(filesListWrapper);

    setStyleName("panelWithTitledToolbar"); // $NON-NLS-1$
    setWidth("100%"); // $NON-NLS-1$

    getElement().setId("filesListPanel");

    setupNativeHooks(this);

    SolutionDocumentManager.getInstance().addSolutionDocumentListener(this);
  }
示例#9
0
  public ReadTrack(String trackName, String dbType) {
    super("Read Track");

    getConfig().setParameter(CONFIG_DB_TYPE, dbType);

    layoutTable.setBorderWidth(0);
    layoutTable.setCellPadding(0);
    layoutTable.setCellSpacing(0);
    layoutTable.setWidget(0, 1, geneCanvas);

    updateClickAction();
  }
示例#10
0
  public void showDate(Date dateToShow) {
    this.date = dateToShow;
    updateBeginAndEnd();

    lists.clear();
    selectionManager.clear();

    FlexTable table = new FlexTable();
    table.setWidth("100%");
    table.setCellPadding(2);
    table.getColumnFormatter().setWidth(0, "25px");
    table.getColumnFormatter().setWidth(1, "40px");
    table.getColumnFormatter().setWidth(2, "30px");
    table.getColumnFormatter().setWidth(3, "40px");

    // table.setBorderWidth(1);
    int row = 0;
    Date d = begin;
    int month = 0;
    int week = 0;
    while (d.compareTo(end) <= 0) {
      int w = d.getWeek();
      if (w != week) {
        week = w;
        Widget weekWidget = Gwt.createDiv("DayListWidget-week", String.valueOf(week));
        table.setWidget(row, 0, weekWidget);
      }
      int m = d.getMonth();
      if (m != month) {
        month = m;
        Widget monthWidget = Gwt.createDiv("DayListWidget-month", Gwt.getMonthShort(month));
        table.setWidget(row, 1, monthWidget);
      }
      table.setWidget(row, 2, Gwt.createDiv("DayListWidget-date", Gwt.formatDay(d.toJavaDate())));
      table.setWidget(
          row, 3, Gwt.createDiv("DayListWidget-date", Gwt.formatWeekdayShort(d.toJavaDate())));
      table.setWidget(row, 4, createDayContent(d));

      formatRow(table, row);
      d = d.nextDay();
      row++;
    }

    Widget downloadLink =
        ScrumGwt.createPdfLink(
            "Download as PDF", "calendar", "from", begin.toString(), "to", end.toString());
    wrapper.setWidget(Gwt.createFlowPanel(table, Gwt.createSpacer(1, 10), downloadLink));
  }
  protected void onTableAdded(final BuilderPanel wrapper, final FlexTable table) {
    table.setWidth("100%");
    table.setCellSpacing(10);
    table.setCellPadding(10);
    table.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            clickEvent = event;
            Cell cell = table.getCellForEvent(event);
            if (cell == null) return;
            int row = cell.getRowIndex();
            int columnIndex = cell.getCellIndex();
            if (row == getColumnsTitleRow()) {
              if (!isCustomSortingEnabled()) return;
              if (sortColumnIndex == columnIndex) {
                reverseSort = !reverseSort;
              } else {
                sortColumnIndex = columnIndex;
                reverseSort = false;
              }
              update();
              return;
            } else if (row == getColumnsFilterRow()) {
              return;
            }
            O object = getObject(row);
            if (object == null) return;

            columns.get(columnIndex).onClick(object);
            clickEvent = null;
          }

          private int getColumnsTitleRow() {
            if (!isColumnTitlesEnabled()) return -2;
            return 0;
          }

          private int getColumnsFilterRow() {
            if (!isColumnFilteringEnabled()) return -2;
            int row = 0;
            if (isColumnTitlesEnabled()) row++;
            return row;
          }
        });
  }
示例#12
0
 WeaknessManagerView() {
   // this.topBarViewListener = topBarViewListener;
   initWidget(vendorTable);
   vendorTable.setWidth("32em");
   vendorTable.setCellSpacing(5);
   vendorTable.setCellPadding(3);
   cellFormatter.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
   vendorTable.getFlexCellFormatter().setColSpan(1, 0, 2);
   vendorTable.setWidget(1, 0, new HTML("<b>Your Weakness Manager</b>"));
   addGoalType();
   /*registerButton.addStyleName("registerButton");
   registerButton.addClickHandler(new ClickHandler() {
         public void onClick(ClickEvent event) {
         //  addStock();
         }
       });*/
 }
  public DefinitionsMappingPanel(
      DefinitionWidgetProvider<T> widgetProvider,
      String definitionsLabel,
      String targetsLabel,
      boolean includeTargetColumn) {
    this.widgetProvider = widgetProvider;
    this.definitionsLabel = definitionsLabel;
    this.targetsLabel = targetsLabel;
    this.includeTargetColumn = includeTargetColumn;
    container = new SimplePanel();
    table = new FlexTable();
    table.setCellPadding(5);
    table.setCellSpacing(5);
    table.setStyleName(style.table());
    setupLoadingContainer();

    container.setWidget(table);
    initWidget(container);
  }
示例#14
0
  /**
   * Default constructor
   *
   * @param delHandler Обработчик нажатия на "Удалить
   * @param title Заголовок окна
   * @param message Сообщение
   */
  public DeleteDialog(final ClickHandler delHandler, String title, String message) {

    this.setText(title);

    FlexTable flexTable = new FlexTable();
    flexTable.setCellSpacing(5);
    flexTable.setCellPadding(5);
    setWidget(flexTable);
    flexTable.setSize("100%", "100%");

    Label messageLabel = new Label(message);
    flexTable.setWidget(0, 0, messageLabel);

    Button delBtn = new Button("Удалить");
    flexTable.setWidget(1, 0, delBtn);
    delBtn.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            hide();
            delHandler.onClick(event);
          }
        });

    Button cancelBtn = new Button("Отмена");
    flexTable.setWidget(1, 1, cancelBtn);
    cancelBtn.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            // Просто тупо закрываем. Печалька
            hide();
          }
        });

    flexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
    flexTable.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
    flexTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    flexTable.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_CENTER);
  }
  @UiFactory
  public FlexTable createFlexTable() {
    FlexTable table = new FlexTable();
    table.getElement().getStyle().setProperty("margin", "10px");
    table.setCellSpacing(8);
    table.setCellPadding(4);

    for (int i = 0; i < LayoutRegion.values().length; i++) {
      final LayoutRegion r = LayoutRegion.values()[i];
      if (r == LayoutRegion.CENTER) {
        continue;
      }

      SelectHandler handler =
          new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
              TextButton btn = (TextButton) event.getSource();
              String txt = btn.getText();
              if (txt.equals("Expand")) {
                con.expand(r);
              } else if (txt.equals("Collapse")) {
                con.collapse(r);
              } else if (txt.equals("Show")) {
                con.show(r);
              } else {
                con.hide(r);
              }
            }
          };

      table.setHTML(i, 0, "<div style='font-size: 12px; width: 100px'>" + r.name() + ":</span>");
      table.setWidget(i, 1, new TextButton("Expand", handler));
      table.setWidget(i, 2, new TextButton("Collapse", handler));
      table.setWidget(i, 3, new TextButton("Show", handler));
      table.setWidget(i, 4, new TextButton("Hide", handler));
    }
    return table;
  }
示例#16
0
 public ValueListEditorImpl(ValueEditorFactory<O> valueEditorFactory) {
   this.valueEditorFactory = valueEditorFactory;
   HTMLPanel rootElement = ourUiBinder.createAndBindUi(this);
   initWidget(rootElement);
   valueChangeHandler =
       new ValueChangeHandler<Optional<O>>() {
         @Override
         public void onValueChange(ValueChangeEvent<Optional<O>> event) {
           handleValueEditorValueChanged();
         }
       };
   dirtyChangedHandler =
       new DirtyChangedHandler() {
         @Override
         public void handleDirtyChanged(DirtyChangedEvent event) {
           handleValueEditorDirtyChanged(event);
         }
       };
   tableField.setBorderWidth(0);
   tableField.setCellPadding(0);
   tableField.setCellSpacing(0);
   ensureBlank();
 }
示例#17
0
  /**
   * Prepares the widgets from the items as A FORM FOR SETTINGS
   *
   * @param items
   */
  public void prepareSettings(final ArrayList<ApplicationFormItem> items) {

    // refresh table events
    final JsonCallbackEvents refreshEvents =
        new JsonCallbackEvents() {
          public void onFinished(JavaScriptObject jso) {
            prepareSettings(items);
          }
        };

    FlexTable ft = new FlexTable();
    ft.addStyleName("borderTable");
    ft.setWidth("100%");
    ft.setCellPadding(8);
    FlexCellFormatter fcf = ft.getFlexCellFormatter();

    ft.setHTML(0, 0, "<strong>Short name</strong>");
    ft.setHTML(0, 1, "<strong>Type</strong>");
    ft.setHTML(0, 2, "<strong>Preview</strong>");
    ft.setHTML(0, 3, "<strong>Edit</strong>");

    fcf.setStyleName(0, 0, "GPBYFDEFD");
    fcf.setStyleName(0, 1, "GPBYFDEFD");
    fcf.setStyleName(0, 2, "GPBYFDEFD");
    fcf.setStyleName(0, 3, "GPBYFDEFD");

    String locale = "en";

    if (LocaleInfo.getCurrentLocale().getLocaleName().equals("default")
        || LocaleInfo.getCurrentLocale().getLocaleName().equals("en")) {
      locale = "en";
    } else {
      locale = "cs";
    }

    int i = 1;
    for (final ApplicationFormItem item : items) {

      final int index = i - 1;

      // not yet set locale on config page
      RegistrarFormItemGenerator gen = new RegistrarFormItemGenerator(item, locale);

      // 0 = label
      String label = "";
      if (gen.isLabelShown()) {
        label = item.getShortname();
      }
      if (item.isRequired() == true) {
        label += "*";
      }
      ft.setHTML(i, 0, label);

      // 1 = type
      ft.setHTML(i, 1, item.getType());

      // 2 = preview
      Widget w = gen.getWidget();
      ft.setWidget(i, 2, w);

      // 3 = EDIT
      FlexTable editTable = new FlexTable();
      editTable.setStyleName("noBorder");
      ft.setWidget(i, 3, editTable);

      // color for items with unsaved changes
      if (item.wasEdited() == true) {
        ft.getFlexCellFormatter().setStyleName(i, 0, "log-changed");
        ft.getFlexCellFormatter().setStyleName(i, 1, "log-changed");
        ft.getFlexCellFormatter().setStyleName(i, 2, "log-changed");
        ft.getFlexCellFormatter().setStyleName(i, 3, "log-changed");
      }

      // mark row for deletion
      if (item.isForDelete()) {

        ft.getFlexCellFormatter().setStyleName(i, 0, "log-error");
        ft.getFlexCellFormatter().setStyleName(i, 1, "log-error");
        ft.getFlexCellFormatter().setStyleName(i, 2, "log-error");
        ft.getFlexCellFormatter().setStyleName(i, 3, "log-error");

        // undelete button
        CustomButton undelete =
            new CustomButton(
                ButtonTranslation.INSTANCE.undeleteFormItemButton(),
                ButtonTranslation.INSTANCE.undeleteFormItem(),
                SmallIcons.INSTANCE.arrowLeftIcon(),
                new ClickHandler() {
                  public void onClick(ClickEvent event) {
                    items.get(index).setForDelete(false);
                    // refresh
                    prepareSettings(items);
                  }
                });

        FlexTable undelTable = new FlexTable();
        undelTable.setStyleName("noBorder");
        undelTable.setHTML(
            0, 0, "<strong><span style=\"color:red;\">MARKED FOR DELETION</span></strong>");
        undelTable.setWidget(0, 1, undelete);
        ft.setWidget(i, 3, undelTable);
      }

      // color for new items to be saved
      if (item.getId() == 0) {
        ft.getFlexCellFormatter().setStyleName(i, 0, "log-success");
        ft.getFlexCellFormatter().setStyleName(i, 1, "log-success");
        ft.getFlexCellFormatter().setStyleName(i, 2, "log-success");
        ft.getFlexCellFormatter().setStyleName(i, 3, "log-success");
      }

      // up
      PushButton upButton =
          new PushButton(
              new Image(SmallIcons.INSTANCE.arrowUpIcon()),
              new ClickHandler() {

                public void onClick(ClickEvent event) {

                  if (index - 1 < 0) return;

                  // move it
                  items.remove(index);
                  items.add(index - 1, item);
                  item.setOrdnum(item.getOrdnum() - 1);

                  item.setEdited(true);

                  // refresh
                  prepareSettings(items);
                }
              });
      editTable.setWidget(0, 0, upButton);
      upButton.setTitle(ButtonTranslation.INSTANCE.moveFormItemUp());

      // down
      PushButton downButton =
          new PushButton(
              new Image(SmallIcons.INSTANCE.arrowDownIcon()),
              new ClickHandler() {

                public void onClick(ClickEvent event) {

                  if (index + 1 >= items.size()) return;

                  // move it
                  items.remove(index);
                  items.add(index + 1, item);
                  item.setOrdnum(item.getOrdnum() + 1);

                  item.setEdited(true);

                  // refresh
                  prepareSettings(items);
                }
              });
      editTable.setWidget(0, 1, downButton);
      downButton.setTitle(ButtonTranslation.INSTANCE.moveFormItemDown());

      // edit
      CustomButton editButton =
          new CustomButton(
              ButtonTranslation.INSTANCE.editFormItemButton(),
              ButtonTranslation.INSTANCE.editFormItem(),
              SmallIcons.INSTANCE.applicationFormEditIcon());
      editButton.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              session
                  .getTabManager()
                  .addTabToCurrentTab(new EditFormItemTabItem(item, refreshEvents));
            }
          });
      editTable.setWidget(0, 2, editButton);

      // remove
      CustomButton removeButton =
          new CustomButton(
              ButtonTranslation.INSTANCE.deleteButton(),
              ButtonTranslation.INSTANCE.deleteFormItem(),
              SmallIcons.INSTANCE.deleteIcon());
      removeButton.addClickHandler(
          new ClickHandler() {

            public void onClick(ClickEvent event) {
              HTML text =
                  new HTML(
                      "<p>Deleting of form items is <strong>NOT RECOMMENDED!</strong><p>You will loose access to data users submitted in older applications within this form item!<p>Do you want to continue?");
              Confirm c =
                  new Confirm(
                      "Delete confirm",
                      text,
                      new ClickHandler() {
                        public void onClick(ClickEvent event) {
                          // mark for deletion when save changes
                          items.get(index).setForDelete(true);
                          // remove if newly created
                          if (items.get(index).getId() == 0) {
                            items.remove(index);
                          }
                          // refresh
                          prepareSettings(items);
                        }
                      },
                      true);
              c.setNonScrollable(true);
              c.show();
            }
          });
      editTable.setWidget(0, 3, removeButton);

      // format
      fcf.setHeight(i, 0, "28px");
      fcf.setVerticalAlignment(i, 0, HasVerticalAlignment.ALIGN_MIDDLE);
      fcf.setVerticalAlignment(i, 1, HasVerticalAlignment.ALIGN_MIDDLE);
      fcf.setVerticalAlignment(i, 2, HasVerticalAlignment.ALIGN_MIDDLE);

      i++;
    }

    contents.setWidget(ft);
  }
示例#18
0
  /*
   * (non-Javadoc)
   * @see monbulk.shared.Services.MethodService.MethodServiceHandler#onReadMethodList(java.util.ArrayList)
   */
  @Override
  public void onReadMethodList(ArrayList<pojoMethod> arrMethods) {
    try {
      Iterator<pojoMethod> it = arrMethods.iterator();
      SearchWidget _SearchWidget = new SearchWidget(this);
      this._searchPanel.add(_SearchWidget.getHeaderWidget());
      int i = 0;

      while (it.hasNext()) {
        // Use of final to allow access to it in the clickHandlers
        final int index = i; // This keeps track of which item we are looking at
        final pojoMethod tmpMethod = it.next();
        this.methodList.put(tmpMethod.getMethodID(), tmpMethod);

        final Label titleLabel = new Label();
        titleLabel.setText(tmpMethod.getMethodName());
        titleLabel.addStyleName("menuMethodName");
        // titleLabel.setWidth("150px");

        //	PushButton _clone = new PushButton();
        //	_clone.setStyleName("btnCloneMethod");
        //	_clone.addClickHandler(new ClickHandler()
        //	{

        //		@Override
        //		public void onClick(ClickEvent event) {
        //			setActiveMenu(titleLabel.getText());
        //			eventBus.fireEvent(new
        // DragEvent(titleLabel.getText(),"CloneMethod",index,(IPojo)tmpMethod));
        //
        //		}
        //
        //	});

        /// PushButton _edit = new PushButton();
        // _edit.setStyleName("btnEditMethod");
        titleLabel.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent event) {

                // set selected style/should shuffle as well
                setActiveMenu(tmpMethod.getMethodID());
                eventBus.fireEvent(
                    new DragEvent(titleLabel.getText(), "EditMethod", index, (IPojo) tmpMethod));
              }
            });
        // this._MenuStack.setWidget(i,0,tmpItem.asWidget());
        this._MenuStack.setWidget(i, 0, titleLabel);

        // this._MenuStack.setWidget(i,1,_edit);
        Hidden tmpHidden = new Hidden();
        tmpHidden.setValue(tmpMethod.getMethodID());
        this._MenuStack.setWidget(i, 1, tmpHidden);
        if (tmpMethod.getMethodName().length() > 38) {
          _MenuStack.getFlexCellFormatter().setStyleName(i, 0, "long");
        }
        _MenuStack.getFlexCellFormatter().getElement(i, 0).setAttribute("style", "");
        // _MenuStack.getFlexCellFormatter().getElement(i, 1).setAttribute("style",
        // "padding-left:5px;");
        i++;
      }

      _MenuStack.setCellPadding(0);
      _MenuStack.setCellSpacing(0);
    } catch (Exception ex) {
      GWT.log(
          "Error occurs @ MethodList.onReadMethodList"
              + ex.getMessage()
              + ex.getStackTrace().toString());
    }
  }
  private void configure() {
    // Configure parentPanel
    parentPanel.setBorderWidth(50);
    parentPanel.setSize("100%", "100%");
    parentPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    parentPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    // Initialize Labels, Boxes, and Buttons
    Label header;
    if (!isEdit) {
      header = new Label("Create an Event");
    } else {
      header = new Label("Edit Event");
    }
    header.setStyleName("subHeaderText");
    Label nameLabel = new Label("Event Name ");
    Label locLabel = new Label("Location");
    Label dateLabel = new Label("Date");
    Label startTimeLabel = new Label("Start Time");
    Label endTimeLabel = new Label("End Time");
    Label descLabel = new Label("Description");
    Label chosenUsersLabel = new Label("Attendees");
    Label chooseUsersLabel = new Label("Add Attendees\t");
    configureInputFields();

    // Add style and text
    header.setStyleName("header");

    // Everything goes into a FlexTable
    FlexTable flexTable = new FlexTable();
    flexTable.setCellPadding(100);
    flexTable.setCellSpacing(100);

    flexTable.setWidget(0, 0, nameLabel);
    flexTable.setWidget(1, 0, locLabel);
    flexTable.setWidget(2, 0, dateLabel);
    flexTable.setWidget(3, 0, startTimeLabel);
    flexTable.setWidget(4, 0, endTimeLabel);
    flexTable.setWidget(5, 0, descLabel);
    flexTable.setWidget(6, 0, chosenUsersLabel);
    flexTable.setWidget(7, 0, chooseUsersLabel);

    flexTable.setWidget(0, 1, boxes.get(0));
    flexTable.setWidget(1, 1, boxes.get(1));
    flexTable.setWidget(2, 1, boxes.get(2));
    flexTable.setWidget(3, 1, boxes.get(3));
    flexTable.setWidget(4, 1, boxes.get(4));
    flexTable.setWidget(5, 1, areas.get(0));
    flexTable.setWidget(6, 1, areas.get(1));
    flexTable.setWidget(7, 1, userCellList);

    if (createButton != null) {
      flexTable.setWidget(8, 3, cancelButton);
      flexTable.setWidget(8, 4, createButton);
    } else {
      flexTable.setWidget(8, 3, saveButton);
      flexTable.setWidget(8, 4, cancelButton);
      flexTable.setWidget(8, 5, deleteButton);
    }

    // Add the FlexTable to the ParentPanel
    parentPanel.add(header);
    parentPanel.add(flexTable);
    Constants.logger.severe("CREATEEVENTVIEW.JAVA: END OF CONFIGURE().");
  }
示例#20
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");
  }
  /** Construit le tableau de la garantie. */
  private void construireTableauGarantie(GarantiePersonneMoraleModel garantie) {
    if (garantie.getListeInfosGarantie() != null && garantie.getListeInfosGarantie().size() > 0) {
      // On regarde s'il y a des montants souscrits pour afficher la colonne ou non.
      boolean hasMontantSouscrit = false;
      for (InfosGarantiePersonneMoraleModel infosGarantie : garantie.getListeInfosGarantie()) {
        if (infosGarantie.getMontantSouscrit() != null
            && infosGarantie.getMontantSouscrit() > 0.0d) {
          hasMontantSouscrit = true;
          break;
        }
      }

      // Construction du tableau
      final FlexTable tableInfosGarantie = new FlexTable();
      tableInfosGarantie.setWidth(ComposantContratPersonneMoraleConstants.POURCENT_100);
      tableInfosGarantie.setCellPadding(6);
      tableInfosGarantie.setStylePrimaryName(ressources.css().tableau());
      tableInfosGarantie.getRowFormatter().setStyleName(0, ressources.css().ligneEnteteColonne());
      tableInfosGarantie.setWidget(0, 0, new Label(viewConstants.labelCodeTarif()));
      tableInfosGarantie.setWidget(0, 1, new Label(viewConstants.labelGarantieGestion()));
      tableInfosGarantie.setWidget(0, 2, new Label(viewConstants.labelPopulation()));
      if (hasMontantSouscrit) {
        tableInfosGarantie.setWidget(0, 3, new Label(viewConstants.labelCapital()));
      }
      // Remplissage des lignes
      int ligne = 1;
      for (InfosGarantiePersonneMoraleModel infosGarantie : garantie.getListeInfosGarantie()) {
        tableInfosGarantie.setWidget(ligne, 0, new Label(infosGarantie.getCodeTarif()));
        tableInfosGarantie.setWidget(
            ligne, 1, new Label(infosGarantie.getLibelleGarantieGestion()));
        tableInfosGarantie.setWidget(ligne, 2, new Label(infosGarantie.getLibellePopulation()));
        if (hasMontantSouscrit && infosGarantie.getMontantSouscrit() != null) {
          tableInfosGarantie.setWidget(
              ligne, 3, new Label(numberFormat.format(infosGarantie.getMontantSouscrit())));
        }
        final Long idStatut = infosGarantie.getStatut().getIdentifiant();
        if (constantesApp.getIdStatutGarantieEnCours().equals(idStatut)) {
          tableInfosGarantie
              .getRowFormatter()
              .addStyleName(ligne, this.ressources.css().couleurFondGarantieEnCours());
        } else if (constantesApp.getIdStatutGarantieResiliee().equals(idStatut)) {
          tableInfosGarantie
              .getRowFormatter()
              .addStyleName(ligne, this.ressources.css().couleurFondGarantieResiliee());
        }
        ligne++;
      }

      if (hasMontantSouscrit) {
        tableInfosGarantie.getColumnFormatter().setWidth(0, "15%");
        tableInfosGarantie.getColumnFormatter().setWidth(1, "45%");
        tableInfosGarantie.getColumnFormatter().setWidth(2, "25%");
        tableInfosGarantie.getColumnFormatter().setWidth(3, "15%");
      } else {
        tableInfosGarantie.getColumnFormatter().setWidth(0, "20%");
        tableInfosGarantie.getColumnFormatter().setWidth(1, "50%");
        tableInfosGarantie.getColumnFormatter().setWidth(2, "30%");
      }
      conteneurGlobal.add(tableInfosGarantie);
    }
  }
示例#22
0
  public SupplyLayout() {
    this.res = GWT.create(SupplyResources.class);
    res.style().ensureInjected();
    initWidget(uiBinder.createAndBindUi(this));
    final ListDataProvider<Supply> dataProvider = new ListDataProvider<Supply>();
    dataGrid.setMinimumTableWidth(150, Unit.PX);
    dataGrid.setWidth("100%");
    dataGrid.setHeight("450px");
    dataGrid.setAutoHeaderRefreshDisabled(true);
    dataGrid.setEmptyTableWidget(new Label("Нет данных"));

    ListHandler<Supply> sortHandler = new ListHandler<Supply>(dataProvider.getList());
    dataGrid.addColumnSortHandler(sortHandler);

    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(dataGrid);
    pager.setPageSize(10);
    pager.setPageStart(0);
    panel.add(pager);
    final SelectionModel<Supply> selectionModel = new MultiSelectionModel<Supply>();
    dataGrid.setSelectionModel(
        selectionModel, DefaultSelectionEventManager.<Supply>createDefaultManager());

    initTableColumns(selectionModel, sortHandler);

    // Верхняя панелька для поиск
    searchFlexTable = new FlexTable();
    cellFormatter = searchFlexTable.getFlexCellFormatter();
    searchFlexTable.setWidth("80%");
    searchFlexTable.setCellSpacing(5);
    searchFlexTable.setCellPadding(1);

    Label idLabel = new Label("Номер");
    final TextBox idTBox = new TextBox();
    searchFlexTable.setWidget(0, 0, idLabel);
    searchFlexTable.setWidget(0, 1, idTBox);

    Label addressLabel = new Label("Адрес");
    final TextBox addressTBox = new TextBox();
    searchFlexTable.setWidget(1, 0, addressLabel);
    searchFlexTable.setWidget(1, 1, addressTBox);

    // Create a basic date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          public void onValueChange(ValueChangeEvent<Date> event) {
            Date date = event.getValue();
            String dateString = DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM).format(date);
            text.setText(dateString);
          }
        });

    // Set the default value
    // datePicker.setValue(new Date(), true);

    // Create a DateBox
    DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd");
    final DateBox dateBox = new DateBox();
    dateBox.setFormat(new DateBox.DefaultFormat(dateTimeFormat));
    Label dateLabel = new Label("Дата");

    searchFlexTable.setWidget(2, 0, dateLabel);
    searchFlexTable.setWidget(2, 1, dateBox);

    Label typeLabel = new Label("Тип");
    final ListBox typeLB = new ListBox();
    typeLB.addItem("");
    typeLB.addItem("В филиал");
    typeLB.addItem("На склад");
    searchFlexTable.setWidget(3, 0, typeLabel);
    searchFlexTable.setWidget(3, 1, typeLB);

    Label statusLabel = new Label("Статус");
    final ListBox statusLB = new ListBox();
    statusLB.addItem("");
    for (String type : StatusDict.getAsStringList()) {
      statusLB.addItem(type);
    }
    searchFlexTable.setWidget(4, 0, statusLabel);
    searchFlexTable.setWidget(4, 1, statusLB);
    cellFormatter.setRowSpan(5, 0, 2);
    Button search = new Button("Найти");
    searchFlexTable.setWidget(5, 0, search);

    search.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {

            // формируем карту с where statement:
            Map<String, String> whereMap = new HashMap<String, String>();
            if (idTBox.getText() != null && !"".equals(idTBox.getText()))
              whereMap.put("supid", idTBox.getText());
            if (addressTBox.getText() != null && !"".equals(addressTBox.getText()))
              whereMap.put("address", addressTBox.getText());
            if (dateBox.getTextBox().getText() != null
                && !"".equals(dateBox.getTextBox().getText()))
              whereMap.put("date", dateBox.getTextBox().getText());
            if (typeLB.getSelectedIndex() != 0) {
              if (typeLB.getSelectedIndex() == 1) whereMap.put("DeliveryDirection", "1");
              if (typeLB.getSelectedIndex() == 2) whereMap.put("DeliveryDirection", "0");
            }
            if (statusLB.getSelectedIndex() != 0)
              whereMap.put("SupStatusID", Integer.toString(statusLB.getSelectedIndex()));
            supplyService.getByConditions(
                whereMap,
                new AsyncCallback<List<Supply>>() {

                  @Override
                  public void onSuccess(List<Supply> result) {
                    if (result != null) {
                      dataProvider.getList().clear();
                      dataProvider.getList().addAll(result);
                      dataProvider.refresh();
                    }
                  }

                  @Override
                  public void onFailure(Throwable caught) {
                    Window.alert("Ошибка");
                  }
                });
          }
        });
    additionalPanel.add(searchFlexTable);

    // /////////////////////////////////////////////////////
    supplyService.getLast(
        10,
        new AsyncCallback<List<Supply>>() {

          @Override
          public void onSuccess(List<Supply> result) {
            if (result != null) {
              dataProvider.getList().addAll(result);
              dataProvider.addDataDisplay(dataGrid);
              dataProvider.refresh();
            }
          }

          @Override
          public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

          }
        });
  }
  protected void onRender(Element target, int index) {
    super.onRender(target, index);
    final BorderLayout layout = new BorderLayout();
    setLayout(layout);
    setStyleAttribute("padding", "10px");

    ContentPanel north = new ContentPanel();
    ContentPanel west = new ContentPanel();
    ContentPanel center = new ContentPanel();
    center.setHeading("BorderLayout Example");
    center.setScrollMode(Scroll.AUTOX);

    FlexTable table = new FlexTable();
    table.getElement().getStyle().setProperty("margin", "10px");
    table.setCellSpacing(8);
    table.setCellPadding(4);

    for (int i = 0; i < LayoutRegion.values().length; i++) {
      final LayoutRegion r = LayoutRegion.values()[i];
      if (r == LayoutRegion.CENTER) {
        continue;
      }
      SelectionListener<ButtonEvent> sl =
          new SelectionListener<ButtonEvent>() {

            @Override
            public void componentSelected(ButtonEvent ce) {
              String txt = ce.getButton().getText();
              if (txt.equals("Expand")) {
                layout.expand(r);
              } else if (txt.equals("Collapse")) {
                layout.collapse(r);
              } else if (txt.equals("Show")) {
                layout.show(r);
              } else {
                layout.hide(r);
              }
            }
          };
      table.setHTML(i, 0, "<div style='font-size: 12px; width: 100px'>" + r.name() + ":</span>");
      table.setWidget(i, 1, new Button("Expand", sl));
      table.setWidget(i, 2, new Button("Collapse", sl));
      table.setWidget(i, 3, new Button("Show", sl));
      table.setWidget(i, 4, new Button("Hide", sl));
    }
    center.add(table);

    ContentPanel east = new ContentPanel();
    ContentPanel south = new ContentPanel();

    BorderLayoutData northData = new BorderLayoutData(LayoutRegion.NORTH, 100);
    northData.setCollapsible(true);
    northData.setFloatable(true);
    northData.setHideCollapseTool(true);
    northData.setSplit(true);
    northData.setMargins(new Margins(0, 0, 5, 0));

    BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 150);
    westData.setSplit(true);
    westData.setCollapsible(true);
    westData.setMargins(new Margins(0, 5, 0, 0));

    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
    centerData.setMargins(new Margins(0));

    BorderLayoutData eastData = new BorderLayoutData(LayoutRegion.EAST, 150);
    eastData.setSplit(true);
    eastData.setCollapsible(true);
    eastData.setMargins(new Margins(0, 0, 0, 5));

    BorderLayoutData southData = new BorderLayoutData(LayoutRegion.SOUTH, 100);
    southData.setSplit(true);
    southData.setCollapsible(true);
    southData.setFloatable(true);
    southData.setMargins(new Margins(5, 0, 0, 0));

    add(north, northData);
    add(west, westData);
    add(center, centerData);
    add(east, eastData);
    add(south, southData);
  }
示例#24
0
  public iCalCalendarPanel() {

    // style this element as absolute position
    DOM.setStyleAttribute(this.getElement(), "position", "absolute");
    DOM.setStyleAttribute(this.getElement(), "top", "0px");
    DOM.setStyleAttribute(this.getElement(), "left", "0px");
    DOM.setStyleAttribute(this.getElement(), "padding", "0px");

    DOM.setStyleAttribute(DOM.getElementById("messageBox"), "display", "none");

    mainLayoutPanel.setWidth("100%");
    add(mainLayoutPanel);

    // add header
    headerPanel.setStyleName("gwt-cal-HeaderPanel");
    DOM.setInnerHTML(headerPanel.getElement(), "&nbsp;");
    footerPanel.setStyleName("gwt-cal-FooterPanel");
    DOM.setInnerHTML(headerPanel.getElement(), "&nbsp;");
    mainLayoutPanel.add(headerPanel, DockPanel.NORTH);
    mainLayoutPanel.add(footerPanel, DockPanel.SOUTH);

    // add left panel
    datePicker.setValue(new Date());
    dateLayoutPanel.add(datePicker, DockPanel.SOUTH);
    dateLayoutPanel.add(splitterPanel, DockPanel.SOUTH);
    splitterPanel.setStyleName("splitter");
    mainLayoutPanel.add(dateLayoutPanel, DockPanel.WEST);

    // CalendarFormat.INSTANCE.setFirstDayOfWeek(1);

    // change hour offset to false to facilitate iCal style
    settings.setOffsetHourLabels(true);
    settings.setTimeBlockClickNumber(Click.Double);
    // create day view
    calendar = new Calendar();
    calendar.setSettings(settings);
    // set style as google-cal
    calendar.setWidth("100%");
    // set today as default date
    mainLayoutPanel.add(calendar, DockPanel.CENTER);
    mainLayoutPanel.setCellVerticalAlignment(dateLayoutPanel, HasAlignment.ALIGN_BOTTOM);
    dateLayoutPanel.setCellVerticalAlignment(datePicker, HasAlignment.ALIGN_BOTTOM);
    dateLayoutPanel.setWidth("168px");

    // add today button
    todayButton.setStyleName("todayButton");
    todayButton.setText("Today");
    todayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            datePicker.setValue(new Date(), true);
            // dayView.setDate(new Date());
          }
        });
    previousDayButton.setStyleName("previousButton");
    previousDayButton.setHTML("&laquo;");
    previousDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Date d = datePicker.getValue();
            d.setDate(d.getDate() - 1);
            datePicker.setValue(d, true);
          }
        });
    nextDayButton.setStyleName("nextButton");
    nextDayButton.setHTML("&raquo;");
    nextDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            Date d = datePicker.getValue();
            d.setDate(d.getDate() + 1);
            datePicker.setValue(d, true);
          }
        });
    headerPanelLayout.setWidget(0, 0, todayButton);
    headerPanelLayout.setWidget(0, 1, previousDayButton);

    oneDayButton.setText("1 Day");
    oneDayButton.setStyleName("dayButton");
    threeDayButton.setText("3 Day");
    threeDayButton.setStyleName("dayButton");
    threeDayButton.addStyleName("active");
    activeDayButton = threeDayButton;
    weekDayButton.setText("Work Week");
    weekDayButton.setStyleName("dayButton");
    monthButton.setText("Month");
    monthButton.setStyleName("dayButton");
    headerPanelLayout.setWidget(0, 2, oneDayButton);
    headerPanelLayout.setWidget(0, 3, threeDayButton);
    headerPanelLayout.setWidget(0, 4, weekDayButton);
    headerPanelLayout.setWidget(0, 5, monthButton);
    headerPanelLayout.setWidget(0, 6, nextDayButton);
    headerPanelLayout.setHTML(0, 7, "&nbsp;");

    headerPanelLayout.getCellFormatter().setWidth(0, 0, "50%");
    headerPanelLayout.getCellFormatter().setWidth(0, 7, "50%");

    headerPanelLayout.setWidth("100%");
    headerPanelLayout.setCellPadding(0);
    headerPanelLayout.setCellSpacing(0);
    headerPanel.add(headerPanelLayout);

    footerPanel.add(
        new HTML(
            "<a href='http://code.google.com/p/gwt-cal'>gwt-cal</a> widget for Google Web Toolkit, GPLv3, by <a href='http://www.google.com/profiles/Brad.Rydzewski'>Brad Rydzewski</a>"));

    oneDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            activeDayButton.removeStyleName("active");
            activeDayButton = oneDayButton;
            activeDayButton.addStyleName("active");
            calendar.setView(CalendarViews.DAY, 1);
            // calendar.scrollToHour(6);
          }
        });
    threeDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            activeDayButton.removeStyleName("active");
            activeDayButton = threeDayButton;
            activeDayButton.addStyleName("active");
            calendar.setView(CalendarViews.DAY, 3);
            // calendar.scrollToHour(6);
          }
        });
    weekDayButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            activeDayButton.removeStyleName("active");
            activeDayButton = weekDayButton;
            activeDayButton.addStyleName("active");
            calendar.setView(CalendarViews.DAY, 5);
            // calendar.scrollToHour(6);
          }
        });
    monthButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            activeDayButton.removeStyleName("active");
            activeDayButton = monthButton;
            activeDayButton.addStyleName("active");
            calendar.setView(CalendarViews.MONTH);
          }
        });

    datePicker.addValueChangeHandler(
        new ValueChangeHandler<Date>() {
          public void onValueChange(ValueChangeEvent<Date> event) {
            calendar.setDate(event.getValue());
          }
        });
    calendar.addDeleteHandler(
        new DeleteHandler<Appointment>() {
          public void onDelete(DeleteEvent<Appointment> event) {
            boolean commit =
                Window.confirm(
                    "Are you sure you want to delete appointment \""
                        + event.getTarget().getTitle()
                        + "\"");
            if (commit == false) {
              event.setCancelled(true);
              System.out.println("cancelled appointment deletion");
            }
          }
        });
    calendar.addOpenHandler(
        new OpenHandler<Appointment>() {
          public void onOpen(OpenEvent<Appointment> event) {
            Window.alert("You double-clicked appointment \"" + event.getTarget().getTitle() + "\"");
          }
        });

    calendar.addSelectionHandler(
        new SelectionHandler<Appointment>() {
          public void onSelection(SelectionEvent<Appointment> event) {
            System.out.println("selected " + event.getSelectedItem().getTitle());
          }
        });

    calendar.addTimeBlockClickHandler(
        new TimeBlockClickHandler<Date>() {
          public void onTimeBlockClick(TimeBlockClickEvent<Date> event) {
            Window.alert("you clicked time block " + event.getTarget());
          }
        });

    /* Generate random appointments */
    AppointmentBuilder.appointmentsPerDay = 5;
    AppointmentBuilder.HOURS = new Integer[] {7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
    AppointmentBuilder.MINUTES = new Integer[] {0, 30};
    AppointmentBuilder.DURATIONS = new Integer[] {60, 90, 120, 180, 240, 600};
    AppointmentBuilder.DESCRIPTIONS[1] = "Best show on TV!";

    ArrayList<Appointment> appointments = AppointmentBuilder.build(AppointmentBuilder.ICAL_STYLES);
    /* Add appointments to day view */
    calendar.suspendLayout();
    calendar.addAppointments(appointments);

    calendar.resumeLayout();

    // window events to handle resizing
    Window.enableScrolling(false);
    Window.addResizeHandler(
        new ResizeHandler() {
          public void onResize(ResizeEvent event) {
            int h = event.getHeight();
            calendar.setHeight(
                h - headerPanel.getOffsetHeight() - footerPanel.getOffsetHeight() + "px");
          }
        });
    Scheduler.get()
        .scheduleDeferred(
            new ScheduledCommand() {
              public void execute() {
                calendar.setHeight(
                    Window.getClientHeight()
                        - headerPanel.getOffsetHeight()
                        - footerPanel.getOffsetHeight()
                        + "px");
                calendar.scrollToHour(6);
              }
            });
  }
示例#25
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);
  }
示例#26
0
  /** SearchControl */
  public SearchControl() {
    table = new FlexTable();
    table.setCellPadding(2);
    table.setCellSpacing(2);
    scrollPanel = new ScrollPanel(table);
    advancedView = new CheckBox(Main.i18n("search.view.advanced"));
    advancedView.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            if (advancedView.getValue()) {
              clean();
              switchSearchMode(SEARCH_MODE_ADVANCED);
            } else {
              clean();
              switchSearchMode(SEARCH_MODE_SIMPLE);
            }
          }
        });
    compactResultsView = new CheckBox(Main.i18n("search.view.compact.results"));
    compactResultsView.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            if (compactResultsView.getValue()) {
              switchResultsViewMode(RESULTS_VIEW_COMPACT);
              table.getCellFormatter().setVisible(2, 0, false); // hide view property groups
            } else {
              switchResultsViewMode(RESULTS_VIEW_NORMAL);
              table.getCellFormatter().setVisible(2, 0, true); // show view property groups
            }
          }
        });
    showPropertyGroups = new CheckBox(Main.i18n("search.view.propety.groups"));
    showPropertyGroups.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            if (searchButton.isEnabled()) {
              executeSearch();
            }
          }
        });
    saveUserNews = new CheckBox(Main.i18n("search.save.as.news"));
    searchSavedName = new TextBox();
    searchSavedName.setWidth("200");
    controlSearch = new ControlSearchIn();
    resultPage = new ListBox();
    resultPage.addItem("10", "10");
    resultPage.addItem("20", "20");
    resultPage.addItem("30", "30");
    resultPage.addItem("50", "50");
    resultPage.addItem("100", "100");

    keyUpHandler =
        new KeyUpHandler() {
          @Override
          public void onKeyUp(KeyUpEvent event) {
            evaluateSearchButtonVisible();

            if (KeyCodes.KEY_ENTER == event.getNativeKeyCode() && searchButton.isEnabled()) {
              executeSearch();
            }
          }
        };

    searchButton =
        new Button(
            Main.i18n("button.search"),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                executeSearch();
              }
            });

    cleanButton =
        new Button(
            Main.i18n("button.clean"),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                clean();
              }
            });

    saveSearchButton =
        new Button(
            Main.i18n("button.save.search"),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                long domain = 0;
                SearchNormal searchNormal =
                    Main.get().mainPanel.search.searchBrowser.searchIn.searchNormal;
                SearchAdvanced searchAdvanced =
                    Main.get().mainPanel.search.searchBrowser.searchIn.searchAdvanced;
                String operator = GWTQueryParams.OPERATOR_AND;
                params = new GWTQueryParams();

                if (!searchAdvanced.path.getText().equals("")) {
                  params.setPath(searchAdvanced.path.getText());
                } else {
                  params.setPath(
                      searchNormal.context.getValue(searchNormal.context.getSelectedIndex()));
                }

                if (!searchAdvanced.categoryUuid.equals("")) {
                  params.setCategoryUuid(searchAdvanced.categoryUuid);
                  params.setCategoryPath(
                      searchAdvanced.categoryPath.getText().substring(16)); // removes /okm:category
                }

                params.setContent(searchNormal.content.getText());
                params.setName(searchNormal.name.getText());
                params.setKeywords(searchNormal.keywords.getText());
                params.setProperties(
                    Main.get().mainPanel.search.searchBrowser.searchIn.getProperties());
                params.setAuthor(
                    searchNormal.userListBox.getValue(searchNormal.userListBox.getSelectedIndex()));
                params.setLastModifiedFrom(searchNormal.modifyDateFrom);
                params.setLastModifiedTo(searchNormal.modifyDateTo);
                params.setDashboard(saveUserNews.getValue());
                params.setMailFrom(searchAdvanced.from.getText());
                params.setMailTo(searchAdvanced.to.getText());
                params.setMailSubject(searchAdvanced.subject.getText());

                if (searchAdvanced.typeDocument.getValue()) {
                  domain += GWTQueryParams.DOCUMENT;
                }

                if (searchAdvanced.typeFolder.getValue()) {
                  domain += GWTQueryParams.FOLDER;
                }

                if (searchAdvanced.typeMail.getValue()) {
                  domain += GWTQueryParams.MAIL;
                }

                params.setDomain(domain);

                if (searchTypeAnd.getValue()) {
                  operator = GWTQueryParams.OPERATOR_AND;
                } else {
                  operator = GWTQueryParams.OPERATOR_OR;
                }

                params.setOperator(operator);

                // Removes dates if dashboard is checked
                if (saveUserNews.getValue()) {
                  params.setLastModifiedFrom(null);
                  params.setLastModifiedTo(null);
                }

                params.setMimeType(
                    searchAdvanced.mimeTypes.getValue(searchAdvanced.mimeTypes.getSelectedIndex()));

                if (!searchSavedName.getText().equals("")) {
                  saveSearchButton.setEnabled(false);
                  params.setQueryName(searchSavedName.getText());
                  isUserNews = params.isDashboard();
                  saveSearch(params, "sql");
                }
              }
            });

    searchSavedName.addKeyUpHandler(
        new KeyUpHandler() {
          @Override
          public void onKeyUp(KeyUpEvent event) {
            evalueSaveSearchButtonVisible();
          }
        });

    searchButton.setEnabled(false);
    saveSearchButton.setEnabled(false);

    // Type of search
    searchTypePanel = new HorizontalPanel();
    searchTypePanel.setVisible(true); // On OpenKM 4.0 has hidden AND / OR option list
    searchTypeAnd = new CheckBox("AND");
    searchTypeOr = new CheckBox("OR");
    searchTypeAnd.setValue(true);
    searchTypeOr.setValue(false);

    searchTypeAnd.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            searchTypeOr.setValue(
                !searchTypeAnd.getValue()); // Always set changed between and and or type
          }
        });

    searchTypeOr.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            searchTypeAnd.setValue(
                !searchTypeOr.getValue()); // Always set changed between and and or type
          }
        });

    HTML space1 = new HTML("");
    searchTypePanel.add(searchTypeAnd);
    searchTypePanel.add(space1);
    searchTypePanel.add(searchTypeOr);
    searchTypePanel.setCellWidth(space1, "10");

    table.setWidget(0, 0, advancedView);
    table.setWidget(1, 0, compactResultsView);
    table.setWidget(2, 0, showPropertyGroups);
    table.setWidget(3, 0, saveUserNews);
    table.setWidget(4, 0, saveSearchButton);
    table.setWidget(4, 1, searchSavedName);

    resultsPageText = new HTML(Main.i18n("search.page.results"));
    table.setWidget(5, 0, resultsPageText);
    table.setWidget(5, 1, resultPage);

    searchTypeText = new HTML(Main.i18n("search.type"));
    table.setHTML(6, 0, Main.i18n("search.type"));
    table.setWidget(6, 1, searchTypePanel);

    table.setWidget(6, 0, cleanButton);
    table.setWidget(6, 1, searchButton);

    table.setWidget(7, 0, controlSearch);

    table.getCellFormatter().setHorizontalAlignment(4, 0, HasAlignment.ALIGN_RIGHT);
    table.getCellFormatter().setHorizontalAlignment(5, 0, HasAlignment.ALIGN_RIGHT);
    table.getCellFormatter().setHorizontalAlignment(6, 0, HasAlignment.ALIGN_RIGHT);
    table.getFlexCellFormatter().setColSpan(0, 0, 2);
    table.getFlexCellFormatter().setColSpan(1, 0, 2);
    table.getFlexCellFormatter().setColSpan(2, 0, 2);
    table.getFlexCellFormatter().setColSpan(3, 0, 2);
    table.getFlexCellFormatter().setColSpan(7, 0, 2);

    // By default is enabled search mode simple
    table.getCellFormatter().setVisible(3, 0, false);
    table.getCellFormatter().setVisible(4, 0, false);
    table.getCellFormatter().setVisible(4, 1, false);

    searchButton.setStyleName("okm-YesButton");
    saveSearchButton.setStyleName("okm-AddButton");
    saveSearchButton.addStyleName("okm-NoWrap");
    cleanButton.setStyleName("okm-NoButton");
    searchSavedName.setStyleName("okm-Input");
    resultPage.setStyleName("okm-Input");

    initWidget(scrollPanel);
  }
  private void createComponent() {
    hlBack = new Anchor("<<back");
    hlBack.addClickHandler(this);
    vPanel.add(hlBack);
    ProjectItems projectItems = currentUser.getProjectItems();
    if (projectItems.getProjectItemCount() == 0) {
      vPanel.add(new HTML("You are not subscribed to any projects."));
    } else {
      vPanel.add(form);
      lbProjects = new ListBox(false);
      lbProjects.addChangeHandler(this);
      vPanel.setSize("1000px", "500px");
      table.setCellSpacing(5);
      table.setCellPadding(0);
      table.setWidth("100%");
      tbName.setWidth("300px");
      // tbDescription.setWidth("300px");
      txtFileNotes.setHeight("75px");
      upload.setName("uploadFormElement");
      // fileUpload.setName("fileuploadFormElement");
      tbName.setName("name");
      tbDescription.setName("description");
      txtFileNotes.setName("notes");
      lbProjects.setName("projectDetails");
      btnSubmit.addClickHandler(this);
      txtWarnings.setStylePrimaryName("warnings");
      txtWarningDesc.setStylePrimaryName("warnings");
      txtFileNotes.setCharacterWidth(50);
      tbName.setMaxLength(50);
      // tbDescription.setMaxLength(255);
      // tbDescription.setText("");
      txtLogin = new TextBox();
      txtLogin.setName("user");
      txtLogin.setVisible(false);

      txtProject = new TextBox();
      txtProject.setName("projectName");
      txtProject.setVisible(false);

      int projectId = currentUser.getPreferredProjectId();

      for (int i = 0; i < projectItems.getProjectItemCount(); i++) {
        ProjectItem item = projectItems.getProjectItem(i);
        lbProjects.addItem(item.getProjectName(), String.valueOf(item.getProjectId()));
        if (projectId > 0) {
          if (projectId == item.getProjectId()) {
            lbProjects.setItemSelected(i, true);
          }
        } else {
          lbProjects.setItemSelected(0, true);
        }
      }

      table.setText(0, 0, "");
      table.setWidget(0, 1, txtWarnings);
      table.setText(1, 0, "");
      table.setWidget(1, 1, txtWarningDesc);
      table.setWidget(2, 0, new HTML("<b>Name:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(2, 1, tbName);
      table.setWidget(3, 0, new HTML("<b>File:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(3, 1, upload);
      // table.setWidget(4, 0, new HTML("<b>Description:</b>&nbsp;&nbsp;&nbsp;"));
      // table.setWidget(4, 1, fileUpload);
      table.setWidget(5, 0, new HTML("<b>Project:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(5, 1, lbProjects);
      table.setWidget(6, 0, new HTML("<b>Notes:</b>&nbsp;&nbsp;&nbsp;"));
      table.setWidget(6, 1, txtFileNotes);
      table.setWidget(7, 1, btnSubmit);
      table.setWidget(7, 2, txtLogin);
      table.setWidget(7, 3, txtProject);

      table.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(5, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(5, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(6, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(6, 0, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_RIGHT);
      table.getCellFormatter().setVerticalAlignment(7, 0, HasVerticalAlignment.ALIGN_TOP);

      table.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(1, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(2, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(3, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(4, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(5, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(5, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(6, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(6, 1, HasVerticalAlignment.ALIGN_TOP);
      table.getCellFormatter().setHorizontalAlignment(7, 1, HasHorizontalAlignment.ALIGN_LEFT);
      table.getCellFormatter().setVerticalAlignment(7, 1, HasVerticalAlignment.ALIGN_TOP);

      form.add(table);

      form.setAction(UPLOAD_ACTION_URL);
      form.setEncoding(FormPanel.ENCODING_MULTIPART);
      form.setMethod(FormPanel.METHOD_POST);

      form.addSubmitHandler(
          new FormPanel.SubmitHandler() {
            public void onSubmit(SubmitEvent event) {
              // This event is fired just before the form is submitted. We can
              // take this opportunity to perform validation.
              String fileName1 = upload.getFilename().trim();
              // String fileName2 = fileUpload.getFilename().trim();
              // System.out.println("File1: " + fileName1);
              if (fileName1.length() == 0 && tbName.getText().length() == 0) {
                txtWarnings.setHTML("*Please upload a file.");
                txtWarningDesc.setHTML("*Please enter the Job name.");
                event.cancel();
              }
              if ((fileName1.length() == 0) && tbName.getText().length() != 0) {
                txtWarnings.setText("");
                txtWarningDesc.setText("");
                txtWarnings.setHTML("*Please upload a file.");
                event.cancel();
              }
              if ((!(fileName1.length() == 0)) && tbName.getText().length() == 0) {
                txtWarnings.setText("");
                txtWarningDesc.setText("");
                txtWarnings.setHTML("*Please enter the Job name.");
                event.cancel();
              }
            }
          });

      form.addSubmitCompleteHandler(
          new FormPanel.SubmitCompleteHandler() {
            public void onSubmitComplete(SubmitCompleteEvent event) {
              txtFileNotes.setText("");
              txtWarningDesc.setText("");
              String sessionID = Cookies.getCookie("sid");
              if (sessionID != null) {
                String result = event.getResults();
                System.out.println("UploadJob Result: " + result);
                // Log.info("Result: " + result);
                String[] results = result.split("~");
                /*for(int i = 0; i < results.length; i++)
                {
                	 System.out.println(results[i]);
                	 try
                	 {
                		 jobId = Integer.parseInt(results[0]);
                	 }
                	 catch(NumberFormatException e)
                	 {
                		 e.printStackTrace();
                	 }
                }*/
                int jobId = -1;
                try {
                  jobId = Integer.parseInt(results[0]);
                } catch (NumberFormatException e) {
                  e.printStackTrace();
                }
                // Code modified
                if (jobId == 0) {
                  txtWarnings.setHTML(results[1]);
                }
                // Code modified
                // txtWarnings.setHTML(results[1]);

                else {
                  if (currentUser.getUsertype().equalsIgnoreCase("user")) {
                    History.newItem("userJobList");
                  } else {
                    if (tab == 0) {

                      History.newItem("adminJobList");
                    } else {
                      History.newItem("jobList");
                    }
                    // AdminPage adminPage = new AdminPage(tab);
                    // RootPanel.get("content").add(adminPage);
                  }
                }
              } else {
                Login login = new Login();
                login.displayLoginBox();
              }
            }
          });
    }
  }
示例#28
0
  public FindFolderSelectPopup() {
    // Establishes auto-close when click outside
    super(false, true);

    status = new Status();
    status.setStyleName("okm-StatusPopup");

    vPanel = new VerticalPanel();
    vPanel.setWidth("700");
    vPanel.setHeight("350");
    hPanel = new HorizontalPanel();

    scrollFolderPanel = new ScrollPanel();
    scrollFolderPanel.setStyleName("okm-Popup-text");

    cancelButton =
        new Button(
            Main.i18n("button.close"),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                hide();
              }
            });

    actionButton =
        new Button(
            Main.i18n("search.result.menu.go.folder"),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                CommonUI.openPath(folderTable.getText(selectedRow, 1), "");
                hide();
              }
            });

    keyword = new TextBox();
    keyword.setWidth("692");
    keyword.addKeyUpHandler(
        new KeyUpHandler() {
          @Override
          public void onKeyUp(KeyUpEvent event) {
            if (keyword.getText().length() >= 3) {
              GWTQueryParams gwtParams = new GWTQueryParams();
              int actualView = Main.get().mainPanel.desktop.navigator.stackPanel.getStackIndex();

              switch (actualView) {
                case UIDesktopConstants.NAVIGATOR_TAXONOMY:
                  gwtParams.setPath(Main.get().taxonomyRootFolder.getPath());
                  break;
                case UIDesktopConstants.NAVIGATOR_TEMPLATES:
                  gwtParams.setPath(Main.get().templatesRootFolder.getPath());
                  break;
                case UIDesktopConstants.NAVIGATOR_PERSONAL:
                  gwtParams.setPath(Main.get().personalRootFolder.getPath());
                  break;
                case UIDesktopConstants.NAVIGATOR_MAIL:
                  gwtParams.setPath(Main.get().mailRootFolder.getPath());
                  break;
                case UIDesktopConstants.NAVIGATOR_TRASH:
                  gwtParams.setPath(Main.get().trashRootFolder.getPath());
                  break;
              }

              gwtParams.setMimeType("");
              gwtParams.setKeywords("");
              gwtParams.setMimeType("");
              gwtParams.setName(keyword.getText() + "*"); // add wildcard at ends
              gwtParams.setAuthor("");
              gwtParams.setMailFrom("");
              gwtParams.setMailTo("");
              gwtParams.setMailSubject("");
              gwtParams.setOperator(GWTQueryParams.OPERATOR_AND);
              gwtParams.setLastModifiedFrom(null);
              gwtParams.setLastModifiedTo(null);
              gwtParams.setDomain(GWTQueryParams.FOLDER);
              gwtParams.setProperties(new HashMap<String, GWTPropertyParams>());
              find(gwtParams);
            } else {
              removeAllRows();
            }
          }
        });

    folderTable = new FlexTable();
    folderTable.setWidth("100%");
    folderTable.setCellPadding(2);
    folderTable.setCellSpacing(0);

    folderTable.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            markSelectedRow(folderTable.getCellForEvent(event).getRowIndex());
            evaluateEnableAction();
          }
        });

    folderTable.addDoubleClickHandler(
        new DoubleClickHandler() {
          @Override
          public void onDoubleClick(DoubleClickEvent event) {
            CommonUI.openPath(folderTable.getText(selectedRow, 1), "");
            hide();
          }
        });

    scrollFolderPanel.add(folderTable);
    scrollFolderPanel.setPixelSize(690, 300);

    vPanel.add(keyword);
    vPanel.add(scrollFolderPanel);
    vPanel.add(new HTML("<br>"));
    hPanel.add(cancelButton);
    HTML space = new HTML();
    space.setWidth("50");
    hPanel.add(space);
    hPanel.add(actionButton);
    vPanel.add(hPanel);
    vPanel.add(new HTML("<br>"));

    vPanel.setCellHorizontalAlignment(keyword, HasAlignment.ALIGN_CENTER);
    vPanel.setCellVerticalAlignment(keyword, HasAlignment.ALIGN_MIDDLE);
    vPanel.setCellHorizontalAlignment(scrollFolderPanel, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHorizontalAlignment(hPanel, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHeight(keyword, "25");
    vPanel.setCellHeight(scrollFolderPanel, "300");

    cancelButton.setStyleName("okm-NoButton");
    actionButton.setStyleName("okm-YesButton");
    folderTable.setStyleName("okm-NoWrap");
    folderTable.addStyleName("okm-Table-Row");
    keyword.setStyleName("okm-Input");

    super.hide();
    setWidget(vPanel);
  }
  private void loadCommentWidget(final boolean forceOpen) {
    clear();
    if (permissibleObject.isAllowComments()) {

      String fileName = permissibleObject.getName();
      final DisclosurePanel commentDisclosurePanel =
          new DisclosurePanel("View comments (" + numComments + ") for " + fileName);

      VerticalPanel commentsPanel = new VerticalPanel();
      commentsPanel.setSpacing(0);
      if (numComments > 0) {
        commentsPanel.setStyleName("commentsPanel");
      }
      commentsPanel.setWidth("100%");

      int renderedComments = 0;
      boolean userCanManage =
          AuthenticationHandler.getInstance().getUser() != null
              && (AuthenticationHandler.getInstance().getUser().isAdministrator()
                  || AuthenticationHandler.getInstance()
                      .getUser()
                      .equals(permissibleObject.getOwner()));
      List<PermissibleObject> sortedComments = new ArrayList<PermissibleObject>();
      if (comments != null) {
        sortedComments.addAll(comments);
      }
      if (!flatten) {
        sortedComments = sortComments(sortedComments);
      }

      for (PermissibleObject obj : sortedComments) {
        final Comment comment = (Comment) obj;
        int commentDepth = getCommentDepth(comment);

        int maxDepth =
            Integer.parseInt(
                maxCommentDepthListBox.getValue(maxCommentDepthListBox.getSelectedIndex()));
        if (commentDepth >= maxDepth) {
          continue;
        }

        boolean userIsAuthorOfComment =
            AuthenticationHandler.getInstance().getUser() != null
                && comment.getAuthor() != null
                && comment.getAuthor().equals(AuthenticationHandler.getInstance().getUser());

        if (userCanManage || userIsAuthorOfComment || comment.isApproved()) {

          FlexTable commentHeaderPanel = new FlexTable();
          commentHeaderPanel.setCellPadding(0);
          commentHeaderPanel.setCellSpacing(0);
          commentHeaderPanel.setStyleName("commentHeader");
          commentHeaderPanel.setWidth("100%");

          String authorLabelString =
              comment.getAuthor() == null ? comment.getEmail() : comment.getAuthor().getUsername();
          if (comment.getAuthor() != null
              && comment.getAuthor().getFirstname() != null
              && !"".equals(comment.getAuthor().getFirstname())) {
            authorLabelString += " (" + comment.getAuthor().getFirstname();
            if (comment.getAuthor() != null
                && comment.getAuthor().getLastname() != null
                && !"".equals(comment.getAuthor().getLastname())) {
              authorLabelString += " " + comment.getAuthor().getLastname() + ")";
            } else {
              authorLabelString += ")";
            }
          }

          Image replyCommentImage = new Image();
          replyCommentImage.setResource(BaseImageBundle.images.reply());
          replyCommentImage.setStyleName("commentActionButton");
          replyCommentImage.setTitle("Reply to this comment");
          replyCommentImage.addClickHandler(
              new ClickHandler() {

                public void onClick(ClickEvent event) {
                  replyToComment(comment);
                }
              });
          int columnIndex = 0;
          commentHeaderPanel.setWidget(0, columnIndex, replyCommentImage);
          commentHeaderPanel
              .getFlexCellFormatter()
              .setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_LEFT);
          columnIndex++;

          Label authorLabel = new Label(authorLabelString, false);
          commentHeaderPanel.setWidget(0, columnIndex, authorLabel);
          commentHeaderPanel
              .getFlexCellFormatter()
              .setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_LEFT);
          columnIndex++;
          commentHeaderPanel.setWidget(0, columnIndex, new Label());
          commentHeaderPanel.getFlexCellFormatter().setWidth(0, columnIndex, "100%");
          commentHeaderPanel
              .getFlexCellFormatter()
              .setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);
          columnIndex++;
          Label dateLabel = new Label(new Date(comment.getCommentDate()).toLocaleString(), false);
          commentHeaderPanel.setWidget(0, columnIndex, dateLabel);
          if (!userCanManage && !userIsAuthorOfComment) {
            DOM.setStyleAttribute(dateLabel.getElement(), "padding", "0 5px 0 0");
          }
          commentHeaderPanel
              .getFlexCellFormatter()
              .setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);

          columnIndex++;
          if (userCanManage || userIsAuthorOfComment) {
            if (userCanManage && !comment.isApproved()) {
              final Image approveCommentImage = new Image();
              approveCommentImage.setResource(BaseImageBundle.images.approve());
              approveCommentImage.setStyleName("commentActionButton");
              approveCommentImage.setTitle("Approve comment");
              approveCommentImage.addClickHandler(
                  new ClickHandler() {

                    public void onClick(ClickEvent event) {
                      workingOnComment = comment;
                      approveComment(comment);
                    }
                  });
              commentHeaderPanel.setWidget(0, columnIndex, approveCommentImage);
              commentHeaderPanel
                  .getFlexCellFormatter()
                  .setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);
              columnIndex++;
            } else {
              // put 16x16 spacer here for alignment
              final Image approveSpacerImage = new Image();
              approveSpacerImage.setResource(BaseImageBundle.images.empty16x16());
              approveSpacerImage.setStyleName("commentActionButton");
              commentHeaderPanel.setWidget(0, columnIndex, approveSpacerImage);
              commentHeaderPanel
                  .getFlexCellFormatter()
                  .setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);
              columnIndex++;
            }
            Image deleteCommentImage = new Image();
            deleteCommentImage.setResource(BaseImageBundle.images.delete());
            deleteCommentImage.setStyleName("commentActionButton");
            deleteCommentImage.setTitle("Remove comment");
            deleteCommentImage.addClickHandler(
                new ClickHandler() {

                  public void onClick(ClickEvent event) {
                    IDialogCallback callback =
                        new IDialogCallback() {

                          public void cancelPressed() {}

                          public void okPressed() {
                            deleteComment(comment);
                          }
                        };
                    PromptDialogBox dialogBox =
                        new PromptDialogBox("Question", "Yes", null, "No", false, true);
                    dialogBox.setContent(
                        new Label(
                            "Delete comment by "
                                + (comment.getAuthor() == null
                                    ? comment.getEmail()
                                    : comment.getAuthor().getUsername())
                                + "?"));
                    dialogBox.setCallback(callback);
                    dialogBox.center();
                  }
                });
            commentHeaderPanel.setWidget(0, columnIndex, deleteCommentImage);
            commentHeaderPanel
                .getFlexCellFormatter()
                .setHorizontalAlignment(0, columnIndex, HasHorizontalAlignment.ALIGN_RIGHT);
            columnIndex++;
          }

          if (commentDepth > 0) {
            HorizontalPanel commentHeaderPanelWrapper = new HorizontalPanel();
            commentHeaderPanelWrapper.setWidth("100%");
            Label spacerLabel = new Label();
            commentHeaderPanelWrapper.add(spacerLabel);
            if (!flatten) {
              commentHeaderPanelWrapper.setCellWidth(spacerLabel, (commentDepth * 20) + "px");
            }
            commentHeaderPanelWrapper.add(commentHeaderPanel);
            commentsPanel.add(commentHeaderPanelWrapper);
          } else {
            commentsPanel.add(commentHeaderPanel);
          }

          // Label commentLabel = new Label(comment.getId() + " " + comment.getComment(), true);
          Label commentLabel = new Label(comment.getComment(), true);
          if (comment.isApproved()) {
            commentLabel.setStyleName("comment");
          } else if (userCanManage || userIsAuthorOfComment) {
            commentLabel.setStyleName("commentAwaitingApproval");
          }

          if (commentDepth > 0) {
            HorizontalPanel commentHeaderPanelWrapper = new HorizontalPanel();
            commentHeaderPanelWrapper.setWidth("100%");
            Label spacerLabel = new Label();
            commentHeaderPanelWrapper.add(spacerLabel);
            if (!flatten) {
              commentHeaderPanelWrapper.setCellWidth(spacerLabel, (commentDepth * 20) + "px");
            }
            commentHeaderPanelWrapper.add(commentLabel);
            commentsPanel.add(commentHeaderPanelWrapper);
          } else {
            commentsPanel.add(commentLabel);
          }
          renderedComments++;
        }
      }

      final FlexTable mainPanel = new FlexTable();
      mainPanel.setWidth("100%");
      int row = 0;
      if (paginate) {
        mainPanel.setWidget(row, 0, createButtonPanel(mainPanel, forceOpen));
        mainPanel
            .getCellFormatter()
            .setHorizontalAlignment(row++, 0, HasHorizontalAlignment.ALIGN_LEFT);
      }
      mainPanel.setWidget(row, 0, commentsPanel);
      mainPanel.getCellFormatter().setWidth(row++, 0, "100%");

      commentDisclosurePanel.setContent(mainPanel);
      commentDisclosurePanel.setOpen(renderedComments == 0 || forceOpen);
      commentDisclosurePanel.setWidth("100%");
      add(createCommentPostPanel());
      add(commentDisclosurePanel);
    }
    if (layoutCallback != null) {
      layoutCallback.layoutComplete();
    }
  }