Java Code Examples for org.apache.commons.lang3.SystemUtils#USER_DIR

The following examples show how to use org.apache.commons.lang3.SystemUtils#USER_DIR . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataTest.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void loadGameModes()
{
	String pccLoc = TestHelper.findDataFolder();
	System.out.println("Got data folder of " + pccLoc);
	try
	{
		String configFolder = "testsuite";
		TestHelper.createDummySettingsFile(TEST_CONFIG_FILE, configFolder,
			pccLoc);
	}
	catch (IOException e)
	{
		Logging.errorPrint("DataTest.loadGameModes failed", e);
	}
	
	PropertyContextFactory configFactory = new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings.getInstance(TEST_CONFIG_FILE));
	Main.loadProperties(false);
	PCGenTask loadPluginTask = Main.createLoadPluginTask();
	loadPluginTask.run();
	PCGenTask gameModeFileLoader = new GameModeFileLoader();
	gameModeFileLoader.run();
	PCGenTask campaignFileLoader = new CampaignFileLoader();
	campaignFileLoader.run();
}
 
Example 2
Source File: ConfigurationSettings.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public String getSettingsDir()
{
	switch (this)
	{
		case user:
			return SystemUtils.USER_HOME + File.separator + '.' + APPLICATION; // $NON-NLS-1$
		case pcgen:
			return SystemUtils.USER_DIR + File.separator + "settings"; // $NON-NLS-1$
		case mac_user:
			return SystemUtils.USER_HOME + "/Library/Preferences/" + APPLICATION; // $NON-NLS-1$
		case FD_USER:
			String config = System.getenv("XDG_CONFIG_HOME"); // $NON-NLS-1$
			if ((config == null) || config.isEmpty())
			{
				config = SystemUtils.USER_HOME + File.separator + ".config"; // $NON-NLS-1$
			}
			return config + File.separator + APPLICATION;
		default:
			throw new InternalError();
	}
}
 
Example 3
Source File: Main.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static String getConfigPath()
{
	//TODO: convert to a proper command line argument instead of a -D java property
	// First see if it was specified on the command line
	String aPath = System.getProperty("pcgen.config"); //$NON-NLS-1$
	if (aPath != null)
	{
		File testPath = new File(aPath);
		// Then make sure it's an existing folder
		if (testPath.exists() && testPath.isDirectory())
		{
			return aPath;
		}
	}
	// Otherwise return user dir
	return SystemUtils.USER_DIR;
}
 
Example 4
Source File: Main.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static String getConfigPath()
{
	//TODO: convert to a proper command line argument instead of a -D java property
	// First see if it was specified on the command line
	String aPath = System.getProperty("pcgen.config"); //$NON-NLS-1$
	if (aPath != null)
	{
		File testPath = new File(aPath);
		// Then make sure it's an existing folder
		if (testPath.exists() && testPath.isDirectory())
		{
			return aPath;
		}
	}
	// Otherwise return user dir
	return SystemUtils.USER_DIR;
}
 
Example 5
Source File: ConfigurationSettings.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
public String getSettingsDir()
{
	switch (this)
	{
		case user:
			return SystemUtils.USER_HOME + File.separator + '.' + APPLICATION; // $NON-NLS-1$
		case pcgen:
			return SystemUtils.USER_DIR + File.separator + "settings"; // $NON-NLS-1$
		case mac_user:
			return SystemUtils.USER_HOME + "/Library/Preferences/" + APPLICATION; // $NON-NLS-1$
		case FD_USER:
			String config = System.getenv("XDG_CONFIG_HOME"); // $NON-NLS-1$
			if ((config == null) || config.isEmpty())
			{
				config = SystemUtils.USER_HOME + File.separator + ".config"; // $NON-NLS-1$
			}
			return config + File.separator + APPLICATION;
		default:
			throw new InternalError();
	}
}
 
Example 6
Source File: DataTest.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static void loadGameModes()
{
	String pccLoc = TestHelper.findDataFolder();
	System.out.println("Got data folder of " + pccLoc);
	try
	{
		String configFolder = "testsuite";
		TestHelper.createDummySettingsFile(TEST_CONFIG_FILE, configFolder,
			pccLoc);
	}
	catch (IOException e)
	{
		Logging.errorPrint("DataTest.loadGameModes failed", e);
	}
	
	PropertyContextFactory configFactory = new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings.getInstance(TEST_CONFIG_FILE));
	Main.loadProperties(false);
	PCGenTask loadPluginTask = Main.createLoadPluginTask();
	loadPluginTask.run();
	PCGenTask gameModeFileLoader = new GameModeFileLoader();
	gameModeFileLoader.run();
	PCGenTask campaignFileLoader = new CampaignFileLoader();
	campaignFileLoader.run();
}
 
Example 7
Source File: TestHelper.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void loadGameModes(String testConfigFile)
{
	String configFolder = "testsuite";
	String pccLoc = TestHelper.findDataFolder();
	System.out.println("Got data folder of " + pccLoc);
	try
	{
		TestHelper.createDummySettingsFile(testConfigFile, configFolder,
			pccLoc);
	}
	catch (IOException e)
	{
		Logging.errorPrint("DataTest.loadGameModes failed", e);
	}

	PropertyContextFactory configFactory =
			new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings
		.getInstance(testConfigFile));
	Main.loadProperties(false);
	PCGenTask loadPluginTask = Main.createLoadPluginTask();
	loadPluginTask.run();
	GameModeFileLoader gameModeFileLoader = new GameModeFileLoader();
	gameModeFileLoader.run();
	CampaignFileLoader campaignFileLoader = new CampaignFileLoader();
	campaignFileLoader.run();
}
 
