00001
00058 package com.arcle.rmt.j2se.swing.vc.rqml;
00059
00060 import javax.swing.*;
00061 import java.awt.BorderLayout;
00062 import java.awt.GridBagLayout;
00063 import java.awt.GridBagConstraints;
00064 import java.awt.Insets;
00065 import java.awt.Container;
00066 import java.util.Observable;
00067
00068 import com.arcle.rmt.rqml.RQMLFirstClass;
00069 import com.arcle.rmt.rqml.Usecase;
00070 import com.arcle.rmt.rqml.Course;
00071
00081 public class UsecaseAttributes3 extends FirstClassPanel {
00082 public UsecaseAttributes3(RQMLFirstClass fc) {
00083 super(fc);
00084 setName("Courses");
00085 }
00086
00087
00088
00089
00090
00091 protected void initChildren() {
00092 ccNormalCourse = createCourseComponent("Normal Courses");
00093 ccAlternativeCourse = createCourseComponent("Alternative Courses");
00094 ccException = createCourseComponent("Exceptions");
00095 }
00096
00097 protected void layoutChildren() {
00098 Container p1, p2, p3;
00099 setLayout(new BorderLayout());
00100 p1 = createTabbedPane();
00101 p1.add(ccNormalCourse);
00102 p1.add(ccAlternativeCourse);
00103 p1.add(ccException);
00104 add(p1, BorderLayout.CENTER);
00105 }
00106
00107
00108
00109
00110 protected void loadData() {
00111 RQMLFirstClass elem = getElement();
00112 if (elem instanceof Usecase) {
00113 Usecase uc = (Usecase) elem;
00114 ccNormalCourse.loadData(uc.getNormalCourse());
00115 ccAlternativeCourse.loadData(uc.getAlternativeCourse());
00116 ccException.loadData(uc.getException());
00117 }
00118 }
00119
00120 protected void saveData() {
00121 RQMLFirstClass elem = getElement();
00122 if (elem instanceof Usecase) {
00123 Usecase uc = (Usecase) elem;
00124 ccNormalCourse.saveData(uc.getNormalCourse());
00125 ccAlternativeCourse.saveData(uc.getAlternativeCourse());
00126 ccException.saveData(uc.getException());
00127 }
00128 }
00129
00130
00131
00132
00133 protected CourseComponent createCourseComponent(String title) {
00134 return new CourseComponent(title);
00135 }
00136
00137 protected JTabbedPane createTabbedPane() {
00138 return new JTabbedPane();
00139 }
00140
00141
00142
00143
00144
00145 private CourseComponent ccNormalCourse;
00146 private CourseComponent ccAlternativeCourse;
00147 private CourseComponent ccException;
00148
00149
00150
00151
00177 protected class CourseComponent extends JComponent {
00178
00179 public CourseComponent(String title) {
00180 setName(title);
00181 }
00182
00183
00184 public void addNotify() {
00185 super.addNotify();
00186 if (!initialized) {
00187 initChildren();
00188 layoutChildren();
00189 initialized = true;
00190 }
00191 }
00192
00193
00194
00195 protected void initChildren() {
00196 lbDescription = createLabel("Description");
00197 lbActorAction = createLabel("Actor Actions");
00198 lbSystemResponse = createLabel("System Responses");
00199
00200 edDescription = createTextArea();
00201 edActorAction = createTextArea();
00202 edSystemResponse = createTextArea();
00203 }
00204
00205 protected void layoutChildren() {
00206 Container p1, p2, p3;
00207 JSplitPane sp1, sp2;
00208 setLayout(new BorderLayout());
00209
00210
00211 sp1 = createSplitPane();
00212 sp1.setOrientation(JSplitPane.VERTICAL_SPLIT);
00213
00214
00215 p1 = new JPanel();
00216 p1.setLayout(new BorderLayout());
00217 p1.add(lbDescription, BorderLayout.NORTH);
00218 p1.add(createScrollPane(edDescription), BorderLayout.CENTER);
00219 sp1.add(p1, JSplitPane.TOP);
00220
00221
00222 sp2 = createSplitPane();
00223 sp2.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
00224
00225 p1 = new JPanel();
00226 p1.setLayout(new BorderLayout());
00227 p1.add(lbActorAction, BorderLayout.NORTH);
00228 p1.add(createScrollPane(edActorAction), BorderLayout.CENTER);
00229 sp2.add(p1, JSplitPane.LEFT);
00230
00231 p1 = new JPanel();
00232 p1.setLayout(new BorderLayout());
00233 p1.add(lbSystemResponse, BorderLayout.NORTH);
00234 p1.add(createScrollPane(edSystemResponse), BorderLayout.CENTER);
00235 sp2.add(p1, JSplitPane.RIGHT);
00236 sp1.add(sp2, JSplitPane.BOTTOM);
00237 add(sp1, BorderLayout.CENTER);
00238 }
00239
00240
00241
00242
00243 public void loadData(Course elem) {
00244 edDescription.setText(elem.getDescription().getString());
00245 edActorAction.setText(elem.getActorAction().getString());
00246 edSystemResponse.setText(elem.getSystemResponse().getString());
00247 }
00248
00249 public void saveData(Course elem) {
00250 elem.getDescription().setString(edDescription.getText());
00251 elem.getActorAction().setString(edActorAction.getText());
00252 elem.getSystemResponse().setString(edSystemResponse.getText());
00253 }
00254
00255
00256
00257
00258 protected JSplitPane createSplitPane() {
00259 JSplitPane sp = new JSplitPane();
00260 sp.setContinuousLayout(false);
00261 sp.setOneTouchExpandable(false);
00262 sp.setDividerSize(SPLITPANE_DIVIDER_SIZE);
00263 sp.setResizeWeight(SPLITPANE_RESIZE_WEIGHT);
00264 return sp;
00265 }
00266
00267
00268
00269
00270
00271 private JLabel lbActorAction;
00272
00273 private JLabel lbSystemResponse;
00274
00275 private JLabel lbDescription;
00276
00277 private JTextArea edDescription;
00278
00279
00280
00281 private JTextArea edActorAction;
00282
00283 private JTextArea edSystemResponse;
00284
00285 private String _title;
00286
00287 private boolean initialized = false;
00288
00292 protected static final int SPLITPANE_DIVIDER_SIZE = 2;
00293
00297 protected static final float SPLITPANE_RESIZE_WEIGHT = 0.5f;
00298 }
00299
00300 }
00301