private void createDatePickerDialog() {
    dpDialog = new Dialog();
    dpDialog.setHeading(HarvesterUI.CONSTANTS.datePicker());
    dpDialog.setIcon(HarvesterUI.ICONS.calendar());
    dpDialog.setButtons("");
    dpDialog.setResizable(false);
    dpDialog.setWidth(400);
    dpDialog.setHeight(250);
    dpDialog.setLayout(new FitLayout());
    dpDialog.setBodyStyleName("pad-text");
    dpDialog.setHideOnButtonClick(true);

    DatePicker datePicker = new DatePicker();
    datePicker.setValue(new Date());
    datePicker.addListener(
        Events.Select,
        new Listener<DatePickerEvent>() {
          public void handleEvent(DatePickerEvent be) {
            calendar.setDate(be.getDate());
            DateTimeFormat formatter = DateTimeFormat.getFormat("MMMM yyyy");
            String result = formatter.format(calendar.getDate());
            currentMonthAndYear.setText(result);
            calendarTaskManager.updateScheduleTasks();
          }
        });

    dpDialog.add(datePicker);
  }
Example #2
0
  private void createViewDSInfoPanel() {
    BorderLayoutData data = new BorderLayoutData(Style.LayoutRegion.EAST, 475, 100, 750);
    data.setMargins(new Margins(1, 1, 1, 5));
    data.setCollapsible(true);

    viewDsInfoPanel = new ContentPanel();
    viewDsInfoPanel.setLayout(new CenterLayout());
    viewDsInfoPanel.setLayoutOnChange(true);
    //        filterPanel.setAnimCollapse(true);
    viewDsInfoPanel.setId("eastPanel");
    viewDsInfoPanel.setBodyBorder(false);
    viewDsInfoPanel.setIcon(HarvesterUI.ICONS.view_info_icon());
    viewDsInfoPanel.setHeading(HarvesterUI.CONSTANTS.viewDataSetInformation());
    LabelToolItem noDsSelectedLabel = new LabelToolItem(HarvesterUI.CONSTANTS.noDataSetSelected());
    noDsSelectedLabel.setStyleName("noDataSetSelected");
    viewDsInfoPanel.add(noDsSelectedLabel);

    mainBorderLayout.addListener(
        Events.Expand,
        new Listener<BorderLayoutEvent>() {
          @Override
          public void handleEvent(BorderLayoutEvent be) {
            if (be.getRegion().equals(Style.LayoutRegion.EAST)) setOnExpandDataSet();
          }
        });

    mainGridPanel.add(viewDsInfoPanel, data);
  }
