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