private Locale getLocale() {

    java.util.List result = new java.util.ArrayList();
    String language = "";
    String country = "";
    String variant = "";

    // -----------------------------------------------------------------
    // <locale language="en" country="GB" variant="J" />
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_LOCALE);
    if (result.size() == 1) {
      Element el = (Element) result.get(0);
      language = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_LANGUAGE);
      country = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_COUNTRY);
      variant = PM_XML_Utils.getAttribute(el, ATTR_LOCALE_VARIANT);
    }

    if (language.length() == 0) {
      return null;
    }
    // if (country.length() == 0) {
    // return new Locale(language);
    // }
    // if (variant.length() == 0) {
    // return new Locale(language, country);
    // }

    return new Locale(language, country, variant);
  }
  // =====================================================
  // private: setPreftch()
  //
  // <prefetch plus="2" minus="0"/>
  //
  // =====================================================
  private void setPrefetch() {
    java.util.List result = new java.util.ArrayList();

    // -----------------------------------------------------------------
    // <datum>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_PREFETCH);
    if (result.size() == 1) {
      Element elPrefetch = (Element) result.get(0);
      prefetchPlus = PM_XML_Utils.getAttributeInt(elPrefetch, ATTR_PREFETCH_PLUS);
      prefetchMinus = PM_XML_Utils.getAttributeInt(elPrefetch, ATTR_PREFETCH_MINUS);
    }
  }
  // =====================================================
  // private: setDatumJahrVonBis()
  //
  // <datum jahr-von="1998" jahr-bis="2007"/>
  //
  // =====================================================
  private void setDateFromTo() {
    java.util.List result = new java.util.ArrayList();

    // -----------------------------------------------------------------
    // <datum>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_DATUM);
    if (result.size() == 1) {
      Element elDatum = (Element) result.get(0);
      datumJahrVon = PM_XML_Utils.getAttributeInt(elDatum, ATTR_DATUM_JAHR_VON);
      datumJahrBis = PM_XML_Utils.getAttributeInt(elDatum, ATTR_DATUM_JAHR_BIS);
    }
  }
  private void setSlideshow() {
    java.util.List result = new java.util.ArrayList();

    // -----------------------------------------------------------------
    // <diashow>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_DIASHOW);
    if (result.size() == 1) {
      Element el = (Element) result.get(0);
      slideshowText1 = PM_XML_Utils.getAttribute(el, ATTR_DIASHOW_TEXT1);
      slideshowText2 = PM_XML_Utils.getAttribute(el, ATTR_DIASHOW_TEXT2);
      slideshowText3 = PM_XML_Utils.getAttribute(el, ATTR_DIASHOW_TEXT3);
    }
  }
 /**
  * Read all printer formats from config file.
  *
  * <pre>
  *   <bild-format name="13 x 15" papier-format="F2" breite-mm="130" hoehe-mm="150" />
  * </pre>
  */
 private void setPrinterFormat() {
   PM_PictureFormatCollection instance = PM_PictureFormatCollection.getInstance();
   List formatList = PM_XML_Utils.getElementListe(document, "//" + TAG_BILD_FORMAT);
   // loop over all tags
   for (Iterator itFormate = formatList.iterator(); itFormate.hasNext(); ) {
     Element format = (Element) itFormate.next();
     String name = PM_XML_Utils.getAttribute(format, ATTR_FORMAT_NAME);
     String papierFormatString = PM_XML_Utils.getAttribute(format, ATTR_FORMAT_FORMAT);
     int breite = PM_XML_Utils.getAttributeInt(format, ATTR_FORMAT_BREITE);
     int hoehe = PM_XML_Utils.getAttributeInt(format, ATTR_FORMAT_HOEHE);
     PM_PaperFormat papierFormat = PM_PaperFormat.getPaperFormat(papierFormatString);
     if (papierFormat == null) {
       continue;
     }
     if (hoehe == 0 || breite == 0) continue; // unzul�ssige Eingaben
     instance.addBildFormat(
         new PM_PictureFormatFix(papierFormat, new Rectangle(breite, hoehe), name));
   }
 }
  private void setMpeg() {
    java.util.List result = new java.util.ArrayList();

    // -----------------------------------------------------------------
    // <diashow>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_VDR);
    if (result.size() == 1) {
      // support vdr (make for example mpeg files)
      mpeg = true;
    }
  }
 // =====================================================
 // private: setHomeBilder()
 //
 // <home>
 // <bilder> ..path.. </bilder>
 // </home>
 //
 // =====================================================
 private void setHomeBilder(String path) {
   Element root = document.getRootElement();
   // pr�fen,ob home-tag vorhanden
   java.util.List homeListe = PM_XML_Utils.getElementListe(document, "//" + TAG_HOME);
   Element homeElement = null;
   if (homeListe.isEmpty()) {
     homeElement = new org.dom4j.tree.DefaultElement(TAG_HOME);
     addTag(homeElement, TAG_BILDER, path);
     root.add(homeElement);
   } else {
     homeElement = (Element) homeListe.get(0);
     addTag(homeElement, TAG_BILDER, path);
   }
 }
  private void setAllPrinter() {
    java.util.List systemDruckerList =
        PM_XML_Utils.getElementListe(document, "//" + TAG_SYSTEM_DRUCKER);
    // --------------------------------------------------------------
    // Loop ueber ALLE Systemdrucker
    // --------------------------------------------------------------
    for (Iterator itSystemDrucker = systemDruckerList.iterator(); itSystemDrucker.hasNext(); ) {
      Element systemDrucker = (Element) itSystemDrucker.next();
      String systemPrinterName = PM_XML_Utils.getAttribute(systemDrucker, ATTR_SYSTEM_DRUCKER_NAME);
      PM_SystemPrinter systemPrinter = systemPrinters.getSystemPrinter(systemPrinterName);
      if (systemPrinter == null) {
        continue; // system printer not found
      }
      // --------------------------------------------------------------
      // loop ueber alle pm-drucker innerhalb EINES Systemdruckers
      // --------------------------------------------------------------
      java.util.List pmDruckerList = PM_XML_Utils.getElementListe(systemDrucker, TAG_PM_DRUCKER);
      for (Iterator itPmDrucker = pmDruckerList.iterator(); itPmDrucker.hasNext(); ) {
        Element pmDrucker = (Element) itPmDrucker.next();
        String pmDruckerName = PM_XML_Utils.getAttribute(pmDrucker, ATTR_PM_DRUCKER_NAME);
        // init pmPrinter
        PM_PmPrinter pmPrinter = new PM_PmPrinter(systemPrinter, pmDruckerName);
        // add to system printer
        systemPrinter.addPmDrucker(pmPrinter);
        // drucker.setPapierBereich(papierBereich);
        // ---- Druck-Bereich innerhalb eines pm-druckers -------
        Element druckBereichElement = pmDrucker.element(TAG_DRUCK_BEREICH);
        if (druckBereichElement != null) {
          double oben =
              PM_XML_Utils.getAttributeDouble(druckBereichElement, ATTR_DRUCK_BEREICH_OBEN);
          double rechts =
              PM_XML_Utils.getAttributeDouble(druckBereichElement, ATTR_DRUCK_BEREICH_RECHTS);
          double unten =
              PM_XML_Utils.getAttributeDouble(druckBereichElement, ATTR_DRUCK_BEREICH_UNTEN);
          double links =
              PM_XML_Utils.getAttributeDouble(druckBereichElement, ATTR_DRUCK_BEREICH_LINKS);
          pmPrinter.setDruckBereichGesamtRaender(oben, rechts, unten, links);
        }
      } // ende alle pm-drucker fuer einen system-drucker
    } // ende alle Systemdrucker

    // Wenn kein Drucker, dann Default-Drucker anlegen

  }
  private File getHomeFile() {

    File home = null;
    java.util.List result = new java.util.ArrayList();
    String value = null;

    // -----------------------------------------------------------------
    // <bilder>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_HOME + "/" + TAG_BILDER);
    if (result.size() == 1) {
      value = ((Element) result.get(0)).getTextTrim();
      value = PM_Utils.removeLastSeparatorChar(value);
      home = new File(value);
      if (!home.isDirectory()) {
        home = null;
      }
    }
    return home;
  }
