01: package org.drools.brms.client.common;
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 java.util.ArrayList;
20: import java.util.Iterator;
21:
22: import com.google.gwt.user.client.ui.Composite;
23: import com.google.gwt.user.client.ui.FlexTable;
24: import com.google.gwt.user.client.ui.Widget;
25:
26: public class DirtyableFlexTable extends FlexTable implements
27: DirtyableContainer {
28:
29: private int length;
30: private ArrayList list = new ArrayList();
31:
32: public boolean hasDirty() {
33:
34: Pair coordinates;
35: Widget element;
36:
37: for (Iterator iter = list.iterator(); iter.hasNext();) {
38: coordinates = (Pair) iter.next();
39: element = (Widget) getWidget(coordinates.getRow(),
40: coordinates.getColumn());
41: if (element instanceof DirtyableWidget)
42: if (((DirtyableWidget) element).isDirty())
43: return true;
44: if (element instanceof DirtyableContainer)
45: if (((DirtyableContainer) element).hasDirty())
46: return true;
47: }
48: return false;
49: }
50:
51: public void setWidget(int row, int column, Widget arg2) {
52: super .setWidget(row, column, arg2);
53:
54: if ((arg2 instanceof IDirtyable)) {
55: list.add(length++, new Pair(row, column));
56: }
57: }
58:
59: }
60:
61: class Pair {
62: private int row;
63: private int column;
64:
65: public Pair(int row, int column) {
66: this .row = row;
67: this .column = column;
68: }
69:
70: public int getColumn() {
71: return column;
72: }
73:
74: public int getRow() {
75: return row;
76: }
77:
78: }
|