Package org.osgi.service.prefs

Examples of org.osgi.service.prefs.Preferences


        }
    }

    private void firstRun() throws Exception {
        // getWindowConfigurer().getWindow().getShell().setMaximized(true);
        Preferences userPreferences = UiPlugin.getUserPreferences();
        userPreferences
                .node("org.locationtech.udig.ui.firstRun").putBoolean("org.locationtech.udig.ui.isFirstRun", false); //$NON-NLS-1$ //$NON-NLS-2$

//        if (Platform.getOS().equals(Platform.OS_LINUX)) {
//            MessageDialog.openWarning(getWindowConfigurer().getWindow()
//                    .getShell(), "Warning", "Some Linux users have experienced issues with map display being slow or strange artifacts on some versions of Linux. This is now very rare but if you experience this problem go into the preferences and disable *Advanced Graphics*.");
 
View Full Code Here


        }
    }
   
    private void store(String name, String pass) {
        try {
            Preferences node = UiPlugin.getUserPreferences().node(getNodeKey());
            node.put(NAME, name);
            node.put(PASSWORD, pass);
        } catch (Exception e) {
            UiPlugin.log("", e); //$NON-NLS-1$
        }
    }
View Full Code Here

        }
    }

    private String loadPassword() {
        try {
            Preferences node = UiPlugin.getUserPreferences().node(getNodeKey());
            String pass = node.get(PASSWORD, null);
            if( pass == null )
                return null;
           
            return pass;
        } catch (Exception e) {
View Full Code Here

        return URL_AUTHENTICATION + URLEncoder.encode(getRequestingURL().toString(), "UTF-8"); //$NON-NLS-1$
    }

    private String loadName() {
        try {
            Preferences node = UiPlugin.getUserPreferences().node(getNodeKey());
            return node.get(NAME, null);
           
        } catch (Exception e) {
            UiPlugin.log("", e); //$NON-NLS-1$
            return null;
        }
View Full Code Here

*/
public class NavigationPreferenceInitializer extends AbstractPreferenceInitializer {

    @Override
    public void initializeDefaultPreferences() {
        Preferences node = DefaultScope.INSTANCE.getNode(ToolsPlugin.ID);
        node.putBoolean(NavigationToolPreferencePage.SCALE,false);
        node.putBoolean(NavigationToolPreferencePage.TILED,false);
    }
View Full Code Here

            SERVICE: for (String id : node.childrenNames()) {
                if( id == null ){
                    continue SERVICE;
                }
                try {
                    Preferences servicePref = node.node(id);
                    ID url = decodeID(id);
                   
                    Map<String, Serializable> connectionParams = new HashMap<String, Serializable>();
                    String[] nodes = servicePref.childrenNames();
                   
                   
                    Map<ID,Map<String, Serializable>> resourcePropertyMap = new HashMap<ID, Map<String,Serializable>>();
                    Map<String, Serializable> properties = new HashMap<String, Serializable>();
                   
                    RESOURCE: for (String childName : nodes) {
                        if( childName == null ){
                            continue RESOURCE; // skip
                        }
                        if( PROPERTIES_KEY.equals(childName)) {
                            Preferences propertiesPref = servicePref.node(PROPERTIES_KEY);
                            propertiesPref.flush();

                            properties= restoreProperties(propertiesPref);
                        }
                        else if( childName.startsWith(CHILD_PREFIX)){
                            String childIDEncoded = childName.substring(CHILD_PREFIX.length());
                            if( childIDEncoded.length() == 0 ){
                                continue RESOURCE;
                            }
                            ID childID = decodeID( childIDEncoded );
                           
                            Preferences childPref = servicePref.node(childName);
                            childPref.flush();
                            Map<String, Serializable> childProperties = restoreProperties(childPref);
                           
                           
                            resourcePropertyMap.put(childID, childProperties);
                        }
View Full Code Here

     * @param connectionParams
     * @param currentKey
     * @throws MalformedURLException
     */
    private void mapAsObject(Preferences servicePreferenceNode, Map<String, Serializable> connectionParams, String currentKey) {
        Preferences paramNode = servicePreferenceNode.node(currentKey);
        String value=paramNode.get(VALUE_ID, null);
        try {
            value = URLDecoder.decode(value, ENCODING);
        } catch (UnsupportedEncodingException e) {
            CatalogPlugin.log("error decoding value, using undecoded value", e); //$NON-NLS-1$
        }
        String type=paramNode.get(TYPE_ID, null);       
        Serializable obj = toObject( value, type );
        connectionParams.put(currentKey, obj);
    }
View Full Code Here

                    continue;
               
                ID serviceID = service.getID();
                String id = encodeID( serviceID );

                Preferences serviceNode = node.node(id);

                for ( Map.Entry<String, Serializable> entry : service.getConnectionParams().entrySet()) {
                    String key = entry.getKey().toString();
                   
                    Serializable object = entry.getValue();
                    URL url=null;
                    if( object instanceof URL){
                        url = (URL) object;
                    }else if( object instanceof File ){
                        File file = (File) object;
                        URL old=file.toURI().toURL();
                        url=file.toURI().toURL();
                        if( !old.equals(url)){
                            CatalogPlugin.trace("old url:"+old,null); //$NON-NLS-1$
                            CatalogPlugin.trace("new url:"+url,null); //$NON-NLS-1$
                        }
                    }
                   
                    String value;
                    // if reference is null then we can only encode the absolute path
                    if( reference!=null && url !=null ){
                        URL relativeURL = URLUtils.toRelativePath(this.reference, url);
                        value = URLUtils.urlToString(relativeURL, true);
                    }else{
                        value = object == null ? null : object.toString();
                    }

                    if (value != null){
                        value= URLEncoder.encode( value, ENCODING );
                        Preferences paramNode = serviceNode.node(key);
                        paramNode.put(VALUE_ID, value);
                        paramNode.put(TYPE_ID, object.getClass().getName());
                    }
                }
                try {
                    Map<String, Serializable> persistentProperties = service.getPersistentProperties();
                   
                    Preferences propertiesNode = serviceNode.node(PROPERTIES_KEY);                   
                    storeProperties( propertiesNode, persistentProperties );
                    propertiesNode.flush();
                } catch (Exception e) {
                    throw (RuntimeException) new RuntimeException( ).initCause( e );
                }
                boolean resourcePropertiesSaved = false;
                if( service.getStatus() == Status.CONNECTED ){
                    try {
                        // we can check against the available resources (and thus clean up from any removed resources)
                        List< ? extends IGeoResource> resources = service.resources(null);
                        if( resources != null && !resources.isEmpty() ){
                            for( IGeoResource child : resources){
                                ID childID = child.getID();
                               
                                Map<String, Serializable> childProperties = service.getPersistentProperties(childID);
                               
                                String encodeID = encodeID(childID);
                                String childKey = CHILD_PREFIX+encodeID;
                               
                                Preferences childNode = serviceNode.node(childKey);
                                storeProperties( childNode, childProperties );
                                childNode.flush();
                            }
                        }       
                        resourcePropertiesSaved=true;
                    } catch (Exception e) {
                        CatalogPlugin.log("Unable to access resource list for "+service.getID()+":"+e, e);
                    }
                }
               
                if( !resourcePropertiesSaved ){
                    // We could not confirm the list of resources - so go ahead and save everything back out
                    //
                    for( Entry<ID, Map<String, Serializable>> entry : service.resourceProperties.entrySet() ){
                        Map<String, Serializable> childProperties = entry.getValue();
                       
                        String encodeID = encodeID( entry.getKey() );
                        String childKey = CHILD_PREFIX+encodeID;
                       
                        Preferences childNode = serviceNode.node(childKey);
                        storeProperties( childNode, childProperties );
                        childNode.flush();
                    }
                }

                if (serviceNode.keys().length > 0){
                    serviceNode.flush();
View Full Code Here

            }

            if (txt != null){
                try {
                    txt= URLEncoder.encode( txt, ENCODING );
                    Preferences paramNode = prefs.node(KEY);
                   
                    paramNode.put(VALUE_ID, txt);
                    paramNode.put(TYPE_ID, object.getClass().getName());
                    paramNode.flush();
                   
                } catch (Exception e) {
                    CatalogPlugin.trace("Could not encode "+KEY+" - "+e, e); //$NON-NLS-1$ //$NON-NLS-2$
                }
            }
View Full Code Here

        String[] keys;
        try {
            keys = preference.childrenNames(); //preference.keys();
            for( int j = 0; j < keys.length; j++ ) {
                final String KEY = keys[j];
                Preferences paramNode = preference.node(KEY);               
                String txt = paramNode.get(VALUE_ID,null);
                if( txt == null ) continue;
                try {
                    txt= URLDecoder.decode( txt, ENCODING );
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                String type = paramNode.get(TYPE_ID,null);
               
                Serializable value = toObject( txt, type );
                map.put(KEY, value );
            }
        } catch (BackingStoreException e) {
View Full Code Here

TOP

Related Classes of org.osgi.service.prefs.Preferences

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.