Statistics
| Branch: | Tag: | Revision:

root / web_client / src / gr / grnet / pithos / web / client / FileUploadDialog.java @ 4d3dcdf6

History | View | Annotate | Download (11.2 kB)

1 ab1eb3f8 Christos Stathis
/*
2 58777026 Christos Stathis
 * Copyright 2011 GRNET S.A. All rights reserved.
3 58777026 Christos Stathis
 *
4 58777026 Christos Stathis
 * Redistribution and use in source and binary forms, with or
5 58777026 Christos Stathis
 * without modification, are permitted provided that the following
6 58777026 Christos Stathis
 * conditions are met:
7 58777026 Christos Stathis
 *
8 58777026 Christos Stathis
 *   1. Redistributions of source code must retain the above
9 58777026 Christos Stathis
 *      copyright notice, this list of conditions and the following
10 58777026 Christos Stathis
 *      disclaimer.
11 58777026 Christos Stathis
 *
12 58777026 Christos Stathis
 *   2. Redistributions in binary form must reproduce the above
13 58777026 Christos Stathis
 *      copyright notice, this list of conditions and the following
14 58777026 Christos Stathis
 *      disclaimer in the documentation and/or other materials
15 58777026 Christos Stathis
 *      provided with the distribution.
16 58777026 Christos Stathis
 *
17 58777026 Christos Stathis
 * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
18 58777026 Christos Stathis
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 58777026 Christos Stathis
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 58777026 Christos Stathis
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
21 58777026 Christos Stathis
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 58777026 Christos Stathis
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 58777026 Christos Stathis
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 58777026 Christos Stathis
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 58777026 Christos Stathis
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 58777026 Christos Stathis
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
27 58777026 Christos Stathis
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 58777026 Christos Stathis
 * POSSIBILITY OF SUCH DAMAGE.
29 58777026 Christos Stathis
 *
30 58777026 Christos Stathis
 * The views and conclusions contained in the software and
31 58777026 Christos Stathis
 * documentation are those of the authors and should not be
32 58777026 Christos Stathis
 * interpreted as representing official policies, either expressed
33 58777026 Christos Stathis
 * or implied, of GRNET S.A.
34 ab1eb3f8 Christos Stathis
 */
35 ab1eb3f8 Christos Stathis
package gr.grnet.pithos.web.client;
36 ab1eb3f8 Christos Stathis
37 26cbae7a Christos Stathis
import com.google.gwt.core.client.Scheduler;
38 26cbae7a Christos Stathis
import com.google.gwt.http.client.Response;
39 26cbae7a Christos Stathis
import gr.grnet.pithos.web.client.foldertree.File;
40 26cbae7a Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Folder;
41 26cbae7a Christos Stathis
import gr.grnet.pithos.web.client.foldertree.Resource;
42 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.GetCommand;
43 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.PostCommand;
44 26cbae7a Christos Stathis
import gr.grnet.pithos.web.client.rest.PutRequest;
45 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.RestCommand;
46 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.RestException;
47 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.resource.FileResource;
48 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.resource.FolderResource;
49 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper;
50 ab1eb3f8 Christos Stathis
import gr.grnet.pithos.web.client.rest.resource.UploadStatusResource;
51 ab1eb3f8 Christos Stathis
52 ab1eb3f8 Christos Stathis
import java.util.ArrayList;
53 ab1eb3f8 Christos Stathis
import java.util.List;
54 ab1eb3f8 Christos Stathis
55 ab1eb3f8 Christos Stathis
import com.google.gwt.core.client.GWT;
56 ab1eb3f8 Christos Stathis
import com.google.gwt.dom.client.NativeEvent;
57 ab1eb3f8 Christos Stathis
import com.google.gwt.event.dom.client.ClickEvent;
58 ab1eb3f8 Christos Stathis
import com.google.gwt.event.dom.client.ClickHandler;
59 ab1eb3f8 Christos Stathis
import com.google.gwt.event.dom.client.KeyCodes;
60 ab1eb3f8 Christos Stathis
import com.google.gwt.http.client.URL;
61 ab1eb3f8 Christos Stathis
import com.google.gwt.json.client.JSONObject;
62 ab1eb3f8 Christos Stathis
import com.google.gwt.json.client.JSONString;
63 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.DeferredCommand;
64 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.Event.NativePreviewEvent;
65 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.Timer;
66 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.Button;
67 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.DialogBox;
68 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.FileUpload;
69 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.FormPanel;
70 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
71 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
72 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
73 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
74 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.Grid;
75 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HTML;
76 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
77 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.Hidden;
78 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.HorizontalPanel;
79 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.Label;
80 ab1eb3f8 Christos Stathis
import com.google.gwt.user.client.ui.VerticalPanel;
81 26cbae7a Christos Stathis
import javax.xml.transform.Templates;
82 ab1eb3f8 Christos Stathis
83 ab1eb3f8 Christos Stathis
/**
84 ab1eb3f8 Christos Stathis
 * The 'File upload' dialog box implementation.
85 ab1eb3f8 Christos Stathis
 */
