public boolean processSelectInsert() {

    if (enabledControls.contains(new String("dt_initdebate_hansarddate"))) {
      // get the value and set it into the document
      String dateOfHansard = (String) theControlDataMap.get("dt_initdebate_hansarddate");
      ooDocMetadata meta = new ooDocMetadata(ooDocument);
      meta.AddProperty("Bungeni_DebateOfficialDate", dateOfHansard);
      XTextRange selRange = (XTextRange) ooDocument.getSingleSelectionRange().get("XTextRange");
      String strSelection = selRange.getString();
      boolean bDateAdd =
          action_replaceTextWithField(ooDocument, "debaterecord_official_date", strSelection);
      if (!bDateAdd) {
        checkFieldsMessages.add("There was an error while marking the handard date");
      }
      return bDateAdd;
    }

    if (enabledControls.contains(new String("dt_initdebate_timeofhansard"))) {
      // get the current time value into the document
      String timeOfHansard = (String) theControlDataMap.get("dt_initdebate_timeofhansard");
      ooDocMetadata meta = new ooDocMetadata(ooDocument);
      meta.AddProperty("Bungeni_DebateOfficialTime", timeOfHansard);
      XTextRange selRange = (XTextRange) ooDocument.getSingleSelectionRange().get("XTextRange");
      String strSelection = selRange.getString();
      boolean bTimeAdd =
          action_replaceTextWithField(ooDocument, "debaterecord_official_time", strSelection);
      if (!bTimeAdd) {
        checkFieldsMessages.add("There was an error while marking the handard time");
      }
      return bTimeAdd;
    }
    return true;
  }
 protected void setControlData() {
   try {
     // only in edit mode, only if the metadata properties exist
     if (theMode == SelectorDialogModes.TEXT_EDIT) {
       if (ooDocument.propertyExists("Bungeni_DebateOfficialDate")
           && ooDocument.propertyExists("Bungeni_DebateOfficialTime")) {
         ooDocMetadata meta = new ooDocMetadata(ooDocument);
         String strDate = meta.GetProperty("Bungeni_DebateOfficialDate");
         String strTime = meta.GetProperty("Bungeni_DebateOfficialTime");
         SimpleDateFormat formatter = new SimpleDateFormat("MMMM dd yyyy");
         this.dt_initdebate_hansarddate.setDate(formatter.parse(strDate));
         SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
         this.dt_initdebate_timeofhansard.setValue(timeFormat.parse(strTime));
       }
     }
   } catch (ParseException ex) {
     log.error("SetControlData: " + ex.getMessage());
   }
 }
  public boolean postFullEdit() {
    boolean bFullEdit = false;
    try {
      ooDocMetadata meta = new ooDocMetadata(ooDocument);
      meta.AddProperty(
          "Bungeni_DebateOfficialDate",
          (String) theControlDataMap.get("dt_initdebate_hansarddate"));
      meta.AddProperty(
          "Bungeni_DebateOfficialTime",
          (String) theControlDataMap.get("dt_initdebate_timeofhansard"));
      bFullEdit = true;

    } catch (Exception ex) {
      log.error("postFullEdit: error :" + ex.getMessage());
      checkFieldsMessages.add("There was an error setting document level metadata");
      bFullEdit = false;
      return bFullEdit;
    } finally {
      return bFullEdit;
    }
  }
