2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.ui
.dialog
;
13 import java
.net
.URISyntaxException
;
15 import org
.eclipse
.jface
.dialogs
.IInputValidator
;
16 import org
.eclipse
.jface
.dialogs
.InputDialog
;
17 import org
.eclipse
.jface
.window
.Window
;
18 import org
.eclipse
.swt
.widgets
.Shell
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
23 * <p>UriDialog class.</p>
29 * TODO make this extend TitleAreaDialog
31 public class UriDialog
extends InputDialog
{
36 * @param dialogMessage
40 private UriDialog(Shell parentShell
, String dialogTitle
,
41 String dialogMessage
) {
42 super(parentShell
, dialogTitle
,
43 dialogMessage
, "http://", new IInputValidator() {
45 public String
isValid(String text
) {
49 } catch (URISyntaxException e
) {
50 return "URL not correctly formed.";
54 if (text
.length() <= "http://".length()) {
63 private URI
getUri() {
66 uri
= new URI(getValue());
67 } catch (URISyntaxException e
) {
68 MessagingUtils
.error(getClass(), e
);
76 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
77 * @param dialogTitle a {@link java.lang.String} object.
78 * @param dialogMessage a {@link java.lang.String} object.
79 * @return a {@link java.net.URI} object.
81 public static URI
getUri(Shell shell
, String dialogTitle
,
82 String dialogMessage
) {
83 UriDialog dialog
= new UriDialog(shell
,
86 if (dialog
.open() == Window
.CANCEL
) {
89 return dialog
.getUri();