public void loadTable(final IncludedInDetail detail) {
    int row = 0;
    table.resizeRows(detail.getBranches().size() + 1);
    table.addStyleName(Gerrit.RESOURCES.css().changeTable());
    final CellFormatter fmt = table.getCellFormatter();
    fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().dataHeader());
    table.setText(row, 0, Util.C.includedInTableBranch());

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

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

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

    table.setVisible(true);
    loaded = true;
  }
  private void toggleSplit() {
    isSplit = !isSplit;
    if (isSplit) {
      splitPurchaseGrid = new SplitPurchaseGrid(billTypeManager);

      splitPurchaseGrid.setTotalCost(getCost());

      costField.setFieldLabel("Total Cost");

      fieldPanel.removeRow(3);
      fieldPanel.removeRow(3);

      matchingField.addDisplayableReportWidget(splitPurchaseGrid);
    } else {
      costField.setFieldLabel("Cost");

      fieldPanel.insertRow(3);

      fieldPanel.setText(2, 0, "Bill Type:");
      fieldPanel.setWidget(2, 1, billTypeComboBox);

      fieldPanel.insertRow(4);
      fieldPanel.setText(3, 0, "Note:");
      fieldPanel.setWidget(3, 1, noteField);

      matchingField.addDisplayableReportWidget(null);
    }
  }
Example #3
0
 private void row(Grid grid, int row, String name, Widget field) {
   final CellFormatter fmt = grid.getCellFormatter();
   if (LocaleInfo.getCurrentLocale().isRTL()) {
     grid.setText(row, 1, name);
     grid.setWidget(row, 0, field);
     fmt.addStyleName(row, 1, Gerrit.RESOURCES.css().header());
   } else {
     grid.setText(row, 0, name);
     grid.setWidget(row, 1, field);
     fmt.addStyleName(row, 0, Gerrit.RESOURCES.css().header());
   }
 }
Example #4
0
 private void addDatePanel() {
   Grid datePanel = new Grid(2, 2);
   datePanel.setText(0, 0, "Departure Date:");
   DateBox departureBox = new DateBox();
   Date departureDate = new Date();
   departureBox.setValue(departureDate);
   datePanel.setWidget(0, 1, departureBox);
   datePanel.setText(1, 0, "Return Date:");
   DateBox returnBox = new DateBox();
   Date returnDate = DateUtils.datePlusWeek(departureDate);
   returnBox.setValue(returnDate);
   datePanel.setWidget(1, 1, returnBox);
   RootPanel.get("date-panel").add(datePanel);
 }
