001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.examples.readmetool;
011:
012: import org.eclipse.ui.views.properties.IPropertyDescriptor;
013: import org.eclipse.ui.views.properties.IPropertySource;
014: import org.eclipse.ui.views.properties.PropertyDescriptor;
015:
016: /**
017: * This class encapsulates property sheet properties
018: * for MarkElement. This will display properties for
019: * the MarkElement when selected in the readme editor's
020: * content outline.
021: */
022: public class MarkElementProperties implements IPropertySource {
023: protected MarkElement element;
024:
025: protected static final String PROPERTY_LINECOUNT = "lineno"; //$NON-NLS-1$
026:
027: protected static final String PROPERTY_START = "start"; //$NON-NLS-1$
028:
029: protected static final String PROPERTY_LENGTH = "length"; //$NON-NLS-1$
030:
031: /**
032: * Creates a new MarkElementProperties.
033: *
034: * @param element the element whose properties this instance represents
035: */
036: public MarkElementProperties(MarkElement element) {
037: super ();
038: this .element = element;
039: }
040:
041: /* (non-Javadoc)
042: * Method declared on IPropertySource
043: */
044: public Object getEditableValue() {
045: return this ;
046: }
047:
048: /* (non-Javadoc)
049: * Method declared on IPropertySource
050: */
051: public IPropertyDescriptor[] getPropertyDescriptors() {
052: // Create the property vector.
053: IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[3];
054:
055: // Add each property supported.
056: PropertyDescriptor descriptor;
057:
058: descriptor = new PropertyDescriptor(PROPERTY_LINECOUNT,
059: MessageUtil.getString("Line_count")); //$NON-NLS-1$
060: propertyDescriptors[0] = descriptor;
061: descriptor = new PropertyDescriptor(PROPERTY_START, MessageUtil
062: .getString("Title_start")); //$NON-NLS-1$
063: propertyDescriptors[1] = descriptor;
064: descriptor = new PropertyDescriptor(PROPERTY_LENGTH,
065: MessageUtil.getString("Title_length")); //$NON-NLS-1$
066: propertyDescriptors[2] = descriptor;
067:
068: // Return it.
069: return propertyDescriptors;
070: }
071:
072: /* (non-Javadoc)
073: * Method declared on IPropertySource
074: */
075: public Object getPropertyValue(Object name) {
076: if (name.equals(PROPERTY_LINECOUNT))
077: return new Integer(element.getNumberOfLines());
078: if (name.equals(PROPERTY_START))
079: return new Integer(element.getStart());
080: if (name.equals(PROPERTY_LENGTH))
081: return new Integer(element.getLength());
082: return null;
083: }
084:
085: /* (non-Javadoc)
086: * Method declared on IPropertySource
087: */
088: public boolean isPropertySet(Object property) {
089: return false;
090: }
091:
092: /* (non-Javadoc)
093: * Method declared on IPropertySource
094: */
095: public void resetPropertyValue(Object property) {
096: // do nothing
097: }
098:
099: /* (non-Javadoc)
100: * Method declared on IPropertySource
101: */
102: public void setPropertyValue(Object name, Object value) {
103: // do nothing
104: }
105: }
|