86 26cbae7a Christos Stathis
public class FileUploadDialog extends DialogBox {
87 ab1eb3f8 Christos Stathis
88 26cbae7a Christos Stathis
    public static final boolean DONE = true;
89 ab1eb3f8 Christos Stathis
90 ab1eb3f8 Christos Stathis
        /**
91 ab1eb3f8 Christos Stathis
         * The Form element that performs the file upload.
92 ab1eb3f8 Christos Stathis
         */
93 ab1eb3f8 Christos Stathis
        private final FormPanel form = new FormPanel();
94 ab1eb3f8 Christos Stathis
95 ab1eb3f8 Christos Stathis
        private final FileUpload upload = new FileUpload();
96 ab1eb3f8 Christos Stathis
97 26cbae7a Christos Stathis
        private final Label filenameLabel = new Label();
98 ab1eb3f8 Christos Stathis
99 26cbae7a Christos Stathis
    private final Label foldernameLabel = new Label();
100 ab1eb3f8 Christos Stathis
101 26cbae7a Christos Stathis
    private Button submit;
102 ab1eb3f8 Christos Stathis
103 26cbae7a Christos Stathis
        protected Folder folder;
104 ab1eb3f8 Christos Stathis
105 26cbae7a Christos Stathis
    protected GSS app;
106 ab1eb3f8 Christos Stathis
107 ab1eb3f8 Christos Stathis
        /**
108 ab1eb3f8 Christos Stathis
         * The widget's constructor.
109 ab1eb3f8 Christos Stathis
         */
110 ab1eb3f8 Christos Stathis
        public FileUploadDialog() {
111 ab1eb3f8 Christos Stathis
                // Set the dialog's caption.
112 ab1eb3f8 Christos Stathis
                setText("File upload");
113 ab1eb3f8 Christos Stathis
                setAnimationEnabled(true);
114 ab1eb3f8 Christos Stathis
                // Since we're going to add a FileUpload widget, we'll need to set the
115 ab1eb3f8 Christos Stathis
                // form to use the POST method, and multipart MIME encoding.
116 ab1eb3f8 Christos Stathis
                form.setEncoding(FormPanel.ENCODING_MULTIPART);
117 ab1eb3f8 Christos Stathis
                form.setMethod(FormPanel.METHOD_POST);
118 ab1eb3f8 Christos Stathis
119 ab1eb3f8 Christos Stathis
                // Create a panel to hold all of the form widgets.
120 ab1eb3f8 Christos Stathis
                VerticalPanel panel = new VerticalPanel();
121 ab1eb3f8 Christos Stathis
                form.setWidget(panel);
122 ab1eb3f8 Christos Stathis
                final HTML info = new HTML("You may select a file to upload. Install" +
123 ab1eb3f8 Christos Stathis
                                " <a href='http://gears.google.com/' target='_blank'>Google " +
124 ab1eb3f8 Christos Stathis
                                "Gears</a><br> for uploading multiple files simultaneously.");
125 ab1eb3f8 Christos Stathis
                info.addStyleName("pithos-uploadNote");
126 ab1eb3f8 Christos Stathis
                panel.add(info);
127 26cbae7a Christos Stathis
128 26cbae7a Christos Stathis
        final Hidden auth = new Hidden("X-Auth-Token", "");
129 26cbae7a Christos Stathis
        panel.add(auth);
130 ab1eb3f8 Christos Stathis
                upload.setName("file");
131 ab1eb3f8 Christos Stathis
                filenameLabel.setText("");
132 ab1eb3f8 Christos Stathis
                filenameLabel.setVisible(false);
133 ab1eb3f8 Christos Stathis
                filenameLabel.setStyleName("props-labels");
134 26cbae7a Christos Stathis
                HorizontalPanel fileUploadPanel = new HorizontalPanel();
135 26cbae7a Christos Stathis
                fileUploadPanel.add(filenameLabel);
136 26cbae7a Christos Stathis
                fileUploadPanel.add(upload);
137 ab1eb3f8 Christos Stathis
                Grid generalTable = new Grid(2, 2);
138 ab1eb3f8 Christos Stathis
                generalTable.setText(0, 0, "Folder");
139 26cbae7a Christos Stathis
        generalTable.setWidget(0, 1, foldernameLabel);
140 ab1eb3f8 Christos Stathis
                generalTable.setText(1, 0, "File");
141 26cbae7a Christos Stathis
                generalTable.setWidget(1, 1, fileUploadPanel);
142 ab1eb3f8 Christos Stathis
                generalTable.getCellFormatter().setStyleName(0, 0, "props-labels");
143 26cbae7a Christos Stathis
        generalTable.getCellFormatter().setStyleName(0, 1, "props-values");
144 ab1eb3f8 Christos Stathis
                generalTable.getCellFormatter().setStyleName(1, 0, "props-labels");
145 ab1eb3f8 Christos Stathis
                generalTable.getCellFormatter().setStyleName(1, 1, "props-values");
146 ab1eb3f8 Christos Stathis
                generalTable.setCellSpacing(4);
147 ab1eb3f8 Christos Stathis
148 ab1eb3f8 Christos Stathis
                panel.add(generalTable);
149 ab1eb3f8 Christos Stathis
150 ab1eb3f8 Christos Stathis
                // Create a panel to hold the buttons.
151 ab1eb3f8 Christos Stathis
                HorizontalPanel buttons = new HorizontalPanel();
152 ab1eb3f8 Christos Stathis
153 ab1eb3f8 Christos Stathis
                // Create the 'upload' button, along with a listener that submits the
154 ab1eb3f8 Christos Stathis
                // form.
155 26cbae7a Christos Stathis
                submit = new Button("Upload", new ClickHandler() {
156 ab1eb3f8 Christos Stathis
                        @Override
157 ab1eb3f8 Christos Stathis
                        public void onClick(ClickEvent event) {
158 ab1eb3f8 Christos Stathis
                                prepareAndSubmit();
159 ab1eb3f8 Christos Stathis
                        }
160 ab1eb3f8 Christos Stathis
                });
161 ab1eb3f8 Christos Stathis
                buttons.add(submit);
162 ab1eb3f8 Christos Stathis
                buttons.setCellHorizontalAlignment(submit, HasHorizontalAlignment.ALIGN_CENTER);
163 ab1eb3f8 Christos Stathis
                // Create the 'Cancel' button, along with a listener that hides the
164 ab1eb3f8 Christos Stathis
                // dialog when the button is clicked.
165 ab1eb3f8 Christos Stathis
                final Button cancel = new Button("Cancel", new ClickHandler() {
166 ab1eb3f8 Christos Stathis
                        @Override
167 ab1eb3f8 Christos Stathis
                        public void onClick(ClickEvent event) {
168 ab1eb3f8 Christos Stathis
                                hide();
169 ab1eb3f8 Christos Stathis
                        }
170 ab1eb3f8 Christos Stathis
                });
171 ab1eb3f8 Christos Stathis
                buttons.add(cancel);
172 ab1eb3f8 Christos Stathis
                buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
173 ab1eb3f8 Christos Stathis
                buttons.setSpacing(8);
174 ab1eb3f8 Christos Stathis
                buttons.addStyleName("pithos-DialogBox");
175 26cbae7a Christos Stathis
        panel.add(buttons);
176 26cbae7a Christos Stathis
        panel.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
177 ab1eb3f8 Christos Stathis
178 ab1eb3f8 Christos Stathis
                // Add an event handler to the form.
179 ab1eb3f8 Christos Stathis
                form.addSubmitHandler(new SubmitHandler() {
180 ab1eb3f8 Christos Stathis
181 ab1eb3f8 Christos Stathis
                        @Override
182 ab1eb3f8 Christos Stathis
                        public void onSubmit(SubmitEvent event) {
183 26cbae7a Christos Stathis
                auth.setValue(app.getToken()); //This is done here because the app object is not available in the constructor
184 ab1eb3f8 Christos Stathis
                        }
185 ab1eb3f8 Christos Stathis
                });
186 ab1eb3f8 Christos Stathis
                form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
187 ab1eb3f8 Christos Stathis
188 ab1eb3f8 Christos Stathis
                        @Override
189 ab1eb3f8 Christos Stathis
                        public void onSubmitComplete(SubmitCompleteEvent event) {
190 ab1eb3f8 Christos Stathis
                                // When the form submission is successfully completed, this
191 ab1eb3f8 Christos Stathis
                                // event is fired. Assuming the service returned a response
192 ab1eb3f8 Christos Stathis
                                // of type text/html, we can get the result text here (see
193 ab1eb3f8 Christos Stathis
                                // the FormPanel documentation for further explanation).
194 ab1eb3f8 Christos Stathis
                                String results = event.getResults();
195 ab1eb3f8 Christos Stathis
196 ab1eb3f8 Christos Stathis
                                // Unfortunately the results are never empty, even in
197 ab1eb3f8 Christos Stathis
                                // the absense of errors, so we have to check for '<pre></pre>'.
198 26cbae7a Christos Stathis
                                if (results != null && !results.equalsIgnoreCase("<pre></pre>")) {
199 ab1eb3f8 Christos Stathis
                                        GWT.log(results, null);
200 26cbae7a Christos Stathis
                                        app.displayError(results);
201 ab1eb3f8 Christos Stathis
                                }
202 26cbae7a Christos Stathis
                app.updateFolder(folder);
203 26cbae7a Christos Stathis
                                hide();
204 ab1eb3f8 Christos Stathis
                        }
205 ab1eb3f8 Christos Stathis
                });
