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
.ui
.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
.store
.StoreUtil
;
23 import eu
.etaxonomy
.taxeditor
.ui
.element
.AbstractCdmFormElement
;
24 import eu
.etaxonomy
.taxeditor
.ui
.element
.CdmFormFactory
;
25 import eu
.etaxonomy
.taxeditor
.ui
.element
.ICdmFormElement
;
26 import eu
.etaxonomy
.taxeditor
.ui
.element
.LayoutConstants
;
30 * @created Jan 31, 2011
33 public class OpenUrlSelectorElement
extends AbstractCdmFormElement
implements SelectionListener
{
35 private Button button
;
37 private Reference reference
;
39 private String referenceDetail
;
41 private IOpenUrlEnabled openUrlEnabled
;
45 * @param parentElement
51 public OpenUrlSelectorElement(CdmFormFactory formFactory
,
52 ICdmFormElement parentElement
, String labelString
, IOpenUrlEnabled openUrlEnabled
, int style
) {
53 super(formFactory
, parentElement
);
54 this.openUrlEnabled
= openUrlEnabled
;
56 Label label
= formFactory
.createLabel(getLayoutComposite(), null);
59 button
= formFactory
.createButton(getLayoutComposite(), labelString
, SWT
.PUSH
);
60 button
.setLayoutData(LayoutConstants
.RIGHT());
62 button
.addSelectionListener(this);
66 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
69 public void widgetSelected(SelectionEvent e
) {
70 if(openUrlEnabled
.getReference() == null){
71 StoreUtil
.warningDialog("No reference", getClass(), "The given reference is empty");
75 OpenUrlSelectorWizard wizard
= new OpenUrlSelectorWizard(openUrlEnabled
.getReference(), openUrlEnabled
.getDetail());
77 WizardDialog dialog
= new WizardDialog(getLayoutComposite().getShell(), wizard
);
79 if(dialog
.open() == IStatus
.OK
){
80 openUrlEnabled
.setOpenUrl(wizard
.getOpenUrlReference().getUri());
87 public String
getDetail() {
88 return referenceDetail
;
91 public void setDetail(String referenceDetail
){
92 this.referenceDetail
= referenceDetail
;
96 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
99 public void widgetDefaultSelected(SelectionEvent e
) {}
102 * @param reference the reference to set
104 public void setReference(Reference reference
) {
105 this.reference
= reference
;
109 * @return the reference
111 public Reference
getReference() {