Example #1
0
  @Override
  public void initialize() {
    container =
        Panels.content(
            null,
            false,
            Layouts.vBoxLayout(
                VBoxLayout.VBoxLayoutAlign.STRETCH, new Layouts.LayoutOptions(new Padding(10))),
            "x-border-layout-ct");
    container.setScrollMode(Style.Scroll.AUTOY);
    container.addStyleName("contact-details-container");
    add(container);

    saveButton = Forms.button(I18N.CONSTANTS.save(), IconImageBundle.ICONS.save());
    deleteButton = Forms.button(I18N.CONSTANTS.delete(), IconImageBundle.ICONS.remove());
    exportButton = Forms.button(I18N.CONSTANTS.export(), IconImageBundle.ICONS.excel());

    toolBar = new ToolBar();
    toolBar.setAlignment(Style.HorizontalAlignment.LEFT);
    toolBar.setBorders(false);
    toolBar.add(saveButton);
    toolBar.add(deleteButton);
    toolBar.add(exportButton);

    container.setTopComponent(toolBar);
  }
Example #2
0
  public CoordinateEditor(String negHemiChars, String posHemiChars) {
    this.negHemiChars = negHemiChars;
    this.posHemiChars = posHemiChars;
    this.decimalSeperators = ".,";
    this.noHemisphereMessage = I18N.CONSTANTS.noHemisphere();
    this.tooManyNumbersErrorMessage = I18N.CONSTANTS.tooManyNumbers();
    this.invalidMinutesMessage = I18N.CONSTANTS.invalidMinutes();
    this.invalidSecondsMessage = I18N.CONSTANTS.invalidSeconds();
    this.noNumberErrorMessage = I18N.CONSTANTS.noNumber();

    dddFormat = NumberFormat.getFormat("+0.000000;-0.000000");
    shortFracFormat = NumberFormat.getFormat("0.00");
    intFormat = NumberFormat.getFormat("0");
  }
Example #3
0
  @Override
  public void initialize() {

    mainPanel = Panels.content("");
    mainPanel.setHeaderVisible(false);

    Label label = new Label(I18N.CONSTANTS.projectCoreSelectVersion());

    mainPanel.add(label);

    amendmentsComboBox1 = new ComboBox<AmendmentDTO>();
    amendmentsComboBox1.setStore(new ListStore<AmendmentDTO>());
    amendmentsComboBox1.setDisplayField("name");
    amendmentsComboBox1.setTriggerAction(ComboBox.TriggerAction.ALL);

    amendmentsComboBox2 = new ComboBox<AmendmentDTO>();
    amendmentsComboBox2.setStore(new ListStore<AmendmentDTO>());
    amendmentsComboBox2.setDisplayField("name");
    amendmentsComboBox2.setTriggerAction(ComboBox.TriggerAction.ALL);

    final LayoutContainer container = Layouts.hBox(HBoxLayoutAlign.TOP);

    container.add(amendmentsComboBox1, Layouts.hBoxData(Margin.LEFT));
    container.add(amendmentsComboBox2, Layouts.hBoxData(Margin.LEFT));

    projectFields = buildGrid();

    mainPanel.setScrollMode(Scroll.AUTO);
    mainPanel.add(container);
    mainPanel.add(projectFields);

    initPopup(mainPanel);
  }
  public void loadGroups(final IndicatorDTO indicator) {
    clear();
    setEmptyText(I18N.CONSTANTS.loading());
    dispatcher.execute(
        GetIndicators.forDatabase(indicator.getDatabaseId()),
        null,
        new AsyncCallback<IndicatorListResult>() {
          @Override
          public void onFailure(Throwable caught) {}

          @Override
          public void onSuccess(IndicatorListResult result) {
            store.add(result.getGroups());
            if (indicator.getGroupId() != null) {
              for (IndicatorGroup group : result.getGroups()) {
                if (group.getId() == indicator.getGroupId()) {
                  setValue(group);
                  return;
                }
              }
            }
            setEmptyText("");
          }
        });
  }
