01: /*
02: * Created on 26 avr. 2005
03: *
04: */
05: package org.openwfe.gpe.model;
06:
07: import org.eclipse.jface.dialogs.MessageDialog;
08: import org.eclipse.ui.IWorkbenchWindow;
09:
10: /**
11: * @author Christelle
12: *
13: */
14: public class OneChild extends CompositeOrOneChild {
15:
16: protected int maximum = 0;
17: private IWorkbenchWindow window;
18:
19: public OneChild() {
20: }
21:
22: public void addChild(FlowElement child) {
23: addChild(child, -1);
24: }
25:
26: public void addChild(FlowElement child, int index) {
27: if (index >= 0 && maximum < 1) {
28: children.add(index, child);
29: maximum++;
30: fireStructureChange(CHILDREN, child);
31: } else if (maximum < 1) {
32: children.add(child);
33: maximum++;
34: fireStructureChange(CHILDREN, child);
35: } else {
36: MessageDialog.openInformation(null, "Alert",
37: "No more elements can be added");
38: }
39:
40: }
41:
42: public void removeChild(FlowElement child) {
43: children.remove(child);
44: maximum--;
45: fireStructureChange(CHILDREN, child);
46: }
47:
48: }
|