Example #1
0
/**
 * Create CI_Citation model Citation data for the resource
 *
 * @version 5.0 - August 2014
 * @author Marzia Grasso
 */
public class MD_Medium extends CI {

  /** Constants declaration */
  protected iso19115Constants constants = GWT.create(iso19115Constants.class);

  /** Messages declaration */
  protected iso19115Messages messages = GWT.create(iso19115Messages.class);

  /** title control declaration */
  CharacterString titleObj =
      new CharacterString(constants.title(), "", true, CheckFunctions.normal, true);

  /** alternateTitle control declaration */
  CharacterString alternateTitleObj =
      new CharacterString(constants.alternateTitle(), "", false, CheckFunctions.normal, true);

  /** identifier control declaration */
  RS_Identifier identifierObj = new RS_Identifier(constants.md_identifier(), false, true, "");

  CIMultiple identifierContainerObj =
      new CIMultiple(constants.md_identifier(), identifierObj, false, "resourceidentifier");

  /** identifier control declaration */
  CI_Date dateObj = new CI_Date(constants.date(), true, true, "");

  CIMultiple dateContainerObj = new CIMultiple(constants.date(), dateObj, true, "");

  /** List of specification for RDSI AppMode */
  final CodeListFree specificationObj =
      new CodeListFree(
          constants.specifications(),
          "specification",
          false,
          "15",
          "",
          CheckFunctions.normal,
          true,
          false);

  /**
   * constructor MD_Medium model
   *
   * @param label {@link String} = the header
   * @param required {@link Boolean} = if true, it is required
   * @param multiple {@link Boolean} = if true, it could be added more than ones
   * @param help {@link String} = the anchor in the help
   * @return the widget composed by CI_Citation fields
   */
  public MD_Medium(String label, boolean required, boolean multiple, String help) {
    super(label, required, multiple, help, CIOrientations.VERTICAL);
    fieldsGroup.add(titleObj);
    fieldsGroup.add(alternateTitleObj);
    fieldsGroup.add(identifierContainerObj);
    fieldsGroup.add(dateContainerObj);

    specificationObj
        .myTextBox
        .getValueBox()
        .addBlurHandler(
            new BlurHandler() {
              @Override
              public void onBlur(BlurEvent event) {
                TreeItem myTreeItem = null;
                myTreeItem =
                    Utilities.getSelectTreeItem(specificationObj.myTextBox.getValueBox().getName());
                if (myTreeItem != null) {
                  Utilities.ensureItemVisible(myTreeItem);
                  Utilities.setTextTreeItem(myTreeItem, specificationObj.myTextBox.getText());
                }
              }
            });

    setInterface(-1);
  }

  @Override
  public void myCheck() {
    if (this.getParent().isVisible()) {
      if (titleObj.isVisible()) titleObj.myCheck();
      if (alternateTitleObj.isVisible()) alternateTitleObj.myCheck();
      if (identifierObj.isVisible()) identifierObj.myCheck();
      if (dateObj.isVisible()) dateObj.myCheck();
      if (specificationObj.isVisible()) specificationObj.myCheck();
    }
  }

  @Override
  public void setFormName(String name) {
    super.setFormName(name);
    titleObj.setFormName(name + ".title[1].characterstring[1]");
    specificationObj.setFormName(name + ".title[1].characterstring[1]");
    alternateTitleObj.setFormName(name + ".alternatetitle[1].characterstring[1]");
    identifierObj.setFormName(name + ".identifier[1].rs_identifier[1]");
    identifierContainerObj.setFormName(name + ".identifier[1]");
    dateObj.setFormName(name + ".date[1].ci_date[1]");
    dateContainerObj.setFormName(name + ".date[1]");
  }

  @Override
  public void setInterface(int i) {
    if (EUOSMEGWT.appMode.equalsIgnoreCase(AppModes.EENVPLUS.toString())
        || EUOSMEGWT.appMode.equalsIgnoreCase(AppModes.GEOSS.toString())
        || EUOSMEGWT.appMode.equalsIgnoreCase(AppModes.GEOPORTAL.toString())
        || EUOSMEGWT.appMode.equalsIgnoreCase(AppModes.RDSI.toString())) {
      identifierObj.setRequired(true);
      identifierContainerObj.setRequired(true);
      if (EUOSMEGWT.metadataType.equals(DataTypes.DATA_SERVICE.toString())) {
        identifierObj.setRequired(false);
        identifierContainerObj.setRequired(false);

        identifierContainerObj.setVisible(false);
        identifierObj.setVisible(false);
      }
      if (i == 0) { // TAB Identification
        alternateTitleObj.setVisible(false);
        titleObj.setLabel(constants.resourceTitle());
        titleObj.setHelpAnchor("resourcetitle");
        // remove dates because are in conflict with tab temporal (publication date has the same
        // xpath)
        dateObj.setVisible(false);
        dateContainerObj.setVisible(false);
        dateContainerObj.removeFromParent();
        dateObj.removeFromParent();
      }
      if (i == 1) { // TAB keyword			
        alternateTitleObj.setVisible(false);
        identifierObj.setVisible(false);
        identifierContainerObj.setVisible(false);
        dateObj.removeDisclosure();
        dateObj.dateObj.setLabel(constants.referenceDate());
        dateObj.setMultiple(false);
        fieldsGroup.add(dateObj);
        dateContainerObj.setVisible(false);
        // do not autoupdate the free keyword field to the tree
        titleObj.setAutoupdate(false);
      }
      if (i == 2) { // TAB conformity
        fieldsGroup.clear();
        fieldsGroup.add(specificationObj);
        fieldsGroup.add(alternateTitleObj);
        fieldsGroup.add(identifierContainerObj);
        fieldsGroup.add(dateContainerObj);
        alternateTitleObj.setVisible(false);
        identifierObj.setVisible(false);
        identifierContainerObj.setVisible(false);
        dateContainerObj.setVisible(false);
        dateObj.setMultiple(false);
        dateObj.removeDisclosure();
        fieldsGroup.add(dateObj);
      }
    } // TAB Identification
    else if (i == 0) {
      titleObj.setLabel(constants.resourceTitle());
      alternateTitleObj.setLabel(constants.resourceAlternateTitle());
      identifierContainerObj.setLabel(constants.resourceIdentifier());
      identifierObj.setLabel(constants.resourceIdentifier());
    }
  }
}