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: FileCompoundPropertySource.java 6847 2007-04-17 07:16:57Z lzheng $
023: */
024: package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.file;
025:
026: import java.util.List;
027:
028: import org.eclipse.core.runtime.Assert;
029: import org.eclipse.emf.common.notify.AdapterFactory;
030: import org.eclipse.emf.edit.provider.IItemPropertySource;
031: import org.eclipse.ui.views.properties.PropertyDescriptor;
032:
033: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.File;
034: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.FileConsumer;
035: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.FileProvider;
036: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.BCCompoundPropertySource;
037: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.ComponentFlowEditorBasicPropertySource;
038:
039: public class FileCompoundPropertySource extends
040: BCCompoundPropertySource {
041:
042: //Category unique keys
043: public static final String C_CONSUMER = "c.read";
044: public static final String C_PROVIDER = "c.write";
045:
046: //Category display keys
047: public static final String C_DISPLAY_CONSUMER = "Read";
048: public static final String C_DISPLAY_PROVIDER = "Write";
049:
050: /**
051: * This is the object for which this class is a property source.
052: */
053: //private List services;
054: private FileConsumer fileRead;
055: private FileProvider fileWrite;
056: private IItemPropertySource readItemPropertySource;
057: private IItemPropertySource writeItemPropertySource;
058:
059: /**
060: * @param object
061: * @param itemPropertySource
062: */
063: public FileCompoundPropertySource(Object object,
064: AdapterFactory adapterFactory) {
065: super (object, adapterFactory);
066: Assert.isTrue(object instanceof File);
067: this .fileRead = ((File) object).getFileConsumer();
068: this .readItemPropertySource = getIItemPropertySourceAdapter(fileRead);
069:
070: this .fileWrite = ((File) object).getFileProvider();
071: this .writeItemPropertySource = getIItemPropertySourceAdapter(fileWrite);
072:
073: }
074:
075: protected List getSubLevelPropertyDescriptorList() {
076: List result = super .getSubLevelPropertyDescriptorList();
077: updateSubSourcesMap();
078: result.add(new PropertyDescriptor(C_CONSUMER,
079: C_DISPLAY_CONSUMER));
080: result.add(new PropertyDescriptor(C_PROVIDER,
081: C_DISPLAY_PROVIDER));
082:
083: return result;
084: }
085:
086: protected void updateSubSourcesMap() {
087: super .updateSubSourcesMap();
088: subSourcesMap.put(C_CONSUMER, new FileConsumerPropertySource(
089: fileRead, adapterFactory));
090: subSourcesMap.put(C_PROVIDER,
091: new ComponentFlowEditorBasicPropertySource(fileWrite,
092: writeItemPropertySource));
093:
094: }
095:
096: /* (non-Javadoc)
097: * @see com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.ComponentFlowEditorBasicCompoundPropertySource#getPropertyValue(java.lang.Object)
098: */
099: public Object getPropertyValue(Object id) {
100: if (id.equals(C_CONSUMER)) {
101: Object obj = subSourcesMap.get(C_CONSUMER);
102: Assert.isTrue(obj instanceof FileConsumerPropertySource);
103: return obj;
104: }
105: if (id.equals(C_PROVIDER)) {
106: Object obj = subSourcesMap.get(C_PROVIDER);
107: Assert
108: .isTrue(obj instanceof ComponentFlowEditorBasicPropertySource);
109: return obj;
110: }
111:
112: return super .getPropertyValue(id);
113: }
114:
115: /* (non-Javadoc)
116: * @see com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.ComponentFlowEditorBasicCompoundPropertySource#isPropertySet(java.lang.Object)
117: */
118: public boolean isPropertySet(Object id) {
119: if (id.equals(C_CONSUMER))
120: return true;
121: if (id.equals(C_PROVIDER))
122: return true;
123: return super .isPropertySet(id);
124: }
125:
126: public String toString() {
127: return "";
128: }
129:
130: }
|