Revision 191f2328
Added by Patrick Plitzner almost 9 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/UriWithLabelElement.java | ||
---|---|---|
11 | 11 |
package eu.etaxonomy.taxeditor.ui.element; |
12 | 12 |
|
13 | 13 |
import java.net.URI; |
14 |
import java.net.URISyntaxException; |
|
15 |
|
|
16 | 14 |
|
15 |
import org.eclipse.swt.SWT; |
|
16 |
import org.eclipse.swt.widgets.Label; |
|
17 | 17 |
|
18 | 18 |
/** |
19 | 19 |
* @author n.hoffmann |
... | ... | |
22 | 22 |
*/ |
23 | 23 |
public class UriWithLabelElement extends TextWithLabelElement { |
24 | 24 |
|
25 |
/** |
|
26 |
* @param formFactory |
|
27 |
* @param parentElement |
|
28 |
* @param labelString |
|
29 |
* @param initialText |
|
30 |
* @param textHeight |
|
31 |
* @param style |
|
32 |
*/ |
|
25 |
private final Label labelException; |
|
26 |
|
|
33 | 27 |
protected UriWithLabelElement(CdmFormFactory formFactory, |
34 | 28 |
ICdmFormElement parentElement, String labelString, |
35 | 29 |
URI initialUri, Integer textHeight, int style) { |
36 | 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); |
|
37 | 35 |
setUri(initialUri); |
38 | 36 |
} |
39 | 37 |
|
40 |
/** |
|
41 |
* |
|
42 |
*/ |
|
43 | 38 |
public void setUri(URI uri) { |
44 | 39 |
if(uri != null){ |
45 | 40 |
super.setText(uri.toString()); |
46 | 41 |
} |
47 | 42 |
} |
48 | 43 |
|
49 |
public URI getUri() throws URISyntaxException{ |
|
50 |
if(super.getText()!=null){ |
|
51 |
return new URI(super.getText()); |
|
52 |
} |
|
53 |
return null; |
|
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 |
} |
|
54 | 52 |
} |
55 | 53 |
|
56 | 54 |
} |
Also available in: Unified diff
Show URI parsing exceptions below URI text field (fixes #5055, #5003, #4587)