root / src / gr / grnet / pithos / web / client / FilesPropertiesDialog.java @ 61e48609
History | View | Annotate | Download (5.2 kB)
1 | a57faaf0 | Christos Stathis | /*
|
---|---|---|---|
2 | cae2a8db | Christos Stathis | * Copyright 2011-2012 GRNET S.A. All rights reserved.
|
3 | 63366925 | Christos Stathis | *
|
4 | 63366925 | Christos Stathis | * Redistribution and use in source and binary forms, with or
|
5 | 63366925 | Christos Stathis | * without modification, are permitted provided that the following
|
6 | 63366925 | Christos Stathis | * conditions are met:
|
7 | 63366925 | Christos Stathis | *
|
8 | 63366925 | Christos Stathis | * 1. Redistributions of source code must retain the above
|
9 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
10 | 63366925 | Christos Stathis | * disclaimer.
|
11 | 63366925 | Christos Stathis | *
|
12 | 63366925 | Christos Stathis | * 2. Redistributions in binary form must reproduce the above
|
13 | 63366925 | Christos Stathis | * copyright notice, this list of conditions and the following
|
14 | 63366925 | Christos Stathis | * disclaimer in the documentation and/or other materials
|
15 | 63366925 | Christos Stathis | * provided with the distribution.
|
16 | 63366925 | Christos Stathis | *
|
17 | 63366925 | Christos Stathis | * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
18 | 63366925 | Christos Stathis | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19 | 63366925 | Christos Stathis | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
20 | 63366925 | Christos Stathis | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
21 | 63366925 | Christos Stathis | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
22 | 63366925 | Christos Stathis | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
23 | 63366925 | Christos Stathis | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
24 | 63366925 | Christos Stathis | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
25 | 63366925 | Christos Stathis | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
26 | 63366925 | Christos Stathis | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
27 | 63366925 | Christos Stathis | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 | 63366925 | Christos Stathis | * POSSIBILITY OF SUCH DAMAGE.
|
29 | 63366925 | Christos Stathis | *
|
30 | 63366925 | Christos Stathis | * The views and conclusions contained in the software and
|
31 | 63366925 | Christos Stathis | * documentation are those of the authors and should not be
|
32 | 63366925 | Christos Stathis | * interpreted as representing official policies, either expressed
|
33 | 63366925 | Christos Stathis | * or implied, of GRNET S.A.
|
34 | a57faaf0 | Christos Stathis | */
|
35 | a57faaf0 | Christos Stathis | package gr.grnet.pithos.web.client; |
36 | a57faaf0 | Christos Stathis | |
37 | f6cd2099 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.File; |
38 | f6cd2099 | Christos Stathis | import gr.grnet.pithos.web.client.foldertree.Folder; |
39 | a57faaf0 | Christos Stathis | |
40 | a57faaf0 | Christos Stathis | import java.util.List; |
41 | a57faaf0 | Christos Stathis | |
42 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ClickEvent; |
43 | a57faaf0 | Christos Stathis | import com.google.gwt.event.dom.client.ClickHandler; |
44 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.Button; |
45 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.FlexTable; |
46 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.FocusPanel; |
47 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.HasHorizontalAlignment; |
48 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.HorizontalPanel; |
49 | a57faaf0 | Christos Stathis | import com.google.gwt.user.client.ui.VerticalPanel; |
50 | a57faaf0 | Christos Stathis | |
51 | a57faaf0 | Christos Stathis | /**
|
52 | a57faaf0 | Christos Stathis | * The 'Multiple file properties' dialog box implementation.
|
53 | a57faaf0 | Christos Stathis | *
|
54 | a57faaf0 | Christos Stathis | */
|
55 | a57faaf0 | Christos Stathis | public class FilesPropertiesDialog extends AbstractPropertiesDialog { |
56 | a57faaf0 | Christos Stathis | |
57 | f6cd2099 | Christos Stathis | private final List<File> files; |
58 | a57faaf0 | Christos Stathis | |
59 | a57faaf0 | Christos Stathis | /**
|
60 | a57faaf0 | Christos Stathis | * The widget's constructor.
|
61 | a57faaf0 | Christos Stathis | *
|
62 | a57faaf0 | Christos Stathis | * @param _files
|
63 | a57faaf0 | Christos Stathis | */
|
64 | 749068ba | Christos Stathis | public FilesPropertiesDialog(Pithos _app, final List<File> _files) { |
65 | a7c43f26 | Christos Stathis | super(_app);
|
66 | a57faaf0 | Christos Stathis | |
67 | a57faaf0 | Christos Stathis | files = _files; |
68 | a57faaf0 | Christos Stathis | |
69 | a57faaf0 | Christos Stathis | // Set the dialog's caption.
|
70 | a57faaf0 | Christos Stathis | setText("Files properties");
|
71 | a57faaf0 | Christos Stathis | |
72 | a57faaf0 | Christos Stathis | // Outer contains inner and buttons.
|
73 | a57faaf0 | Christos Stathis | final VerticalPanel outer = new VerticalPanel(); |
74 | a57faaf0 | Christos Stathis | final FocusPanel focusPanel = new FocusPanel(outer); |
75 | a57faaf0 | Christos Stathis | // Inner contains generalPanel and permPanel.
|
76 | 9326b841 | Christos Stathis | inner = new VerticalPanel();
|
77 | a57faaf0 | Christos Stathis | |
78 | 9326b841 | Christos Stathis | inner.add(createGeneralPanel()); |
79 | a57faaf0 | Christos Stathis | |
80 | f6cd2099 | Christos Stathis | outer.add(inner); |
81 | a57faaf0 | Christos Stathis | |
82 | f6cd2099 | Christos Stathis | final HorizontalPanel buttons = new HorizontalPanel(); |
83 | a57faaf0 | Christos Stathis | // Create the 'OK' button, along with a listener that hides the dialog
|
84 | a57faaf0 | Christos Stathis | // when the button is clicked.
|
85 | a57faaf0 | Christos Stathis | final Button ok = new Button("OK", new ClickHandler() { |
86 | a57faaf0 | Christos Stathis | @Override
|
87 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
88 | a57faaf0 | Christos Stathis | accept(); |
89 | a57faaf0 | Christos Stathis | closeDialog(); |
90 | a57faaf0 | Christos Stathis | } |
91 | a57faaf0 | Christos Stathis | }); |
92 | a57faaf0 | Christos Stathis | buttons.add(ok); |
93 | a57faaf0 | Christos Stathis | buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); |
94 | a57faaf0 | Christos Stathis | // Create the 'Cancel' button, along with a listener that hides the
|
95 | a57faaf0 | Christos Stathis | // dialog when the button is clicked.
|
96 | a57faaf0 | Christos Stathis | final Button cancel = new Button("Cancel", new ClickHandler() { |
97 | a57faaf0 | Christos Stathis | @Override
|
98 | ebead1b5 | Christos Stathis | public void onClick(ClickEvent event) { |
99 | a57faaf0 | Christos Stathis | closeDialog(); |
100 | a57faaf0 | Christos Stathis | } |
101 | a57faaf0 | Christos Stathis | }); |
102 | a57faaf0 | Christos Stathis | buttons.add(cancel); |
103 | a57faaf0 | Christos Stathis | buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); |
104 | a57faaf0 | Christos Stathis | buttons.setSpacing(8);
|
105 | a57faaf0 | Christos Stathis | buttons.addStyleName("pithos-TabPanelBottom");
|
106 | f6cd2099 | Christos Stathis | outer.add(buttons); |
107 | f6cd2099 | Christos Stathis | outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); |
108 | f6cd2099 | Christos Stathis | outer.addStyleName("pithos-TabPanelBottom");
|
109 | a57faaf0 | Christos Stathis | |
110 | f6cd2099 | Christos Stathis | focusPanel.setFocus(true);
|
111 | f6cd2099 | Christos Stathis | setWidget(outer); |
112 | f6cd2099 | Christos Stathis | } |
113 | a57faaf0 | Christos Stathis | |
114 | f6cd2099 | Christos Stathis | private VerticalPanel createGeneralPanel() {
|
115 | f6cd2099 | Christos Stathis | VerticalPanel generalPanel = new VerticalPanel();
|
116 | a57faaf0 | Christos Stathis | |
117 | f6cd2099 | Christos Stathis | final FlexTable generalTable = new FlexTable(); |
118 | f6cd2099 | Christos Stathis | generalTable.setText(0, 0, String.valueOf(files.size())+" files selected"); |
119 | f6cd2099 | Christos Stathis | generalTable.setText(1, 0, "Folder"); |
120 | f6cd2099 | Christos Stathis | generalTable.setText(2, 0, "Tags"); |
121 | f6cd2099 | Christos Stathis | Folder parent = files.get(0).getParent();
|
122 | f6cd2099 | Christos Stathis | if(parent != null) |
123 | f6cd2099 | Christos Stathis | generalTable.setText(1, 1, parent.getName()); |
124 | f6cd2099 | Christos Stathis | else
|
125 | f6cd2099 | Christos Stathis | generalTable.setText(1, 1, "-"); |
126 | f6cd2099 | Christos Stathis | |
127 | f6cd2099 | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
128 | f6cd2099 | Christos Stathis | generalTable.getFlexCellFormatter().setColSpan(0, 0, 2); |
129 | f6cd2099 | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); |
130 | f6cd2099 | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); |
131 | f6cd2099 | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); |
132 | f6cd2099 | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values"); |
133 | f6cd2099 | Christos Stathis | generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values"); |
134 | f6cd2099 | Christos Stathis | generalTable.setCellSpacing(4);
|
135 | f6cd2099 | Christos Stathis | |
136 | f6cd2099 | Christos Stathis | generalPanel.add(generalTable); |
137 | f6cd2099 | Christos Stathis | |
138 | f6cd2099 | Christos Stathis | return generalPanel;
|
139 | f6cd2099 | Christos Stathis | } |
140 | a57faaf0 | Christos Stathis | |
141 | a57faaf0 | Christos Stathis | /**
|
142 | a57faaf0 | Christos Stathis | * Accepts any change and updates the file
|
143 | 0099339a | Christos Stathis | * @return
|
144 | a57faaf0 | Christos Stathis | *
|
145 | a57faaf0 | Christos Stathis | */
|
146 | a57faaf0 | Christos Stathis | @Override
|
147 | 0099339a | Christos Stathis | protected boolean accept() { |
148 | 0099339a | Christos Stathis | return true; |
149 | a57faaf0 | Christos Stathis | } |
150 | a57faaf0 | Christos Stathis | } |