/** * Gets the current user's application data directory. * * @return the current user's application data directory * * @since BEAM 4.2 */ public static File getApplicationDataDir() { return getApplicationDataDir(false); }
private File getIODir() { File dir = SystemUtils.getUserHomeDir(); if (propertyMap != null) { dir = new File(propertyMap.getPropertyString(PROPERTY_KEY_IO_DIR, dir.getPath())); } return dir; }
/** * Optionally creates and returns the current user's application data directory. * * @param force if true, the directory will be created if it didn't exist before * * @return the current user's application data directory * * @since BEAM 4.2 */ public static File getApplicationDataDir(boolean force) { String contextId = getApplicationContextId(); final File dir = new File(getUserHomeDir(), "." + contextId); if (force && !dir.exists()) { dir.mkdirs(); } return dir; }
public static String getApplicationRemoteVersionUrl() { final String key = getApplicationContextId() + ".remoteVersion.url"; return System.getProperty(key, getApplicationHomepageUrl() + "software/version.txt"); }
public VersionChecker() { this(new File(SystemUtils.getApplicationHomeDir(), "VERSION.txt"), SystemUtils.getApplicationRemoteVersionUrl()); }
private static File getDirectory(String propertyName, String beamRelDefaultPath) { String filePath = System.getProperty(propertyName); if (filePath != null) { return new File(filePath); } return new File(SystemUtils.getBeamHomeDir(), SystemUtils.convertToLocalPath(beamRelDefaultPath)); } }
@Test public void testGetApplicationDataDir() { final File applicationDataDir = SystemUtils.getApplicationDataDir(); assertNotNull(applicationDataDir); final String prefix = SystemUtils.getUserHomeDir().getPath(); assertTrue(applicationDataDir.getPath().startsWith(prefix)); }
@Test public void testApplicationProperties() { assertNotNull(SystemUtils.getApplicationContextId()); assertFalse(SystemUtils.getApplicationContextId().isEmpty()); assertNotNull(SystemUtils.getApplicationName()); assertFalse(SystemUtils.getApplicationName().isEmpty()); assertNotNull(SystemUtils.getApplicationHomepageUrl()); assertFalse(SystemUtils.getApplicationHomepageUrl().isEmpty()); assertNotNull(SystemUtils.getApplicationHomeDir()); }
public static String getApplicationHomePropertyName() { return getApplicationContextId() + ".home"; }
public static BeamFileFilter getSessionFileFilter() { return new BeamFileFilter("BEAM-SESSION", String.format(".%s", SystemUtils.getApplicationContextId()), String.format("%s session", SystemUtils.getApplicationName())); }
public void actionPerformed(ActionEvent e) { SystemUtils.copyToClipboard(image); } });
private static void initSystem() { if (System.getProperty("ceres.context") == null) { System.setProperty("ceres.context", "beam"); } Locale.setDefault(Locale.ENGLISH); // Force usage of english locale SystemUtils.init3rdPartyLibs(GPT.class.getClassLoader()); }
/** * Gets the application's home directory as set by the system property "${ceres.context}.home". * If not set, the method determines the home directory by retrieving the URL of this * class using the method {@link #getApplicationHomeDir(java.net.URL)}. * * @return an assumption of an application's home directory, never <code>null</code> */ public static File getApplicationHomeDir() { final String homeKey = getApplicationHomePropertyName(); final String homeValue = System.getProperty(homeKey); if (homeValue != null) { return new File(homeValue); } // Use fallback final URL url = SystemUtils.class.getResource(getClassFileName(SystemUtils.class)); return getApplicationHomeDir(url); }
public static File getBeamTestDataOutputFile(String relPath) { return new File(getBeamTestDataOutputDirectory(), SystemUtils.convertToLocalPath(relPath)); }
final String title = "Missing DEM"; /*I18N*/ String message = "The DEM '" + getName() + "' is not installed yet.\n" + "Please visit the project home page at " + SystemUtils.getApplicationHomepageUrl() + "\n" + "in order to download and install it.\n"; /*I18N*/ if (getDemInstallDir() == null || getDemArchiveUrl() == null) { "You can continue using %s while the DEM is installed.\n\n" + "Do you wish to install the DEM now?", SystemUtils.getApplicationName(), archiveSizeMB, SystemUtils.getApplicationName()); /*I18N*/ final int answer = JOptionPane.showConfirmDialog(parent, message,
private static File createCacheDir() throws IOException { // todo - this is not acceptable - beam-home might have no write access for current user final File cacheDir = new File(SystemUtils.getApplicationHomeDir(), "temp"); if (!cacheDir.exists() && !cacheDir.mkdir()) { throw new IOException("Failed to create directory '" + cacheDir + "'."); } return cacheDir; }
protected String getDefaultLookAndFeelClassName() { String defaultLookAndFeelClassName = UIManager.getSystemLookAndFeelClassName(); String osName = System.getProperty("os.name").toLowerCase(); // returning Nimbus as default LAF if not Mac OS and not Windows if (!SystemUtils.isRunningOnMacOS() && !osName.contains("windows")) { final UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels(); for (UIManager.LookAndFeelInfo laf : lookAndFeels) { if ("nimbus".equalsIgnoreCase(laf.getName())) { defaultLookAndFeelClassName = laf.getClassName(); } } } return defaultLookAndFeelClassName; }
/** * Launches the default browser to display the BEAM Wiki. * Invoked when a command action is performed. * * @param event the command event. */ @Override public void actionPerformed(CommandEvent event) { final String homePageUrl = SystemUtils.getApplicationHomepageUrl(); try { final Desktop desktop = Desktop.getDesktop(); desktop.browse(URI.create(homePageUrl)); } catch (IOException e) { // TODO - handle } catch (UnsupportedOperationException e) { // TODO - handle } } }
private static String getDialogTitle() { return SystemUtils.getApplicationName() + " Version Check"; }
/** * Gets the application home page URL as set by the system property "${ceres.context}.homepage.url". Default is * "http://www.brockmann-consult.de/beam/". * * @return the current user's application data directory * * @since BEAM 4.10 */ public static String getApplicationHomepageUrl() { return System.getProperty(getApplicationContextId() + ".homepage.url", "http://www.brockmann-consult.de/beam/"); }