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 widget for moving a row up or down.
29: * @author Steven Williams
30: */
31: public class ShuffleAction extends Composite {
32:
33: private HorizontalPanel panel = new HorizontalPanel();
34: private Image shuffle;
35: private int row;
36:
37: public final static ShuffleAction EMPTY1 = new ShuffleAction() {
38:
39: };
40:
41: public ShuffleAction() {
42: initWidget(panel);
43: }
44:
45: /**
46: * Pass in the click listener delegate for when the respective action is clicked and the
47: * direction to move the row
48: * @param currentRow
49: * @param clickListener
50: * @param direction
51: */
52: public ShuffleAction(final int currentRow,
53: final RowClickListener clickListener, final String direction) {
54: row = currentRow;
55: shuffle = new Image("images/shuffle_" + direction + ".gif");
56: shuffle.setTitle("Move this row " + direction);
57: shuffle.addClickListener(new ClickListener() {
58: public void onClick(final Widget w) {
59: clickListener.onClick(w, row);
60: }
61: });
62:
63: panel.add(shuffle);
64:
65: initWidget(panel);
66: }
67:
68: public void setRow(final int row) {
69: this .row = row;
70: }
71:
72: public int getRow() {
73: return row;
74: }
75:
76: }
|