List of usage examples for org.apache.commons.lang SystemUtils getUserDir
public static File getUserDir()
Gets the user directory as a File
.
From source file:com.jaspersoft.studio.server.wizard.exp.ExportMetadataPage.java
protected ExportMetadataPage() { super("exportmetadata"); //$NON-NLS-1$ setTitle(Messages.ExportMetadataPage_0); setDescription(Messages.ExportMetadataPage_1); bindingContext = new DataBindingContext(); try {/*from w w w.j a va2s.co m*/ value.setFile(SystemUtils.getUserDir().getCanonicalPath() + File.separator + "export.zip"); //$NON-NLS-1$ } catch (IOException e) { e.printStackTrace(); } }
From source file:me.philnate.textmanager.utils.PDFCreator.java
@SuppressWarnings("deprecation") private void preparePDF() { try {/*ww w. j av a 2 s. co m*/ File path = new File(SystemUtils.getUserDir(), "template"); File template = new File(path, Setting.find("template").getValue()); Velocity.setProperty("file.resource.loader.path", path.getAbsolutePath()); Velocity.init(); VelocityContext ctx = new VelocityContext(); // User data/Settings for (Setting setting : ds.find(Setting.class).asList()) { ctx.put(setting.getKey(), setting.getValue()); } NumberFormat format = NumberFormat.getNumberInstance(new Locale(Setting.find("locale").getValue())); // #60 always show 2 digits for fraction no matter if right most(s) // are zero format.setMinimumFractionDigits(2); format.setMaximumFractionDigits(2); ctx.put("number", format); // TODO update schema to have separate first and lastname // Customer data ctx.put("customer", customer); // General data ctx.put("month", new DateFormatSymbols().getMonths()[month]); ctx.put("math", new MathTool()); // Billing data ctx.put("allItems", BillingItem.find(customer.getId(), year, month)); ctx.put("billNo", bill.getBillNo()); StringWriter writer = new StringWriter(); Velocity.mergeTemplate(template.getName(), ctx, writer); File filledTemplate = new File(path, bill.getBillNo() + ".tex"); FileUtils.writeStringToFile(filledTemplate, writer.toString(), "ISO-8859-1"); ProcessBuilder pdfLatex = new ProcessBuilder(Setting.find("pdfLatex").getValue(), "-interaction nonstopmode", "-output-format pdf", filledTemplate.toString()); // Saving template file (just in case it may be needed later GridFSFile texFile = tex.createFile(filledTemplate); texFile.put("month", month); texFile.put("year", year); texFile.put("customerId", customer.getId()); texFile.save(); pdfLatex.directory(path); String pdfPath = filledTemplate.toString().replaceAll("tex$", "pdf"); if (0 == printOutputStream(pdfLatex)) { // display Bill in DocumentViewer new ProcessBuilder(Setting.find("pdfViewer").getValue(), pdfPath).start().waitFor(); GridFSFile pdfFile = pdf.createFile(new File(pdfPath)); pdfFile.put("month", month); pdfFile.put("year", year); pdfFile.put("customerId", customer.getId()); pdf.remove(QueryBuilder.start("month").is(month).and("year").is(year).and("customerId") .is(customer.getId()).get()); pdfFile.save(); File[] files = path.listFiles((FileFilter) new WildcardFileFilter(bill.getBillNo() + ".*")); for (File file : files) { FileUtils.forceDelete(file); } } else { new JOptionPane( "Bei der Erstellung der Rechnung ist ein Fehler aufgetreten. Es wurde keine Rechnung erstellt.\n Bitte Schauen sie in die Logdatei fr nhere Fehlerinformationen.", JOptionPane.ERROR_MESSAGE).setVisible(true); } } catch (IOException e) { Throwables.propagate(e); } catch (InterruptedException e) { Throwables.propagate(e); } }
From source file:de.interactive_instruments.ShapeChange.Options.java
private void setStandardParameters() { setParameter("reportLevel", "INFO"); setParameter("xsltFile", "src/main/resources/xslt/result.xsl"); setParameter("appSchemaName", ""); setParameter("appSchemaNameRegex", ""); setParameter("appSchemaNamespaceRegex", ""); setParameter("publicOnly", "true"); setParameter("inputFile", "http://shapechange.net/resources/test/test.xmi"); setParameter("inputModelType", "XMI10"); setParameter("logFile", "log.xml"); setParameter("representTaggedValues", ""); setParameter("addTaggedValues", ""); setParameter("extractSeparator", "--IMPROBABLE--DUMMY--SEPARATOR--"); setParameter("definitionSeparator", "-- Definition --"); setParameter("descriptionSeparator", "-- Description --"); setParameter("nameSeparator", "-- Name --"); setParameter("outputDirectory", SystemUtils.getUserDir().getPath()); setParameter("sortedSchemaOutput", "true"); setParameter("sortedOutput", "true"); setParameter("oclConstraintTypeRegex", "(OCL|Invariant)"); setParameter("folConstraintTypeRegex", "(SBVR)"); setParameter(Options.TargetXmlSchemaClass, "defaultEncodingRule", Options.ISO19136_2007); setParameter(Options.TargetXmlSchemaClass, "gmlVersion", "3.2"); setParameter(Options.TargetOWLISO19150Class, "defaultEncodingRule", Options.ISO19150_2014); setParameter(Options.TargetSQLClass, "defaultEncodingRule", Options.SQL); }
From source file:nl.strohalm.cyclos.setup.ExportScript.java
/** * Export the script for creating the database *///from w w w. j a va2 s . co m public void run() { if (!exportTo.isAbsolute()) { exportTo = new File(SystemUtils.getUserDir(), exportTo.getPath()); } // Resolve the file name if (exportTo.isDirectory()) { exportTo = new File(exportTo, "cyclos.ddl"); } // Create the directory if needed final File dir = exportTo.getParentFile(); if (!dir.exists()) { if (!dir.mkdirs()) { throw new IllegalStateException("Could not create directory: " + dir); } } final String fileName = exportTo.getAbsolutePath(); Setup.out.println(bundle.getString("export-script.start")); final SchemaExport schemaExport = new SchemaExport(configuration); schemaExport.setDelimiter(";"); schemaExport.setOutputFile(fileName); schemaExport.create(true, false); Setup.out.println(bundle.getString("export-script.end") + " " + fileName); }
From source file:org.rapidcontext.app.Main.java
/** * Attempts to locate the application directory based on the * current working directory and the class path. * * @return the application directory found, or * null otherwise/* w w w.jav a 2 s. c om*/ */ private static File locateAppDir() { File[] dirs = { new File("."), SystemUtils.getUserDir(), ClasspathUtil.locateFile(ServerApplication.class) }; for (int i = 0; i < dirs.length; i++) { File file = dirs[i]; for (int j = 0; file != null && j < 4; j++) { if (isAppDir(file)) { return file; } file = file.getParentFile(); } } return null; }
From source file:org.tonguetied.datatransfer.exporting.TemplateTester.java
protected final void processTemplate() throws Exception { long start = System.currentTimeMillis(); Settings settings = new Settings(SystemUtils.getUserDir()); settings.set(NAME_SOURCE_ROOT, templateDir.getAbsolutePath()); settings.set(NAME_OUTPUT_ENCODING, "UTF-8"); freemarker.log.Logger.selectLoggerLibrary(LIBRARY_LOG4J); settings.set(NAME_REPLACE_EXTENSIONS, new String[] { "ftl", outputExtension }); settings.set(NAME_OUTPUT_ROOT, outputDir.getAbsolutePath()); settings.set(NAME_SOURCES, templateName); Map<String, Object> root = new HashMap<String, Object>(); root.put("translations", translations); // TODO: follow best practice and put in the configuration as a // shared variable, see: http://freemarker.sourceforge.net/docs/pgui_datamodel_directive.html // TemplateEnvironment.getCurrentInstance().getFreemarkerEnvironment().getConfiguration().setSharedVariable("native2ascii", new Native2AsciiDirective()); root.put("native2ascii", new Native2AsciiDirective()); settings.set(NAME_DATA, root);/*from ww w . j ava 2s. com*/ settings.addProgressListener(new LoggerProgressListener()); settings.execute(); if (logger.isInfoEnabled()) { float totalMillis = System.currentTimeMillis() - start; logger.info("import complete in " + (totalMillis / 1000) + " seconds"); } }