Ejemplo n.º 10
0
 public void setLocale(Locale locale) {
   // locale == null --> l�schen
   Element root = document.getRootElement();
   // pr�fen,ob locale-tag vorhanden
   java.util.List localeListe = PM_XML_Utils.getElementListe(document, "//" + TAG_LOCALE);
   Element localeElement = null;
   if (localeListe.isEmpty()) {
     if (locale == null) {
       return; // soll gel�scht sein
     }
     localeElement = new org.dom4j.tree.DefaultElement(TAG_LOCALE);
     updateAttribute(localeElement, ATTR_LOCALE_LANGUAGE, locale.getLanguage());
     root.add(localeElement);
   } else {
     localeElement = (Element) localeListe.get(0);
     if (locale != null) {
       updateAttribute(localeElement, ATTR_LOCALE_LANGUAGE, locale.getLanguage());
     } else {
       // l�schen
       updateAttribute(localeElement, ATTR_LOCALE_LANGUAGE, null);
     }
   }
 }
Ejemplo n.º 11
0
  private void setBackup() {
    List result = new ArrayList();

    // -----------------------------------------------------------------
    // <vdr-plugin>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_BACKUP + "/" + TAG_VDR_PLUGIN);
    if (result.size() == 1) {
      vdrPlugin = true;
      Element elPlugin = (Element) result.get(0);

      vdrPlugHost = PM_XML_Utils.getAttribute(elPlugin, ATTR_VDR_HOST);
      vdrPlugName = PM_XML_Utils.getAttribute(elPlugin, ATTR_VDR_NAME);
      vdrPlugINDEX = PM_XML_Utils.getAttribute(elPlugin, ATTR_VDR_INDEX);
      vdrPlugMPG = PM_XML_Utils.getAttribute(elPlugin, ATTR_VDR_MPG);
      vdrOverscanX = PM_XML_Utils.getAttribute(elPlugin, ATTR_VDR_OV_X);
      vdrOverscanY = PM_XML_Utils.getAttribute(elPlugin, ATTR_VDR_OV_Y);
    }
    // -----------------------------------------------------------------
    // <bilder>
    // -----------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_BACKUP + "/" + TAG_BILDER_BILDER);
    for (int i = 0; i < result.size(); i++) {
      Element el = (Element) result.get(i);
      BackUp bB =
          new BackUp(
              PM_XML_Utils.getAttribute(el, ATTR_BILDER_NAME),
              homeBilder.getPath(), // from
              PM_XML_Utils.getAttribute(el, ATTR_BILDER_DIR), // TO
              PM_XML_Utils.getAttributeBoolean(el, ATTR_BILDER_MPEG));
      backupBilderList.add(bB);
    }

    // ----------------------------------------------------------------------------------------------
    // <daten>
    // ----------------------------------------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_BACKUP + "/" + TAG_DATEN);
    for (int i = 0; i < result.size(); i++) {
      Element el = (Element) result.get(i);
      BackUp bB =
          new BackUp(
              PM_XML_Utils.getAttribute(el, ATTR_DATEN_NAME),
              PM_XML_Utils.getAttribute(el, ATTR_DATEN_FROM), // from
              PM_XML_Utils.getAttribute(el, ATTR_DATEN_TO), // TO
              false // no mepeg files
              );
      backupDatenList.add(bB);
    }
    // ----------------------------------------------------------------------------------------------
    // <album>
    // ----------------------------------------------------------------------------------------------
    result = PM_XML_Utils.getElementListe(document, "//" + TAG_BACKUP + "/" + TAG_ALBUM);
    for (int i = 0; i < result.size(); i++) {
      Element el = (Element) result.get(i);
      BackUp bB =
          new BackUp(
              PM_XML_Utils.getAttribute(el, ATTR_ALBUM_NAME),
              homeBilder.getPath(), // from
              PM_XML_Utils.getAttribute(el, ATTR_ALBUM_DIR),
              false // no mpeg files
              );
      backupAlbumList.add(bB);
    }
  }