Exemplo n.º 1
0
 @Override
 public void setMode(String mode) {
   if (mode.equals(Tokens.MAP)) {
     countryColumn.setVisible(false);
     yearColumn.setVisible(false);
   } else {
     countryColumn.setVisible(true);
     yearColumn.setVisible(true);
   }
 }
  @PostConstruct
  public void init() {
    initWidget(uiBinder.createAndBindUi(this));

    accordion.setId(DOM.createUniqueId());
    formAccordionHeader.setDataParent(accordion.getId());
    formAccordionHeader.setDataTargetWidget(formAccordionCollapse);
    resultAccordionHeader.setDataParent(accordion.getId());
    resultAccordionHeader.setDataTargetWidget(resultAccordionCollapse);

    // TODO {porcelli} due a bug on bootstrap we can't use custom date formats
    createdAfter.setFormat(ApplicationPreferences.getDroolsDateFormat());
    createdBefore.setFormat(ApplicationPreferences.getDroolsDateFormat());
    lastModifiedAfter.setFormat(ApplicationPreferences.getDroolsDateFormat());
    lastModifiedBefore.setFormat(ApplicationPreferences.getDroolsDateFormat());

    formGroup.setStyleName(null);

    formatTypeahead.setDatasets(
        new StringDataset(
            new ArrayList<String>() {
              {
                for (final ClientResourceType resourceType :
                    clientTypeRegistry.getRegisteredTypes()) {
                  add(resourceType.getShortName());
                }
              }
            }));
  }
Exemplo n.º 3
0
  /** Update the status */
  private void updateStatus(String textValue) {
    isValid = true;
    String msg = null;

    for (TextValidator vdater : validators) {
      if (!vdater.validate(textValue)) {
        isValid = false;
        msg = vdater.getErrorMessage();
        break;
      }
    }

    if (isValid) {
      formgroup.setValidationState(ValidationState.NONE);
      fgHelpBlock.setText(null);
    } else {
      formgroup.setValidationState(ValidationState.ERROR);
      fgHelpBlock.setText(msg);
    }
  }
  private Widget createValuePairItem(
      final Annotation annotation,
      final AnnotationValuePairDefinition valuePairDefinition,
      final AnnotationSource annotationSource) {
    final Row valuePairRow = new Row();
    final FormGroup formGroup = new FormGroup();
    valuePairRow.add(formGroup);

    final FormLabel formLabel = new FormLabel();
    formLabel.addStyleName(ColumnSize.MD_3.getCssName());
    formLabel.setText(valuePairDefinition.getName());
    formGroup.add(formLabel);

    final Column column = new Column(ColumnSize.MD_9);
    formGroup.add(column);
    final TextBox content = new TextBox();
    column.add(content);
    final String valuePairString =
        getValuePairStringValue(annotation, valuePairDefinition, annotationSource);
    content.setText(valuePairString);
    content.setReadOnly(true);
    content.setTitle(valuePairString);

    final Button editButton =
        new Button(
            Constants.INSTANCE.advanced_domain_annotation_list_editor_action_edit(),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                presenter.onEditValuePair(annotation, valuePairDefinition.getName());
              }
            });
    editButton.setEnabled(!readonly);
    editButton.setIcon(IconType.EDIT);

    final Button clearButton =
        new Button(
            Constants.INSTANCE.advanced_domain_annotation_list_editor_action_clear(),
            new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                presenter.onClearValuePair(annotation, valuePairDefinition.getName());
              }
            });
    clearButton.setEnabled(!readonly);
    clearButton.setIcon(IconType.ERASER);

    final FormGroup formGroupButton = new FormGroup();
    formGroupButton.add(editButton);
    formGroupButton.add(clearButton);
    final Column columnButton = new Column(ColumnSize.MD_9);
    columnButton.setOffset(ColumnOffset.MD_3);
    columnButton.add(formGroupButton);
    valuePairRow.add(columnButton);

    return valuePairRow;
  }
 @Override
 public void error() {
   form.setValidationState(ValidationState.ERROR);
 }
 @UiHandler("searchPatternTextBox")
 public void onPatternChanged(ChangeEvent event) {
   presenter.viewUpdated();
   form.setValidationState(ValidationState.NONE);
 }
 @Override
 public void setPattern(String pattern) {
   form.setValidationState(ValidationState.NONE);
   searchPatternTextBox.setText(pattern);
 }
  @UiHandler("search")
  public void onSearchClick(final ClickEvent e) {
    errorPanel.clear();
    formGroup.setValidationState(ValidationState.NONE);
    final Map<String, Object> metadata = new HashMap<String, Object>();
    if (!sourceTextBox.getText().trim().isEmpty()) {
      metadata.put("dcore.source[0]", sourceTextBox.getText().trim());
    }

    if (!createdByTextBox.getText().trim().isEmpty()) {
      metadata.put("createdBy", createdByTextBox.getText().trim());
    }

    if (!descriptionByTextBox.getText().trim().isEmpty()) {
      metadata.put("dcore.description[0]", descriptionByTextBox.getText().trim());
    }

    if (!formatTypeahead.getText().trim().isEmpty()) {
      final String pattern =
          clientTypeRegistry.resolveWildcardPattern(formatTypeahead.getText().trim());
      metadata.put("filename", pattern);
    }

    if (!subjectTextBox.getText().trim().isEmpty()) {
      metadata.put("dcore.subject[0]", subjectTextBox.getText().trim());
    }

    if (!typeTextBox.getText().trim().isEmpty()) {
      metadata.put("dcore.type[0]", typeTextBox.getText().trim());
    }

    if (!lastModifiedByTextBox.getText().trim().isEmpty()) {
      metadata.put("lastModifiedBy", lastModifiedByTextBox.getText().trim());
    }

    if (!externalLinkTextBox.getText().trim().isEmpty()) {
      metadata.put("dcore.relation[0]", externalLinkTextBox.getText().trim());
    }

    if (!checkinCommentTextBox.getText().trim().isEmpty()) {
      metadata.put("checkinComment", checkinCommentTextBox.getText().trim());
    }

    boolean hasSomeDateValue = false;

    if (createdAfter.getValue() != null) {
      hasSomeDateValue = true;
    }

    if (createdBefore.getValue() != null) {
      hasSomeDateValue = true;
    }

    if (lastModifiedAfter.getValue() != null) {
      hasSomeDateValue = true;
    }

    if (lastModifiedBefore.getValue() != null) {
      hasSomeDateValue = true;
    }

    if (metadata.size() == 0 && !hasSomeDateValue) {
      formGroup.setValidationState(ValidationState.ERROR);
      Alert alert = new Alert(Constants.INSTANCE.AtLeastOneFieldMustBeSet(), AlertType.DANGER);
      alert.setVisible(true);
      alert.setDismissable(true);
      errorPanel.add(alert);
      return;
    }

    final SearchResultTable queryTable =
        new SearchResultTable(
            new QueryMetadataPageRequest(
                metadata,
                createdAfter.getValue(),
                createdBefore.getValue(),
                lastModifiedAfter.getValue(),
                lastModifiedBefore.getValue(),
                0,
                null));
    simplePanel.clear();

    simplePanel.add(queryTable);

    formAccordionCollapse.setIn(false);
    resultAccordionCollapse.setIn(true);
  }