Statistics
| Branch: | Tag: | Revision:

root / src / gr / grnet / pithos / web / client / FileShareDialog.java @ ddbf7059

History | View | Annotate | Download (22.8 kB)

1
/*
2
 * Copyright 2011-2013 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 com.google.gwt.event.dom.client.*;
38
import com.google.gwt.http.client.URL;
39
import com.google.gwt.user.client.Event;
40
import com.google.gwt.user.client.ui.*;
41
import gr.grnet.pithos.web.client.foldertree.File;
42
import gr.grnet.pithos.web.client.rest.HeadRequest;
43
import gr.grnet.pithos.web.client.rest.PostRequest;
44

    
45
import com.google.gwt.core.client.GWT;
46
import com.google.gwt.core.client.Scheduler;
47
import com.google.gwt.dom.client.NativeEvent;
48
import com.google.gwt.http.client.Response;
49
import com.google.gwt.http.client.UrlBuilder;
50
import com.google.gwt.resources.client.ImageResource;
51
import com.google.gwt.user.client.Command;
52
import com.google.gwt.user.client.Window;
53
import com.google.gwt.user.client.Event.NativePreviewEvent;
54

    
55
import java.util.Map;
56

    
57
/**
58
 * UI for the "Share" command.
59
 */
60
public class FileShareDialog extends AbstractPropertiesDialog {
61
    private static final class LinkTextContextMenu extends PopupPanel {
62
        private final TextBox toCopy;
63

    
64
        public LinkTextContextMenu(TextBox toCopy) {
65
            super(true); // autoHide
66

    
67
            this.toCopy = toCopy;
68

    
69
            final MenuBar contextMenu = new MenuBar(true);
70
            final MenuItem copy = new MenuItem("Copy", false, new Command() {
71
                @Override
72
                public void execute() {
73
                    Pithos.LOG("Copying ", LinkTextContextMenu.this.toCopy.getText());
74
                    LinkTextContextMenu.this.hide();
75
                    Helpers.copyToClipboardFrom(LinkTextContextMenu.this.toCopy.getElement());
76
                }
77
            });
78
            contextMenu.addItem(copy);
79

    
80
            add(contextMenu);
81
        }
82
    }
83

    
84
    private static final class LinkTextBox extends TextBox {
85
        public LinkTextBox() {
86
            sinkEvents(Event.ONCONTEXTMENU);
87

    
88
            addHandler(new ContextMenuHandler() {
89
                @Override
90
                public void onContextMenu(ContextMenuEvent event) {
91
                    final int x = event.getNativeEvent().getClientX();
92
                    final int y = event.getNativeEvent().getClientY();
93

    
94
                    final LinkTextContextMenu menu = new LinkTextContextMenu(LinkTextBox.this);
95
                    menu.setPopupPosition(x, y);
96
                    menu.show();
97

    
98
                }
99
            }, ContextMenuEvent.getType());
100
        }
101
    }
102

    
103
    // For public sharing
104
        private final HorizontalPanel publicPathPanel = new HorizontalPanel();
105
        private final TextBox publicPathText = new LinkTextBox();
106

    
107
    // For private sharing
108
    private final HorizontalPanel privatePathPanel = new HorizontalPanel();
109
    private final TextBox privatePathText = new LinkTextBox();
110
    private PermissionsList permList;
111
        
112
        /**
113
         * An image bundle for this widgets images.
114
         */
115
        public interface PublicSharingImages extends MessagePanel.Images {
116

    
117
                @Source("gr/grnet/pithos/resources/edit_user.png")
118
                ImageResource permUser();
119

    
120
                @Source("gr/grnet/pithos/resources/groups22.png")
121
                ImageResource permGroup();
122

    
123
                @Source("gr/grnet/pithos/resources/editdelete.png")
124
                ImageResource delete();
125
    }
126

    
127
    public interface PrivateSharingImages extends MessagePanel.Images {
128

    
129
        @Source("gr/grnet/pithos/resources/edit_user.png")
130
        ImageResource permUser();
131

    
132
        @Source("gr/grnet/pithos/resources/groups22.png")
133
        ImageResource permGroup();
134

    
135
        @Source("gr/grnet/pithos/resources/delete.gif")
136
        ImageResource delete();
137
    }
138

    
139
    private final File file;
140

    
141
    private final PublicSharingImages publicSharingImages = GWT.create(PublicSharingImages.class);
142
    private final PrivateSharingImages privateSharingImages = GWT.create(PrivateSharingImages.class);
143

    
144
        /**
145
         * The widget's constructor.
146
         */
147
        public FileShareDialog(Pithos app, File file) {
148
        super(app);
149
        this.file = file;
150

    
151
                Anchor close = new Anchor("close");
152
                close.addStyleName("close");
153
                close.addClickHandler(new ClickHandler() {
154
                        
155
                        @Override
156
                        public void onClick(ClickEvent event) {
157
                                hide();
158
                        }
159
                });
160
                // Set the dialog's caption.
161
                setText(Const.TXT_SHARE_FILE);
162
                setGlassEnabled(true);
163
                setStyleName("pithos-DialogBox");
164

    
165
                // Outer contains inner and buttons.
166
                final VerticalPanel outer = new VerticalPanel();
167
                outer.add(close);
168
                final FocusPanel focusPanel = new FocusPanel(outer);
169
                // Inner contains generalPanel and permPanel.
170
                inner = new VerticalPanel();
171
                inner.addStyleName("inner");
172

    
173
        inner.add(createMainPanel());
174

    
175
        outer.add(inner);
176

    
177
                final Button ok = new Button("OK", new ClickHandler() {
178
                        @Override
179
                        public void onClick(ClickEvent event) {
180
                                closeDialog();
181
                        }
182
                });
183
                ok.addStyleName("button");
184

    
185
        outer.add(ok);
186
        outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
187

    
188
        focusPanel.setFocus(true);
189
        setWidget(outer);
190
        }
191

    
192
    private boolean IamOwner() {
193
        return file.getOwnerID().equals(app.getUserID());
194
    }
195

    
196
    private void populatePublicSharingPanel(VerticalPanel publicSharingPanel) {
197
        if(IamOwner()) {
198
            final HorizontalPanel publicCheckPanel = new HorizontalPanel();
199
            publicCheckPanel.setSpacing(8);
200

    
201
            // Check box header
202
            final CheckBox publicCheckBox = new CheckBox();
203
            Label publicCheckTitle = new InlineHTML("<b>Public on the Internet</b>");
204
            Label publicCheckInfo = new Label("Anyone who has the public link can access. No sign-in required.", true);
205

    
206
            publicCheckBox.setValue(isFilePubliclyShared());
207
            publicCheckBox.addClickHandler(new ClickHandler() {
208
                @Override
209
                public void onClick(ClickEvent event) {
210
                    final Boolean published;
211
                    if(publicCheckBox.getValue() != file.isPublished() && IamOwner()) {
212
                        published = publicCheckBox.getValue();
213
                    }
214
                    else {
215
                        published = Boolean.FALSE;
216
                    }
217

    
218
                    updateMetaDataForPublicSharing(published);
219
                }
220
            });
221

    
222
            publicCheckPanel.add(publicCheckBox);
223
            publicCheckPanel.add(publicCheckTitle);
224
            publicCheckPanel.add(publicCheckInfo);
225

    
226
            // Public Link
227
            publicPathPanel.setVisible(false);
228
            publicPathPanel.setWidth(Const.PERCENT_100);
229
            publicPathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
230
            publicPathPanel.add(new Label(Const.TXT_PUBLIC_LINK));
231
            publicPathPanel.setSpacing(8);
232
            publicPathPanel.addStyleName("pithos-TabPanelBottom");
233

    
234
            publicPathText.setWidth(Const.PERCENT_100);
235
            publicPathText.addClickHandler(new ClickHandler() {
236
                @Override
237
                public void onClick(ClickEvent event) {
238
                    Pithos.enableIESelection();
239
                    ((TextBox) event.getSource()).selectAll();
240
                    Pithos.preventIESelection();
241
                }
242
            });
243
            publicPathText.setText(Window.Location.getHost() + file.getPublicUri());
244
            publicPathText.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");
245
            publicPathText.setReadOnly(true);
246
            publicPathPanel.add(publicPathText);
247

    
248
            publicSharingPanel.add(publicCheckPanel);
249
            publicSharingPanel.add(publicPathPanel);
250

    
251
            Scheduler.get().scheduleDeferred(new Command() {
252
                @Override
253
                public void execute() {
254
                    showLinkForPublicSharing();
255
                }
256
            });
257
        }
258
    }
259

    
260
    private void populatePrivateSharingPanel(VerticalPanel privateSharingPanel) {
261
        final HorizontalPanel privateCheckPanel = new HorizontalPanel();
262
        final VerticalPanel privatePermPanel = new VerticalPanel();
263
        final HorizontalPanel permButtons = new HorizontalPanel();
264

    
265
        privateCheckPanel.setSpacing(8);
266
        privatePermPanel.setVisible(isFilePrivatelyShared());
267
        permButtons.setSpacing(8);
268

    
269
        // Check box header
270
        final CheckBox privateCheckBox = new CheckBox();
271
        final Label privateCheckTitle = new  InlineHTML("<b>Private sharing</b>");
272
        final Label privateCheckInfo = new Label("Only people explicitly granted permission can access. Sign-in required.", true);
273

    
274
        privateCheckBox.setValue(isFilePrivatelyShared());
275
        privateCheckBox.addClickHandler(new ClickHandler() {
276
            @Override
277
            public void onClick(ClickEvent event) {
278
                if(isFilePrivatelyShared()) {
279
                    // ignore the click, set it always to "checked"
280
                    privateCheckBox.setValue(true);
281
                    // show permissions
282
                    privatePermPanel.setVisible(true);
283
                }
284
                else {
285
                    // This is the value *after* the click is applied :)
286
                    boolean isChecked = privateCheckBox.getValue();
287
                    privatePermPanel.setVisible(isChecked);
288
                }
289
            }
290
        });
291

    
292
        privateCheckPanel.add(privateCheckBox);
293
        privateCheckPanel.add(privateCheckTitle);
294
        privateCheckPanel.add(privateCheckInfo);
295

    
296
        // Permission list
297
        permList = new PermissionsList(app, privateSharingImages, file.getPermissions(), file.getOwnerID(), false, new Command() {
298
            @Override
299
            public void execute() {
300
                updateMetaDataForPrivateSharing();
301
            }
302
        });
303

    
304
        // Permission Add buttons
305
        Button addUser = new Button("Add User", new ClickHandler() {
306
            @Override
307
            public void onClick(ClickEvent event) {
308
                PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, true);
309
                dlg.center();
310
                permList.updatePermissionTable();
311
            }
312
        });
313
        addUser.addStyleName("button");
314
        permButtons.add(addUser);
315

    
316
        final boolean haveGroups = app.getAccount().getGroups().size() > 0;
317

    
318
        if(haveGroups) {
319
            Button addGroup = new Button("Add Group", new ClickHandler() {
320
                @Override
321
                public void onClick(ClickEvent event) {
322
                    PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
323
                    dlg.center();
324
                    permList.updatePermissionTable();
325
                }
326
            });
327
            addGroup.addStyleName("button");
328

    
329
            permButtons.add(addGroup);
330
            permButtons.setCellHorizontalAlignment(addGroup, HasHorizontalAlignment.ALIGN_CENTER);
331
        }
332

    
333
        final Button addEverybody = new Button("Add everybody", new ClickHandler() {
334
            @Override
335
            public void onClick(ClickEvent event) {
336
                Pithos.LOG("Adding to Everybody");
337
                Pithos.LOG("");
338
                permList.addPermission("*", true, false);
339
                permList.updatePermissionTable();
340
            }
341
        });
342
        addEverybody.addStyleName("button");
343
        permButtons.add(addEverybody);
344

    
345
        privatePermPanel.add(permList);
346
        privatePermPanel.add(permButtons);
347

    
348
        // Private Link
349
        privatePathPanel.setVisible(false);
350
        privatePathPanel.setWidth(Const.PERCENT_100);
351
        privatePathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
352
        privatePathPanel.add(new Label(Const.TXT_PRIVATE_LINK));
353
        privatePathPanel.setSpacing(8);
354
        privatePathPanel.addStyleName("pithos-TabPanelBottom");
355

    
356
        privatePathText.setWidth(Const.PERCENT_100);
357

    
358
        privatePathText.addClickHandler(new ClickHandler() {
359
            @Override
360
            public void onClick(ClickEvent event) {
361
                Pithos.enableIESelection();
362
                ((TextBox) event.getSource()).selectAll();
363
                Pithos.preventIESelection();
364
            }
365
        });
366
        privatePathText.setText(Window.Location.getHost() + file.getPublicUri());
367
        privatePathText.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");
368
        privatePathText.setWidth(Const.PERCENT_100);
369
        privatePathText.setReadOnly(true);
370
        privatePathPanel.add(privatePathText);
371

    
372
        Scheduler.get().scheduleDeferred(new Command() {
373
            @Override
374
            public void execute() {
375
                showLinkForPrivateSharing();
376
            }
377
        });
378

    
379
        privateSharingPanel.add(privateCheckPanel);
380
        privateSharingPanel.add(privatePermPanel);
381
        privateSharingPanel.add(privatePathPanel);
382
    }