Example #5
0
  /**
   * Returns the given {@code code} corresponding string value. This method should be executed from
   * client-side. If executed from server-side, it returns the enum constant name.
   *
   * @param code The {@code ImportStatusCode} code.
   * @return the given {@code code} corresponding string value, or {@code null}.
   */
  public static String getStringValue(final ImportStatusCode code) {

    if (code == null) {
      return null;
    }

    if (!GWT.isClient()) {
      return code.name();
    }

    switch (code) {
      case ORGUNIT_FOUND_CODE:
        return I18N.CONSTANTS.importOrgUnitFound();
      case ORGUNIT_NOT_FOUND_CODE:
        return I18N.CONSTANTS.importOrgUnitNotFound();
      case PROJECT_FOUND_CODE:
        return I18N.CONSTANTS.importProjectFound();
      case PROJECT_LOCKED_CODE:
        return I18N.CONSTANTS.importProjectCoreLocked();
      case PROJECT_NOT_FOUND_CODE:
        return I18N.CONSTANTS.importProjectNotFound();
      case SEVERAL_ORGUNITS_FOUND_CODE:
        return I18N.CONSTANTS.importSeveralOrgUnitsFound();
      case SEVERAL_PROJECTS_FOUND_CODE:
        return I18N.CONSTANTS.importSeveralProjectsFound();
      default:
        return code.name();
    }
  }
  @Override
  public void updateDistantDatabase() {
    fireOnStart();
    fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationUpload_0());

    final Factory factory = Factory.getInstance();

    if (factory != null) {
      final Database database = factory.createDatabase();
      database.open(OnlineMode.LOCAL_DATABASE_NAME);

      try {
        OrganizationDAO.truncateTables(database);

        fireOnComplete();

      } catch (DatabaseException ex) {
        Log.debug("Error while removing the organization dto from the local database.", ex);
        fireOnFailure(
            false, I18N.CONSTANTS.synchronizerOrganizationUpload_0_failed() + ex.getMessage());

      } finally {
        try {
          database.close();
        } catch (DatabaseException ex) {
          Log.debug("Database closing error.", ex);
          fireOnFailure(
              false, I18N.CONSTANTS.synchronizerOrganizationUpload_0_failed() + ex.getMessage());
        }
      }

    } else
      fireOnFailure(
          false,
          I18N.CONSTANTS.synchronizerOrganizationUpload_0_failed()
              + "Google Gears isn't available.");
  }
Example #7
0
  /** {@inheritDoc} */
  @Override
  public void buildExportDialog(final ContactDetailsPresenter.ExportActionHandler handler) {

    final Window w = new Window();
    w.setPlain(true);
    w.setModal(true);
    w.setBlinkModal(true);
    w.setLayout(new FitLayout());
    w.setSize(400, 180);
    w.setHeadingHtml(I18N.CONSTANTS.exportData());

    final FormPanel panel = Forms.panel();

    final CheckBox synthesisBox = Forms.checkbox(I18N.CONSTANTS.caracteristics(), Boolean.TRUE);
    synthesisBox.setEnabled(false);
    final CheckBox allRelationsBox = Forms.checkbox(I18N.CONSTANTS.allRelations());
    final CheckBox frameworkRelationsBox = Forms.checkbox(I18N.CONSTANTS.frameworkRelations());
    final CheckBox relationsByElementBox = Forms.checkbox(I18N.CONSTANTS.relationsByElement());

    final CheckBoxGroup options =
        Forms.checkBoxGroup(
            I18N.CONSTANTS.exportOptions(),
            com.extjs.gxt.ui.client.Style.Orientation.VERTICAL,
            synthesisBox,
            allRelationsBox,
            frameworkRelationsBox,
            relationsByElementBox);

    panel.add(options);

    final Button export = Forms.button(I18N.CONSTANTS.export());
    panel.getButtonBar().add(export);
    export.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(final ButtonEvent ce) {
            if (handler != null) {
              handler.onExportContact(
                  synthesisBox.getValue(),
                  allRelationsBox.getValue(),
                  frameworkRelationsBox.getValue(),
                  relationsByElementBox.getValue());
            }
            w.hide();
          }
        });

    w.add(panel);
    w.show();
  }
  @Override
  public void synchronizeLocalDatabase() {
    fireOnStart();
    fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationDownload_0());

    final Factory factory = Factory.getInstance();

    if (factory != null) {

      dispatcher.execute(
          new GetOrganization(authentication.getOrganizationId()),
          null,
          new AsyncCallback<OrganizationDTO>() {

            @Override
            public void onFailure(Throwable caught) {
              fireOnFailure(
                  false,
                  I18N.CONSTANTS.synchronizerOrganizationDownload_0_failed() + caught.getMessage());
            }

            @Override
            public void onSuccess(OrganizationDTO result) {
              final Database database = factory.createDatabase();
              database.open(OnlineMode.LOCAL_DATABASE_NAME);

              try {
                fireOnUpdate(0.1);
                fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationDownload_1());
                OrganizationDAO.createTablesIfNotExists(database);

                fireOnUpdate(0.2);
                fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationDownload_2());
                OrganizationDAO.insertOrReplaceOrganization(result, database);

                final LocalServer localServer = factory.createLocalServer();
                final ResourceStore store = localServer.createStore(OnlineMode.LOCAL_DATABASE_NAME);

                fireOnUpdate(0.8);
                fireOnTaskChange(I18N.CONSTANTS.synchronizerOrganizationDownload_3());
                store.capture(
                    new ResourceStoreUrlCaptureHandler() {

                      @Override
                      public void onCapture(ResourceStoreUrlCaptureEvent event) {
                        fireOnComplete();
                      }
                    },
                    GWT.getModuleBaseURL()
                        + "image-provider?"
                        + FileUploadUtils.IMAGE_URL
                        + "="
                        + result.getLogo());

              } catch (DatabaseException ex) {
                Log.debug("Error while writing the organization dto to the local database.", ex);
                fireOnFailure(
                    false,
                    I18N.CONSTANTS.synchronizerOrganizationDownload_0_failed() + ex.getMessage());

              } finally {
                try {
                  database.close();
                } catch (DatabaseException ex) {
                  Log.debug("Database closing error.", ex);
                  fireOnFailure(
                      false,
                      I18N.CONSTANTS.synchronizerOrganizationDownload_0_failed() + ex.getMessage());
                }
              }
            }
          });

    } else
      fireOnFailure(
          false,
          I18N.CONSTANTS.synchronizerOrganizationDownload_0_failed()
              + "Google Gears isn't available.");
  }
