ee6867db2b3a57827f7e4f552affc3713903b1bc
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / element / UriWithLabelElement.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.ui.element;
12
13 import java.net.URI;
14
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.widgets.Label;
17
18 /**
19 * @author n.hoffmann
20 * @created Dec 20, 2010
21 * @version 1.0
22 */
23 public class UriWithLabelElement extends TextWithLabelElement {
24
25 private final Label labelException;
26
27 protected UriWithLabelElement(CdmFormFactory formFactory,
28 ICdmFormElement parentElement, String labelString,
29 URI initialUri, Integer textHeight, int style) {
30 super(formFactory, parentElement, labelString, null, textHeight, style);
31
32 labelException = formFactory.createLabel(getLayoutComposite(), "", SWT.WRAP);
33 labelException.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
34 addControl(labelException);
35 setUri(initialUri);
36 }
37
38 public void setUri(URI uri) {
39 if(uri != null){
40 super.setText(uri.toString());
41 }
42 }
43
44 public URI getUri(){
45 try {
46 labelException.setText("");
47 return new URI(super.getText());
48 } catch (Exception e) {
49 labelException.setText(e.getMessage());
50 return null;
51 }
52 }
53
54 }