Statistics
| Branch: | Tag: | Revision:

root / src / gr / ebs / gss / client / dnd / DnDFocusPanel.java @ a60ea262

History | View | Annotate | Download (2.3 kB)

1 14ad7326 pastith
/*
2 14ad7326 pastith
 * Copyright 2008, 2009 Electronic Business Systems Ltd.
3 14ad7326 pastith
 *
4 14ad7326 pastith
 * This file is part of GSS.
5 14ad7326 pastith
 *
6 14ad7326 pastith
 * GSS is free software: you can redistribute it and/or modify
7 14ad7326 pastith
 * it under the terms of the GNU General Public License as published by
8 14ad7326 pastith
 * the Free Software Foundation, either version 3 of the License, or
9 14ad7326 pastith
 * (at your option) any later version.
10 14ad7326 pastith
 *
11 14ad7326 pastith
 * GSS is distributed in the hope that it will be useful,
12 14ad7326 pastith
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 14ad7326 pastith
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14ad7326 pastith
 * GNU General Public License for more details.
15 14ad7326 pastith
 *
16 14ad7326 pastith
 * You should have received a copy of the GNU General Public License
17 14ad7326 pastith
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18 14ad7326 pastith
 */
19 14ad7326 pastith
package gr.ebs.gss.client.dnd;
20 14ad7326 pastith
21 a52ea5e4 pastith
import gr.ebs.gss.client.rest.resource.FileResource;
22 14ad7326 pastith
23 14ad7326 pastith
import java.util.List;
24 14ad7326 pastith
25 ff8eb545 Giannis Koutsoubos
import com.google.gwt.dom.client.NativeEvent;
26 ff8eb545 Giannis Koutsoubos
import com.google.gwt.user.client.DOM;
27 ff8eb545 Giannis Koutsoubos
import com.google.gwt.user.client.Event;
28 14ad7326 pastith
import com.google.gwt.user.client.ui.FocusPanel;
29 14ad7326 pastith
import com.google.gwt.user.client.ui.HTML;
30 14ad7326 pastith
import com.google.gwt.user.client.ui.Widget;
31 14ad7326 pastith
32 14ad7326 pastith
33 14ad7326 pastith
/**
34 14ad7326 pastith
 * @author kman
35 14ad7326 pastith
 *
36 14ad7326 pastith
 */
37 0e4865ee pastith
public class DnDFocusPanel extends FocusPanel {
38 14ad7326 pastith
        private DnDTreeItem item;
39 a52ea5e4 pastith
        private List<FileResource> files;
40 14ad7326 pastith
41 0e4865ee pastith
        public DnDFocusPanel(Widget widget, DnDTreeItem anItem) {
42 14ad7326 pastith
                super(widget);
43 ff8eb545 Giannis Koutsoubos
                sinkEvents(Event.ONMOUSEDOWN);
44 0e4865ee pastith
                item = anItem;
45 14ad7326 pastith
        }
46 14ad7326 pastith
47 14ad7326 pastith
        public DnDFocusPanel(Widget widget){
48 14ad7326 pastith
                super(widget);
49 14ad7326 pastith
        }
50 14ad7326 pastith
51 14ad7326 pastith
        /**
52 14ad7326 pastith
         * Retrieve the item.
53 14ad7326 pastith
         *
54 14ad7326 pastith
         * @return the item
55 14ad7326 pastith
         */
56 14ad7326 pastith
        public DnDTreeItem getItem() {
57 14ad7326 pastith
                return item;
58 14ad7326 pastith
        }
59 14ad7326 pastith
60 14ad7326 pastith
        /**
61 14ad7326 pastith
         * Retrieve the files.
62 14ad7326 pastith
         *
63 14ad7326 pastith
         * @return the files
64 14ad7326 pastith
         */
65 a52ea5e4 pastith
        public List<FileResource> getFiles() {
66 14ad7326 pastith
                return files;
67 14ad7326 pastith
        }
68 14ad7326 pastith
69 14ad7326 pastith
        /**
70 14ad7326 pastith
         * Modify the files.
71 14ad7326 pastith
         *
72 0e4865ee pastith
         * @param newFiles the files to set
73 14ad7326 pastith
         */
74 0e4865ee pastith
        public void setFiles(List<FileResource> newFiles) {
75 0e4865ee pastith
                files = newFiles;
76 14ad7326 pastith
        }
77 14ad7326 pastith
78 14ad7326 pastith
        public HTML cloneHTML(){
79 14ad7326 pastith
                if(getWidget() instanceof HTML){
80 14ad7326 pastith
                        HTML ht = (HTML)getWidget();
81 14ad7326 pastith
                        HTML res = new HTML(ht.getHTML());
82 14ad7326 pastith
                        return res;
83 14ad7326 pastith
                }
84 14ad7326 pastith
                return null;
85 14ad7326 pastith
        }
86 ff8eb545 Giannis Koutsoubos
87 ff8eb545 Giannis Koutsoubos
        @Override
88 ff8eb545 Giannis Koutsoubos
        public void onBrowserEvent(Event event) {
89 ff8eb545 Giannis Koutsoubos
                switch (DOM.eventGetType(event)) {
90 ff8eb545 Giannis Koutsoubos
                        case Event.ONMOUSEDOWN:
91 ff8eb545 Giannis Koutsoubos
                                if (DOM.eventGetButton(event) == NativeEvent.BUTTON_RIGHT || DOM.eventGetButton(event) == NativeEvent.BUTTON_LEFT)
92 ff8eb545 Giannis Koutsoubos
                                        getItem().tree.setSelectedItem(getItem());
93 ff8eb545 Giannis Koutsoubos
                                break;
94 ff8eb545 Giannis Koutsoubos
                }
95 ff8eb545 Giannis Koutsoubos
                super.onBrowserEvent(event);
96 ff8eb545 Giannis Koutsoubos
97 ff8eb545 Giannis Koutsoubos
        }
98 14ad7326 pastith
}