383

    
384
    private Panel createMainPanel() {
385
        VerticalPanel panelAll = new VerticalPanel();
386
        VerticalPanel panelPublic = new VerticalPanel();
387
        VerticalPanel panelPrivate = new VerticalPanel();
388

    
389
        populatePrivateSharingPanel(panelPrivate);
390
        populatePublicSharingPanel(panelPublic);
391

    
392
        panelAll.add(panelPrivate);
393
        panelAll.add(new InlineHTML("<hr/>"));
394
        panelAll.add(panelPublic);
395

    
396
        return panelAll;
397
    }
398

    
399
    private boolean isFilePubliclyShared() {
400
        return file.isPublished();
401
    }
402

    
403
    private boolean isFilePrivatelyShared() {
404
        return file.isShared();
405
    }
406

    
407
    private void showLinkForPublicSharing() {
408
                if (isFilePubliclyShared()) {
409
                        UrlBuilder b = Window.Location.createUrlBuilder();
410
                        b.setPath(file.getPublicUri());
411
                        publicPathText.setText(b.buildString());
412
                publicPathPanel.setVisible(true);
413
                }
414
                else {
415
                        publicPathPanel.setVisible(false);
416
                }
417
    }
418

    
419
    private void showLinkForPrivateSharing() {
420
        if (isFilePrivatelyShared()) {
421
            UrlBuilder b = Window.Location.createUrlBuilder();
422
            b.setPath(app.getApiPath() + file.getOwnerID() + file.getUri());
423
            String href = Window.Location.getHref();
424
            boolean hasParameters = href.contains(Const.QUESTION_MARK);
425
            privatePathText.setText(href + (hasParameters ? Const.AMPERSAND : Const.QUESTION_MARK) + Const.GOTO_EQ + b.buildString());
426
            privatePathPanel.setVisible(true);
427
        }
428
        else {
429
            privatePathPanel.setVisible(false);
430
        }
431
    }
