From cafd9f15ebbcebf16bce836f1497301c45367c7c Mon Sep 17 00:00:00 2001 From: David Dykstal Date: Thu, 5 Apr 2007 18:51:14 +0000 Subject: [PATCH] [150939] added readOnly attribute to IProperty --- .../org/eclipse/rse/core/model/IProperty.java | 81 ++++++++++++++-- .../eclipse/rse/core/model/IPropertyType.java | 29 +++++- .../org/eclipse/rse/core/model/Property.java | 93 ++++++++++++++----- .../eclipse/rse/core/model/PropertyType.java | 49 +++++++--- 4 files changed, 206 insertions(+), 46 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IProperty.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IProperty.java index 42550ed90ea..44053aa529c 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IProperty.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IProperty.java @@ -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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is * 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. * * 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; -public interface IProperty { +/** + * 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 { + + /** + * @return the name of the property. + */ 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 setValue(String value); + /** + * @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); + + /** + * @return the value of this property + */ 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); + /** + * @return the type of this property + */ 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); + /** + * 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(); + + /** + * 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(); + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertyType.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertyType.java index c02f6e344b5..7d44e472f1c 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertyType.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/IPropertyType.java @@ -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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is * 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. * * Contributors: - * {Name} (company) - description of contribution. + * David Dykstal (IBM) - added javadoc ********************************************************************************/ package org.eclipse.rse.core.model; +/** + * Property types are used to type instances of {@link IProperty}. + */ public interface IPropertyType { + public static final int TYPE_STRING = 0; public static final int TYPE_INTEGER = 1; public static final int TYPE_ENUM = 2; public static final int TYPE_BOOLEAN = 3; + /** + * @return true if the property is of TYPE_STRING + */ public boolean isString(); + /** + * @return true if the property is of TYPE_INTEGER + */ public boolean isInteger(); + /** + * @return true if the property is of TYPE_ENUM + */ public boolean isEnum(); + /** + * @return true if the property is of TYPE_BOOLEAN + */ public boolean isBoolean(); - + + /** + * @return the integer value of the property type + */ public int getType(); + /** + * @return the array of values that comprise the enumeration + */ public String[] getEnumValues(); + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/Property.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/Property.java index d46af1ab753..6c4f5713233 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/Property.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/Property.java @@ -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 * of the Eclipse Public License v1.0 which accompanies this distribution, and is * 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. * * 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; +/** + * + */ public class Property implements IProperty { - protected String _name; - protected String _label; - protected String _value; - protected IPropertyType _type; - protected boolean _isEnabled; + + private String _name; + private String _label; + private String _value; + private IPropertyType _type; + private boolean _isEnabled = true; + private boolean _isReadOnly = false; public Property(IProperty property) { _name = property.getKey(); @@ -38,10 +44,23 @@ public class Property implements IProperty { _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) { _label = label; } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IProperty#getLabel() + */ public String getLabel() { if (_label == null) { return _name; @@ -49,32 +68,60 @@ public class Property implements IProperty { return _label; } - public String getKey() { - return _name; - } - - public String getValue() { - return _value; - } - - public IPropertyType getType() { - return _type; - } - - public boolean isEnabled() { - return _isEnabled; - } - + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IProperty#setValue(java.lang.String) + */ public void setValue(String 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) { _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) { _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; + } + } \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertyType.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertyType.java index 711506e77ef..1d6fe0161e2 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertyType.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/model/PropertyType.java @@ -11,12 +11,18 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David Dykstal (IBM) - added javadoc, minor changes ********************************************************************************/ 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 { + private int _type = 0; private String[] _enumValues; @@ -29,17 +35,17 @@ public class PropertyType implements IPropertyType { private PropertyType(int type) { _type = type; } - + /** - * Return an instance of boolean property type. + * Returns an instance of boolean property type. * @return IPropertyType */ public static IPropertyType getBooleanPropertyType() { return _booleanPropertyType; } - + /** - * Return an instance of integer property type. + * Returns an instance of integer property type. * @return IPropertyType */ 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 */ 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. * @return IPropertyType */ public static IPropertyType getEnumPropertyType(String[] values) { PropertyType type = new PropertyType(TYPE_ENUM); - type.setEnumValues(values); + type._enumValues = values; 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(). * @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() { return _type; } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IPropertyType#isString() + */ public boolean isString() { return _type == TYPE_STRING; } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IPropertyType#isInteger() + */ public boolean isInteger() { return _type == TYPE_INTEGER; } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IPropertyType#isEnum() + */ public boolean isEnum() { return _type == TYPE_ENUM; } + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IPropertyType#isBoolean() + */ public boolean isBoolean() { return _type == TYPE_BOOLEAN; } - private void setEnumValues(String[] enumValues) { - _enumValues = enumValues; - } - + /* (non-Javadoc) + * @see org.eclipse.rse.core.model.IPropertyType#getEnumValues() + */ public String[] getEnumValues() { return _enumValues; } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ public String toString() { if (isString()) { return String.class.getName();