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
.openurl
;
12 import org
.eclipse
.core
.runtime
.IStatus
;
13 import org
.eclipse
.jface
.wizard
.WizardDialog
;
14 import org
.eclipse
.swt
.SWT
;
15 import org
.eclipse
.swt
.events
.SelectionEvent
;
16 import org
.eclipse
.swt
.events
.SelectionListener
;
17 import org
.eclipse
.swt
.widgets
.Button
;
18 import org
.eclipse
.swt
.widgets
.Label
;
20 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractCdmFormElement
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
29 * @created Jan 31, 2011
32 public class OpenUrlSelectorElement
extends AbstractCdmFormElement
implements SelectionListener
{
34 private Button button
;
36 private Reference reference
;
38 private String referenceDetail
;
40 private IOpenUrlEnabled openUrlEnabled
;
44 * @param parentElement
50 public OpenUrlSelectorElement(CdmFormFactory formFactory
,
51 ICdmFormElement parentElement
, String labelString
, IOpenUrlEnabled openUrlEnabled
, int style
) {
52 super(formFactory
, parentElement
);
53 this.openUrlEnabled
= openUrlEnabled
;
55 Label label
= formFactory
.createLabel(getLayoutComposite(), null);
58 button
= formFactory
.createButton(getLayoutComposite(), labelString
, SWT
.PUSH
);
59 button
.setLayoutData(LayoutConstants
.RIGHT());
61 button
.addSelectionListener(this);
65 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
68 public void widgetSelected(SelectionEvent e
) {
69 if(openUrlEnabled
.getReference() == null){
70 MessagingUtils
.warningDialog("No reference", getClass(), "The given reference is empty");
74 OpenUrlSelectorWizard wizard
= new OpenUrlSelectorWizard(openUrlEnabled
.getReference(), openUrlEnabled
.getDetail());
76 WizardDialog dialog
= new WizardDialog(getLayoutComposite().getShell(), wizard
);
78 if(dialog
.open() == IStatus
.OK
){
79 openUrlEnabled
.setOpenUrl(wizard
.getOpenUrlReference().getUri());
86 public String
getDetail() {
87 return referenceDetail
;
90 public void setDetail(String referenceDetail
){
91 this.referenceDetail
= referenceDetail
;
95 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
98 public void widgetDefaultSelected(SelectionEvent e
) {}
101 * @param reference the reference to set
103 public void setReference(Reference reference
) {
104 this.reference
= reference
;
108 * @return the reference
110 public Reference
getReference() {