432

    
433
        protected void updateMetaDataForPublicSharing(String api, String owner, final String path, final Boolean published) {
434
        if (published != null) {
435
            PostRequest updateFile = new PostRequest(api, owner, path) {
436
                @Override
437
                public void onSuccess(Resource result) {
438
                        HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwnerID(), path, file) {
439

    
440
                                                @Override
441
                                                public void onSuccess(File _result) {
442
                                                        showLinkForPublicSharing();
443
                                                        if (!app.isMySharedSelected()) {
444
                                            app.updateFolder(file.getParent(), true, new Command() {
445
                                                                        
446
                                                                        @Override
447
                                                                        public void execute() {
448
                                                                                app.updateMySharedRoot();
449
                                                                        }
450
                                                                }, true);
451
                            }
452
                                                        else {
453
                                                                app.updateSharedFolder(file.getParent(), true);
454
                            }
455
                                                }
456

    
457
                                                @Override
458
                                                public void onError(Throwable t) {
459
                                                        app.setError(t);
460
                                    app.displayError("System error modifying file:" + t.getMessage());
461
                                                }
462

    
463
                                                @Override
464
                                                protected void onUnauthorized(Response response) {
465
                                                        app.sessionExpired();
466
                                                }
467
                                        };
468
                                        headFile.setHeader(Const.X_AUTH_TOKEN, app.getUserToken());
469
                                        Scheduler.get().scheduleDeferred(headFile);
470
                }
471

    
472
                @Override
473
                public void onError(Throwable t) {
474
                                        app.setError(t);
475
                    app.displayError("System error modifying file:" + t.getMessage());
476
                }
477

    
478
                                @Override
479
                                protected void onUnauthorized(Response response) {
480
                                        app.sessionExpired();
481
                                }
482
            };
483
            updateFile.setHeader(Const.X_AUTH_TOKEN, app.getUserToken());
484
            updateFile.setHeader(Const.X_OBJECT_PUBLIC, published.toString());
485
            Scheduler.get().scheduleDeferred(updateFile);
486
        }