Example #3
0
  private ColumnModel createColumnModel() {
    ArrayList<ColumnConfig> columns = new ArrayList<ColumnConfig>();

    mainGridSelectionModel = new CheckBoxSelectionModel<ModelData>();
    mainGridSelectionModel.setSelectionMode(Style.SelectionMode.MULTI);
    columns.add(mainGridSelectionModel.getColumn());

    countryColumn = new ColumnConfig("country", HarvesterUI.ICONS.worldmap().getHTML(), 35);
    countryColumn.setAlignment(Style.HorizontalAlignment.CENTER);

    countryColumn.setRenderer(
        new GridCellRenderer<ModelData>() {
          public Object render(
              ModelData model,
              String property,
              ColumnData config,
              int rowIndex,
              int colIndex,
              ListStore<ModelData> store,
              Grid<ModelData> grid) {
            if (model instanceof DataProviderUI) {
              if (model.get("country") != null && !model.get("country").equals("none")) {
                return "<img src=\"resources/images/countries/"
                    + model.get("country")
                    + ".png\" alt=\""
                    + model.get("countryName")
                    + "\" title=\""
                    + model.get("countryName")
                    + "\"/> ";
              }
            }
            return "";
          }
        });
    columns.add(countryColumn);

    ColumnConfig name =
        new ColumnConfig("name", "<CENTER>" + HarvesterUI.CONSTANTS.name() + "</CENTER>", 100);
    name.setRenderer(new TreeGridCellRenderer<ModelData>());
    name.setWidth(260);
    columns.add(name);

    // Europeana column only
    if (HarvesterUI.getProjectType().equals("EUROPEANA")) {
      ColumnConfig nameCode =
          new ColumnConfig(
              "nameCode", "<CENTER>" + HarvesterUI.CONSTANTS.nameCodeHeader() + "</CENTER>", 100);
      columns.add(nameCode);
    }

    ColumnConfig dataSourceSet =
        new ColumnConfig(
            "dataSourceSet", "<CENTER>" + HarvesterUI.CONSTANTS.dataSetHeader() + "</CENTER>", 100);
    columns.add(dataSourceSet);

    ColumnConfig metadataFormat =
        new ColumnConfig(
            "metadataFormat",
            "<CENTER>" + HarvesterUI.CONSTANTS.oaiSchemasHeader() + "</CENTER>",
            100);
    metadataFormat.setWidth(110);
    columns.add(metadataFormat);

    ColumnConfig ingest =
        new ColumnConfig(
            "ingest", "<CENTER>" + HarvesterUI.CONSTANTS.ingestTypeHeader() + "</CENTER>", 150);
    ingest.setRenderer(new IngestTypeRenderer());
    columns.add(ingest);
    ColumnConfig lastIngest =
        new ColumnConfig(
            "lastIngest", "<CENTER>" + HarvesterUI.CONSTANTS.lastIngestHeader() + "</CENTER>", 100);
    lastIngest.setWidth(130);
    lastIngest.setAlignment(Style.HorizontalAlignment.CENTER);
    lastIngest.setRenderer(new LastIngestRenderer());
    columns.add(lastIngest);
    ColumnConfig nextIngest =
        new ColumnConfig(
            "nextIngest", "<CENTER>" + HarvesterUI.CONSTANTS.nextIngestHeader() + "</CENTER>", 100);
    nextIngest.setRenderer(new NextIngestRenderer());
    nextIngest.setAlignment(Style.HorizontalAlignment.CENTER);
    nextIngest.setWidth(130);
    columns.add(nextIngest);
    ColumnConfig records =
        new ColumnConfig(
            "records", "<CENTER>" + HarvesterUI.CONSTANTS.records() + "</CENTER>", 100);
    records.setAlignment(Style.HorizontalAlignment.RIGHT);
    records.setRenderer(new RecordsRenderer());
    columns.add(records);
    ColumnConfig ingestStatus =
        new ColumnConfig(
            "status", "<CENTER>" + HarvesterUI.CONSTANTS.ingestStatusHeader() + "</CENTER>", 100);
    ingestStatus.setRenderer(new IngestStatusRenderer());
    ingestStatus.setAlignment(Style.HorizontalAlignment.CENTER);
    columns.add(ingestStatus);

    return new ColumnModel(columns);
  }
