use of org.cytoscape.application.CyApplicationConfiguration in project cytoscape-impl by cytoscape.
the class LinkOut method readLocalProperties.
/**
* Read properties values from linkout.props file included in the
* linkout.jar file and apply those properties to the base Cytoscape
* properties. Only apply the properties from the jar file if NO linkout
* properties already exist. This allows linkout properties to be specified
* on the command line, edited in the preferences dialog, and to be saved
* with other properties.
*/
private void readLocalProperties() {
final CyApplicationConfiguration config = registrar.getService(CyApplicationConfiguration.class);
final File propertyFile = new File(config.getConfigurationDirectoryLocation(), File.separator + "linkout.props");
try {
if (propertyFile.canRead())
linkoutProps.getProperties().load(new FileInputStream(propertyFile));
} catch (Exception e) {
logger.warn("Couldn't load linkout props from \'" + propertyFile.getAbsolutePath() + "\'.", e);
}
}
use of org.cytoscape.application.CyApplicationConfiguration in project cytoscape-impl by cytoscape.
the class ConfigDirPropertyWriter method handleEvent.
@Override
public void handleEvent(final CyShutdownEvent event) {
for (final Map.Entry<CyProperty<?>, Map<?, ?>> keyAndValue : configDirProperties.entrySet()) {
final String propertyName = (String) keyAndValue.getValue().get("cyPropertyName");
if (propertyName == null || propertyName.isEmpty())
continue;
final String propertyFileName;
if (propertyName.endsWith(".props"))
propertyFileName = propertyName;
else
propertyFileName = propertyName + ".props";
final CyApplicationConfiguration config = serviceRegistrar.getService(CyApplicationConfiguration.class);
final File outputFile = new File(config.getConfigurationDirectoryLocation(), propertyFileName);
final Properties props = (Properties) keyAndValue.getKey().getProperties();
try {
FileOutputStream out = new FileOutputStream(outputFile);
props.store(out, null);
out.close();
} catch (Exception e) {
logger.error("Error in wring properties file.");
}
}
}
use of org.cytoscape.application.CyApplicationConfiguration in project cytoscape-impl by cytoscape.
the class Cy3PreferencesPanel method saveStateToConfigDirectory.
// ---------------------------------------------------------------------------------------------------------
public void saveStateToConfigDirectory() {
copyLocalToGlobalProperties();
Map<String, Properties> prefs = propertyMap;
System.out.println("saveStateToConfigDirectory");
for (String key : prefs.keySet()) {
if (key.startsWith("layout"))
continue;
if (key.startsWith("vizmap"))
continue;
final String propertyName = key;
if (propertyName == null || propertyName.isEmpty())
continue;
String propertyFileName = propertyName;
if (!propertyFileName.endsWith(".props"))
propertyFileName += ".props";
final CyApplicationConfiguration config = serviceRegistrar.getService(CyApplicationConfiguration.class);
final File outputFile = new File(config.getConfigurationDirectoryLocation(), propertyFileName);
Properties properties = prefs.get(key);
try {
FileOutputStream out = new FileOutputStream(outputFile);
properties.store(out, null);
out.close();
} catch (Exception e) {
System.err.println("Error in writing properties file.");
}
}
}
use of org.cytoscape.application.CyApplicationConfiguration in project cytoscape-impl by cytoscape.
the class CytoscapeToolBar method writeStopList.
private void writeStopList(List<String> list) {
BufferedWriter writer = null;
try {
CyApplicationConfiguration cyApplicationConfiguration = serviceRegistrar.getService(CyApplicationConfiguration.class);
if (cyApplicationConfiguration == null) {
System.err.println("cyApplicationConfiguration not found");
return;
}
File configDirectory = cyApplicationConfiguration.getConfigurationDirectoryLocation();
File configFile = null;
if (configDirectory.exists())
configFile = new File(configDirectory.toPath() + "/toolbar.stoplist");
writer = new BufferedWriter(new FileWriter(configFile));
for (String line : list) {
if (line != null)
writer.write(line + "\n");
}
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
} finally {
if (writer != null) {
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
use of org.cytoscape.application.CyApplicationConfiguration in project cytoscape-impl by cytoscape.
the class CytoscapeToolBar method readStopList.
private void readStopList() {
stopList.clear();
final List<String> lines;
try {
CyApplicationConfiguration cyApplicationConfiguration = serviceRegistrar.getService(CyApplicationConfiguration.class);
if (cyApplicationConfiguration == null)
return;
File configDirectory = cyApplicationConfiguration.getConfigurationDirectoryLocation();
File configFile = null;
if (configDirectory.exists())
configFile = new File(configDirectory.toPath() + "/toolbar.stoplist");
lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset());
} catch (IOException e) {
// file not found: there's no customization, just return
return;
}
for (String line : lines) stopList.add(line.trim());
}
Aggregations