001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id$
023: */
024: package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers;
025:
026: import java.util.ArrayList;
027: import java.util.Iterator;
028: import java.util.List;
029: import org.eclipse.core.runtime.Assert;
030: import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
031: import org.eclipse.emf.edit.provider.IItemPropertySource;
032: import org.eclipse.emf.edit.ui.provider.PropertySource;
033: import org.eclipse.ui.views.properties.IPropertyDescriptor;
034:
035: public class ComponentFlowEditorBasicPropertySource extends
036: PropertySource {
037: /**
038: * @param object
039: * @param itemPropertySource
040: */
041: public ComponentFlowEditorBasicPropertySource(Object object,
042: IItemPropertySource itemPropertySource) {
043: super (object, itemPropertySource);
044: }
045:
046: public boolean isPropertySet(Object id) {
047: Assert.isTrue(id instanceof PropertyDescriptorWithObjectedID);
048: Object obj = ((PropertyDescriptorWithObjectedID) id)
049: .getObject();
050: return ((PropertyDescriptorWithObjectedID) id)
051: .getItemPropertyDescriptor().isPropertySet(obj);//id - is dummy!
052:
053: }
054:
055: public Object getPropertyValue(Object id) {
056: Assert.isTrue(id instanceof PropertyDescriptorWithObjectedID);
057: Object obj = ((PropertyDescriptorWithObjectedID) id)
058: .getObject();
059: return ((PropertyDescriptorWithObjectedID) id)
060: .getItemPropertyDescriptor().getPropertyValue(obj);//id - is dummy!
061:
062: }
063:
064: public IPropertyDescriptor[] getPropertyDescriptors() {
065: List result = new ArrayList();
066: addPropertyDescriptorsFromPropertySource(result, object,
067: itemPropertySource);
068: return (IPropertyDescriptor[]) result
069: .toArray(new IPropertyDescriptor[result.size()]);
070: }
071:
072: public void resetPropertyValue(Object id) {
073: Assert.isTrue(id instanceof PropertyDescriptorWithObjectedID);
074: Object obj = ((PropertyDescriptorWithObjectedID) id)
075: .getObject();
076: ((PropertyDescriptorWithObjectedID) id)
077: .getItemPropertyDescriptor().resetPropertyValue(obj);//id - is dummy!
078: }
079:
080: public void setPropertyValue(Object id, Object value) {
081: Assert.isTrue(id instanceof PropertyDescriptorWithObjectedID);
082: Object obj = ((PropertyDescriptorWithObjectedID) id)
083: .getObject();
084: ((PropertyDescriptorWithObjectedID) id)
085: .getItemPropertyDescriptor().setPropertyValue(obj,
086: value);//id - is dummy!
087: }
088:
089: public Object getEditableValue() {
090: return this ;
091: }
092:
093: protected void addPropertyDescriptorsFromPropertySource(
094: List result, Object obj, IItemPropertySource propertySource) {
095: List itemPropertyDescriptors = propertySource
096: .getPropertyDescriptors(obj);
097: if (itemPropertyDescriptors != null) {
098: for (Iterator j = itemPropertyDescriptors.iterator(); j
099: .hasNext();) {
100: IItemPropertyDescriptor itemPropertyDescriptor = (IItemPropertyDescriptor) j
101: .next();
102: result.add(createPropertyDescriptor(obj,
103: itemPropertyDescriptor));
104: }
105: }
106: }
107:
108: protected IPropertyDescriptor createPropertyDescriptor(
109: Object object,
110: IItemPropertyDescriptor itemPropertyDescriptor) {
111: return new PropertyDescriptorWithObjectedID(object,
112: itemPropertyDescriptor);
113: }
114:
115: /**
116: * The value as displayed in the Property Sheet.
117: * @return java.lang.String
118: */
119: public String toString() {
120: return "";
121: }
122: }
|