001: package org.osbl.riskmanagement.gui;
002:
003: import org.conform.*;
004: import org.conform.modifier.InlineModifier;
005: import org.conform.wings.editor.*;
006: import org.osbl.client.wings.form.ComponentProvider;
007: import org.osbl.client.wings.form.GenericObjectForm;
008: import org.osbl.client.wings.form.editor.ManyToOneAssociationEditor;
009: import org.osbl.client.wings.form.format.BusinessObjectFormat;
010: import org.osbl.client.wings.form.layouter.*;
011: import org.osbl.client.wings.shell.Client;
012: import org.osbl.riskmanagement.model.*;
013: import org.osbl.persistence.*;
014: import org.osbl.persistence.model.TreeNodeEntityFormat;
015: import org.osbl.ServiceProvider;
016: import org.osbl.identity.model.Identity;
017: import org.osbl.identity.model.User;
018: import org.wings.*;
019: import org.wings.session.SessionManager;
020:
021: import java.awt.event.ActionEvent;
022: import java.awt.event.ActionListener;
023: import java.beans.PropertyChangeEvent;
024: import java.beans.PropertyChangeListener;
025: import java.util.*;
026:
027: public class RiskForm extends GenericObjectForm {
028: private AbstractDomainProvider riskTypeDomain = new AbstractDynamicDomainProvider(
029: "type") {
030: protected List createValues() {
031: Persistence persistence = (Persistence) ServiceProvider
032: .getInstance().getService(
033: "RiskManagementPersistence");
034: SimpleQueryCommand queryCommand = (SimpleQueryCommand) persistence
035: .createCommand("list");
036: queryCommand.setType(RiskType.class);
037: queryCommand.addSort("path", Sort.ASCENDING);
038: queryCommand.addSort("name", Sort.ASCENDING);
039: List<RiskType> riskTypes = queryCommand.execute();
040: riskTypes.add(0, null);
041: return riskTypes;
042: }
043:
044: protected boolean isSorted() {
045: return false;
046: }
047: };
048:
049: public RiskForm() {
050: setDocumentLook(true);
051: }
052:
053: @Override
054: protected Object getObject(String path) {
055: if (ComponentProvider.ROOT.equals(path))
056: return object;
057:
058: return null;
059: }
060:
061: @Override
062: protected void setObject(String path, Object object) {
063: if (ComponentProvider.ROOT.equals(path))
064: this .object = object;
065: }
066:
067: protected Instruction createLayoutInstruction() {
068: return new Page(new Division(Risk.class.getName(),
069: new Column(new LabelAndEditor(ComponentProvider.ROOT,
070: "key"), new LabelAndEditor(
071: ComponentProvider.ROOT, "type"),
072: new LabelAndEditor(ComponentProvider.ROOT,
073: "assignee")), new Column(
074: new LabelAndEditors("businessobject.created",
075: new Editor(ComponentProvider.ROOT,
076: "created"), new Editor(
077: ComponentProvider.ROOT,
078: "createdBy")))), new Division(
079: Risk.class.getName() + ".state", new Column(
080: new LabelAndEditor(ComponentProvider.ROOT,
081: "coverage"), new LabelAndEditor(
082: ComponentProvider.ROOT, "amount"),
083: new LabelAndEditor(ComponentProvider.ROOT,
084: "probability")), new Column(
085: new LabelAndEditor(ComponentProvider.ROOT,
086: "criticality"), new LabelAndEditor(
087: ComponentProvider.ROOT, "progression"),
088: new LabelAndEditor(ComponentProvider.ROOT,
089: "obsolete"))), new Division(Risk.class
090: .getName()
091: + ".comment", new Column(new LabelAndEditor(
092: ComponentProvider.ROOT, "comment"))));
093: }
094:
095: protected BeanMeta createBeanMeta(String path) {
096: return new VariationBeanMetaProvider(Client.getInstance()
097: .getBeanMetaProvider()).addModifier(
098: new InlineModifier() {
099: protected void configure() {
100: property("comment").setAttribute(
101: StringEditor.ROWS, 8);
102: property("obsolete").setWritable(false);
103:
104: property("type").setDomainProvider(
105: riskTypeDomain);
106: property("type").setFormat(
107: new TreeNodeEntityFormat(Client
108: .getInstance()
109: .getBeanMetaProvider()
110: .getBeanMeta(RiskType.class)
111: .getFormat()));
112: property("type").setAttribute(
113: org.conform.wings.Editor.CUSTOM_EDITOR,
114: new ManyToOneAssociationEditor());
115: property("type").setAttribute("objectEditor",
116: new RiskTypeEditor());
117: property("assignee").setAttribute(
118: org.conform.wings.Editor.CUSTOM_EDITOR,
119: new DefaultEditor());
120: property("assignee").setFormat(
121: new BusinessObjectFormat());
122:
123: property("criticality").setInitializer(
124: new Initializer() {
125: public Object getValue() {
126: return Criticality.UNKNOWN;
127: }
128: });
129: property("criticality").setAttribute(
130: org.conform.wings.Editor.CUSTOM_EDITOR,
131: new EnumerationAsIconsEditor());
132: property("criticality").setAttribute(
133: EnumerationAsIconsEditor.ICONS,
134: RiskManagementIcons.ICONS);
135:
136: property("progression").setAttribute(
137: org.conform.wings.Editor.CUSTOM_EDITOR,
138: new ProgressionEditor());
139: }
140: }).getBeanMeta(Risk.class);
141: }
142: }
|