01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10:
11: package de.uka.ilkd.key.casetool.patternimplementor;
12:
13: import java.util.Observable;
14: import java.util.Observer;
15:
16: /**
17: * This is a PIParameterGroup that is dependent of a PIParameterMultiString The
18: * number of elements in the Group are equal to the size of the MultiString
19: */
20: public class PIParameterDependent extends PIParameterGroup implements
21: Observer {
22:
23: // multistring to watch
24: PIParameterMultiString pipms;
25:
26: public PIParameterDependent(String internalName, String name,
27: PIParameterMultiString pipms) {
28: super (internalName, name); //, new PIParameters());
29:
30: pipms.addObserver(this );
31: this .pipms = pipms;
32: adjustGroup();
33: }
34:
35: public void update(Observable o, Object arg) {
36: //System.out.println("PIPDependent : update");
37: adjustGroup();
38:
39: // setChanged();
40: // notifyObservers(this);
41: }
42:
43: public void adjustGroup() {
44: //System.out.println("Dependent,adjustGroup");
45: PIParameters pips = new PIParameters();
46:
47: for (int i = 0; i < pipms.size(); i++) {
48: if (i < group.size()) {
49: group.get(i).setName(pipms.getMultiString().get(i));
50: pips.add(group.get(i));
51:
52: //System.out.println("old size: "+i);
53: } else {
54: pips.add(new PIParameterMultiString(getInternalName(),
55: pipms.getMultiString().get(i),
56: getInternalName() + (i + 1)));
57:
58: //System.out.println("new size: "+i);
59: }
60: }
61:
62: this .group = pips;
63: setChanged();
64: notifyObservers(pips);
65: }
66:
67: public PIParameter get(int i) {
68: return group.get(i);
69: }
70:
71: public PIParameterMultiString getSubject() {
72: return pipms;
73: }
74: }
|