01: package org.drools.brms.client.ruleeditor;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.drools.brms.client.common.DirtyableComposite;
20: import org.drools.brms.client.rpc.MetaData;
21:
22: import com.google.gwt.user.client.ui.ChangeListener;
23: import com.google.gwt.user.client.ui.TextArea;
24: import com.google.gwt.user.client.ui.Widget;
25:
26: /**
27: * This holds the editor and viewer for rule documentation.
28: * It will update the model when the text is changed.
29: * @author Michael Neale
30: *
31: */
32: public class RuleDocumentWidget extends DirtyableComposite {
33:
34: private TextArea text;
35:
36: public RuleDocumentWidget(MetaData data) {
37: //
38: // HorizontalPanel horiz = new HorizontalPanel();
39: //
40:
41: text = new TextArea();
42:
43: // horiz.add( text );
44: // Image max = new Image("images/max_min.gif");
45: // max.setTitle( "Show/hide the documentation panel." );
46: // max.addClickListener( new ClickListener() {
47: // public void onClick(Widget w) {
48: // text.setVisible( !text.isVisible() );
49: // }
50: // });
51: // horiz.add( max );
52: // horiz.setWidth( "100%" );
53: text.setWidth("100%");
54: text.setVisibleLines(10);
55: text.setStyleName("rule-viewer-Documentation");
56: text
57: .setTitle("This is rule documentation. Human friendly descriptions of the business logic.");
58: initWidget(text);
59: loadData(data);
60: }
61:
62: private void loadData(final MetaData data) {
63: text.setText(data.description);
64: text.addChangeListener(new ChangeListener() {
65: public void onChange(Widget w) {
66: data.description = text.getText();
67: makeDirty();
68: }
69: });
70: if (data.description == null || "".equals(data.description)) {
71: text.setText("<documentation>");
72: }
73: }
74:
75: }
|