Example #9
0
  /**
   * Creates the toolbar of this component.
   *
   * @param enabled <code>true</code> to enable the buttons of this toolbar, <code>false</code> to
   *     disable them.
   * @return A new toolbar.
   */
  private ToolBar createToolbar(final ListStore<ReportReference> store) {
    final ToolBar toolbar = new ToolBar();

    // Creating buttons
    final Button createReportButton =
        new Button(I18N.CONSTANTS.reportCreateReport(), IconImageBundle.ICONS.add());

    // "Create" button action
    createReportButton.addSelectionListener(
        new SelectionListener<ButtonEvent>() {

          @Override
          public void componentSelected(ButtonEvent ce) {
            MessageBox.prompt(
                I18N.CONSTANTS.reportCreateReport(),
                I18N.CONSTANTS.reportName(),
                new Listener<MessageBoxEvent>() {

                  @Override
                  public void handleEvent(MessageBoxEvent be) {
                    if (Dialog.OK.equals(be.getButtonClicked().getItemId())) {
                      final String name = be.getValue();

                      final HashMap<String, Serializable> properties =
                          new HashMap<String, Serializable>();
                      properties.put("name", name);
                      properties.put("flexibleElementId", getId());
                      properties.put("reportModelId", getModelId());
                      properties.put("containerId", currentContainerDTO.getId());
                      if (currentContainerDTO instanceof ProjectDTO)
                        properties.put("projectId", currentContainerDTO.getId());

                      if (currentContainerDTO instanceof OrgUnitDTO)
                        properties.put("orgUnitId", currentContainerDTO.getId());

                      properties.put("multiple", true);

                      if (currentContainerDTO instanceof ProjectDTO)
                        properties.put(
                            "phaseName",
                            ((ProjectDTO) currentContainerDTO)
                                .getCurrentPhase()
                                .getPhaseModel()
                                .getName());

                      if (currentContainerDTO instanceof OrgUnitDTO)
                        properties.put("phaseName", null);

                      dispatch.execute(
                          new CreateEntity(ProjectReportDTO.ENTITY_NAME, properties),
                          new CommandResultHandler<CreateResult>() {

                            @Override
                            public void onCommandFailure(final Throwable caught) {
                              N10N.error(
                                  I18N.CONSTANTS.projectTabReports(),
                                  I18N.CONSTANTS.reportCreateError());
                            }

                            @Override
                            public void onCommandSuccess(final CreateResult result) {

                              final ProjectReportDTO createdProjetReport =
                                  (ProjectReportDTO) result.getEntity();

                              final ReportReference reference = new ReportReference();
                              reference.setId(createdProjetReport.getId());
                              reference.setName(name);
                              reference.setLastEditDate(new Date());
                              reference.setEditorName(auth().getUserShortName());
                              store.add(reference);

                              N10N.validNotif(
                                  I18N.CONSTANTS.projectTabReports(),
                                  I18N.CONSTANTS.reportCreateSuccess());
                            }
                          });
                    }
                  }
                });
          }
        });

    // Adding buttons to the toolbar
    toolbar.add(createReportButton);

    return toolbar;
  }
