01: package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.rules;
02:
03: import org.eclipse.swt.widgets.MessageBox;
04:
05: import com.bostechcorp.cbesb.common.i18n.I18N;
06: import com.bostechcorp.cbesb.common.i18n.Messages;
07: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.BaseElement;
08: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.BindingComponent;
09: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.DecorativeModelElement;
10: import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.RoleType;
11:
12: public class BCSource extends Source {
13:
14: public BindingComponent bcom;
15:
16: // public BaseElement target;
17: public BCSource(BindingComponent bcom, BaseElement target) {
18: super (bcom, target);
19: this .bcom = bcom;
20: this .target = target;
21: }
22:
23: public boolean asSource() {
24:
25: // TODO Eric Lu : to reduce duplicate code for MessageBox
26:
27: if (target instanceof DecorativeModelElement) {
28: // if the target is an external system, we have to make sure that the mode of the file is write or both.
29: RoleType type = bcom.getRole();
30: if (type.equals(RoleType.get(RoleType.CONSUMER))) {
31: String text = I18N.getString(Messages.COMP_SUG);
32: String message = Messages.get(Messages.COMP_PRO_BOTH,
33: this .bcom.getName());
34: MessageBox messageBox = RuleFactory.getMessageBox(text,
35: message);
36: messageBox.open();
37: return false;
38: }
39: }
40:
41: else {
42: // if the target is an external system, we have to make sure that the mode of the file is write or both.
43: RoleType type = bcom.getRole();
44: if (type.equals(RoleType.get(RoleType.PROVIDER))) {
45: String text = I18N.getString(Messages.COMP_SUG);
46: String message = Messages.get(Messages.COMP_CON_BOTH,
47: this .bcom.getName());
48: MessageBox messageBox = RuleFactory.getMessageBox(text,
49: message);
50:
51: messageBox.open();
52:
53: return false;
54: }
55: }
56:
57: return true;
58: }
59:
60: }
|