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.
9 package eu
.etaxonomy
.taxeditor
.ui
.dialog
;
11 import eu
.etaxonomy
.cdm
.common
.URI
;
12 import java
.net
.URISyntaxException
;
14 import org
.eclipse
.jface
.dialogs
.IInputValidator
;
15 import org
.eclipse
.jface
.dialogs
.InputDialog
;
16 import org
.eclipse
.jface
.window
.Window
;
17 import org
.eclipse
.swt
.widgets
.Shell
;
19 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 * <p>UriDialog class.</p>
27 * TODO make this extend TitleAreaDialog
29 public class UriDialog
extends InputDialog
{
34 * @param dialogMessage
38 private UriDialog(Shell parentShell
, String dialogTitle
,
39 String dialogMessage
) {
40 super(parentShell
, dialogTitle
,
41 dialogMessage
, "http://", new IInputValidator() {
43 public String
isValid(String text
) {
47 } catch (URISyntaxException e
) {
48 return "URL not correctly formed.";
51 if (text
.length() <= "http://".length()) {
60 private URI
getUri() {
63 uri
= new URI(getValue());
64 } catch (URISyntaxException e
) {
65 MessagingUtils
.error(getClass(), e
);
73 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
74 * @param dialogTitle a {@link java.lang.String} object.
75 * @param dialogMessage a {@link java.lang.String} object.
76 * @return a {@link eu.etaxonomy.cdm.common.URI} object.
78 public static URI
getUri(Shell shell
, String dialogTitle
,
79 String dialogMessage
) {
80 UriDialog dialog
= new UriDialog(shell
,
83 if (dialog
.open() == Window
.CANCEL
) {
86 return dialog
.getUri();