206 ab1eb3f8 Christos Stathis
207 ab1eb3f8 Christos Stathis
208 ab1eb3f8 Christos Stathis
                panel.addStyleName("pithos-DialogBox");
209 ab1eb3f8 Christos Stathis
                addStyleName("pithos-DialogBox");
210 ab1eb3f8 Christos Stathis
                setWidget(form);
211 ab1eb3f8 Christos Stathis
        }
212 ab1eb3f8 Christos Stathis
213 ab1eb3f8 Christos Stathis
        @Override
214 ab1eb3f8 Christos Stathis
        protected void onPreviewNativeEvent(NativePreviewEvent preview) {
215 ab1eb3f8 Christos Stathis
                super.onPreviewNativeEvent(preview);
216 ab1eb3f8 Christos Stathis
217 ab1eb3f8 Christos Stathis
                NativeEvent evt = preview.getNativeEvent();
218 ab1eb3f8 Christos Stathis
                if (evt.getType().equals("keydown"))
219 ab1eb3f8 Christos Stathis
                        // Use the popup's key preview hooks to close the dialog when either
220 ab1eb3f8 Christos Stathis
                        // enter or escape is pressed.
221 ab1eb3f8 Christos Stathis
                        switch (evt.getKeyCode()) {
222 ab1eb3f8 Christos Stathis
                                case KeyCodes.KEY_ENTER:
223 ab1eb3f8 Christos Stathis
                                        prepareAndSubmit();
224 ab1eb3f8 Christos Stathis
                                        break;
225 ab1eb3f8 Christos Stathis
                                case KeyCodes.KEY_ESCAPE:
226 26cbae7a Christos Stathis
                                        hide();
227 ab1eb3f8 Christos Stathis
                                        break;
228 ab1eb3f8 Christos Stathis
                        }
229 ab1eb3f8 Christos Stathis
        }
