001: package org.drools.brms.client.decisiontable;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import com.google.gwt.user.client.ui.ClickListener;
020: import com.google.gwt.user.client.ui.Composite;
021: import com.google.gwt.user.client.ui.HorizontalPanel;
022: import com.google.gwt.user.client.ui.Image;
023: import com.google.gwt.user.client.ui.Widget;
024:
025: /**
026: * This shows the widget for moving a row up or down.
027: * @author Steven Williams
028: */
029: public class Toolbar extends Composite {
030:
031: private HorizontalPanel toolbar = new HorizontalPanel();
032: private int row;
033:
034: public Toolbar() {
035: initWidget(toolbar);
036: }
037:
038: /**
039: * Pass in the click listener delegate for when the respective action is clicked and the
040: * direction to move the row
041: * @param currentRow
042: * @param clickListener
043: * @param direction
044: */
045: public Toolbar(final EditableDTGrid grid) {
046: toolbar.add(createInsertRow(grid));
047: toolbar.add(createDeleteRow(grid));
048: toolbar.add(createMoveUp(grid));
049: toolbar.add(createMoveDown(grid));
050: toolbar.add(createMergeCol(grid));
051: toolbar.add(createSplitCol(grid));
052: toolbar.add(createMergeRow(grid));
053: toolbar.add(createSplitRow(grid));
054: toolbar.setStyleName("dt-editor-Toolbar");
055:
056: initWidget(toolbar);
057: }
058:
059: private Image createSplitRow(final EditableDTGrid grid) {
060: Image split = new Image("images/split_row.gif");
061: split.addClickListener(new ClickListener() {
062:
063: public void onClick(Widget w) {
064: grid.splitRow();
065: }
066: });
067: return split;
068: }
069:
070: private Image createMergeRow(final EditableDTGrid grid) {
071: Image merge = new Image("images/merge_row.gif");
072: merge.addClickListener(new ClickListener() {
073:
074: public void onClick(Widget w) {
075: grid.mergeRow();
076: }
077: });
078: return merge;
079: }
080:
081: private Image createSplitCol(final EditableDTGrid grid) {
082: Image split = new Image("images/split_col.gif");
083: split.addClickListener(new ClickListener() {
084:
085: public void onClick(Widget w) {
086: grid.splitCol();
087: }
088: });
089: return split;
090: }
091:
092: private Image createMergeCol(final EditableDTGrid grid) {
093: Image merge = new Image("images/merge_col.gif");
094: merge.addClickListener(new ClickListener() {
095:
096: public void onClick(Widget w) {
097: grid.mergeCol();
098: }
099: });
100: return merge;
101: }
102:
103: private Image createMoveDown(final EditableDTGrid grid) {
104: Image moveDown = new Image("images/shuffle_down.gif");
105: moveDown.addClickListener(new ClickListener() {
106:
107: public void onClick(Widget w) {
108: grid.moveDown();
109: }
110: });
111: return moveDown;
112: }
113:
114: private Image createMoveUp(final EditableDTGrid grid) {
115: Image moveUp = new Image("images/shuffle_up.gif");
116: moveUp.addClickListener(new ClickListener() {
117:
118: public void onClick(Widget w) {
119: grid.moveUp();
120: }
121: });
122: return moveUp;
123: }
124:
125: private Image createDeleteRow(final EditableDTGrid grid) {
126: Image delete = new Image("images/clear_item.gif");
127: delete.setTitle("Delete row");
128: delete.addClickListener(new ClickListener() {
129:
130: public void onClick(Widget w) {
131: grid.deleteRow();
132: }
133: });
134: return delete;
135: }
136:
137: private Image createInsertRow(final EditableDTGrid grid) {
138: Image insert = new Image("images/new_item.gif");
139: insert.addClickListener(new ClickListener() {
140:
141: public void onClick(Widget w) {
142: grid.insertRow();
143: }
144: });
145: return insert;
146: }
147:
148: public void setRow(final int row) {
149: this .row = row;
150: }
151:
152: public int getRow() {
153: return row;
154: }
155:
156: }
|