487
        else if (!app.isMySharedSelected())
488
            app.updateFolder(file.getParent(), true, new Command() {
489
                                @Override
490
                                public void execute() {
491
                                        if (file.isSharedOrPublished()) {
492
                        app.updateMySharedRoot();
493
                    }
494
                                }
495
                        }, true);
496
        else
497
                app.updateSharedFolder(file.getParent(), true);
498
    }
499
    protected void updateMetaDataForPublicSharing(Boolean published) {
500
        updateMetaDataForPublicSharing(
501
            app.getApiPath(),
502
            app.getUserID(),
503
            file.getUri() + Const.QUESTION_MARK_UPDATE_EQ,
504
            published
505
        );
506
    }
507

    
508
    protected void updateMetaDataForPrivateSharing(String api, String owner, final String path, final Map<String, Boolean[]> newPermissions) {
509
        if (newPermissions != null) {
510
            PostRequest updateFile = new PostRequest(api, owner, path) {
511
                @Override
512
                public void onSuccess(Resource result) {
513
                    HeadRequest<File> headFile = new HeadRequest<File>(File.class, app.getApiPath(), file.getOwnerID(), path, file) {
514

    
515
                        @Override
516
                        public void onSuccess(File _result) {
517
                            showLinkForPrivateSharing();
518
                            if (!app.isMySharedSelected())
519
                                app.updateFolder(file.getParent(), true, new Command() {
520

    
521
                                    @Override
522
                                    public void execute() {
523
                                        app.updateMySharedRoot();
524
                                    }
525
                                }, true);
526
                            else
527
                                app.updateSharedFolder(file.getParent(), true);
528
                        }
529

    
530
                        @Override
531
                        public void onError(Throwable t) {
532
                            app.setError(t);
533
                            app.displayError("System error modifying file:" + t.getMessage());
534
                        }
535

    
536
                        @Override
537
                        protected void onUnauthorized(Response response) {
538
                            app.sessionExpired();
539
                        }
540
                    };
541
                    headFile.setHeader(Const.X_AUTH_TOKEN, app.getUserToken());
542
                    Scheduler.get().scheduleDeferred(headFile);
543
                }
544

    
545
                @Override
546
                public void onError(Throwable t) {
547
                    app.setError(t);
548
                    app.displayError("System error modifying file:" + t.getMessage());
549
                }
550

    
551
                @Override
552
                protected void onUnauthorized(Response response) {
553
                    app.sessionExpired();
554
                }
555
            };
556
            updateFile.setHeader(Const.X_AUTH_TOKEN, app.getUserToken());
557

    
558
            String readPermHeader = Const.READ_EQ;
559
            String writePermHeader = Const.WRITE_EQ;
560
            for (String u : newPermissions.keySet()) {
561
                Boolean[] p = newPermissions.get(u);
562
                if (p[0] != null && p[0]) {
563
                    readPermHeader += u + Const.COMMA;
564
                }
565
                if (p[1] != null && p[1]) {
566
                    writePermHeader += u + Const.COMMA;
567
                }
568
            }
569
            if (readPermHeader.endsWith(Const.EQ)) {
570
                readPermHeader = "";
571
            }
572
            else if (readPermHeader.endsWith(Const.COMMA)) {
573
                readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);
574
            }
575
            if (writePermHeader.endsWith(Const.EQ)) {
576
                writePermHeader = "";
577
            }
578
            else if (writePermHeader.endsWith(Const.COMMA)) {
579
                writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);
580
            }
