1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-28 19:35:36 +02:00

Terminal: Clean out ISettings API

This commit is contained in:
Uwe Stieber 2015-02-16 11:38:20 +01:00
parent 4e9cddc64f
commit 2c2dbb710b
16 changed files with 284 additions and 268 deletions

View file

@ -46,7 +46,7 @@ public class LocalTerminalSettings implements ILocalTerminalSettings {
Field field = declaredField[index]; Field field = declaredField[index];
Class<?> type = field.getType(); Class<?> type = field.getType();
Object value = store.getProperty(field.getName()); Object value = store.get(field.getName());
if (type.equals(boolean.class)) { if (type.equals(boolean.class)) {
value = Boolean.valueOf((String)value); value = Boolean.valueOf((String)value);
@ -81,7 +81,7 @@ public class LocalTerminalSettings implements ILocalTerminalSettings {
try { try {
field.setAccessible(true); field.setAccessible(true);
store.setProperty(field.getName(), String.valueOf(field.get(this))); store.set(field.getName(), String.valueOf(field.get(this)));
} }
catch (IllegalAccessException illegalAccess) { catch (IllegalAccessException illegalAccess) {

View file

@ -28,7 +28,7 @@ public class LayeredSettingsStore extends Settings {
/** /**
* @param stores the stores used to search the values. * @param stores the stores used to search the values.
* {@link #setProperty(String, Object)} will put the value in the * {@link #set(String, Object)} will put the value in the
* first store in the list. * first store in the list.
*/ */
public LayeredSettingsStore(ISettings[] stores) { public LayeredSettingsStore(ISettings[] stores) {
@ -43,17 +43,17 @@ public class LayeredSettingsStore extends Settings {
this(new ISettings[]{s1,s2}); this(new ISettings[]{s1,s2});
} }
public Object getProperty(String key) { public Object get(String key) {
for (int i = 0; i < fStores.length; i++) { for (int i = 0; i < fStores.length; i++) {
Object value=fStores[i].getProperty(key); Object value=fStores[i].get(key);
if (value!=null) if (value!=null)
return value; return value;
} }
return null; return null;
} }
public boolean setProperty(String key, Object value) { public boolean set(String key, Object value) {
return fStores[0].setProperty(key,value); return fStores[0].set(key,value);
} }
} }

View file

@ -36,11 +36,11 @@ public class PreferenceSettingStore extends org.eclipse.tm.internal.terminal.pro
fPrefix=prefix; fPrefix=prefix;
} }
public Object getProperty(String key) { public Object get(String key) {
return fPreferences.getString(makeKey(key)); return fPreferences.getString(makeKey(key));
} }
public boolean setProperty(String key, Object value) { public boolean set(String key, Object value) {
if (value instanceof String) { if (value instanceof String) {
fPreferences.setValue(makeKey(key), (String)value); fPreferences.setValue(makeKey(key), (String)value);
} }

View file

@ -20,11 +20,11 @@ public class SettingStorePrefixDecorator extends org.eclipse.tm.internal.termina
fStore=store; fStore=store;
} }
public Object getProperty(String key) { public Object get(String key) {
return fStore.getProperty(fPrefix+key); return fStore.get(fPrefix+key);
} }
public boolean setProperty(String key, Object value) { public boolean set(String key, Object value) {
return super.setProperty(fPrefix+key,value); return super.set(fPrefix+key,value);
} }
} }

View file

@ -49,17 +49,17 @@ class SettingsStore extends org.eclipse.tm.internal.terminal.provisional.api.Set
} }
if(m!=null) { if(m!=null) {
// cache the value in the map // cache the value in the map
setProperty(key,m.getString(path[path.length-1])); set(key,m.getString(path[path.length-1]));
} }
} }
} }
} }
} }
public boolean setProperty(String key, Object value) { public boolean set(String key, Object value) {
if(!key.matches("^[\\w.]+$")) //$NON-NLS-1$ if(!key.matches("^[\\w.]+$")) //$NON-NLS-1$
throw new IllegalArgumentException("Key '"+key+"' is not alpha numeric or '.'!"); //$NON-NLS-1$ //$NON-NLS-2$ throw new IllegalArgumentException("Key '"+key+"' is not alpha numeric or '.'!"); //$NON-NLS-1$ //$NON-NLS-2$
return super.setProperty(key, value); return super.set(key, value);
} }
/** /**
@ -68,7 +68,7 @@ class SettingsStore extends org.eclipse.tm.internal.terminal.provisional.api.Set
* @param memento Memento to save state into. * @param memento Memento to save state into.
*/ */
public void saveState(IMemento memento) { public void saveState(IMemento memento) {
Map map = getProperties(); Map map = getAll();
String[] keyNames=(String[]) map.keySet().toArray(new String[map.size()]); String[] keyNames=(String[]) map.keySet().toArray(new String[map.size()]);
Arrays.sort(keyNames); Arrays.sort(keyNames);
StringBuffer buffer=new StringBuffer(); StringBuffer buffer=new StringBuffer();

View file

@ -487,7 +487,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi
*/ */
private ITerminalConnector loadSettings(ISettings store, ITerminalConnector[] connectors) { private ITerminalConnector loadSettings(ISettings store, ITerminalConnector[] connectors) {
ITerminalConnector connector=null; ITerminalConnector connector=null;
String connectionType=store.getStringProperty(STORE_CONNECTION_TYPE); String connectionType=store.getString(STORE_CONNECTION_TYPE);
for (int i = 0; i < connectors.length; i++) { for (int i = 0; i < connectors.length; i++) {
connectors[i].load(getStore(store,connectors[i])); connectors[i].load(getStore(store,connectors[i]));
if(connectors[i].getId().equals(connectionType)) if(connectors[i].getId().equals(connectionType))
@ -521,7 +521,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi
if(connector!=null) { if(connector!=null) {
connector.save(getStore(store, connector)); connector.save(getStore(store, connector));
// the last saved connector becomes the default // the last saved connector becomes the default
store.setProperty(STORE_CONNECTION_TYPE,connector.getId()); store.set(STORE_CONNECTION_TYPE,connector.getId());
} }
} }
@ -531,7 +531,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi
} }
public void saveState(IMemento memento) { public void saveState(IMemento memento) {
super.saveState(memento); super.saveState(memento);
fStore.setProperty(STORE_TITLE,getPartName()); fStore.set(STORE_TITLE,getPartName());
fMultiConnectionManager.saveState(new SettingStorePrefixDecorator(fStore,"connectionManager")); //$NON-NLS-1$ fMultiConnectionManager.saveState(new SettingStorePrefixDecorator(fStore,"connectionManager")); //$NON-NLS-1$
fStore.saveState(memento); fStore.saveState(memento);
} }
@ -683,10 +683,10 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi
*/ */
private void legacyLoadState() { private void legacyLoadState() {
// TODO legacy: load the old title.... // TODO legacy: load the old title....
String summary=fStore.getStringProperty(STORE_SETTING_SUMMARY); String summary=fStore.getString(STORE_SETTING_SUMMARY);
if(summary!=null) { if(summary!=null) {
getActiveConnection().setSummary(summary); getActiveConnection().setSummary(summary);
fStore.setProperty(STORE_SETTING_SUMMARY,null); fStore.set(STORE_SETTING_SUMMARY,null);
} }
} }
/** /**
@ -697,10 +697,10 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalVi
*/ */
private void legacySetTitle() { private void legacySetTitle() {
// restore the title of this view // restore the title of this view
String title=fStore.getStringProperty(STORE_TITLE); String title=fStore.getString(STORE_TITLE);
if(title!=null && title.length()>0) { if(title!=null && title.length()>0) {
setViewTitle(title); setViewTitle(title);
fStore.setProperty(STORE_TITLE, null); fStore.set(STORE_TITLE, null);
} }
} }

View file

@ -93,13 +93,13 @@ class TerminalViewConnection implements ITerminalViewConnection {
return new SettingStorePrefixDecorator(store,connector.getId()+"."); //$NON-NLS-1$ return new SettingStorePrefixDecorator(store,connector.getId()+"."); //$NON-NLS-1$
} }
public void loadState(ISettings store) { public void loadState(ISettings store) {
fPartName=store.getStringProperty(STORE_PART_NAME); fPartName=store.getString(STORE_PART_NAME);
fSummary=store.getStringProperty(STORE_SUMMARY); fSummary=store.getString(STORE_SUMMARY);
fHistory=store.getStringProperty(STORE_COMMAND_INPUT_FIELD_HISTORY); fHistory=store.getString(STORE_COMMAND_INPUT_FIELD_HISTORY);
fEncoding=store.getStringProperty(STORE_ENCODING); fEncoding=store.getString(STORE_ENCODING);
// load the state of the connection types // load the state of the connection types
ITerminalConnector[] connectors=fCtlTerminal.getConnectors(); ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
String connectionType=store.getStringProperty(STORE_CONNECTION_TYPE); String connectionType=store.getString(STORE_CONNECTION_TYPE);
for (int i = 0; i < connectors.length; i++) { for (int i = 0; i < connectors.length; i++) {
connectors[i].load(getStore(store,connectors[i])); connectors[i].load(getStore(store,connectors[i]));
// if this is active connection type // if this is active connection type
@ -107,26 +107,26 @@ class TerminalViewConnection implements ITerminalViewConnection {
fCtlTerminal.setConnector(connectors[i]); fCtlTerminal.setConnector(connectors[i]);
} }
if("true".equals(store.getStringProperty(STORE_HAS_COMMAND_INPUT_FIELD))) //$NON-NLS-1$ if("true".equals(store.getString(STORE_HAS_COMMAND_INPUT_FIELD))) //$NON-NLS-1$
setCommandInputField(true); setCommandInputField(true);
} }
public void saveState(ISettings store) { public void saveState(ISettings store) {
store.setProperty(STORE_PART_NAME, fPartName); store.set(STORE_PART_NAME, fPartName);
store.setProperty(STORE_SUMMARY,fSummary); store.set(STORE_SUMMARY,fSummary);
store.setProperty(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory); store.set(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory);
store.setProperty(STORE_ENCODING, fEncoding); store.set(STORE_ENCODING, fEncoding);
if(fCommandInputField!=null) if(fCommandInputField!=null)
store.setProperty(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory()); store.set(STORE_COMMAND_INPUT_FIELD_HISTORY, fCommandInputField.getHistory());
else else
store.setProperty(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory); store.set(STORE_COMMAND_INPUT_FIELD_HISTORY, fHistory);
store.setProperty(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false"); //$NON-NLS-1$//$NON-NLS-2$ store.set(STORE_HAS_COMMAND_INPUT_FIELD,hasCommandInputField()?"true":"false"); //$NON-NLS-1$//$NON-NLS-2$
ITerminalConnector[] connectors=fCtlTerminal.getConnectors(); ITerminalConnector[] connectors=fCtlTerminal.getConnectors();
for (int i = 0; i < connectors.length; i++) { for (int i = 0; i < connectors.length; i++) {
connectors[i].save(getStore(store,connectors[i])); connectors[i].save(getStore(store,connectors[i]));
} }
if(fCtlTerminal.getTerminalConnector()!=null) { if(fCtlTerminal.getTerminalConnector()!=null) {
store.setProperty(STORE_CONNECTION_TYPE,fCtlTerminal.getTerminalConnector().getId()); store.set(STORE_CONNECTION_TYPE,fCtlTerminal.getTerminalConnector().getId());
} }
} }
public boolean hasCommandInputField() { public boolean hasCommandInputField() {

View file

@ -109,7 +109,7 @@ public class TerminalViewConnectionManager implements ITerminalViewConnectionMan
} }
public void saveState(ISettings store) { public void saveState(ISettings store) {
store.setProperty(STORE_SIZE,""+fConnections.size()); //$NON-NLS-1$ store.set(STORE_SIZE,""+fConnections.size()); //$NON-NLS-1$
// save all connections // save all connections
int n=0; int n=0;
for (Iterator iterator = fConnections.iterator(); iterator.hasNext();) { for (Iterator iterator = fConnections.iterator(); iterator.hasNext();) {
@ -119,7 +119,7 @@ public class TerminalViewConnectionManager implements ITerminalViewConnectionMan
n++; n++;
// remember the active connection by its prefix // remember the active connection by its prefix
if(connection.equals(fActiveConnection)) if(connection.equals(fActiveConnection))
store.setProperty(STORE_ACTIVE_CONNECTION,prefix); store.set(STORE_ACTIVE_CONNECTION,prefix);
connection.saveState(new SettingStorePrefixDecorator(store,prefix)); connection.saveState(new SettingStorePrefixDecorator(store,prefix));
} }
} }
@ -127,13 +127,13 @@ public class TerminalViewConnectionManager implements ITerminalViewConnectionMan
public void loadState(ISettings store,ITerminalViewConnectionFactory factory) { public void loadState(ISettings store,ITerminalViewConnectionFactory factory) {
int size=0; int size=0;
try { try {
size=Integer.parseInt(store.getStringProperty(STORE_SIZE)); size=Integer.parseInt(store.getString(STORE_SIZE));
} catch(Exception e) { } catch(Exception e) {
// ignore // ignore
} }
if(size>0) { if(size>0) {
// a slot for the connections // a slot for the connections
String active=store.getStringProperty(STORE_ACTIVE_CONNECTION); String active=store.getString(STORE_ACTIVE_CONNECTION);
int n=0; int n=0;
for (int i=0;i<size;i++) { for (int i=0;i<size;i++) {
// the name under which we stored the connection // the name under which we stored the connection

View file

@ -39,16 +39,16 @@ public class RemoteSettings implements IRemoteSettings {
* Load information into the RemoteSettings object. * Load information into the RemoteSettings object.
*/ */
public void load(ISettings store) { public void load(ISettings store) {
fRemoteServices = store.getStringProperty(REMOTE_SERVICES); fRemoteServices = store.getString(REMOTE_SERVICES);
fConnectionName = store.getStringProperty(CONNECTION_NAME); fConnectionName = store.getString(CONNECTION_NAME);
} }
/** /**
* Extract information from the RemoteSettings object. * Extract information from the RemoteSettings object.
*/ */
public void save(ISettings store) { public void save(ISettings store) {
store.getStringProperty(REMOTE_SERVICES, fRemoteServices); store.getString(REMOTE_SERVICES, fRemoteServices);
store.getStringProperty(CONNECTION_NAME, fConnectionName); store.getString(CONNECTION_NAME, fConnectionName);
} }
public void setConnectionName(String name) { public void setConnectionName(String name) {

View file

@ -154,22 +154,22 @@ public class SerialSettings implements ISerialSettings {
} }
public void load(ISettings store) { public void load(ISettings store) {
fSerialPort = store.getStringProperty("SerialPort", fProperties.getDefaultSerialPort());//$NON-NLS-1$ fSerialPort = store.getString("SerialPort", fProperties.getDefaultSerialPort());//$NON-NLS-1$
fBaudRate = store.getStringProperty("BaudRate", fProperties.getDefaultBaudRate());//$NON-NLS-1$ fBaudRate = store.getString("BaudRate", fProperties.getDefaultBaudRate());//$NON-NLS-1$
fDataBits = store.getStringProperty("DataBits", fProperties.getDefaultDataBits());//$NON-NLS-1$ fDataBits = store.getString("DataBits", fProperties.getDefaultDataBits());//$NON-NLS-1$
fStopBits = store.getStringProperty("StopBits", fProperties.getDefaultStopBits());//$NON-NLS-1$ fStopBits = store.getString("StopBits", fProperties.getDefaultStopBits());//$NON-NLS-1$
fParity = store.getStringProperty("Parity", fProperties.getDefaultParity());//$NON-NLS-1$ fParity = store.getString("Parity", fProperties.getDefaultParity());//$NON-NLS-1$
fFlowControl = store.getStringProperty("FlowControl", fProperties.getDefaultFlowControl());//$NON-NLS-1$ fFlowControl = store.getString("FlowControl", fProperties.getDefaultFlowControl());//$NON-NLS-1$
fTimeout = store.getStringProperty("Timeout",fProperties.getDefaultTimeout()); //$NON-NLS-1$ fTimeout = store.getString("Timeout",fProperties.getDefaultTimeout()); //$NON-NLS-1$
} }
public void save(ISettings store) { public void save(ISettings store) {
store.setProperty("SerialPort", fSerialPort); //$NON-NLS-1$ store.set("SerialPort", fSerialPort); //$NON-NLS-1$
store.setProperty("BaudRate", fBaudRate); //$NON-NLS-1$ store.set("BaudRate", fBaudRate); //$NON-NLS-1$
store.setProperty("DataBits", fDataBits); //$NON-NLS-1$ store.set("DataBits", fDataBits); //$NON-NLS-1$
store.setProperty("StopBits", fStopBits); //$NON-NLS-1$ store.set("StopBits", fStopBits); //$NON-NLS-1$
store.setProperty("Parity", fParity); //$NON-NLS-1$ store.set("Parity", fParity); //$NON-NLS-1$
store.setProperty("FlowControl", fFlowControl); //$NON-NLS-1$ store.set("FlowControl", fFlowControl); //$NON-NLS-1$
} }
public SerialProperties getProperties() { public SerialProperties getProperties() {

View file

@ -40,27 +40,27 @@ public class SshSettings implements ISshSettings {
} }
public void load(ISettings store) { public void load(ISettings store) {
fHost = store.getStringProperty("Host");//$NON-NLS-1$ fHost = store.getString("Host");//$NON-NLS-1$
fUser = store.getStringProperty("User");//$NON-NLS-1$ fUser = store.getString("User");//$NON-NLS-1$
// ISettingsStore providers have to make sure that // ISettingsStore providers have to make sure that
// the password is not saved in some as plain text // the password is not saved in some as plain text
// on disk. [bug 313991] // on disk. [bug 313991]
fPassword = store.getStringProperty("Password");//$NON-NLS-1$ fPassword = store.getString("Password");//$NON-NLS-1$
fPort = store.getStringProperty("Port");//$NON-NLS-1$ fPort = store.getString("Port");//$NON-NLS-1$
fTimeout = store.getStringProperty("Timeout");//$NON-NLS-1$ fTimeout = store.getString("Timeout");//$NON-NLS-1$
fKeepalive = store.getStringProperty("Keepalive");//$NON-NLS-1$ fKeepalive = store.getString("Keepalive");//$NON-NLS-1$
} }
public void save(ISettings store) { public void save(ISettings store) {
store.setProperty("Host", fHost);//$NON-NLS-1$ store.set("Host", fHost);//$NON-NLS-1$
store.setProperty("User", fUser);//$NON-NLS-1$ store.set("User", fUser);//$NON-NLS-1$
store.setProperty("Port", fPort);//$NON-NLS-1$ store.set("Port", fPort);//$NON-NLS-1$
// We do *not* store the password in the settings because // We do *not* store the password in the settings because
// this can cause the password to be stored as plain text // this can cause the password to be stored as plain text
// in some settings file // in some settings file
store.setProperty("Timeout", fTimeout);//$NON-NLS-1$ store.set("Timeout", fTimeout);//$NON-NLS-1$
store.setProperty("Keepalive", fKeepalive);//$NON-NLS-1$ store.set("Keepalive", fKeepalive);//$NON-NLS-1$
} }

View file

@ -52,15 +52,15 @@ public class TelnetSettings implements ITelnetSettings {
} }
public void load(ISettings store) { public void load(ISettings store) {
fHost = store.getStringProperty("Host", fProperties.getDefaultHost());//$NON-NLS-1$ fHost = store.getString("Host", fProperties.getDefaultHost());//$NON-NLS-1$
fNetworkPort = store.getStringProperty("NetworkPort", fProperties.getDefaultNetworkPort());//$NON-NLS-1$ fNetworkPort = store.getString("NetworkPort", fProperties.getDefaultNetworkPort());//$NON-NLS-1$
fTimeout = store.getStringProperty("Timeout","10");//$NON-NLS-1$ //$NON-NLS-2$ fTimeout = store.getString("Timeout","10");//$NON-NLS-1$ //$NON-NLS-2$
} }
public void save(ISettings store) { public void save(ISettings store) {
store.setProperty("Host", fHost);//$NON-NLS-1$ store.set("Host", fHost);//$NON-NLS-1$
store.setProperty("NetworkPort", fNetworkPort);//$NON-NLS-1$ store.set("NetworkPort", fNetworkPort);//$NON-NLS-1$
store.setProperty("Timeout", fTimeout);//$NON-NLS-1$ store.set("Timeout", fTimeout);//$NON-NLS-1$
} }
public TelnetProperties getProperties() { public TelnetProperties getProperties() {

View file

@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright (c) 2015 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tm.terminal.telnet.interfaces;
/**
* Telnet terminal connection settings constants.
*/
public interface ITelnetSettingConstants {
}

View file

@ -37,14 +37,14 @@ public class SpeedTestSettings {
fInputFile = testFile; fInputFile = testFile;
} }
public void load(ISettings store) { public void load(ISettings store) {
fInputFile=store.getStringProperty("inputFile"); fInputFile=store.getString("inputFile");
fBufferSize=store.getStringProperty("bufferSize"); fBufferSize=store.getString("bufferSize");
fThrottle=store.getStringProperty("throttle"); fThrottle=store.getString("throttle");
} }
public void save(ISettings store) { public void save(ISettings store) {
store.setProperty("inputFile", fInputFile); store.set("inputFile", fInputFile);
store.setProperty("bufferSize", fBufferSize); store.set("bufferSize", fBufferSize);
store.setProperty("throttle", fThrottle); store.set("throttle", fThrottle);
} }
public String getThrottleString() { public String getThrottleString() {
return fThrottle; return fThrottle;

View file

@ -32,213 +32,213 @@ import org.eclipse.core.runtime.IAdaptable;
public interface ISettings extends IAdaptable { public interface ISettings extends IAdaptable {
/** /**
* Set the properties from the given map. Calling this method * Set the settings from the given map. Calling this method
* will overwrite all previous set properties. * will overwrite all previous set settings.
* <p> * <p>
* <b>Note:</b> The method will have no effect if the given properties are the * <b>Note:</b> The method will have no effect if the given settings are the
* same as the already set properties. * same as the already set settings.
* *
* @param properties The map of properties to set. Must not be <code>null</code>. * @param settings The map of settings to set. Must not be <code>null</code>.
*/ */
public void setProperties(Map<String, Object> properties); public void set(Map<String, Object> settings);
/** /**
* Adds all properties from the given map. If a property already exist * Adds all settings from the given map. If a setting already exist
* in the properties container, than the value of the property is overwritten. * in the settings, than the value of the setting is overwritten.
* *
* @param properties The map of properties to add. Must not be <code>null</code>. * @param settings The map of settings to add. Must not be <code>null</code>.
*/ */
public void addProperties(Map<String, ?> properties); public void addAll(Map<String, ?> settings);
/** /**
* Stores the property under the given property key using the given property value. * Stores the setting under the given key using the given value. If the current
* If the current property value is equal to the given property value, no store * value is equal to the given value, no store operation will be executed. If the
* operation will be executed. If the property value is not <code>null</code> and * value is not <code>null</code> and is different from the current value, the new
* is different from the current property value, the new value will be written to * value will be written to the settings. If the value is <code>null</code>, the
* the property store and a property change event is fired. If the property value * key and the currently stored value are removed from the settings.
* is <code>null</code>, the property key and the currently stored value are removed
* from the property store.
* *
* @param key The key. Must not be <code>null</code>!
* @param value The value.
* *
* @param key The property key. Must not be <code>null</code>! * @return <code>true</code> if the value had been applied to the settings, <code>false</code> otherwise.
* @param value The property value.
* @return <code>true</code> if the property value had been applied to the property store, <code>false</code> otherwise.
*/ */
public boolean setProperty(String key, Object value); public boolean set(String key, Object value);
/** /**
* Stores the property under the given property key using the given long * Stores the setting under the given key using the given long value. The given
* property value. The given long value is transformed to an <code>Long</code> * long value is transformed to an <code>Long</code> object and stored to the
* object and stored to the properties store via <code>setProperty(java.lang.String, java.lang.Object)</code>. * settings store via <code>set(java.lang.String, java.lang.Object)</code>.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @param value The property value. * @param value The value.
* @return <code>true</code> if the property value had been applied to the property store, <code>false</code> otherwise.
* *
* @see <code>setProperty(java.lang.String, java.lang.Object)</code> * @return <code>true</code> if the value had been applied to the settings, <code>false</code> otherwise.
*
* @see <code>set(java.lang.String, java.lang.Object)</code>
*/ */
public boolean setProperty(String key, long value); public boolean set(String key, long value);
/** /**
* Stores the property under the given property key using the given integer * Stores the setting under the given key using the given integer value. The given
* property value. The given integer value is transformed to an <code>Integer</code> * integer value is transformed to an <code>Integer</code> object and stored to the
* object and stored to the properties store via <code>setProperty(java.lang.String, java.lang.Object)</code>. * settings via <code>set(java.lang.String, java.lang.Object)</code>.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @param value The property value. * @param value The value.
* @return <code>true</code> if the property value had been applied to the property store, <code>false</code> otherwise.
* *
* @see <code>setProperty(java.lang.String, java.lang.Object)</code> * @return <code>true</code> if the value had been applied to the settings, <code>false</code> otherwise.
*
* @see <code>set(java.lang.String, java.lang.Object)</code>
*/ */
public boolean setProperty(String key, int value); public boolean set(String key, int value);
/** /**
* Stores the property under the given property key using the given boolean * Stores the setting under the given key using the given boolean value. The given
* property value. The given boolean value is transformed to an <code>Boolean</code> * boolean value is transformed to an <code>Boolean</code> object and stored to the
* object and stored to the properties store via <code>setProperty(java.lang.String, java.lang.Object)</code>. * settings via <code>set(java.lang.String, java.lang.Object)</code>.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @param value The property value. * @param value The value.
* @return <code>true</code> if the property value had been applied to the property store, <code>false</code> otherwise.
* *
* @see <code>setProperty(java.lang.String, java.lang.Object)</code> * @return <code>true</code> if the value had been applied to the settings, <code>false</code> otherwise.
*
* @see <code>set(java.lang.String, java.lang.Object)</code>
*/ */
public boolean setProperty(String key, boolean value); public boolean set(String key, boolean value);
/** /**
* Stores the property under the given property key using the given float * Stores the setting under the given key using the given float value. The given
* property value. The given float value is transformed to an <code>Float</code> * float value is transformed to an <code>Float</code> object and stored to the
* object and stored to the properties store via <code>setProperty(java.lang.String, java.lang.Object)</code>. * settings via <code>set(java.lang.String, java.lang.Object)</code>.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @param value The property value. * @param value The value.
* @return <code>true</code> if the property value had been applied to the property store, <code>false</code> otherwise.
* *
* @see <code>setProperty(java.lang.String, java.lang.Object)</code> * @return <code>true</code> if the value had been applied to the settings, <code>false</code> otherwise.
*
* @see <code>set(java.lang.String, java.lang.Object)</code>
*/ */
public boolean setProperty(String key, float value); public boolean set(String key, float value);
/** /**
* Stores the property under the given property key using the given double * Stores the setting under the given key using the given double value. The given
* property value. The given double value is transformed to an <code>Double</code> * double value is transformed to an <code>Double</code> object and stored to the
* object and stored to the properties store via <code>setProperty(java.lang.String, java.lang.Object)</code>. * settings via <code>set(java.lang.String, java.lang.Object)</code>.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @param value The property value. * @param value The value.
* @return <code>true</code> if the property value had been applied to the property store, <code>false</code> otherwise.
* *
* @see <code>setProperty(java.lang.String, java.lang.Object)</code> * @return <code>true</code> if the value had been applied to the settings, <code>false</code> otherwise.
*
* @see <code>set(java.lang.String, java.lang.Object)</code>
*/ */
public boolean setProperty(String key, double value); public boolean set(String key, double value);
/** /**
* Return all properties. The result map is read-only. * Return all settings. The result map is read-only.
* *
* @return A map containing all properties. * @return A map containing all settings.
*/ */
public Map<String, Object> getProperties(); public Map<String, Object> getAll();
/** /**
* Queries the property value stored under the given property key. If the property * Queries the value stored under the given key. If the setting does not exist,
* does not exist, <code>null</code> is returned. * <code>null</code> is returned.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @return The stored property value or <code>null</code>. * @return The stored value or <code>null</code>.
*/ */
public Object getProperty(String key); public Object get(String key);
/** /**
* Queries the property value stored under the given property key. If the property * Queries the value stored under the given key. If the setting exist and is of type
* exist and is of type <code>java.lang.String</code>, the property value casted to * <code>java.lang.String</code>, the value casted to <code>java.lang.String</code>
* <code>java.lang.String</code> is returned. In all other cases, <code>null</code> * is returned. In all other cases, <code>null</code> is returned.
* is returned.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @return The stored property value casted <code>java.lang.String</code> or <code>null</code>. * @return The stored value casted <code>java.lang.String</code> or <code>null</code>.
*/ */
public String getStringProperty(String key); public String getString(String key);
/** /**
* Queries the property value stored under the given property key. If the property * Queries the value stored under the given key. If the setting exist and is of type
* exist and is of type <code>java.lang.String</code>, the property value casted to * <code>java.lang.String</code>, the value casted to <code>java.lang.String</code>
* <code>java.lang.String</code> is returned. In all other cases, the given default * is returned. In all other cases, the given default value is returned.
* value is returned.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @param defaultValue The default value or <code>null</code>. * @param defaultValue The default value or <code>null</code>.
* *
* @return The stored property value casted <code>java.lang.String</code> or <code>null</code>. * @return The stored value casted <code>java.lang.String</code> or the default value.
*/ */
public String getStringProperty(String key, String defaultValue); public String getString(String key, String defaultValue);
/** /**
* Queries the property value stored under the given property key. If the property * Queries the value stored under the given key. If the setting exist and is of type
* exist and is of type <code>java.lang.Long</code>, the property value converted * <code>java.lang.Long</code>, the value converted to an long value is returned. In
* to an long value is returned. In all other cases, <code>-1</code> is returned. * all other cases, <code>-1</code> is returned.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @return The stored property value converted to a long value or <code>-1</code>. * @return The stored value converted to a long value or <code>-1</code>.
*/ */
public long getLongProperty(String key); public long getLong(String key);
/** /**
* Queries the property value stored under the given property key. If the property * Queries the value stored under the given key. If the setting exist and is of type
* exist and is of type <code>java.lang.Integer</code>, the property value converted * <code>java.lang.Integer</code>, the value converted to an integer value is returned.
* to an integer value is returned. In all other cases, <code>-1</code> is returned. * In all other cases, <code>-1</code> is returned.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @return The stored property value converted to an integer value or <code>-1</code>. * @return The stored value converted to an integer value or <code>-1</code>.
*/ */
public int getIntProperty(String key); public int getInt(String key);
/** /**
* Queries the property value stored under the given property key. If the property * Queries the value stored under the given key. If the setting exist and is of type
* exist and is of type <code>java.lang.Boolean</code>, the property value converted * <code>java.lang.Boolean</code>, the value converted to an boolean value is returned.
* to an boolean value is returned. In all other cases, <code>false</code> is returned. * In all other cases, <code>false</code> is returned.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @return The stored property value converted to an boolean value or <code>false</code>. * @return The stored value converted to an boolean value or <code>false</code>.
*/ */
public boolean getBooleanProperty(String key); public boolean getBoolean(String key);
/** /**
* Queries the property value stored under the given property key. If the property * Queries the value stored under the given key. If the setting exist and is of type
* exist and is of type <code>java.lang.Float</code>, the property value converted * <code>java.lang.Float</code>, the value converted to an float value is returned.
* to an float value is returned. In all other cases, <code>Float.NaN</code> is returned. * In all other cases, <code>Float.NaN</code> is returned.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @return The stored property value converted to a float value or <code>Float.NaN</code>. * @return The stored value converted to a float value or <code>Float.NaN</code>.
*/ */
public float getFloatProperty(String key); public float getFloat(String key);
/** /**
* Queries the property value stored under the given property key. If the property * Queries the value stored under the given key. If the setting exist and is of type
* exist and is of type <code>java.lang.Double</code>, the property value converted * <code>java.lang.Double</code>, the value converted to an double value is returned.
* to an double value is returned. In all other cases, <code>Double.NaN</code> is returned. * In all other cases, <code>Double.NaN</code> is returned.
* *
* @param key The property key. Must not be <code>null</code>! * @param key The key. Must not be <code>null</code>!
* @return The stored property value converted to a double value or <code>Double.NaN</code>. * @return The stored value converted to a double value or <code>Double.NaN</code>.
*/ */
public double getDoubleProperty(String key); public double getDouble(String key);
/** /**
* Remove all properties from the properties store. The method does not fire any * Remove all settings.
* properties changed event.
*/ */
public void clearProperties(); public void clear();
/** /**
* Returns whether this properties container is empty or not. * Returns whether the settings are empty or not.
* *
* @return <code>True</code> if the properties container is empty, <code>false</code> if not. * @return <code>True</code> if the settings are empty, <code>false</code> if not.
*/ */
public boolean isEmpty(); public boolean isEmpty();
/** /**
* Returns whether this properties container contains the given key. * Returns whether the settings contains the given key.
* *
* @param key The key. Must not be <code>null</code>. * @param key The key. Must not be <code>null</code>.
* @return <code>True</code> if the properties container contains the key, <code>false</code> if not. * @return <code>True</code> if the settings contains the key, <code>false</code> if not.
*/ */
public boolean containsKey(String key); public boolean containsKey(String key);
} }

View file

@ -59,7 +59,7 @@ public class Settings extends PlatformObject implements ISettings {
public String toString() { public String toString() {
final StringBuilder buffer = new StringBuilder(); final StringBuilder buffer = new StringBuilder();
// print the first level of the properties map only // print the first level of the settings map only
buffer.append("settings={"); //$NON-NLS-1$ buffer.append("settings={"); //$NON-NLS-1$
for (String key : settings.keySet()) { for (String key : settings.keySet()) {
buffer.append(key); buffer.append(key);
@ -84,27 +84,27 @@ public class Settings extends PlatformObject implements ISettings {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getProperties() * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#getAll()
*/ */
@Override @Override
public Map<String, Object> getProperties() { public Map<String, Object> getAll() {
return Collections.unmodifiableMap(new HashMap<String, Object>(settings)); return Collections.unmodifiableMap(new HashMap<String, Object>(settings));
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getProperty(java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#get(java.lang.String)
*/ */
@Override @Override
public Object getProperty(String key) { public Object get(String key) {
return settings.get(key); return settings.get(key);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getBooleanProperty(java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#getBoolean(java.lang.String)
*/ */
@Override @Override
public final boolean getBooleanProperty(String key) { public final boolean getBoolean(String key) {
Object value = getProperty(key); Object value = get(key);
if (value instanceof Boolean) { if (value instanceof Boolean) {
return ((Boolean)value).booleanValue(); return ((Boolean)value).booleanValue();
} }
@ -117,11 +117,11 @@ public class Settings extends PlatformObject implements ISettings {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getLongProperty(java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#getLong(java.lang.String)
*/ */
@Override @Override
public final long getLongProperty(String key) { public final long getLong(String key) {
Object value = getProperty(key); Object value = get(key);
try { try {
if (value instanceof Long) { if (value instanceof Long) {
return ((Long)value).longValue(); return ((Long)value).longValue();
@ -140,11 +140,11 @@ public class Settings extends PlatformObject implements ISettings {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getIntProperty(java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#getInt(java.lang.String)
*/ */
@Override @Override
public final int getIntProperty(String key) { public final int getInt(String key) {
Object value = getProperty(key); Object value = get(key);
try { try {
if (value instanceof Integer) { if (value instanceof Integer) {
return ((Integer)value).intValue(); return ((Integer)value).intValue();
@ -163,30 +163,29 @@ public class Settings extends PlatformObject implements ISettings {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getStringProperty(java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#getString(java.lang.String)
*/ */
@Override @Override
public final String getStringProperty(String key) { public final String getString(String key) {
Object value = getProperty(key); Object value = get(key);
return value instanceof String ? (String)value : return value instanceof String ? (String)value : null;
(value != null ? value.toString() : null);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getStringProperty(java.lang.String, java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#getString(java.lang.String, java.lang.String)
*/ */
@Override @Override
public String getStringProperty(String key, String defaultValue) { public String getString(String key, String defaultValue) {
String value = getStringProperty(key); String value = getString(key);
return value != null ? value : defaultValue; return value != null ? value : defaultValue;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getFloatProperty(java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#getFloat(java.lang.String)
*/ */
@Override @Override
public final float getFloatProperty(String key) { public final float getFloat(String key) {
Object value = getProperty(key); Object value = get(key);
try { try {
if (value instanceof Float) { if (value instanceof Float) {
return ((Float)value).floatValue(); return ((Float)value).floatValue();
@ -205,11 +204,11 @@ public class Settings extends PlatformObject implements ISettings {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#getDoubleProperty(java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#getDouble(java.lang.String)
*/ */
@Override @Override
public final double getDoubleProperty(String key) { public final double getDouble(String key) {
Object value = getProperty(key); Object value = get(key);
try { try {
if (value instanceof Double) { if (value instanceof Double) {
return ((Double)value).doubleValue(); return ((Double)value).doubleValue();
@ -228,97 +227,97 @@ public class Settings extends PlatformObject implements ISettings {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#setProperties(java.util.Map) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#set(java.util.Map)
*/ */
@Override @Override
public final void setProperties(Map<String, Object> properties) { public final void set(Map<String, Object> settings) {
Assert.isNotNull(properties); Assert.isNotNull(settings);
// Change the properties only if they have changed really // Change the settings only if they have changed really
if (this.settings.equals(properties)) { if (this.settings.equals(settings)) {
return; return;
} }
// Clear out all old properties // Clear out all old settings
this.settings.clear(); this.settings.clear();
// Apply everything from the given properties // Apply everything from the given settings
this.settings.putAll(properties); this.settings.putAll(settings);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#addProperties(java.util.Map) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#addAll(java.util.Map)
*/ */
@Override @Override
public final void addProperties(Map<String, ?> properties) { public final void addAll(Map<String, ?> settings) {
// Apply everything from the given properties // Apply everything from the given settings
this.settings.putAll(properties); this.settings.putAll(settings);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#setProperty(java.lang.String, boolean) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#set(java.lang.String, boolean)
*/ */
@Override @Override
public final boolean setProperty(String key, boolean value) { public final boolean set(String key, boolean value) {
boolean oldValue = getBooleanProperty(key); boolean oldValue = getBoolean(key);
if (oldValue != value) { if (oldValue != value) {
return setProperty(key, Boolean.valueOf(value)); return set(key, Boolean.valueOf(value));
} }
return false; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#setProperty(java.lang.String, long) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#set(java.lang.String, long)
*/ */
@Override @Override
public final boolean setProperty(String key, long value) { public final boolean set(String key, long value) {
long oldValue = getLongProperty(key); long oldValue = getLong(key);
if (oldValue != value) { if (oldValue != value) {
return setProperty(key, Long.valueOf(value)); return set(key, Long.valueOf(value));
} }
return false; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#setProperty(java.lang.String, int) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#set(java.lang.String, int)
*/ */
@Override @Override
public final boolean setProperty(String key, int value) { public final boolean set(String key, int value) {
int oldValue = getIntProperty(key); int oldValue = getInt(key);
if (oldValue != value) { if (oldValue != value) {
return setProperty(key, Integer.valueOf(value)); return set(key, Integer.valueOf(value));
} }
return false; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#setProperty(java.lang.String, float) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#set(java.lang.String, float)
*/ */
@Override @Override
public final boolean setProperty(String key, float value) { public final boolean set(String key, float value) {
float oldValue = getFloatProperty(key); float oldValue = getFloat(key);
if (oldValue != value) { if (oldValue != value) {
return setProperty(key, Float.valueOf(value)); return set(key, Float.valueOf(value));
} }
return false; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#setProperty(java.lang.String, double) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#set(java.lang.String, double)
*/ */
@Override @Override
public final boolean setProperty(String key, double value) { public final boolean set(String key, double value) {
double oldValue = getDoubleProperty(key); double oldValue = getDouble(key);
if (oldValue != value) { if (oldValue != value) {
return setProperty(key, Double.valueOf(value)); return set(key, Double.valueOf(value));
} }
return false; return false;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#setProperty(java.lang.String, java.lang.Object) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#set(java.lang.String, java.lang.Object)
*/ */
@Override @Override
public boolean setProperty(String key, Object value) { public boolean set(String key, Object value) {
Assert.isNotNull(key); Assert.isNotNull(key);
Object oldValue = settings.get(key); Object oldValue = settings.get(key);
@ -334,15 +333,15 @@ public class Settings extends PlatformObject implements ISettings {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#clearProperties() * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#clear()
*/ */
@Override @Override
public final void clearProperties() { public final void clear() {
settings.clear(); settings.clear();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#isEmpty() * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#isEmpty()
*/ */
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
@ -350,7 +349,7 @@ public class Settings extends PlatformObject implements ISettings {
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore#containsKey(java.lang.String) * @see org.eclipse.tm.internal.terminal.provisional.api.ISettings#containsKey(java.lang.String)
*/ */
@Override @Override
public boolean containsKey(String key) { public boolean containsKey(String key) {