230 ab1eb3f8 Christos Stathis
231 ab1eb3f8 Christos Stathis
        /**
232 ab1eb3f8 Christos Stathis
         * Make any last minute checks and start the upload.
233 ab1eb3f8 Christos Stathis
         */
234 26cbae7a Christos Stathis
        protected void prepareAndSubmit() {
235 26cbae7a Christos Stathis
        if (upload.getFilename().length() == 0) {
236 26cbae7a Christos Stathis
            app.displayError("You must select a file!");
237 26cbae7a Christos Stathis
            return;
238 26cbae7a Christos Stathis
        }
239 26cbae7a Christos Stathis
        final String fname = getFilename(upload.getFilename());
240 26cbae7a Christos Stathis
        String apath = app.getApiPath() + app.getUsername() + folder.getUri() + "/" + fname;
241 26cbae7a Christos Stathis
        form.setAction(apath);
242 26cbae7a Christos Stathis
        submit.setEnabled(false);
243 26cbae7a Christos Stathis
        upload.setVisible(false);
244 26cbae7a Christos Stathis
        filenameLabel.setText(fname);
245 26cbae7a Christos Stathis
        filenameLabel.setVisible(true);
246 26cbae7a Christos Stathis
247 ab1eb3f8 Christos Stathis
                if (getFileForName(fname) == null) {
248 26cbae7a Christos Stathis
                        doUpload(apath);
249 ab1eb3f8 Christos Stathis
                }
250 ab1eb3f8 Christos Stathis
                else {
251 ab1eb3f8 Christos Stathis
                        // We are going to update an existing file, so show a confirmation dialog.
252 ab1eb3f8 Christos Stathis
                        ConfirmationDialog confirm = new ConfirmationDialog("Are you sure " +
253 ab1eb3f8 Christos Stathis
                                        "you want to update " + fname + "?", "Update") {
254 ab1eb3f8 Christos Stathis
255 ab1eb3f8 Christos Stathis
                                @Override
256 ab1eb3f8 Christos Stathis
                                public void cancel() {
257 ab1eb3f8 Christos Stathis
                                        FileUploadDialog.this.hide();
258 ab1eb3f8 Christos Stathis
                                }
259 ab1eb3f8 Christos Stathis
260 ab1eb3f8 Christos Stathis
                                @Override
261 ab1eb3f8 Christos Stathis
                                public void confirm() {
262 ab1eb3f8 Christos Stathis
                                        form.submit();
263 ab1eb3f8 Christos Stathis
                                }
264 ab1eb3f8 Christos Stathis
265 ab1eb3f8 Christos Stathis
                        };
266 ab1eb3f8 Christos Stathis
                        confirm.center();
267 ab1eb3f8 Christos Stathis
                }
268 ab1eb3f8 Christos Stathis
        }
