mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 01:55:24 +02:00
[150939] added readOnly attribute to IProperty
This commit is contained in:
parent
092ed936f3
commit
cafd9f15eb
4 changed files with 206 additions and 46 deletions
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
* Copyright (c) 2006, 2007 IBM Corporation. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* 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
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -11,27 +11,94 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* David Dykstal (IBM) - added javadoc
|
||||||
|
* David Dykstal (IBM) - [150939] added read-only attribute
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.core.model;
|
package org.eclipse.rse.core.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properties are contained in property sets ({@link IPropertySet}) and may be associated with objects that
|
||||||
|
* implement {@link IPropertySetContainer}. These would typically be model objects.
|
||||||
|
* Properties also have a type (see {@link IPropertyType}).
|
||||||
|
* @see IRSEModelObject
|
||||||
|
*/
|
||||||
public interface IProperty {
|
public interface IProperty {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the property.
|
||||||
|
*/
|
||||||
public String getKey();
|
public String getKey();
|
||||||
|
|
||||||
public String getLabel();
|
/**
|
||||||
|
* Sets the displayable label of the property.
|
||||||
|
* @param label the label for this property.
|
||||||
|
*/
|
||||||
public void setLabel(String label);
|
public void setLabel(String label);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the displayable label of this property
|
||||||
|
*/
|
||||||
|
public String getLabel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of this property.
|
||||||
|
* May raise a runtime exception if the new value of the property is
|
||||||
|
* not compatible with its type.
|
||||||
|
* @param value the new value for this property.
|
||||||
|
*/
|
||||||
public void setValue(String value);
|
public void setValue(String value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the value of this property
|
||||||
|
*/
|
||||||
public String getValue();
|
public String getValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the type of this property.
|
||||||
|
* May raise an runtime exception if the value of the property is not compatible
|
||||||
|
* with the new type.
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
public void setType(IPropertyType type);
|
public void setType(IPropertyType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the type of this property
|
||||||
|
*/
|
||||||
public IPropertyType getType();
|
public IPropertyType getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the "enabled" presentation attribute of this property.
|
||||||
|
* This is an attribute that can be used to drive the presentation of this
|
||||||
|
* property and does not otherwise affect how this property can be used.
|
||||||
|
* Properties are enabled by default.
|
||||||
|
* @param flag true if the property is to be enabled.
|
||||||
|
*/
|
||||||
public void setEnabled(boolean flag);
|
public void setEnabled(boolean flag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the "enabled" presentation attribute of this property.
|
||||||
|
* This is an attribute that can be used to drive the presentation of this
|
||||||
|
* property and does not otherwise affect how this property can be used.
|
||||||
|
* @return true if the property is enabled.
|
||||||
|
*/
|
||||||
public boolean isEnabled();
|
public boolean isEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the "read-only" presentation attribute of this property.
|
||||||
|
* This is an attribute that can be used to drive the presentation of this
|
||||||
|
* property and does not otherwise affect how this property can be used.
|
||||||
|
* Properties are read-write by default.
|
||||||
|
* @param flag true if the property is to be read-only.
|
||||||
|
*/
|
||||||
|
public void setReadOnly(boolean flag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the "read-only" presentation attribute of this property.
|
||||||
|
* This is an attribute that can be used to drive the presentation of this
|
||||||
|
* property and does not otherwise affect how this property can be used.
|
||||||
|
* @return true if the property is read-only.
|
||||||
|
*/
|
||||||
|
public boolean isReadOnly();
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
* Copyright (c) 2006, 2007 IBM Corporation. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* 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
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -11,26 +11,49 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* David Dykstal (IBM) - added javadoc
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.core.model;
|
package org.eclipse.rse.core.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Property types are used to type instances of {@link IProperty}.
|
||||||
|
*/
|
||||||
public interface IPropertyType {
|
public interface IPropertyType {
|
||||||
|
|
||||||
public static final int TYPE_STRING = 0;
|
public static final int TYPE_STRING = 0;
|
||||||
public static final int TYPE_INTEGER = 1;
|
public static final int TYPE_INTEGER = 1;
|
||||||
public static final int TYPE_ENUM = 2;
|
public static final int TYPE_ENUM = 2;
|
||||||
public static final int TYPE_BOOLEAN = 3;
|
public static final int TYPE_BOOLEAN = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the property is of TYPE_STRING
|
||||||
|
*/
|
||||||
public boolean isString();
|
public boolean isString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the property is of TYPE_INTEGER
|
||||||
|
*/
|
||||||
public boolean isInteger();
|
public boolean isInteger();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the property is of TYPE_ENUM
|
||||||
|
*/
|
||||||
public boolean isEnum();
|
public boolean isEnum();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the property is of TYPE_BOOLEAN
|
||||||
|
*/
|
||||||
public boolean isBoolean();
|
public boolean isBoolean();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the integer value of the property type
|
||||||
|
*/
|
||||||
public int getType();
|
public int getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the array of values that comprise the enumeration
|
||||||
|
*/
|
||||||
public String[] getEnumValues();
|
public String[] getEnumValues();
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (c) 2006 IBM Corporation. All rights reserved.
|
* Copyright (c) 2006, 2007 IBM Corporation. All rights reserved.
|
||||||
* This program and the accompanying materials are made available under the terms
|
* 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
|
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
@ -11,17 +11,23 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* David Dykstal (IBM) - added javadoc
|
||||||
|
* David Dykstal (IBM) - [150939] added read-only attribute
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.core.model;
|
package org.eclipse.rse.core.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Property implements IProperty {
|
public class Property implements IProperty {
|
||||||
protected String _name;
|
|
||||||
protected String _label;
|
private String _name;
|
||||||
protected String _value;
|
private String _label;
|
||||||
protected IPropertyType _type;
|
private String _value;
|
||||||
protected boolean _isEnabled;
|
private IPropertyType _type;
|
||||||
|
private boolean _isEnabled = true;
|
||||||
|
private boolean _isReadOnly = false;
|
||||||
|
|
||||||
public Property(IProperty property) {
|
public Property(IProperty property) {
|
||||||
_name = property.getKey();
|
_name = property.getKey();
|
||||||
|
@ -38,10 +44,23 @@ public class Property implements IProperty {
|
||||||
_isEnabled = isEnabled;
|
_isEnabled = isEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#getKey()
|
||||||
|
*/
|
||||||
|
public String getKey() {
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#setLabel(java.lang.String)
|
||||||
|
*/
|
||||||
public void setLabel(String label) {
|
public void setLabel(String label) {
|
||||||
_label = label;
|
_label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#getLabel()
|
||||||
|
*/
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
if (_label == null) {
|
if (_label == null) {
|
||||||
return _name;
|
return _name;
|
||||||
|
@ -49,32 +68,60 @@ public class Property implements IProperty {
|
||||||
return _label;
|
return _label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKey() {
|
/* (non-Javadoc)
|
||||||
return _name;
|
* @see org.eclipse.rse.core.model.IProperty#setValue(java.lang.String)
|
||||||
}
|
*/
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return _value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IPropertyType getType() {
|
|
||||||
return _type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled() {
|
|
||||||
return _isEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
_value = value;
|
_value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#getValue()
|
||||||
|
*/
|
||||||
|
public String getValue() {
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#setType(org.eclipse.rse.core.model.IPropertyType)
|
||||||
|
*/
|
||||||
public void setType(IPropertyType type) {
|
public void setType(IPropertyType type) {
|
||||||
_type = type;
|
_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#getType()
|
||||||
|
*/
|
||||||
|
public IPropertyType getType() {
|
||||||
|
return _type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#setEnabled(boolean)
|
||||||
|
*/
|
||||||
public void setEnabled(boolean flag) {
|
public void setEnabled(boolean flag) {
|
||||||
_isEnabled = flag;
|
_isEnabled = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#isEnabled()
|
||||||
|
*/
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return _isEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#setReadOnly(boolean)
|
||||||
|
*/
|
||||||
|
public void setReadOnly(boolean flag) {
|
||||||
|
_isReadOnly = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IProperty#isReadOnly()
|
||||||
|
*/
|
||||||
|
public boolean isReadOnly() {
|
||||||
|
return _isReadOnly;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,12 +11,18 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* David Dykstal (IBM) - added javadoc, minor changes
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.core.model;
|
package org.eclipse.rse.core.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The standard implementation of {@link IPropertyType}.
|
||||||
|
* The constructors are private.
|
||||||
|
* Use the static factory methods to return instances.
|
||||||
|
*/
|
||||||
public class PropertyType implements IPropertyType {
|
public class PropertyType implements IPropertyType {
|
||||||
|
|
||||||
private int _type = 0;
|
private int _type = 0;
|
||||||
private String[] _enumValues;
|
private String[] _enumValues;
|
||||||
|
|
||||||
|
@ -31,7 +37,7 @@ public class PropertyType implements IPropertyType {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an instance of boolean property type.
|
* Returns an instance of boolean property type.
|
||||||
* @return IPropertyType
|
* @return IPropertyType
|
||||||
*/
|
*/
|
||||||
public static IPropertyType getBooleanPropertyType() {
|
public static IPropertyType getBooleanPropertyType() {
|
||||||
|
@ -39,7 +45,7 @@ public class PropertyType implements IPropertyType {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an instance of integer property type.
|
* Returns an instance of integer property type.
|
||||||
* @return IPropertyType
|
* @return IPropertyType
|
||||||
*/
|
*/
|
||||||
public static IPropertyType getIntegerPropertyType() {
|
public static IPropertyType getIntegerPropertyType() {
|
||||||
|
@ -47,7 +53,7 @@ public class PropertyType implements IPropertyType {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an instance of string property type.
|
* Returns an instance of string property type.
|
||||||
* @return IPropertyType
|
* @return IPropertyType
|
||||||
*/
|
*/
|
||||||
public static IPropertyType getStringPropertyType() {
|
public static IPropertyType getStringPropertyType() {
|
||||||
|
@ -55,18 +61,18 @@ public class PropertyType implements IPropertyType {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an instance of enum property type.
|
* Returns an instance of enum property type.
|
||||||
* @param values String[] array of allowed enumerator values.
|
* @param values String[] array of allowed enumerator values.
|
||||||
* @return IPropertyType
|
* @return IPropertyType
|
||||||
*/
|
*/
|
||||||
public static IPropertyType getEnumPropertyType(String[] values) {
|
public static IPropertyType getEnumPropertyType(String[] values) {
|
||||||
PropertyType type = new PropertyType(TYPE_ENUM);
|
PropertyType type = new PropertyType(TYPE_ENUM);
|
||||||
type.setEnumValues(values);
|
type._enumValues = values;
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an instance of property type based on the String specification.
|
* Returns an instance of property type based on the String specification.
|
||||||
* This is the reverse of PropertyType.toString().
|
* This is the reverse of PropertyType.toString().
|
||||||
* @return IPropertyType instance based on String specification.
|
* @return IPropertyType instance based on String specification.
|
||||||
*/
|
*/
|
||||||
|
@ -86,34 +92,51 @@ public class PropertyType implements IPropertyType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IPropertyType#getType()
|
||||||
|
*/
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IPropertyType#isString()
|
||||||
|
*/
|
||||||
public boolean isString() {
|
public boolean isString() {
|
||||||
return _type == TYPE_STRING;
|
return _type == TYPE_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IPropertyType#isInteger()
|
||||||
|
*/
|
||||||
public boolean isInteger() {
|
public boolean isInteger() {
|
||||||
return _type == TYPE_INTEGER;
|
return _type == TYPE_INTEGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IPropertyType#isEnum()
|
||||||
|
*/
|
||||||
public boolean isEnum() {
|
public boolean isEnum() {
|
||||||
return _type == TYPE_ENUM;
|
return _type == TYPE_ENUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.rse.core.model.IPropertyType#isBoolean()
|
||||||
|
*/
|
||||||
public boolean isBoolean() {
|
public boolean isBoolean() {
|
||||||
return _type == TYPE_BOOLEAN;
|
return _type == TYPE_BOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEnumValues(String[] enumValues) {
|
/* (non-Javadoc)
|
||||||
_enumValues = enumValues;
|
* @see org.eclipse.rse.core.model.IPropertyType#getEnumValues()
|
||||||
}
|
*/
|
||||||
|
|
||||||
public String[] getEnumValues() {
|
public String[] getEnumValues() {
|
||||||
return _enumValues;
|
return _enumValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (isString()) {
|
if (isString()) {
|
||||||
return String.class.getName();
|
return String.class.getName();
|
||||||
|
|
Loading…
Add table
Reference in a new issue