Example #5
0
  @Override
  public Grid getWidget() {
    if (table != null) {
      return table;
    }
    table = new Grid(1, 2);

    table.setText(0, 0, "Phone number");
    table.setWidget(0, 1, number);

    return table;
  }
  public UserDisplayView() {

    id = new Label();
    lastName = new Label();
    firstName = new Label();

    Grid grid = new Grid(3, 2);
    grid.setText(0, 0, "Last Name: ");
    grid.setText(1, 0, "First Name: ");
    grid.setText(2, 0, "Generated Id: ");
    grid.setWidget(0, 1, lastName);
    grid.setWidget(1, 1, firstName);
    grid.setWidget(2, 1, id);

    create = new Button("New");

    VerticalPanel mainPanel = new VerticalPanel();
    mainPanel.add(grid);
    mainPanel.add(create);

    initWidget(mainPanel);
  }
 /** Actualiza el selector de meses {@link MonthAndYearSelector} */
 @Override
 protected void refresh() {
   String formattedMonth = getModel().formatCurrentMonth();
   grid.setText(0, monthColumn, formattedMonth);
 }
  private void initialize(BillTypeManager billTypeManager, ServiceLocations serviceLocations) {
    FormData formData = new FormData("-20");

    matchingField = new MatchingItemsControl();
    Widget storeField = createStoreField();
    Widget billTypeField = createBillTypeField(billTypeManager);
    Widget costField = createCostField();
    Widget notesField = createNotesField();
    Widget dateField = createDateField();

    Button okButton = new Button("OK");

    okButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            if (isSplit) {
              submitSplitPurchase();
            } else {
              if (isValid()) {
                submitPurchase();
              } else {
                Window.alert("Not valid");
              }
            }
          }
        });

    Button cancelButton = new Button("Cancel");

    cancelButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            finishPurchase();
          }
        });

    submitWithMatchesButton = new Button("Submit With Matches");

    submitWithMatchesButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            sendPurchase();
          }
        });

    submitWithMatchesButton.setVisible(false);

    Button splitButton = new Button("Split");
    splitButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {
          @Override
          public void componentSelected(ButtonEvent ce) {
            toggleSplit();
          }
        });

    VerticalPanel labelPanel = new VerticalPanel();
    VerticalPanel controlPanel = new VerticalPanel();
    labelPanel.add(new Label("Store"));
    labelPanel.add(new Label("Cost"));
    labelPanel.add(new Label("Date"));
    labelPanel.add(new Label("Bill Type"));
    labelPanel.add(new Label("Note"));
    controlPanel.add(storeField);
    controlPanel.add(costField);
    controlPanel.add(dateField);
    controlPanel.add(billTypeField);
    controlPanel.add(notesField);

    fieldPanel = new Grid(5, 2);

    fieldPanel.setText(0, 0, "Store:");
    fieldPanel.setWidget(0, 1, storeField);

    fieldPanel.setText(1, 0, "Cost:");
    fieldPanel.setWidget(1, 1, costField);

    fieldPanel.setText(2, 0, "Date:");
    fieldPanel.setWidget(2, 1, dateField);

    fieldPanel.setText(3, 0, "Bill Type:");
    fieldPanel.setWidget(3, 1, billTypeField);

    fieldPanel.setText(4, 0, "Note:");
    fieldPanel.setWidget(4, 1, notesField);

    HorizontalPanel buttonPanel = new HorizontalPanel();

    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);

    add(splitButton);
    add(fieldPanel);
    add(matchingField);
    add(submitWithMatchesButton);
    add(buttonPanel);
  }
Example #9
0
 protected void setRow(int row, String label, Widget w) {
   g.setText(row, 0, label);
   g.setWidget(row, 1, w);
 }