269 ab1eb3f8 Christos Stathis
270 26cbae7a Christos Stathis
    private void doUpload(String path) {
271 26cbae7a Christos Stathis
        PutRequest createFile = new PutRequest(path) {
272 26cbae7a Christos Stathis
            @Override
273 26cbae7a Christos Stathis
            public void onSuccess(Resource result) {
274 26cbae7a Christos Stathis
                form.submit();
275 26cbae7a Christos Stathis
            }
276 26cbae7a Christos Stathis
277 26cbae7a Christos Stathis
            @Override
278 26cbae7a Christos Stathis
            public void onError(Throwable t) {
279 26cbae7a Christos Stathis
                GWT.log("", t);
280 26cbae7a Christos Stathis
                if (t instanceof RestException) {
281 26cbae7a Christos Stathis
                    app.displayError("Unable to create file:" + ((RestException) t).getHttpStatusText());
282 26cbae7a Christos Stathis
                }
283 26cbae7a Christos Stathis
                else
284 26cbae7a Christos Stathis
                    app.displayError("System error creating file:" + t.getMessage());
285 26cbae7a Christos Stathis
            }
286 26cbae7a Christos Stathis
        };
287 26cbae7a Christos Stathis
        createFile.setHeader("X-Auth-Token", app.getToken());
288 26cbae7a Christos Stathis
        createFile.setHeader("Content-Length", "0");
289 26cbae7a Christos Stathis
        Scheduler.get().scheduleDeferred(createFile);
290 26cbae7a Christos Stathis
    }
