Search in sources :

Example 21 with Profile

use of jmri.profile.Profile in project JMRI by JMRI.

the class WebAppManager method getAngularDependencies.

public String getAngularDependencies(Profile profile, Locale locale) {
    // NOI18N
    StringJoiner dependencies = new StringJoiner("',\n  '", "\n  '", "'");
    List<String> items = new ArrayList<>();
    this.getManifests(profile).forEach((WebManifest manifest) -> {
        manifest.getAngularDependencies().stream().filter((dependency) -> (!items.contains(dependency))).forEachOrdered((dependency) -> {
            items.add(dependency);
        });
    });
    items.forEach((String dependency) -> {
        dependencies.add(dependency);
    });
    return dependencies.toString();
}
Also used : OVERFLOW(java.nio.file.StandardWatchEventKinds.OVERFLOW) LifeCycle(org.eclipse.jetty.util.component.LifeCycle) URL(java.net.URL) AbstractPreferencesManager(jmri.util.prefs.AbstractPreferencesManager) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) InitializationException(jmri.util.prefs.InitializationException) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayList(java.util.ArrayList) AngularRoute(jmri.server.web.spi.AngularRoute) WatchKey(java.nio.file.WatchKey) HashSet(java.util.HashSet) WebServer(jmri.web.server.WebServer) StandardWatchEventKinds(java.nio.file.StandardWatchEventKinds) ProfileUtils(jmri.profile.ProfileUtils) Locale(java.util.Locale) Map(java.util.Map) Profile(jmri.profile.Profile) Path(java.nio.file.Path) PropertyChangeEvent(java.beans.PropertyChangeEvent) Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Set(java.util.Set) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException) ServiceLoader(java.util.ServiceLoader) WebMenuItem(jmri.server.web.spi.WebMenuItem) File(java.io.File) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) WatchService(java.nio.file.WatchService) List(java.util.List) WebManifest(jmri.server.web.spi.WebManifest) WebServerPreferences(jmri.web.server.WebServerPreferences) FileUtil(jmri.util.FileUtil) StringJoiner(java.util.StringJoiner) FileSystems(java.nio.file.FileSystems) ArrayList(java.util.ArrayList) WebManifest(jmri.server.web.spi.WebManifest) StringJoiner(java.util.StringJoiner)

Example 22 with Profile

use of jmri.profile.Profile in project JMRI by JMRI.

the class JsonUtilHttpService method getConfigProfiles.

/**
     *
     * @param locale the client's Locale.
     * @return the JSON configProfiles message.
     */
public ArrayNode getConfigProfiles(Locale locale) {
    ArrayNode root = mapper.createArrayNode();
    for (Profile p : ProfileManager.getDefault().getProfiles()) {
        boolean isActiveProfile = (p == ProfileManager.getDefault().getActiveProfile());
        // only true for activeprofile 
        boolean isAutoStart = (isActiveProfile && ProfileManager.getDefault().isAutoStartActiveProfile());
        ObjectNode connection = mapper.createObjectNode().put(JSON.TYPE, JSON.CONFIG_PROFILE);
        ObjectNode data = connection.putObject(JSON.DATA);
        data.put(JSON.NAME, p.getName());
        data.put(JSON.UNIQUE_ID, p.getUniqueId());
        data.put(JSON.ID, p.getId());
        data.put(JSON.IS_ACTIVE_PROFILE, isActiveProfile);
        data.put(JSON.IS_AUTO_START, isAutoStart);
        root.add(connection);
    }
    return root;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Profile(jmri.profile.Profile)

Example 23 with Profile

use of jmri.profile.Profile in project JMRI by JMRI.

the class JmriConfigurationManager method storePrefs.

/**
     * Save preferences. Preferences are saved using either the
     * {@link jmri.util.prefs.JmriConfigurationProvider} or
     * {@link jmri.util.prefs.JmriPreferencesProvider} as appropriate to the
     * register preferences handler.
     */
@Override
public void storePrefs() {
    log.debug("Saving preferences...");
    Profile profile = ProfileManager.getDefault().getActiveProfile();
    InstanceManager.getList(PreferencesManager.class).stream().forEach((o) -> {
        log.debug("Saving preferences for {}", o.getClass().getName());
        o.savePreferences(profile);
    });
}
Also used : Profile(jmri.profile.Profile)

Aggregations

Profile (jmri.profile.Profile)23 File (java.io.File)14 Date (java.util.Date)7 ArrayList (java.util.ArrayList)6 InitializationException (jmri.util.prefs.InitializationException)6 HashMap (java.util.HashMap)5 List (java.util.List)5 Set (java.util.Set)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 IOException (java.io.IOException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 HashSet (java.util.HashSet)3 Locale (java.util.Locale)3 Map (java.util.Map)3 ServiceLoader (java.util.ServiceLoader)3 ProfileUtils (jmri.profile.ProfileUtils)3 AbstractPreferencesManager (jmri.util.prefs.AbstractPreferencesManager)3 Test (org.junit.Test)3