root / src / gr / ebs / gss / client / FileTable.java @ a60ea262
History | View | Annotate | Download (2.5 kB)
1 | bc9942d1 | Giannis Koutsoubos | /*
|
---|---|---|---|
2 | bc9942d1 | Giannis Koutsoubos | * Copyright 2010 Electronic Business Systems Ltd.
|
3 | bc9942d1 | Giannis Koutsoubos | *
|
4 | bc9942d1 | Giannis Koutsoubos | * This file is part of GSS.
|
5 | bc9942d1 | Giannis Koutsoubos | *
|
6 | bc9942d1 | Giannis Koutsoubos | * GSS is free software: you can redistribute it and/or modify
|
7 | bc9942d1 | Giannis Koutsoubos | * it under the terms of the GNU General Public License as published by
|
8 | bc9942d1 | Giannis Koutsoubos | * the Free Software Foundation, either version 3 of the License, or
|
9 | bc9942d1 | Giannis Koutsoubos | * (at your option) any later version.
|
10 | bc9942d1 | Giannis Koutsoubos | *
|
11 | bc9942d1 | Giannis Koutsoubos | * GSS is distributed in the hope that it will be useful,
|
12 | bc9942d1 | Giannis Koutsoubos | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | bc9942d1 | Giannis Koutsoubos | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | bc9942d1 | Giannis Koutsoubos | * GNU General Public License for more details.
|
15 | bc9942d1 | Giannis Koutsoubos | *
|
16 | bc9942d1 | Giannis Koutsoubos | * You should have received a copy of the GNU General Public License
|
17 | bc9942d1 | Giannis Koutsoubos | * along with GSS. If not, see <http://www.gnu.org/licenses/>.
|
18 | bc9942d1 | Giannis Koutsoubos | */
|
19 | bc9942d1 | Giannis Koutsoubos | package gr.ebs.gss.client; |
20 | bc9942d1 | Giannis Koutsoubos | |
21 | bc9942d1 | Giannis Koutsoubos | import com.google.gwt.user.client.DOM; |
22 | bc9942d1 | Giannis Koutsoubos | import com.google.gwt.user.client.Element; |
23 | bc9942d1 | Giannis Koutsoubos | import com.google.gwt.user.client.Event; |
24 | bc9942d1 | Giannis Koutsoubos | import com.google.gwt.user.client.ui.Grid; |
25 | 4be3ad42 | koutsoub | import com.google.gwt.user.client.ui.HTML; |
26 | 4be3ad42 | koutsoub | import com.google.gwt.user.client.ui.Widget; |
27 | bc9942d1 | Giannis Koutsoubos | |
28 | bc9942d1 | Giannis Koutsoubos | |
29 | bc9942d1 | Giannis Koutsoubos | /**
|
30 | bc9942d1 | Giannis Koutsoubos | * @author kman
|
31 | bc9942d1 | Giannis Koutsoubos | *
|
32 | bc9942d1 | Giannis Koutsoubos | */
|
33 | bc9942d1 | Giannis Koutsoubos | public class FileTable extends Grid{ |
34 | bc9942d1 | Giannis Koutsoubos | |
35 | bc9942d1 | Giannis Koutsoubos | /**
|
36 | bc9942d1 | Giannis Koutsoubos | *
|
37 | bc9942d1 | Giannis Koutsoubos | */
|
38 | bc9942d1 | Giannis Koutsoubos | public FileTable() {
|
39 | bc9942d1 | Giannis Koutsoubos | super();
|
40 | bc9942d1 | Giannis Koutsoubos | // TODO Auto-generated constructor stub
|
41 | bc9942d1 | Giannis Koutsoubos | } |
42 | bc9942d1 | Giannis Koutsoubos | |
43 | bc9942d1 | Giannis Koutsoubos | /**
|
44 | bc9942d1 | Giannis Koutsoubos | * @param rows
|
45 | bc9942d1 | Giannis Koutsoubos | * @param columns
|
46 | bc9942d1 | Giannis Koutsoubos | */
|
47 | bc9942d1 | Giannis Koutsoubos | public FileTable(int rows, int columns) { |
48 | bc9942d1 | Giannis Koutsoubos | super(rows, columns);
|
49 | bc9942d1 | Giannis Koutsoubos | // TODO Auto-generated constructor stub
|
50 | bc9942d1 | Giannis Koutsoubos | } |
51 | bc9942d1 | Giannis Koutsoubos | |
52 | bc9942d1 | Giannis Koutsoubos | public int getRowForEvent2(Event event) { |
53 | bc9942d1 | Giannis Koutsoubos | Element td = getEventTargetCell(event);
|
54 | bc9942d1 | Giannis Koutsoubos | if (td == null) |
55 | bc9942d1 | Giannis Koutsoubos | return -1; |
56 | bc9942d1 | Giannis Koutsoubos | |
57 | bc9942d1 | Giannis Koutsoubos | Element tr = DOM.getParent(td);
|
58 | bc9942d1 | Giannis Koutsoubos | Element body = DOM.getParent(tr);
|
59 | bc9942d1 | Giannis Koutsoubos | int row = DOM.getChildIndex(body, tr);
|
60 | bc9942d1 | Giannis Koutsoubos | return row;
|
61 | bc9942d1 | Giannis Koutsoubos | } |
62 | 4be3ad42 | koutsoub | |
63 | 4be3ad42 | koutsoub | public static void copyRow(FileTable sourceTable, FileTable targetTable, int sourceRow, int targetRow) { |
64 | 4be3ad42 | koutsoub | targetTable.insertRow(targetRow); |
65 | 4be3ad42 | koutsoub | for (int col = 0; col < sourceTable.getCellCount(sourceRow); col++) { |
66 | 4be3ad42 | koutsoub | HTML html = new HTML(sourceTable.getHTML(sourceRow, col)); |
67 | 4be3ad42 | koutsoub | targetTable.setWidget(targetRow, col, html); |
68 | 4be3ad42 | koutsoub | } |
69 | 4be3ad42 | koutsoub | copyRowStyle(sourceTable, targetTable, sourceRow, targetRow); |
70 | 4be3ad42 | koutsoub | } |
71 | 4be3ad42 | koutsoub | |
72 | 4be3ad42 | koutsoub | private static void copyRowStyle(FileTable sourceTable, FileTable targetTable, int sourceRow, int targetRow) { |
73 | 4be3ad42 | koutsoub | String rowStyle = sourceTable.getRowFormatter().getStyleName(sourceRow);
|
74 | 4be3ad42 | koutsoub | targetTable.getRowFormatter().setStyleName(targetRow, rowStyle); |
75 | 4be3ad42 | koutsoub | } |
76 | 4be3ad42 | koutsoub | |
77 | 4be3ad42 | koutsoub | public static int getWidgetRow(Widget widget, FileTable table) { |
78 | 4be3ad42 | koutsoub | for (int row = 0; row < table.getRowCount(); row++) |
79 | 4be3ad42 | koutsoub | for (int col = 0; col < table.getCellCount(row); col++) { |
80 | 4be3ad42 | koutsoub | Widget w = table.getWidget(row, col); |
81 | 4be3ad42 | koutsoub | if (w == widget)
|
82 | 4be3ad42 | koutsoub | return row;
|
83 | 4be3ad42 | koutsoub | } |
84 | 4be3ad42 | koutsoub | throw new RuntimeException("Unable to determine widget row"); |
85 | 4be3ad42 | koutsoub | } |
86 | bc9942d1 | Giannis Koutsoubos | |
87 | bc9942d1 | Giannis Koutsoubos | } |