291 26cbae7a Christos Stathis
292 26cbae7a Christos Stathis
    /**
293 ab1eb3f8 Christos Stathis
         * Returns the file name from a potential full path argument. Apparently IE
294 ab1eb3f8 Christos Stathis
         * insists on sending the full path name of a file when uploading, forcing
295 ab1eb3f8 Christos Stathis
         * us to trim the extra path info. Since this is only observed on Windows we
296 ab1eb3f8 Christos Stathis
         * get to check for a single path separator value.
297 ab1eb3f8 Christos Stathis
         *
298 ab1eb3f8 Christos Stathis
         * @param name the potentially full path name of a file
299 ab1eb3f8 Christos Stathis
         * @return the file name without extra path information
300 ab1eb3f8 Christos Stathis
         */
301 ab1eb3f8 Christos Stathis
        protected String getFilename(String name) {
302 ab1eb3f8 Christos Stathis
                int pathSepIndex = name.lastIndexOf("\\");
303 ab1eb3f8 Christos Stathis
                if (pathSepIndex == -1) {
304 ab1eb3f8 Christos Stathis
                        pathSepIndex = name.lastIndexOf("/");
305 ab1eb3f8 Christos Stathis
                        if (pathSepIndex == -1)
306 ab1eb3f8 Christos Stathis
                                return name;
307 ab1eb3f8 Christos Stathis
                }
308 ab1eb3f8 Christos Stathis
                return name.substring(pathSepIndex + 1);
309 ab1eb3f8 Christos Stathis
        }
310 ab1eb3f8 Christos Stathis
311 26cbae7a Christos Stathis
        protected File getFileForName(String name){
312 26cbae7a Christos Stathis
                for (File f : folder.getFiles())
313 26cbae7a Christos Stathis
                        if (!f.isInTrash() && f.getName().equals(name))
314 ab1eb3f8 Christos Stathis
                                return f;
315 ab1eb3f8 Christos Stathis
                return null;
316 ab1eb3f8 Christos Stathis
        }
317 ab1eb3f8 Christos Stathis
318 26cbae7a Christos Stathis
    public void setApp(GSS app) {
319 26cbae7a Christos Stathis
        this.app = app;
320 26cbae7a Christos Stathis
    }
321 ab1eb3f8 Christos Stathis
322 26cbae7a Christos Stathis
    public void setFolder(Folder folder) {
323 26cbae7a Christos Stathis
        this.folder = folder;
324 26cbae7a Christos Stathis
        foldernameLabel.setText(folder.getName());
325 26cbae7a Christos Stathis
    }
326 ab1eb3f8 Christos Stathis
}