Example #4
0
  private void createNewUSerDialog() {
    setButtons("");
    setLayout(new FitLayout());
    setHeading(HarvesterUI.CONSTANTS.addUser());
    setIcon(HarvesterUI.ICONS.add16());
    setResizable(false);
    setModal(true);
    setSize(600, 200);
    setBodyBorder(false);
    FormData formData = new FormData("95%");

    newUserFormPanel = new DefaultFormPanel();
    newUserFormPanel.setHeaderVisible(false);

    newUserFormPanel.setLayout(new EditableFormLayout(175));

    userNameField = new TextField<String>();
    userNameField.setFieldLabel(HarvesterUI.CONSTANTS.username() + HarvesterUI.REQUIRED_STR);
    userNameField.setId("userNameField");
    userNameField.setMinLength(4);
    userNameField.setAllowBlank(false);
    newUserFormPanel.add(userNameField, formData);

    Validator usernameValidator =
        new Validator() {
          public String validate(Field<?> field, String s) {
            if (!s.matches("^[A-Za-z0-9]+(?:[ _-][A-Za-z0-9]+)*$"))
              return HarvesterUI.CONSTANTS.usernameValidateMessage();
            return null;
          }
        };
    userNameField.setValidator(usernameValidator);

    emailField = new TextField<String>();
    emailField.setFieldLabel(HarvesterUI.CONSTANTS.email() + HarvesterUI.REQUIRED_STR);
    emailField.setId("emailField");
    emailField.setAllowBlank(false);
    newUserFormPanel.add(emailField, formData);

    Validator emailValidator =
        new Validator() {
          public String validate(Field<?> field, String s) {
            if (!s.matches("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"))
              return HarvesterUI.CONSTANTS.emailValidateMessage();
            return null;
          }
        };
    emailField.setValidator(emailValidator);

    roleCombo = new SimpleComboBox<String>();
    roleCombo.setEditable(false);
    roleCombo.setFieldLabel(HarvesterUI.CONSTANTS.role() + HarvesterUI.REQUIRED_STR);
    roleCombo.setTriggerAction(ComboBox.TriggerAction.ALL);
    for (UserRole userRole : UserRole.values()) {
      if (userRole != UserRole.ANONYMOUS) roleCombo.add(userRole.name());
    }
    roleCombo.setValue(roleCombo.getStore().getAt(0));
    newUserFormPanel.add(roleCombo, formData);

    saveButton =
        new Button(
            HarvesterUI.CONSTANTS.save(),
            HarvesterUI.ICONS.save_icon(),
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent be) {
                AsyncCallback<User> callback =
                    new AsyncCallback<User>() {
                      public void onFailure(Throwable caught) {
                        new ServerExceptionDialog(
                                "Failed to get response from server", caught.getMessage())
                            .show();
                      }

                      public void onSuccess(User user) {
                        AsyncCallback<ResponseState> callback =
                            new AsyncCallback<ResponseState>() {
                              public void onFailure(Throwable caught) {
                                new ServerExceptionDialog(
                                        "Failed to get response from server", caught.getMessage())
                                    .show();
                              }

                              public void onSuccess(ResponseState result) {
                                unmask();
                                if (result == ResponseState.USER_ALREADY_EXISTS) {
                                  HarvesterUI.UTIL_MANAGER.getErrorBox(
                                      HarvesterUI.CONSTANTS.newUser(),
                                      HarvesterUI.CONSTANTS.usernameAlreadyExists());
                                  return;
                                }
                                hide();
                                userManagementGrid.getStore().add(newUser);
                                HarvesterUI.UTIL_MANAGER.getSaveBox(
                                    HarvesterUI.CONSTANTS.newUser(),
                                    HarvesterUI.CONSTANTS.saveNewUserSuccess());
                                Dispatcher.get().dispatch(AppEvents.ViewUserManagementForm);
                              }
                            };
                        mask(HarvesterUI.CONSTANTS.saveUserMask());
                        newUserFormPanel.submit();
                        String role = roleCombo.getValue().getValue().trim();
                        String userName = userNameField.getValue().trim();
                        String email = emailField.getValue().trim();
                        String password = "******";
                        newUser = new User(userName, password, role, email, 15);
                        service.saveNewUser(newUser, callback);
                      }
                    };
                String userName = userNameField.getValue();
                service.getUser(userName, callback);
              }
            });
    newUserFormPanel.addButton(saveButton);
    newUserFormPanel.addButton(
        new Button(
            HarvesterUI.CONSTANTS.cancel(),
            HarvesterUI.ICONS.cancel_icon(),
            new SelectionListener<ButtonEvent>() {
              @Override
              public void componentSelected(ButtonEvent be) {
                hide();
                Dispatcher.get().dispatch(AppEvents.ViewUserManagementForm);
              }
            }));

    newUserFormPanel.setButtonAlign(Style.HorizontalAlignment.CENTER);

    FormButtonBinding binding = new FormButtonBinding(newUserFormPanel);
    binding.addButton(saveButton);

    add(newUserFormPanel);
  }