01: package org.drools.brms.client.decisiontable;
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.decisiontable.EditableDTGrid.RowClickListener;
20:
21: import com.google.gwt.user.client.ui.ClickListener;
22: import com.google.gwt.user.client.ui.Composite;
23: import com.google.gwt.user.client.ui.HorizontalPanel;
24: import com.google.gwt.user.client.ui.Image;
25: import com.google.gwt.user.client.ui.Widget;
26:
27: /**
28: * This shows the widgets for editing a row.
29: * @author Michael Neale
30: */
31: public class EditActions extends Composite {
32:
33: private HorizontalPanel panel = new HorizontalPanel();
34: private Image edit;
35: private Image ok;
36: private int row;
37:
38: /**
39: * Pass in the click listener delegates for when the respective action is clicked
40: * @param editClickListener
41: * @param okClickListener
42: */
43: public EditActions(final int currentRow,
44: final RowClickListener editClickListener,
45: final RowClickListener okClickListener) {
46: row = currentRow;
47: edit = new Image("images/edit.gif");
48: edit.setTitle("Edit this row");
49: edit.addClickListener(new ClickListener() {
50:
51: public void onClick(Widget w) {
52: makeEditable();
53: editClickListener.onClick(w, row);
54: }
55:
56: });
57:
58: ok = new Image("images/tick.gif");
59: ok.setTitle("Apply the edit changes to this row.");
60: ok.addClickListener(new ClickListener() {
61:
62: public void onClick(Widget w) {
63: makeReadOnly();
64: okClickListener.onClick(w, row);
65: }
66:
67: });
68:
69: panel.add(edit);
70: panel.add(ok);
71: ok.setVisible(false);
72:
73: initWidget(panel);
74: }
75:
76: public void makeEditable() {
77: edit.setVisible(false);
78: ok.setVisible(true);
79:
80: }
81:
82: public void makeReadOnly() {
83: edit.setVisible(true);
84: ok.setVisible(false);
85: }
86:
87: public int getRow() {
88: return row;
89: }
90:
91: public void setRow(int row) {
92: this.row = row;
93: }
94:
95: }
|