Search in sources :

Example 1 with PreferenceFilterEntry

use of org.eclipse.core.runtime.preferences.PreferenceFilterEntry in project mdw-designer by CenturyLinkCloud.

the class WorkspaceConfigurator method loadPreferences.

/**
 * Loads preferences from the workspace setup site.
 *
 * @return <code>true</code> if the load was successful
 */
protected boolean loadPreferences() {
    // import all
    IPreferenceFilter[] filters = new IPreferenceFilter[1];
    filters[0] = new IPreferenceFilter() {

        public String[] getScopes() {
            return new String[] { InstanceScope.SCOPE, ConfigurationScope.SCOPE };
        }

        public Map<String, PreferenceFilterEntry[]> getMapping(String scope) {
            return null;
        }
    };
    String baseUrl = getWorkspaceConfig().getMdwSettings().getWorkspaceSetupUrl();
    if (!baseUrl.endsWith("/"))
        baseUrl += "/";
    InputStream is = null;
    try {
        URL url = new URL(baseUrl + "MdwWorkspaceSetup.epf");
        URLConnection connection = url.openConnection();
        is = connection.getInputStream();
        IPreferencesService service = Platform.getPreferencesService();
        IExportedPreferences prefs = service.readPreferences(is);
        service.applyPreferences(prefs, filters);
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "Workspace Setup");
        return false;
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
            // do nothing
            }
        }
    }
    return true;
}
Also used : PreferenceFilterEntry(org.eclipse.core.runtime.preferences.PreferenceFilterEntry) InputStream(java.io.InputStream) IExportedPreferences(org.eclipse.core.runtime.preferences.IExportedPreferences) IPreferenceFilter(org.eclipse.core.runtime.preferences.IPreferenceFilter) IOException(java.io.IOException) Map(java.util.Map) URL(java.net.URL) URLConnection(java.net.URLConnection) IPreferencesService(org.eclipse.core.runtime.preferences.IPreferencesService) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 URLConnection (java.net.URLConnection)1 Map (java.util.Map)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IExportedPreferences (org.eclipse.core.runtime.preferences.IExportedPreferences)1 IPreferenceFilter (org.eclipse.core.runtime.preferences.IPreferenceFilter)1 IPreferencesService (org.eclipse.core.runtime.preferences.IPreferencesService)1 PreferenceFilterEntry (org.eclipse.core.runtime.preferences.PreferenceFilterEntry)1