public URI getPropertyFileURI() { return CWProject.instance().getWritableURI(LuceneIndexManager.DIR_LUCENE + "/" + getClass().getName(), FileUtil.EXTENSION_PROPERTIES); }
/** * Establish how this project finds it's resources. * * @param homeProperty * a property that is used as the home directory name. If this * property has a value then homeDir and altHomeDir are ignored. * Defaults to jsword.home. * @param homeDir * the name of the directory to be used for Unix. Typically this * is a hidden directory, that is, it begins with a '.'. Defaults * to .jsword * @param altHomeDir * the name of the directory to be used for other OSes. This * should not be a hidden directory. Defaults to JSword. */ public static void setHome(String homeProperty, String homeDir, String altHomeDir) { CWProject.homeProperty = homeProperty; CWProject.homeDirectory = homeDir; CWProject.homeAltDirectory = altHomeDir; instance().establishProjectHome(); }
/** * Create a LuceneIndexManager with a default IndexPolicy. */ public LuceneIndexManager() { policy = new IndexPolicyAdapter(); try { baseFolderURI = CWProject.instance().getWritableProjectSubdir(DIR_LUCENE, false); } catch (IOException ex) { log.error("Failed to find lucene index storage area.", ex); } }
@Override public File getWriteLocation() { return getFile(CWProject.instance().getWritableFrontendProjectDir()); } };
@Override public File getReadLocation() { URI[] dirs = CWProject.instance().getProjectResourceDirs(); if (dirs.length > 1) { return getFile(dirs[1]); } return null; } @Override
@Override public File getReadLocation() { return getFile(CWProject.instance().getReadableFrontendProjectDir()); } @Override
@Override public File getWriteLocation() { URI[] dirs = CWProject.instance().getProjectResourceDirs(); if (dirs.length > 0) { return getFile(dirs[0]); } return null; } },
/** * @param newShown * Whether this WebWarning should be shown. */ public void setShown(boolean newShown) { try { shown = newShown; PropertyMap props = new PropertyMap(); props.put(SHOWN_KEY, Boolean.valueOf(shown).toString()); URI outputURI = CWProject.instance().getWritableURI(getClass().getName(), FileUtil.EXTENSION_PROPERTIES); NetUtil.storeProperties(props, outputURI, "JSword WebWarning"); } catch (IOException ex) { log.error("Failed to save JSword WebWarning", ex); } }
/** * Save all properties to the user's local area. Uses the same property name * so as to override it. */ public void save() { PropertyMap props = new PropertyMap(); StringBuilder buf = new StringBuilder(); int i = 1; for (String name : installers.keySet()) { Installer installer = installers.get(name); // Clear the buffer buf.delete(0, buf.length()); buf.append(installer.getType()); buf.append(','); buf.append(name); buf.append(','); buf.append(installer.getInstallerDefinition()); props.put(PREFIX + i++, buf.toString()); } URI outputURI = CWProject.instance().getWritableURI(getClass().getName(), FileUtil.EXTENSION_PLUGIN); try { NetUtil.storeProperties(props, outputURI, "Saved Installer Sites"); } catch (IOException e) { log.error("Failed to save installers", e); } }
private static void migrateBookDir() { // Books should be on this path URI userDataArea = OSType.getOSType().getUserAreaFolder(DIR_SWORD_CONF, DIR_SWORD_CONF_ALT); File swordBookPath = new File(userDataArea.getPath()); // The "old" Book location might be in one of two locations // It might be ~/.jsword or the new project dir File oldPath = new File(CWProject.instance().getDeprecatedWritableProjectDir().getPath()); if (oldPath.isDirectory()) { migrateBookDir(oldPath, swordBookPath); return; } // now trying the new project dir oldPath = new File(CWProject.instance().getWritableProjectDir().getPath()); if (oldPath.isDirectory()) { migrateBookDir(oldPath, swordBookPath); return; } // Finally, it might be ~/.sword oldPath = new File(OSType.DEFAULT.getUserAreaFolder(DIR_SWORD_CONF, DIR_SWORD_CONF_ALT).getPath()); if (oldPath.isDirectory()) { migrateBookDir(oldPath, swordBookPath); } }
/** * Set the current translation, using human readable string. * * @param newTranslation * the translation to use */ public void setCurrent(String newTranslation) { String found = DEFAULT_TRANSLATION; String currentTranslation = ""; for (int i = 0; i < translations.length; i++) { String trans = translations[i]; currentTranslation = toString(translation); if (trans.equals(newTranslation) || currentTranslation.equals(newTranslation)) { found = trans; break; } } try { translation = found; PropertyMap props = new PropertyMap(); if (!DEFAULT_TRANSLATION.equals(translation)) { props.put(TRANSLATION_KEY, translation); } URI outputURI = CWProject.instance().getWritableURI(getClass().getName(), FileUtil.EXTENSION_PROPERTIES); NetUtil.storeProperties(props, outputURI, "BibleDesktop UI Translation"); } catch (IOException ex) { log.error("Failed to save BibleDesktop UI Translation", ex); } }
/** * The URL for the cached index file for this installer */ protected URI getCachedIndexDir() throws InstallException { try { return CWProject.instance().getWritableProjectSubdir(getTempFileExtension(host, catalogDirectory), true); } catch (IOException ex) { throw new InstallException(JSOtherMsg.lookupText("URL manipulation failed"), ex); } }
testDefaultPath(bookDirs, new File(CWProject.instance().getWritableProjectDir().getPath()));
File jswordHome = NetUtil.getAsFile(CWProject.instance().getWritableProjectDir()); IOUtil.unpackZip(NetUtil.getAsFile(temp), jswordHome, false, SwordConstants.DIR_CONF, SwordConstants.DIR_DATA);