private void LoadQueriesBtnMouseClicked( java.awt.event.MouseEvent evt) { // GEN-FIRST:event_LoadQueriesBtnMouseClicked // Algorithm /* * Goto queries' directory and load all queryfile.query to Combobox * Change local directory to repository diretory * List all file there * Try to load all file and add to combobox * * */ String sQueryRepositoryPath = "/home/natuan/Documents/OntologyMysql/QueriesRepository/"; File dir = new File(sQueryRepositoryPath); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { System.out.println("list files"); for (int i = 0; i < children.length; i++) { // Get filename of file or directory String filename = children[i]; String sContent = ReadWholeFileToString(sQueryRepositoryPath + filename); queryList.add(sContent); QueriesCmb.addItem(filename); SparqlTxtArea.setText(sContent); // System.out.println(filename); } QueriesCmb.setSelectedIndex(children.length - 1); } } // GEN-LAST:event_LoadQueriesBtnMouseClicked
public File getSequencesDir() { File dir = new File( homeBilder.getPath() + File.separator + DIR_METADATEN_ROOT + File.separator + DIR_SEQUENCES); dir.mkdirs(); return dir; }
public String getAlbumName() { if (albumName != null) { return albumName; } // from text file "pm_album_name.txt" if (homeBilder == null) { return "not-found"; } // File Album-name nicht vorhanden if (albumName == null) { homeFileAlbumName = new File(getMetaRootDir() + File.separator + FILE_ALBUM_NAME); if (!homeFileAlbumName.exists()) { try { homeFileAlbumName.createNewFile(); PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(homeFileAlbumName))); out.println(homeBilder.getName()); out.close(); // read it now ... } catch (IOException e) { albumName = "cannot-create"; return albumName; } } // File exist. Read it. try { BufferedReader in = new BufferedReader(new FileReader(homeFileAlbumName)); while (true) { String line = in.readLine().trim(); if (line.startsWith("#")) { continue; } albumName = line.trim(); break; } in.close(); } catch (IOException e) { albumName = "cannot-create"; return albumName; } } return albumName; }
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; }
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); } }
public File getMetaRootDir() { return new File(homeBilder.getPath() + File.separator + DIR_METADATEN_ROOT); }
public String getPathMetadatenRoot() { File directory = new File(homeBilder.getPath() + File.separator + DIR_METADATEN_ROOT); return directory.getPath(); }
// The private constructor private PM_Configuration(String[] args) { File fileEinstellungen = null; File directoryHomeBilder = null; // -------------------------------- // �bernehmen Start-Parameter // -------------------------------- int c; Getopt g = new Getopt("photo-manager", args, "e:b:i:n::d::"); String arg; while ((c = g.getopt()) != -1) { switch (c) { case 'e': arg = g.getOptarg(); fileEinstellungen = (arg == null) ? null : new File(arg); break; case 'b': arg = g.getOptarg(); directoryHomeBilder = (arg == null) ? null : new File(arg); break; case 'n': // batch batch = true; break; // case 'd': // daemon und batch // demon = true; // batch = true; // break; case 'i': arg = g.getOptarg(); if (arg != null) { importFiles.add(new File(arg)); } break; } } // Jetzt noch die ohne Options.Das sind dann Import-Files for (int i = g.getOptind(); i < args.length; i++) { importFiles.add(new File(args[i])); } // -------------------------------------------------------------- // Reihenfolge: // 1. a. -e Parameter auswerten // b. nigefu: .photo-manager/pm_einstellungen.xml suchen // c. nigefu: Locale prompten und .photo-manager/pm_einstellungen.xml // neu anlegen // 2. a. -b Parameter auswerten // b. nigefu: Eintrag in .photo-manager/pm_einstellungen.xml suchen // c. nigefu: prompten (ERROR wenn batch) // 3. Wenn in .photo-manager/pm_einstellungen.xml // Bilder-Dir nicht eingetragen, dann dort eintragen. // (wenn vorhanden, nicht �berschreiben) // ------------------------------------------------------------------ // -------------------------------------------------------------------- // (1) pm_einstellungen.xml und locale ermitteln // -------------------------------------------------------------------- if (fileEinstellungen != null && fileEinstellungen.isFile()) { // (1.a.) -e Parameter vorhanden: // open und lesen locale xmlFile = fileEinstellungen; openDocument(OPEN_READ_ONLY); locale = getLocale(); if (locale == null) { locale = (new PM_WindowDialogGetLocale().getLocale()); setLocale(locale); writeDocument(); } } else { // (1.b.) -e nicht angegeben fileEinstellungen = new File(PM_Utils.getConfigDir() + File.separator + FILE_EINSTELLUNGEN); if (fileEinstellungen.isFile()) { // (1.b) in .photo-manager/pm_einstellungen.xml Datei gefunden xmlFile = fileEinstellungen; openDocument(OPEN_READ_ONLY); locale = getLocale(); if (locale == null) { locale = (new PM_WindowDialogGetLocale().getLocale()); setLocale(locale); writeDocument(); } } else { // pm_einstellungen.xml nigefu: // locale prompten und pm_einstellungen neu anlegen locale = (new PM_WindowDialogGetLocale().getLocale()); xmlFile = fileEinstellungen; rootTagName = rootTag; openDocument(OPEN_CREATE); setLocale(locale); writeDocument(); } } // --------------------------------------------------------------- // (2) Bilder Dir ermitteln // --------------------------------------------------------------- if (directoryHomeBilder != null && directoryHomeBilder.isDirectory()) { // --- es wurde -b <top level directory> angegeben homeBilder = directoryHomeBilder; setHomeBilder(homeBilder.getPath()); writeDocument(); } else { // jetzt muss homeBilder aus der xml-Datei gelesen werden. // Wenn nigefu., dann prompten und eingtragen homeBilder = getHomeFile(); if (homeBilder == null || homeBilder.isDirectory() == false) { if (batch) { System.out.println("ERROR: batch kein TLPD gefunden"); System.out.println("abnormal end"); System.exit(0); } PM_MSG.setResourceBundle(locale); PM_WindowGetTLPD sp = new PM_WindowGetTLPD(); homeBilder = sp.getResult(); if (homeBilder == null) { setLocale(locale); writeDocument(); System.out.println("abnormal end (no TLPD)"); System.exit(0); } setLocale(locale); setHomeBilder(homeBilder.getPath()); writeDocument(); } } // ----------------------------------------------------- // Jetzt gibt es: // ein korrektes xmlFile mit einem homeBilder Eintrag // homeBilder ist korrekt versorgt // -------------------------------------------------------- // System.out.println("Locale = "+ locale); PM_MSG.setResourceBundle(locale); setAllPrinter(); setPrinterFormat(); setDateFromTo(); setPrefetch(); setSlideshow(); setBackup(); setSequences(); setMpeg(); // homeLuceneDB in -e nicht eingetragn if (homeLuceneDB == null) { homeLuceneDB = new File( homeBilder.getPath() + File.separator + DIR_METADATEN_ROOT + File.separator + DIR_LUCENE_DB); homeLuceneDB.mkdirs(); } // Temp-Dir nicht vorhanden if (homeTemp == null) { homeTemp = new File(homeBilder.getPath() + File.separator + DIR_PM_TEMP); // "pm_temp"); homeTemp.mkdirs(); } // Externe-Programme nicht vorhanden if (homeExtProgramme == null) { homeExtProgramme = new File(PM_Utils.getConfigDir() + File.separator + FILE_EXTERNE_PROGRAMME); } // InitValues nicht vorhanden if (homeInitValues == null) { homeInitValues = new File(PM_Utils.getConfigDir() + File.separator + FILE_INIT_VALUES); } }