Beispiel #4
0
  @Override
  protected void initFieldsEdit() {
    dt_initdebate_timeofhansard.setModel(
        new SpinnerDateModel(new Date(), null, null, Calendar.HOUR));
    dt_initdebate_timeofhansard.setEditor(
        new JSpinner.DateEditor(dt_initdebate_timeofhansard, "HH:mm"));
    ((JSpinner.DefaultEditor) dt_initdebate_timeofhansard.getEditor())
        .getTextField()
        .setEditable(false);

    if (getOoDocument().propertyExists("Bungeni_DebateOfficialTime")) {
      try {
        ooDocMetadata meta = new ooDocMetadata(getOoDocument());
        String strTime = meta.GetProperty("Bungeni_DebateOfficialTime");
        SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
        dt_initdebate_timeofhansard.setValue(timeFormat.parse(strTime));
      } catch (ParseException ex) {
        log.error("initFieldsEdit : " + ex.getMessage());
      }
    }
    return;
  }
  private boolean sectionEditAction() {
    // if section exists
    // update fields
    String containerSection = theAction.action_naming_convention();
    if (ooDocument.hasSection(containerSection) && ooDocument.hasSection("int:masthead_datetime")) {
      // now edit the fields and set the new values
      String strDebateDate = "", strTimeOfHansard = "";
      Date dtDebate = dt_initdebate_hansarddate.getDate();

      SimpleDateFormat df = new SimpleDateFormat("HH:mm");
      strTimeOfHansard = df.format((Date) dt_initdebate_timeofhansard.getValue()); // .getText();

      SimpleDateFormat formatter = new SimpleDateFormat("MMMM dd yyyy");
      strDebateDate = formatter.format(dtDebate);

      ExternalMacro setFieldValue =
          ExternalMacroFactory.getMacroDefinition("SetReferenceInputFieldValue");
      setFieldValue.addParameter(new String("debaterecord_official_date"));
      setFieldValue.addParameter(strDebateDate);
      setFieldValue.addParameter(new String("int:masthead_datetime"));
      ooDocument.executeMacro(setFieldValue.toString(), setFieldValue.getParams());
      setFieldValue.clearParams();
      setFieldValue.addParameter(new String("debaterecord_official_time"));
      setFieldValue.addParameter(strTimeOfHansard);
      setFieldValue.addParameter(new String("int:masthead_datetime"));
      ooDocument.executeMacro(setFieldValue.toString(), setFieldValue.getParams());
      // set date and time of hansard to document
      ooDocMetadata meta = new ooDocMetadata(ooDocument);
      meta.AddProperty("Bungeni_DebateOfficialDate", strDebateDate);
      meta.AddProperty("Bungeni_DebateOfficialTime", strTimeOfHansard);
      return true;

    } else {
      MessageBox.OK(parent, "There is no masthead section available for editing in this document!");
      return false;
    }
  }
  private boolean sectionInsertionAction() {
    String strDebateDate = "", strTimeOfHansard = "", strLogoPath = "";
    Date dtDebate = dt_initdebate_hansarddate.getDate();
    SimpleDateFormat df = new SimpleDateFormat("HH:mm");
    strTimeOfHansard = df.format((Date) dt_initdebate_timeofhansard.getValue());
    SimpleDateFormat formatter = new SimpleDateFormat("MMMM dd yyyy");
    strDebateDate = formatter.format(dtDebate);
    strLogoPath = m_strLogoPath;

    long sectionBackColor = 0xffffff;
    float sectionLeftMargin = (float) .2;
    log.debug("section left margin : " + sectionLeftMargin);
    // get the parent section name of this action
    // query action parents to find the parent of this action

    // String parentSectionName =

    ExternalMacro AddSectionInsideSection =
        ExternalMacroFactory.getMacroDefinition("AddSectionInsideSectionWithStyle");
    AddSectionInsideSection.addParameter(ooDocument.getComponent());
    AddSectionInsideSection.addParameter(BungeniEditorPropertiesHelper.getDocumentRoot());
    AddSectionInsideSection.addParameter(theAction.action_naming_convention());
    AddSectionInsideSection.addParameter(sectionBackColor);
    AddSectionInsideSection.addParameter(sectionLeftMargin);

    ooDocument.executeMacro(
        AddSectionInsideSection.toString(), AddSectionInsideSection.getParams());

    this.setSectionMetadataForAction(theAction.action_naming_convention(), theAction);
    // embed logo image
    ExternalMacro addImageIntoSection =
        ExternalMacroFactory.getMacroDefinition("AddImageIntoSection");
    addImageIntoSection.addParameter(theAction.action_naming_convention());
    addImageIntoSection.addParameter(m_strLogoPath);
    ooDocument.executeMacro(addImageIntoSection.toString(), addImageIntoSection.getParams());

    // loading the related document
    ExternalMacro insertDocIntoSection =
        ExternalMacroFactory.getMacroDefinition("InsertDocumentIntoSection");
    insertDocIntoSection.addParameter(ooDocument.getComponent());
    insertDocIntoSection.addParameter(theAction.action_naming_convention());
    insertDocIntoSection.addParameter(FragmentsFactory.getFragment("hansard_masthead"));
    ooDocument.executeMacro(insertDocIntoSection.toString(), insertDocIntoSection.getParams());

    ExternalMacro setFieldValue =
        ExternalMacroFactory.getMacroDefinition("SetReferenceInputFieldValue");
    setFieldValue.addParameter(new String("debaterecord_official_date"));
    setFieldValue.addParameter(strDebateDate);
    setFieldValue.addParameter(new String("int:masthead_datetime"));
    ooDocument.executeMacro(setFieldValue.toString(), setFieldValue.getParams());

    setFieldValue.clearParams();
    setFieldValue.addParameter(new String("debaterecord_official_time"));
    setFieldValue.addParameter(strTimeOfHansard);
    setFieldValue.addParameter(new String("int:masthead_datetime"));
    ooDocument.executeMacro(setFieldValue.toString(), setFieldValue.getParams());

    ooDocMetadata meta = new ooDocMetadata(ooDocument);
    meta.AddProperty("Bungeni_DebateOfficialDate", strDebateDate);
    meta.AddProperty("Bungeni_DebateOfficialTime", strTimeOfHansard);

    enableButtons(true);
    // MessageBox.OK(parent, "Prayers section was successfully added");
    return true;
  }