Example #1
0
/**
 * Create the tab Keyword
 *
 * @version 5.0 - August 2014
 * @author Marzia Grasso
 */
public class TabKeyword extends Composite {

  private static TabKeywordUiBinder uiBinder = GWT.create(TabKeywordUiBinder.class);

  interface TabKeywordUiBinder extends UiBinder<Widget, TabKeyword> {}

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

  /** title of the tab */
  @UiField(provided = true)
  Label titleLabel = new Label(constants.keywordTitle());

  /** summary of the tab */
  @UiField(provided = true)
  HTML summaryHTML = new HTML(constants.selectKeywordInfo());

  /** INSPIRE keywords setting */
  MD_Keywords_Group keywordsObj = new MD_Keywords_Group(constants.keyword(), false, false, "");

  @UiField(provided = true)
  CIMultiple keywordsContainerObj = new CIMultiple(constants.keyword(), keywordsObj, false, "");

  /** Note on mandatory fields */
  @UiField(provided = true)
  Label mandatoryFieldLabel = new Label("(*) " + constants.mandatoryField());

  /**
   * constructor TabKeyword
   *
   * @return the widget composed by the Keywords Tab
   */
  public TabKeyword() {
    // initialize widget
    initWidget(uiBinder.createAndBindUi(this));
    // set style
    titleLabel.removeStyleName("gwt-Label");
    // set form names
    setFormName();
    // set interface
    setInterface();
    // change summary if the data type is data service
    if (EUOSMEGWT.metadataType.equalsIgnoreCase(DataTypes.DATA_SERVICE.toString()))
      summaryHTML.setHTML(constants.selectKeywordInfoDataService());
  }

  /** This is called to make a client (first) check of the contained fields */
  public void myCheck() {
    keywordsObj.myCheck();
  }

  /** Set the IDs of the contained objects */
  public void setFormName() {
    keywordsObj.setFormName(
        "md_metadata[1].identificationinfo[1]."
            + MainPanel.identificationInfoSubType
            + "[1].descriptivekeywords[1].md_keywords[1]");
    keywordsContainerObj.setFormName(
        "md_metadata[1].identificationinfo[1]."
            + MainPanel.identificationInfoSubType
            + "[1].descriptivekeywords[1]");
  }

  /** Show or hide elements according to the selected {@link AppModes} */
  public void setInterface() {
    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()))) {
      keywordsObj.setRequired(true);
      keywordsObj.removeDisclosure();
      keywordsObj.setMultiple(false);
      keywordsContainerObj.addButton.setVisible(false);
      keywordsContainerObj.removeDisclosure();
    }
  }

  public void addKeyword(
      String myString,
      String mySource,
      String myDate,
      String myDateType,
      String myUri,
      String nodeName,
      String parent) { // MG 28.04.2015
    keywordsObj.setFormName(nodeName);
    keywordsContainerObj.setFormName(parent);
    keywordsObj.addNew(myString, mySource, myDate, myDateType, myUri, nodeName);
  }
}