Revision b31e9028
b/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java | ||
---|---|---|
71 | 71 |
|
72 | 72 |
final VerticalPanel inner; |
73 | 73 |
|
74 |
final Button updateButton; |
|
75 |
|
|
76 |
private boolean _initialPermissionCheck = true; |
|
77 |
|
|
78 | 74 |
/** |
79 | 75 |
* The widget's constructor. |
80 | 76 |
*/ |
... | ... | |
98 | 94 |
|
99 | 95 |
folder = selected; |
100 | 96 |
|
101 |
setText("Folder permissions");
|
|
97 |
setText(Const.TXT_SHARE_FOLDER);
|
|
102 | 98 |
|
103 | 99 |
// Outer contains inner and buttons |
104 | 100 |
VerticalPanel outer = new VerticalPanel(); |
... | ... | |
107 | 103 |
inner = new VerticalPanel(); |
108 | 104 |
inner.addStyleName("inner"); |
109 | 105 |
|
110 |
|
|
111 | 106 |
folderName.setText(folder.getName()); |
112 | 107 |
|
108 |
final HorizontalPanel privateInfoPanel = new HorizontalPanel(); |
|
109 |
privateInfoPanel.setSpacing(8); |
|
110 |
final Label privateInfoTitle = new InlineHTML("<b>Private sharing</b>"); |
|
111 |
final Label privateInfoText = new Label("Only people explicitly granted permission can access. Sign-in required.", true); |
|
112 |
privateInfoPanel.add(privateInfoTitle); |
|
113 |
privateInfoPanel.add(privateInfoText); |
|
114 |
inner.add(privateInfoPanel); |
|
115 |
|
|
113 | 116 |
VerticalPanel permPanel = new VerticalPanel(); |
114 | 117 |
FileShareDialog.PrivateSharingImages images = GWT.create(FileShareDialog.PrivateSharingImages.class); |
115 |
permList = new PermissionsList(app, images, folder.getPermissions(), folder.getOwnerID(), false, null); |
|
118 |
|
|
119 |
permList = new PermissionsList(app, images, folder.getPermissions(), folder.getOwnerID(), false, new Command() { |
|
120 |
@Override |
|
121 |
public void execute() { |
|
122 |
updateMetadataForPrivateSharing(); |
|
123 |
} |
|
124 |
}); |
|
125 |
|
|
116 | 126 |
permPanel.add(permList); |
117 | 127 |
|
118 | 128 |
HorizontalPanel permButtons = new HorizontalPanel(); |
... | ... | |
121 | 131 |
public void onClick(ClickEvent event) { |
122 | 132 |
PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, true); |
123 | 133 |
dlg.center(); |
124 |
checkUpdateButtonVisibility();
|
|
134 |
permList.updatePermissionTable();
|
|
125 | 135 |
} |
126 | 136 |
}); |
127 | 137 |
addUser.addStyleName("button"); |
128 | 138 |
permButtons.add(addUser); |
129 | 139 |
permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER); |
130 | 140 |
|
131 |
Button add = new Button("Add Group", new ClickHandler() { |
|
132 |
@Override |
|
133 |
public void onClick(ClickEvent event) { |
|
134 |
if(app.getAccount().getGroups().isEmpty()) { |
|
135 |
new GroupCreateDialog(app, new Command() { |
|
136 |
@Override |
|
137 |
public void execute() { |
|
138 |
if(app.getAccount().getGroups().isEmpty()) { |
|
139 |
return; |
|
140 |
} |
|
141 |
PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false); |
|
142 |
dlg.center(); |
|
143 |
checkUpdateButtonVisibility(); |
|
144 |
} |
|
145 |
}).center(); |
|
146 |
} |
|
147 |
else { |
|
141 |
final boolean haveGroups = app.getAccount().getGroups().size() > 0; |
|
142 |
if(haveGroups) { |
|
143 |
Button addGroup = new Button("Add Group", new ClickHandler() { |
|
144 |
@Override |
|
145 |
public void onClick(ClickEvent event) { |
|
148 | 146 |
PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false); |
149 | 147 |
dlg.center(); |
150 |
checkUpdateButtonVisibility();
|
|
148 |
permList.updatePermissionTable();
|
|
151 | 149 |
} |
152 |
} |
|
153 |
});
|
|
154 |
add.addStyleName("button");
|
|
155 |
permButtons.add(add);
|
|
156 |
permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER);
|
|
150 |
});
|
|
151 |
addGroup.addStyleName("button");
|
|
152 |
permButtons.add(addGroup);
|
|
153 |
permButtons.setCellHorizontalAlignment(addGroup, HasHorizontalAlignment.ALIGN_CENTER);
|
|
154 |
}
|
|
157 | 155 |
|
158 | 156 |
permButtons.setSpacing(8); |
159 | 157 |
permPanel.add(permButtons); |
... | ... | |
162 | 160 |
|
163 | 161 |
outer.add(inner); |
164 | 162 |
|
165 |
// Create the 'Create/Update' button, along with a listener that hides the dialog |
|
166 |
// when the button is clicked and quits the application. |
|
167 |
final String okLabel = "Update"; |
|
168 |
updateButton = new Button(okLabel, new ClickHandler() { |
|
163 |
final Button ok = new Button("OK", new ClickHandler() { |
|
169 | 164 |
@Override |
170 | 165 |
public void onClick(ClickEvent event) { |
171 |
updateFolder(); |
|
172 | 166 |
closeDialog(); |
173 | 167 |
} |
174 | 168 |
}); |
175 |
updateButton.addStyleName("button");
|
|
176 |
checkUpdateButtonVisibility(); |
|
177 |
outer.add(updateButton);
|
|
169 |
ok.addStyleName("button");
|
|
170 |
|
|
171 |
outer.add(ok);
|
|
178 | 172 |
outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER); |
179 | 173 |
|
180 | 174 |
setWidget(outer); |
181 | 175 |
} |
182 | 176 |
|
183 |
private void checkUpdateButtonVisibility() { |
|
184 |
if(!this._initialPermissionCheck) { |
|
185 |
updateButton.setVisible(true); |
|
186 |
return; |
|
187 |
} |
|
188 |
|
|
189 |
updateButton.setVisible(permList.hasPermissions()); |
|
190 |
|
|
191 |
this._initialPermissionCheck = false; |
|
192 |
} |
|
193 |
|
|
194 | 177 |
@Override |
195 | 178 |
protected void onPreviewNativeEvent(NativePreviewEvent preview) { |
196 | 179 |
super.onPreviewNativeEvent(preview); |
... | ... | |
202 | 185 |
{ |
203 | 186 |
switch(evt.getKeyCode()) { |
204 | 187 |
case KeyCodes.KEY_ENTER: |
205 |
updateFolder();
|
|
188 |
updateMetadataForPrivateSharing();
|
|
206 | 189 |
closeDialog(); |
207 | 190 |
break; |
208 | 191 |
case KeyCodes.KEY_ESCAPE: |
... | ... | |
221 | 204 |
hide(); |
222 | 205 |
} |
223 | 206 |
|
224 |
void updateFolder() {
|
|
207 |
private void updateMetadataForPrivateSharing() {
|
|
225 | 208 |
final Map<String, Boolean[]> perms = (permList.hasChanges() ? permList.getPermissions() : null); |
226 |
updateMetadata( |
|
209 |
updateMetadataForPrivateSharing(
|
|
227 | 210 |
folder.getUri() + Const.QUESTION_MARK_UPDATE_EQ, |
228 | 211 |
perms |
229 | 212 |
); |
230 | 213 |
} |
231 | 214 |
|
232 |
protected void updateMetadata(final String path, final Map<String, Boolean[]> newPermissions) {
|
|
215 |
private void updateMetadataForPrivateSharing(final String path, final Map<String, Boolean[]> newPermissions) {
|
|
233 | 216 |
if(newPermissions != null) { |
234 | 217 |
PostRequest updateFolder = new PostRequest(app.getApiPath(), folder.getOwnerID(), path) { |
235 | 218 |
@Override |
... | ... | |
251 | 234 |
PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getOwnerID(), path1) { |
252 | 235 |
@Override |
253 | 236 |
public void onSuccess(Resource result) { |
254 |
updateMetadata(path, newPermissions); |
|
237 |
updateMetadataForPrivateSharing(path, newPermissions);
|
|
255 | 238 |
} |
256 | 239 |
|
257 | 240 |
@Override |
Also available in: Unified diff