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
.openurl
;
11 import org
.eclipse
.core
.runtime
.IStatus
;
12 import org
.eclipse
.jface
.wizard
.WizardDialog
;
13 import org
.eclipse
.swt
.SWT
;
14 import org
.eclipse
.swt
.events
.SelectionEvent
;
15 import org
.eclipse
.swt
.events
.SelectionListener
;
16 import org
.eclipse
.swt
.widgets
.Button
;
17 import org
.eclipse
.swt
.widgets
.Label
;
19 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
21 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractCdmFormElement
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
28 * @created Jan 31, 2011
30 public class OpenUrlSelectorElement
extends AbstractCdmFormElement
implements SelectionListener
{
32 private Button button
;
34 private Reference reference
;
36 private String referenceDetail
;
38 private IOpenUrlEnabled openUrlEnabled
;
42 * @param parentElement
48 public OpenUrlSelectorElement(CdmFormFactory formFactory
,
49 ICdmFormElement parentElement
, String labelString
, IOpenUrlEnabled openUrlEnabled
, int style
) {
50 super(formFactory
, parentElement
);
51 this.openUrlEnabled
= openUrlEnabled
;
53 Label label
= formFactory
.createLabel(getLayoutComposite(), null);
56 button
= formFactory
.createButton(getLayoutComposite(), labelString
, SWT
.PUSH
);
57 button
.setLayoutData(LayoutConstants
.RIGHT());
59 button
.addSelectionListener(this);
63 public void widgetSelected(SelectionEvent e
) {
64 if(openUrlEnabled
.getReference() == null){
65 MessagingUtils
.warningDialog("No reference", getClass(), "The given reference is empty");
69 OpenUrlSelectorWizard wizard
= new OpenUrlSelectorWizard(openUrlEnabled
.getReference(), openUrlEnabled
.getDetail());
71 WizardDialog dialog
= new WizardDialog(getLayoutComposite().getShell(), wizard
);
73 if(dialog
.open() == IStatus
.OK
){
74 openUrlEnabled
.setOpenUrl(wizard
.getOpenUrlReference().getUri());
78 public String
getDetail() {
79 return referenceDetail
;
82 public void setDetail(String referenceDetail
){
83 this.referenceDetail
= referenceDetail
;
87 public void widgetDefaultSelected(SelectionEvent e
) {}
89 public void setReference(Reference reference
) {
90 this.reference
= reference
;
93 public Reference
getReference() {