Example 8
Source File: DataLoadTest.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void loadGameModes()
{
	String pccLoc = TestHelper.findDataFolder();
	System.out.println("Got data folder of " + pccLoc);
	try
	{
		String configFolder = "testsuite";
		TestHelper.createDummySettingsFile(TEST_CONFIG_FILE, configFolder,
			pccLoc);
	}
	catch (IOException e)
	{
		Logging.errorPrint("DataTest.loadGameModes failed", e);
	}

	PropertyContextFactory configFactory =
			new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings
		.getInstance(TEST_CONFIG_FILE));
	Main.loadProperties(false);
	PCGenTask loadPluginTask = Main.createLoadPluginTask();
	loadPluginTask.run();
	PCGenTask gameModeFileLoader = new GameModeFileLoader();
	gameModeFileLoader.run();
	PCGenTask campaignFileLoader = new CampaignFileLoader();
	campaignFileLoader.run();
}
 
Example 9
Source File: PCGenSettings.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static String expandRelativePath(String path)
{
	if (path.startsWith("@"))
	{
		path = SystemUtils.USER_DIR + File.separator + path.substring(1);
	}
	return path;
}
 
Example 10
Source File: Main.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static boolean loadCharacterAndExport(String characterFile, String exportSheet, String outputFile,
	String configFile)
{
	Main.characterFile = characterFile;
	Main.exportSheet = exportSheet;
	Main.outputFile = outputFile;

	configFactory = new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings.getInstance(configFile));
	return startupWithoutGUI();
}
 
Example 11
Source File: ConfigurationSettings.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static String expandRelativePath(String path)
{
	if (path.startsWith("@"))
	{
		path = SystemUtils.USER_DIR + File.separator + path.substring(1);
	}
	return path;
}
 
Example 12
Source File: PCGenDataConvert.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void main(String[] args)
{
	Logging.log(Level.INFO, "Starting PCGen Data Converter v" + PCGenPropBundle.getVersionNumber()); //$NON-NLS-1$
	configFactory = new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings.getInstance());
	Main.loadProperties(true);
	getConverter().setVisible(true);
}
 
Example 13
Source File: DataLoadTest.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void loadGameModes()
{
	String pccLoc = TestHelper.findDataFolder();
	System.out.println("Got data folder of " + pccLoc);
	try
	{
		String configFolder = "testsuite";
		TestHelper.createDummySettingsFile(TEST_CONFIG_FILE, configFolder,
			pccLoc);
	}
	catch (IOException e)
	{
		Logging.errorPrint("DataTest.loadGameModes failed", e);
	}

	PropertyContextFactory configFactory =
			new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings
		.getInstance(TEST_CONFIG_FILE));
	Main.loadProperties(false);
	PCGenTask loadPluginTask = Main.createLoadPluginTask();
	loadPluginTask.run();
	PCGenTask gameModeFileLoader = new GameModeFileLoader();
	gameModeFileLoader.run();
	PCGenTask campaignFileLoader = new CampaignFileLoader();
	campaignFileLoader.run();
}
 
Example 14
Source File: PCGenSettings.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static String expandRelativePath(String path)
{
	if (path.startsWith("@"))
	{
		path = SystemUtils.USER_DIR + File.separator + path.substring(1);
	}
	return path;
}
 
Example 15
Source File: Main.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static boolean loadCharacterAndExport(String characterFile, String exportSheet, String outputFile,
	String configFile)
{
	Main.characterFile = characterFile;
	Main.exportSheet = exportSheet;
	Main.outputFile = outputFile;

	configFactory = new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings.getInstance(configFile));
	return startupWithoutGUI();
}
 
Example 16
Source File: ConfigurationSettings.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static String expandRelativePath(String path)
{
	if (path.startsWith("@"))
	{
		path = SystemUtils.USER_DIR + File.separator + path.substring(1);
	}
	return path;
}
 
Example 17
Source File: TestHelper.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static void loadGameModes(String testConfigFile)
{
	String configFolder = "testsuite";
	String pccLoc = TestHelper.findDataFolder();
	System.out.println("Got data folder of " + pccLoc);
	try
	{
		TestHelper.createDummySettingsFile(testConfigFile, configFolder,
			pccLoc);
	}
	catch (IOException e)
	{
		Logging.errorPrint("DataTest.loadGameModes failed", e);
	}

	PropertyContextFactory configFactory =
			new PropertyContextFactory(SystemUtils.USER_DIR);
	configFactory.registerAndLoadPropertyContext(ConfigurationSettings
		.getInstance(testConfigFile));
	Main.loadProperties(false);
	PCGenTask loadPluginTask = Main.createLoadPluginTask();
	loadPluginTask.run();
	GameModeFileLoader gameModeFileLoader = new GameModeFileLoader();
	gameModeFileLoader.run();
	CampaignFileLoader campaignFileLoader = new CampaignFileLoader();
	campaignFileLoader.run();
}
 
Example 18
Source File: ConfigurationSettings.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @return the current user directory
 */
public static String getUserDir()
{
	return SystemUtils.USER_DIR;
}
 
Example 19
Source File: XLSX2CSV.java    From DBus with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    String userDir = SystemUtils.USER_DIR;
    XLSX2CSV xlsx2csv = new XLSX2CSV(userDir + "/table-list.xlsx", userDir + "/out1.csv");
    xlsx2csv.process();
}
 
Example 20
Source File: ConfigurationSettings.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * @return the current user directory
 */
public static String getUserDir()
{
	return SystemUtils.USER_DIR;
}