Revision d2c63e7e
b/gss/src/gr/ebs/gss/client/DeleteFileDialog.java | ||
---|---|---|
49 | 49 |
* |
50 | 50 |
* @param images the supplied images |
51 | 51 |
*/ |
52 |
public DeleteFileDialog(final Images images) {
|
|
53 |
// Use this opportunity to set the dialog's caption.
|
|
54 |
setText("Delete file");
|
|
52 |
public DeleteFileDialog(Images images) { |
|
53 |
// Set the dialog's caption.
|
|
54 |
setText("Confirmation");
|
|
55 | 55 |
setAnimationEnabled(true); |
56 | 56 |
Object selection = GSS.get().getCurrentSelection(); |
57 |
// Create a VerticalPanel to contain the 'about' label and the 'OK' |
|
58 |
// button. |
|
59 |
final VerticalPanel outer = new VerticalPanel(); |
|
60 |
final HorizontalPanel buttons = new HorizontalPanel(); |
|
61 |
|
|
62 |
// Create the 'about' text and set a style name so we can style it with |
|
63 |
// CSS. |
|
64 |
final HTML text; |
|
57 |
// Create a VerticalPanel to contain the label and the buttons. |
|
58 |
VerticalPanel outer = new VerticalPanel(); |
|
59 |
HorizontalPanel buttons = new HorizontalPanel(); |
|
60 |
|
|
61 |
HTML text; |
|
65 | 62 |
if (selection instanceof FileResource) |
66 |
text = new HTML("<table><tr><td rowspan='2'>" + images.warn().getHTML() + "</td><td>" + "Are you sure you want to delete file '" + ((FileResource) selection).getName() + "'?</td></tr><tr><td>" + "(it will be deleted <b>permanently</b>!)" + "</td></tr></table>");
|
|
63 |
text = new HTML("<table><tr><td>" + images.warn().getHTML() + "</td><td>" + "Are you sure you want to <b>permanently</b> delete file '" + ((FileResource) selection).getName() + "'?</td></tr></table>");
|
|
67 | 64 |
else |
68 |
text = new HTML("<table><tr><td rowspan='2'>" + images.warn().getHTML() + "</td><td>" + "Are you sure you want to delete selected files? " + "?</td></tr><tr><td>" + "(it will be deleted <b>permanently</b>!)" + "</td></tr></table>");
|
|
65 |
text = new HTML("<table><tr><td>" + images.warn().getHTML() + "</td><td>" + "Are you sure you want to <b>permanently</b> delete the selected files?</td></tr></table>");
|
|
69 | 66 |
text.setStyleName("gss-warnMessage"); |
70 | 67 |
outer.add(text); |
71 | 68 |
|
72 |
// Create the 'Quit' button, along with a listener that hides the dialog
|
|
73 |
// when the button is clicked and quits the application.
|
|
74 |
final Button ok = new Button("Delete the file", new ClickListener() {
|
|
69 |
// Create the 'Delete' button, along with a listener that hides the dialog
|
|
70 |
// when the button is clicked and deletes the file.
|
|
71 |
Button ok = new Button("Delete", new ClickListener() {
|
|
75 | 72 |
|
76 | 73 |
public void onClick(Widget sender) { |
77 | 74 |
deleteFile(); |
... | ... | |
81 | 78 |
buttons.add(ok); |
82 | 79 |
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); |
83 | 80 |
// Create the 'Cancel' button, along with a listener that hides the |
84 |
// dialog |
|
85 |
// when the button is clicked. |
|
86 |
final Button cancel = new Button("Cancel", new ClickListener() { |
|
81 |
// dialog when the button is clicked. |
|
82 |
Button cancel = new Button("Cancel", new ClickListener() { |
|
87 | 83 |
|
88 | 84 |
public void onClick(Widget sender) { |
89 | 85 |
hide(); |
... | ... | |
106 | 102 |
* @param userId the ID of the current user |
107 | 103 |
*/ |
108 | 104 |
private void deleteFile() { |
109 |
final Object selection = GSS.get().getCurrentSelection();
|
|
105 |
Object selection = GSS.get().getCurrentSelection(); |
|
110 | 106 |
if (selection == null) { |
111 |
GSS.get().displayError("No file was selected!");
|
|
107 |
GSS.get().displayError("No file was selected"); |
|
112 | 108 |
return; |
113 | 109 |
} |
114 | 110 |
if (selection instanceof FileResource) { |
115 | 111 |
FileResource file = (FileResource) selection; |
112 |
|
|
116 | 113 |
ExecuteDelete df = new ExecuteDelete(file.getPath()){ |
117 | 114 |
|
115 |
@Override |
|
118 | 116 |
public void onComplete() { |
119 | 117 |
GSS.get().getFileList().updateFileCache(true); |
120 | 118 |
GSS.get().getStatusPanel().updateStats(); |
121 | 119 |
} |
122 | 120 |
|
123 |
|
|
121 |
@Override |
|
124 | 122 |
public void onError(Throwable t) { |
125 | 123 |
GWT.log("", t); |
126 | 124 |
if(t instanceof RestException){ |
... | ... | |
130 | 128 |
else if(statusCode == 404) |
131 | 129 |
GSS.get().displayError("File not found"); |
132 | 130 |
else |
133 |
GSS.get().displayError("Unable to delete file:"+((RestException)t).getHttpStatusText()); |
|
131 |
GSS.get().displayError("Unable to delete file: "+((RestException)t).getHttpStatusText());
|
|
134 | 132 |
} |
135 | 133 |
else |
136 |
GSS.get().displayError("System error unable to delete file:"+t.getMessage()); |
|
134 |
GSS.get().displayError("System error unable to delete file: "+t.getMessage());
|
|
137 | 135 |
} |
138 | 136 |
}; |
139 |
DeferredCommand.addCommand(df); |
|
140 | 137 |
|
138 |
DeferredCommand.addCommand(df); |
|
141 | 139 |
} |
142 | 140 |
else if(selection instanceof List){ |
143 | 141 |
List<FileResource> files = (List<FileResource>) selection; |
144 |
final List<String> fileIds = new ArrayList<String>();
|
|
142 |
List<String> fileIds = new ArrayList<String>(); |
|
145 | 143 |
for(FileResource f : files) |
146 | 144 |
fileIds.add(f.getPath()); |
145 |
|
|
147 | 146 |
ExecuteMultipleDelete ed = new ExecuteMultipleDelete(fileIds.toArray(new String[0])){ |
148 | 147 |
|
148 |
@Override |
|
149 | 149 |
public void onComplete() { |
150 | 150 |
GSS.get().showFileList(true); |
151 | 151 |
} |
... | ... | |
173 | 173 |
|
174 | 174 |
} |
175 | 175 |
}; |
176 |
|
|
176 | 177 |
DeferredCommand.addCommand(ed); |
177 | 178 |
} |
178 | 179 |
} |
179 | 180 |
|
180 |
/* |
|
181 |
* (non-Javadoc) |
|
182 |
* |
|
183 |
* @see com.google.gwt.user.client.ui.PopupPanel#onKeyDownPreview(char, int) |
|
184 |
*/ |
|
181 |
@Override |
|
185 | 182 |
public boolean onKeyDownPreview(final char key, final int modifiers) { |
186 | 183 |
// Use the popup's key preview hooks to close the dialog when either |
187 | 184 |
// enter or escape is pressed. |
b/gss/src/gr/ebs/gss/client/DeleteFolderDialog.java | ||
---|---|---|
46 | 46 |
* The widget's constructor. |
47 | 47 |
* @param images the supplied images |
48 | 48 |
*/ |
49 |
public DeleteFolderDialog(final Images images) {
|
|
50 |
// Use this opportunity to set the dialog's caption.
|
|
51 |
setText("Delete folder");
|
|
49 |
public DeleteFolderDialog(Images images) { |
|
50 |
// Set the dialog's caption.
|
|
51 |
setText("Confirmation");
|
|
52 | 52 |
setAnimationEnabled(true); |
53 |
final FolderResource folder = (FolderResource) GSS.get().getCurrentSelection(); |
|
54 |
// Create a VerticalPanel to contain the 'about' label and the 'OK' |
|
55 |
// button. |
|
56 |
final VerticalPanel outer = new VerticalPanel(); |
|
57 |
final HorizontalPanel buttons = new HorizontalPanel(); |
|
58 |
|
|
59 |
// Create the 'about' text and set a style name so we can style it with |
|
60 |
// CSS. |
|
61 |
final HTML text = new HTML("<table><tr><td rowspan='2'>" + images.warn().getHTML() + |
|
62 |
"</td><td>" + "Are you sure you want to delete folder '" + folder.getName() + |
|
63 |
"'?</td></tr><tr><td>" + "(it will be deleted <b>permanently</b>!)" + "</td></tr></table>"); |
|
53 |
FolderResource folder = (FolderResource) GSS.get().getCurrentSelection(); |
|
54 |
// Create a VerticalPanel to contain the HTML label and the buttons. |
|
55 |
VerticalPanel outer = new VerticalPanel(); |
|
56 |
HorizontalPanel buttons = new HorizontalPanel(); |
|
57 |
|
|
58 |
HTML text = new HTML("<table><tr><td rowspan='2'>" + images.warn().getHTML() + |
|
59 |
"</td><td>" + "Are you sure you want to <b>permanently</b> delete folder '" + folder.getName() + |
|
60 |
"'?</td></tr></table>"); |
|
64 | 61 |
text.setStyleName("gss-warnMessage"); |
65 | 62 |
outer.add(text); |
66 | 63 |
|
67 |
// Create the 'Quit' button, along with a listener that hides the dialog
|
|
68 |
// when the button is clicked and quits the application.
|
|
69 |
final Button ok = new Button("Delete the folder", new ClickListener() {
|
|
64 |
// Create the 'Delete' button, along with a listener that hides the dialog
|
|
65 |
// when the button is clicked and deletes the folder.
|
|
66 |
Button ok = new Button("Delete", new ClickListener() {
|
|
70 | 67 |
|
71 | 68 |
public void onClick(Widget sender) { |
72 | 69 |
deleteFolder(); |
... | ... | |
76 | 73 |
buttons.add(ok); |
77 | 74 |
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); |
78 | 75 |
// Create the 'Cancel' button, along with a listener that hides the |
79 |
// dialog |
|
80 |
// when the button is clicked. |
|
81 |
final Button cancel = new Button("Cancel", new ClickListener() { |
|
76 |
// dialog when the button is clicked. |
|
77 |
Button cancel = new Button("Cancel", new ClickListener() { |
|
82 | 78 |
|
83 | 79 |
public void onClick(Widget sender) { |
84 | 80 |
hide(); |
... | ... | |
102 | 98 |
*/ |
103 | 99 |
private void deleteFolder() { |
104 | 100 |
|
105 |
final DnDTreeItem folder = (DnDTreeItem) GSS.get().getFolders().getCurrent();
|
|
101 |
DnDTreeItem folder = (DnDTreeItem) GSS.get().getFolders().getCurrent(); |
|
106 | 102 |
if (folder == null) { |
107 |
GSS.get().displayError("No folder was selected!");
|
|
103 |
GSS.get().displayError("No folder was selected"); |
|
108 | 104 |
return; |
109 | 105 |
} |
110 | 106 |
if(folder.getFolderResource() == null) |
111 | 107 |
return; |
108 |
|
|
112 | 109 |
ExecuteDelete df = new ExecuteDelete(folder.getFolderResource().getPath()){ |
110 |
|
|
113 | 111 |
@Override |
114 | 112 |
public void onComplete() { |
115 |
TreeItem folder = GSS.get().getFolders().getCurrent();
|
|
116 |
GSS.get().getFolders().updateFolder((DnDTreeItem) folder.getParentItem());
|
|
113 |
TreeItem curFolder = GSS.get().getFolders().getCurrent();
|
|
114 |
GSS.get().getFolders().updateFolder((DnDTreeItem) curFolder.getParentItem());
|
|
117 | 115 |
} |
116 |
|
|
117 |
@Override |
|
118 | 118 |
public void onError(Throwable t) { |
119 | 119 |
GWT.log("", t); |
120 | 120 |
if(t instanceof RestException){ |
... | ... | |
124 | 124 |
else if(statusCode == 404) |
125 | 125 |
GSS.get().displayError("Folder not found"); |
126 | 126 |
else |
127 |
GSS.get().displayError("Unable to delete folder:"+((RestException)t).getHttpStatusText()); |
|
127 |
GSS.get().displayError("Unable to delete folder: "+((RestException)t).getHttpStatusText());
|
|
128 | 128 |
} |
129 | 129 |
else |
130 |
GSS.get().displayError("System error unable to delete folder:"+t.getMessage()); |
|
130 |
GSS.get().displayError("System error unable to delete folder: "+t.getMessage());
|
|
131 | 131 |
} |
132 | 132 |
}; |
133 |
DeferredCommand.addCommand(df); |
|
134 | 133 |
|
134 |
DeferredCommand.addCommand(df); |
|
135 | 135 |
} |
136 | 136 |
|
137 |
/* |
|
138 |
* (non-Javadoc) |
|
139 |
* |
|
140 |
* @see com.google.gwt.user.client.ui.PopupPanel#onKeyDownPreview(char, int) |
|
141 |
*/ |
|
137 |
@Override |
|
142 | 138 |
public boolean onKeyDownPreview(final char key, final int modifiers) { |
143 | 139 |
// Use the popup's key preview hooks to close the dialog when either |
144 | 140 |
// enter or escape is pressed. |
... | ... | |
151 | 147 |
hide(); |
152 | 148 |
break; |
153 | 149 |
} |
154 |
|
|
155 | 150 |
return true; |
156 | 151 |
} |
157 | 152 |
|
Also available in: Unified diff