core/com.nokia.carbide.templatewizard/src/com/nokia/carbide/template/engine/DialogSettingsPersistedStorage.java
author timkelly
Thu, 10 Dec 2009 13:45:47 -0600
branchRCL_2_4
changeset 671 80524b72f957
parent 355 26cc9825bb33
permissions -rw-r--r--
Add S60 5.2 support.

/*
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/

package com.nokia.carbide.template.engine;


import org.eclipse.jface.dialogs.IDialogSettings;

/**
 * This class is a default implementation of {@link IPersistedSettingStorage} that
 * uses IDialogSettings to store its contents as strings.
 * @since 2.1
 *
 */
public class DialogSettingsPersistedStorage implements
		IPersistedSettingStorage {
	private final IDialogSettings dialogSettings;

	/**
	 * @param dialogSettings
	 */
	public DialogSettingsPersistedStorage(IDialogSettings dialogSettings) {
		this.dialogSettings = dialogSettings;
	}
	
	/**
	 * Override this method if you want a setting to be modified from the template field id.
	 * @param key incoming template field id
	 * @return key for settings storage
	 */
	protected String transformKey(String key) {
		return key;
	}

	public String read(String key) {
		return dialogSettings.get(transformKey(key));
	}

	public void write(String key, String value) {
		dialogSettings.put(transformKey(key), value);
	}
}