Search in sources :

Example 11 with CyApplicationConfiguration

use of org.cytoscape.application.CyApplicationConfiguration in project cytoscape-impl by cytoscape.

the class CommandToolPanel method restoreCommandHistory.

private void restoreCommandHistory() {
    CyApplicationConfiguration appConfig = serviceRegistrar.getService(CyApplicationConfiguration.class);
    File appConfigDir = appConfig.getConfigurationDirectoryLocation();
    savedCommandsFile = new File(appConfigDir.getAbsolutePath() + File.separator + "commandHistory.txt");
    if (savedCommandsFile.exists()) {
        readCommandHistory(savedCommandsFile);
    }
}
Also used : CyApplicationConfiguration(org.cytoscape.application.CyApplicationConfiguration) File(java.io.File)

Example 12 with CyApplicationConfiguration

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.");
        }
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) CyApplicationConfiguration(org.cytoscape.application.CyApplicationConfiguration) File(java.io.File)

Example 13 with CyApplicationConfiguration

use of org.cytoscape.application.CyApplicationConfiguration in project cytoscape-impl by cytoscape.

the class MakeVisualStylesDefaultTask method run.

@Override
public void run(final TaskMonitor monitor) throws Exception {
    if (!confirm)
        return;
    final VisualMappingManager vmMgr = servicesUtil.get(VisualMappingManager.class);
    final Set<VisualStyle> currentStyles = vmMgr.getAllVisualStyles();
    if (!currentStyles.isEmpty()) {
        final VizmapWriterFactory vizmapWriterFactory = servicesUtil.get(VizmapWriterFactory.class);
        final CyApplicationConfiguration config = servicesUtil.get(CyApplicationConfiguration.class);
        final FileOutputStream os = new FileOutputStream(new File(config.getConfigurationDirectoryLocation(), VizMapperProxy.PRESET_VIZMAP_FILE));
        final CyWriter vizmapWriter = vizmapWriterFactory.createWriter(os, currentStyles);
        if (!cancelled)
            vizmapWriter.run(monitor);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) CyWriter(org.cytoscape.io.write.CyWriter) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) VizmapWriterFactory(org.cytoscape.io.write.VizmapWriterFactory) CyApplicationConfiguration(org.cytoscape.application.CyApplicationConfiguration) File(java.io.File)

Aggregations

CyApplicationConfiguration (org.cytoscape.application.CyApplicationConfiguration)13 File (java.io.File)11 IOException (java.io.IOException)4 FileOutputStream (java.io.FileOutputStream)3 Properties (java.util.Properties)3 CyEventHelper (org.cytoscape.event.CyEventHelper)2 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)2 BufferedWriter (java.io.BufferedWriter)1 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AppManagerAction (org.cytoscape.app.internal.action.AppManagerAction)1 CitationsAction (org.cytoscape.app.internal.action.CitationsAction)1 AppManager (org.cytoscape.app.internal.manager.AppManager)1 UpdateManager (org.cytoscape.app.internal.net.UpdateManager)1 WebQuerier (org.cytoscape.app.internal.net.WebQuerier)1 AddAllowOriginHeader (org.cytoscape.app.internal.net.server.AddAllowOriginHeader)1 AppGetResponder (org.cytoscape.app.internal.net.server.AppGetResponder)1 CyHttpd (org.cytoscape.app.internal.net.server.CyHttpd)1