3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.editor
.images
;
13 import java
.net
.MalformedURLException
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.eclipse
.jface
.dialogs
.IInputValidator
;
18 import org
.eclipse
.jface
.dialogs
.InputDialog
;
19 import org
.eclipse
.jface
.window
.Window
;
20 import org
.eclipse
.swt
.widgets
.Shell
;
22 import eu
.etaxonomy
.taxeditor
.controller
.GlobalController
;
29 public class UrlDialog
extends InputDialog
{
30 private static final Logger logger
= Logger
.getLogger(UrlDialog
.class);
36 * @param dialogMessage
40 private UrlDialog(Shell parentShell
, String dialogTitle
,
41 String dialogMessage
) {
42 super(parentShell
, dialogTitle
,
43 dialogMessage
, "http://", new IInputValidator() {
45 public String
isValid(String text
) {
49 } catch (MalformedURLException e
) {
50 return "URL not correctly formed.";
53 if (text
.length() <= "http://".length()) {
62 private URL
getUrl() {
65 url
= new URL(getValue());
66 } catch (MalformedURLException e
) {
67 // TODO Auto-generated catch block
73 public static URL
getUrl(String dialogTitle
,
74 String dialogMessage
) {
75 UrlDialog dialog
= new UrlDialog(GlobalController
.getShell(),
78 if (dialog
.open() == Window
.CANCEL
) {
81 return dialog
.getUrl();