Example #10
0
  /**
   * Creates and configure the column model for the grid contained in this component.
   *
   * @param enabled <code>true</code> to enable the delete column, <code>false</code> to disable it.
   * @return A new array of column configs.
   */
  private ColumnConfig[] createColumnModel(final boolean enabled) {
    final boolean canRemove = enabled && userCanPerformChangeType(ValueEventChangeType.REMOVE);

    // Creating columns
    final ColumnConfig lastEditDateColumn =
        new ColumnConfig("lastEditDate", I18N.CONSTANTS.reportLastEditDate(), 60);
    final ColumnConfig nameColumn = new ColumnConfig("name", I18N.CONSTANTS.reportName(), 100);
    final ColumnConfig editorNameColumn =
        new ColumnConfig("editorName", I18N.CONSTANTS.reportEditor(), 100);
    final ColumnConfig deleteColumn = new ColumnConfig("delete", "", 10);

    // Date column specificities
    lastEditDateColumn.setDateTimeFormat(DateUtils.DATE_SHORT);

    // Name column specificities
    nameColumn.setRenderer(
        new GridCellRenderer<ReportReference>() {

          @Override
          public Object render(
              final ReportReference model,
              String property,
              ColumnData config,
              int rowIndex,
              int colIndex,
              ListStore store,
              Grid grid) {
            final Anchor anchor = new Anchor((String) model.get(property));
            anchor.addStyleName("flexibility-link");
            anchor.addClickHandler(
                new ClickHandler() {

                  @Override
                  public void onClick(ClickEvent event) {
                    eventBus.navigateRequest(createPageRequest(model.getId()));
                  }
                });
            return anchor;
          }
        });

    // Delete column specificities
    deleteColumn.setSortable(false);
    deleteColumn.setRenderer(
        new GridCellRenderer<ReportReference>() {

          @Override
          public Object render(
              final ReportReference model,
              String property,
              ColumnData config,
              int rowIndex,
              int colIndex,
              final ListStore store,
              Grid grid) {
            if (!canRemove) {
              return "-";
            }

            final Image image = IconImageBundle.ICONS.remove().createImage();
            image.setTitle(I18N.CONSTANTS.remove());
            image.addStyleName("flexibility-action");

            // Action
            image.addClickHandler(
                new ClickHandler() {

                  @Override
                  public void onClick(ClickEvent event) {
                    N10N.confirmation(
                        I18N.CONSTANTS.remove(),
                        I18N.MESSAGES.reportRemoveConfirm(model.getName()),
                        new ConfirmCallback() {

                          @Override
                          public void onAction() {
                            // TODO: Delete the report
                            if (Log.isDebugEnabled()) {
                              Log.debug("Removing '" + model.getName() + "' report...");
                            }

                            dispatch.execute(
                                new Delete(ProjectReportDTO.ENTITY_NAME, model.getId()),
                                new CommandResultHandler<VoidResult>() {

                                  @Override
                                  public void onCommandSuccess(final VoidResult result) {
                                    store.remove(model);
                                    N10N.validNotif("OK", "OK");
                                  }

                                  @Override
                                  public void onCommandFailure(final Throwable caught) {
                                    N10N.warn("ERROR", "ERROR");
                                  }
                                });
                          }
                        });
                  }
                });

            return image;
          }
        });

    return new ColumnConfig[] {lastEditDateColumn, nameColumn, editorNameColumn, deleteColumn};
  }
Example #11
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);
    }
  }