Example #10
0
  /**
   * Display the events for the cell located at <code>column</code>, <code>row</code>
   *
   * @param row
   * @param column
   * @param date
   * @param currentMonth
   */
  private void drawEvents(int row, int column, final Date date) {
    final FlexTable grid = (FlexTable) getWidget();

    // final VerticalPanel cell = (VerticalPanel) grid.getWidget(row,
    // column);
    final FlowPanel cell = (FlowPanel) grid.getWidget(row, column);

    if (cell == null)
      throw new NullPointerException(
          "The specified cell (" + row + ',' + column + ") doesn't exist.");

    // Displaying events
    final TreeSet<Event> sortedEvents =
        new TreeSet<Event>(
            new Comparator<Event>() {

              @Override
              public int compare(Event o1, Event o2) {
                int compare = 0;

                if (o1 == null && o2 == null) return 0;
                else if (o2 == null) return 1;
                else if (o1 == null) return -1;

                if (compare == 0 && o1.getDtstart() != null && o2.getDtstart() != null) {
                  long o1Start = o1.getDtstart().getTime();
                  long o2Start = o2.getDtstart().getTime();

                  if (o1Start < o2Start) compare = -1;
                  else if (o1Start > o2Start) compare = 1;
                }

                if (compare == 0 && o1.getSummary() != null && o2.getSummary() != null)
                  compare = o1.getSummary().compareTo(o2.getSummary());

                return compare;
              }
            });

    for (final Calendar calendar : calendars) {
      final Map<Date, List<Event>> eventMap = normalize(calendar);

      final List<Event> events = eventMap.get(date);

      if (events != null) {
        sortedEvents.addAll(events);
      }
    }

    final Iterator<Event> iterator = sortedEvents.iterator();
    for (int i = 0; iterator.hasNext() && i < eventLimit; i++) {
      final Event event = iterator.next();

      final ClickableFlowPanel flowPanel = new ClickableFlowPanel();
      flowPanel.addStyleName("calendar-event");

      boolean fullDayEvent = false;

      final StringBuilder eventDate = new StringBuilder();
      eventDate.append(hourFormatter.format(event.getDtstart()));
      if (event.getDtend() != null) {
        eventDate.append(" ");
        eventDate.append(hourFormatter.format(event.getDtend()));

        if (event.getDtstart().getDate() != event.getDtend().getDate()
            || event.getDtstart().getMonth() != event.getDtend().getMonth()
            || event.getDtstart().getYear() != event.getDtend().getYear()) {
          fullDayEvent = true;
          flowPanel.addStyleName("calendar-fullday-event");
        }
      }

      final InlineLabel dateLabel = new InlineLabel(eventDate.toString());
      dateLabel.addStyleName("calendar-event-date");

      final InlineLabel eventLabel = new InlineLabel(event.getSummary());
      eventLabel.addStyleName("calendar-event-label");

      if (fullDayEvent)
        flowPanel.addStyleName("calendar-fullday-event-" + event.getParent().getStyle());
      else eventLabel.addStyleName("calendar-event-" + event.getParent().getStyle());

      if (!fullDayEvent) flowPanel.add(dateLabel);
      flowPanel.add(eventLabel);

      final DecoratedPopupPanel detailPopup = new DecoratedPopupPanel(true);

      final Grid popupContent = new Grid(event.getParent().isEditable() ? 5 : 3, 1);
      popupContent.setText(0, 0, event.getSummary());
      popupContent.getCellFormatter().addStyleName(0, 0, "calendar-popup-header");

      if (!fullDayEvent) {
        popupContent.getCellFormatter().addStyleName(1, 0, "calendar-popup-date");
        popupContent
            .getCellFormatter()
            .addStyleName(1, 0, "calendar-event-" + event.getParent().getStyle());
        popupContent.setText(1, 0, eventDate.toString());
      } else popupContent.setText(1, 0, "");

      if (event.getDescription() != null && !"".equals(event.getDescription())) {
        popupContent.getCellFormatter().addStyleName(2, 0, "calendar-popup-description");
        popupContent.setText(2, 0, event.getDescription());
      } else popupContent.setText(2, 0, "");

      if (event.getParent().isEditable()
          && ProfileUtils.isGranted(authentication, GlobalPermissionEnum.EDIT_PROJECT_AGENDA)) {

        final Anchor editAnchor = new Anchor(I18N.CONSTANTS.calendarEditEvent());
        editAnchor.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent clickEvent) {
                delegate.edit(event, CalendarWidget.this);
              }
            });

        final Anchor deleteAnchor = new Anchor(I18N.CONSTANTS.calendarDeleteEvent());
        deleteAnchor.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent clickEvent) {
                delegate.delete(event, CalendarWidget.this);
                detailPopup.hide();
              }
            });

        popupContent.setWidget(3, 0, editAnchor);
        popupContent.setWidget(4, 0, deleteAnchor);
      }

      detailPopup.setWidget(popupContent);

      flowPanel.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              final int left = flowPanel.getAbsoluteLeft() - 10;
              final int bottom = Window.getClientHeight() - flowPanel.getAbsoluteTop();

              detailPopup.setWidth((getCellWidth(CELL_DEFAULT_WIDTH) + 20) + "px");

              // Show the popup
              detailPopup.setPopupPositionAndShow(
                  new PositionCallback() {

                    @Override
                    public void setPosition(int offsetWidth, int offsetHeight) {
                      detailPopup.getElement().getStyle().setPropertyPx("left", left);
                      detailPopup.getElement().getStyle().setProperty("top", "");
                      detailPopup.getElement().getStyle().setPropertyPx("bottom", bottom);
                    }
                  });
            }
          });

      cell.add(flowPanel);
    }

    if (eventLimit != UNDEFINED && sortedEvents.size() > eventLimit) {
      final Anchor eventLabel = new Anchor("\u25BC");
      final Date thisDate = new Date(date.getTime());
      eventLabel.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              startDate = thisDate;
              setDisplayMode(DisplayMode.WEEK);
            }
          });
      eventLabel.addStyleName("calendar-event-limit");
      cell.add(eventLabel);
    }
  }