3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.forms
.openurl
;
13 import org
.eclipse
.core
.runtime
.IStatus
;
14 import org
.eclipse
.jface
.wizard
.WizardDialog
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.events
.SelectionEvent
;
17 import org
.eclipse
.swt
.events
.SelectionListener
;
18 import org
.eclipse
.swt
.widgets
.Button
;
19 import org
.eclipse
.swt
.widgets
.Label
;
21 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
22 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
23 import eu
.etaxonomy
.taxeditor
.forms
.AbstractCdmFormElement
;
24 import eu
.etaxonomy
.taxeditor
.forms
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.forms
.ICdmFormElement
;
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(CdmFormFactory
.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 OpenUrlSelectorWizard wizard
= new OpenUrlSelectorWizard(openUrlEnabled
.getReference(), openUrlEnabled
.getDetail());
71 WizardDialog dialog
= new WizardDialog(EditorUtil
.getShell(), wizard
);
73 if(dialog
.open() == IStatus
.OK
){
74 openUrlEnabled
.setOpenUrl(wizard
.getOpenUrlReferenceImageUri());
81 private String
getDetail() {
82 return referenceDetail
;
85 public void setDetail(String referenceDetail
){
86 this.referenceDetail
= referenceDetail
;
90 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
93 public void widgetDefaultSelected(SelectionEvent e
) {}
96 * @param reference the reference to set
98 public void setReference(Reference reference
) {
99 this.reference
= reference
;
103 * @return the reference
105 public Reference
getReference() {
110 * @see eu.etaxonomy.taxeditor.forms.ISelectable#setSelected(boolean)
113 public void setSelected(boolean selected
) {