581
            String permHeader = readPermHeader +
582
                ((readPermHeader.length()  > 0 && writePermHeader.length() > 0) ?  Const.SEMI : "") + writePermHeader;
583
            if (permHeader.length() == 0) {
584
                permHeader=Const.TILDE;
585
            }
586
            else {
587
                permHeader = URL.encodePathSegment(permHeader);
588
            }
589
            updateFile.setHeader(Const.X_OBJECT_SHARING, permHeader);
590
            Scheduler.get().scheduleDeferred(updateFile);
591
        }
592
        else if (!app.isMySharedSelected()) {
593
            app.updateFolder(file.getParent(), true, new Command() {
594
                @Override
595
                public void execute() {
596
                    if (file.isSharedOrPublished())
597
                        app.updateMySharedRoot();
598
                }
599
            }, true);
600
        }
601
        else {
602
            app.updateSharedFolder(file.getParent(), true);
603
        }
604
    }
605
    protected void updateMetaDataForPrivateSharing() {
606
        updateMetaDataForPrivateSharing(
607
            app.getApiPath(),
608
            app.getUserID(),
609
            file.getUri() + Const.QUESTION_MARK_UPDATE_EQ,
610
            permList.getPermissions()
611
        );
612
    }
613
    @Override
614
        protected void onPreviewNativeEvent(NativePreviewEvent preview) {
615
            super.onPreviewNativeEvent(preview);
616

    
617
            NativeEvent evt = preview.getNativeEvent();
618
            if (evt.getType().equals(Const.EVENT_TYPE_KEYDOWN) &&
619
            evt.getKeyCode() == KeyCodes.KEY_ENTER) {
620

    
621
            closeDialog();
622
        }
623
        }
624

    
625
    @Override
626
    protected boolean accept() {
627
        return true;
628
    }
629
}