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.email;
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.Email;
034: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.EmailConsumer;
035: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.EmailProvider;
036: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.HTTP;
037: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.BCCompoundPropertySource;
038:
039: public class EmailPropertySource extends BCCompoundPropertySource {
040:
041: public static final String C_PROVIDER = "c.provider";
042: public static final String C_CONSUMER = "c.consumer";
043:
044: public static final String C_DISPLAY_PROVIDER = "Provider";
045: public static final String C_DISPLAY_CONSUMER = "Consumer";
046:
047: private EmailProvider emailProvider;
048: private EmailConsumer emailConsumer;
049:
050: private IItemPropertySource emailProviderItemPropertySource;
051: private IItemPropertySource emailConsumerItemPropertySource;
052:
053: /**
054: * @param object
055: * @param itemPropertySource
056: */
057: public EmailPropertySource(Object object,
058: AdapterFactory adapterFactory) {
059: super (object, adapterFactory);
060: Assert.isTrue(object instanceof Email);
061: Assert.isNotNull(object);
062: //
063: this .emailProvider = ((Email) object).getEmailProvider();
064: this .emailProviderItemPropertySource = getIItemPropertySourceAdapter(this .emailProvider);
065:
066: this .emailConsumer = ((Email) object).getEmailConsumer();
067: this .emailConsumerItemPropertySource = getIItemPropertySourceAdapter(this .emailConsumer);
068:
069: // This code should be comment out, because the base class already invoke it.
070:
071: // add(getIItemPropertySourceAdapter(object),object);
072: }
073:
074: protected List getSubLevelPropertyDescriptorList() {
075: List result = super .getSubLevelPropertyDescriptorList();
076:
077: updateSubSourcesMap();
078: result.add(new PropertyDescriptor(C_PROVIDER,
079: C_DISPLAY_PROVIDER));
080: result.add(new PropertyDescriptor(C_CONSUMER,
081: C_DISPLAY_CONSUMER));
082: return result;
083: }
084:
085: protected void updateSubSourcesMap() {
086: Assert.isNotNull(emailProvider);
087: Assert.isNotNull(emailProviderItemPropertySource);
088: super .updateSubSourcesMap();
089:
090: subSourcesMap.put(C_PROVIDER, new EmailProviderPropertySource(
091: emailProvider, adapterFactory));
092: subSourcesMap.put(C_CONSUMER, new EmailConsumerPropertySource(
093: emailConsumer, adapterFactory));
094:
095: }
096:
097: /* (non-Javadoc)
098: * @see com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.ComponentFlowEditorBasicCompoundPropertySource#getPropertyValue(java.lang.Object)
099: */
100: public Object getPropertyValue(Object id) {
101: if (id.equals(C_PROVIDER)) {
102: Object obj = subSourcesMap.get(C_PROVIDER);
103: Assert.isTrue(obj instanceof EmailProviderPropertySource);
104: return obj;
105: }
106: if (id.equals(C_CONSUMER)) {
107: Object obj = subSourcesMap.get(C_CONSUMER);
108: Assert.isTrue(obj instanceof EmailConsumerPropertySource);
109: return obj;
110: }
111: return super .getPropertyValue(id);
112: }
113:
114: /* (non-Javadoc)
115: * @see com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.ComponentFlowEditorBasicCompoundPropertySource#isPropertySet(java.lang.Object)
116: */
117: public boolean isPropertySet(Object id) {
118: if (id.equals(C_PROVIDER))
119: return true;
120: if (id.equals(C_CONSUMER))
121: return true;
122: return super.isPropertySet(id);
123: }
124:
125: }
|