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
.dialog
.selection
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.jface
.wizard
.WizardDialog
;
19 import org
.eclipse
.swt
.SWT
;
20 import org
.eclipse
.swt
.widgets
.Composite
;
21 import org
.eclipse
.swt
.widgets
.Control
;
22 import org
.eclipse
.swt
.widgets
.Event
;
23 import org
.eclipse
.swt
.widgets
.Link
;
24 import org
.eclipse
.swt
.widgets
.Listener
;
25 import org
.eclipse
.swt
.widgets
.Shell
;
27 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
28 import eu
.etaxonomy
.cdm
.api
.service
.IFeatureTreeService
;
29 import eu
.etaxonomy
.cdm
.model
.common
.UuidAndTitleCache
;
30 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
31 import eu
.etaxonomy
.taxeditor
.featuretree
.FeatureTreeEditorWizard
;
32 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
33 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
36 * <p>FilteredFeatureTreeSelectionDialog class.</p>
39 * @created Sep 17, 2010
42 public class FeatureTreeSelectionDialog
extends
43 AbstractFilteredCdmResourceSelectionDialog
<FeatureTree
> {
46 * Creates a filtered selection dialog to select a named area.
49 * The shell for displaying this widget
50 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
51 * @param featureTree a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
52 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
54 public static FeatureTree
select(Shell shell
, ConversationHolder conversation
, FeatureTree featureTree
) {
55 FeatureTreeSelectionDialog dialog
= new FeatureTreeSelectionDialog(shell
, conversation
,
56 "Choose a feature tree", false, featureTree
);
57 return getSelectionFromDialog(dialog
);
61 * <p>Constructor for FilteredFeatureTreeSelectionDialog.</p>
63 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
64 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
65 * @param title a {@link java.lang.String} object.
66 * @param multi a boolean.
67 * @param cdmObject a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
69 protected FeatureTreeSelectionDialog(Shell shell
,
70 ConversationHolder conversation
, String title
, boolean multi
,
71 FeatureTree cdmObject
) {
72 super(shell
, conversation
, title
, multi
, FeatureTreeSelectionDialog
.class.getCanonicalName(), cdmObject
);
76 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
80 protected FeatureTree
getPersistentObject(UUID uuid
) {
81 return CdmStore
.getService(IFeatureTreeService
.class).load(uuid
);
85 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
89 protected void initModel() {
90 List
<FeatureTree
> featureTrees
= CdmStore
.getService(IFeatureTreeService
.class).list(FeatureTree
.class, null, null, null, null);
93 model
= new ArrayList
<UuidAndTitleCache
<FeatureTree
>>();
96 for(FeatureTree featureTree
: featureTrees
){
97 UuidAndTitleCache
<FeatureTree
> element
= new UuidAndTitleCache
<FeatureTree
>(FeatureTree
.class, featureTree
.getUuid(), featureTree
.getTitleCache());
103 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
107 protected Control
createExtendedContentArea(Composite parent
) {
108 Link link
= new Link(parent
, SWT
.NONE
);
109 link
.setText(getNewWizardLinkText());
110 link
.addListener (SWT
.Selection
, new Listener () {
111 public void handleEvent(Event event
) {
113 FeatureTreeEditorWizard wizard
= new FeatureTreeEditorWizard();
114 WizardDialog dialog
= new WizardDialog(getShell(), wizard
);
115 int status
= dialog
.open();
117 if (status
== IStatus
.OK
) {
126 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
130 protected String
getNewWizardLinkText() {
131 return "Click <A>here</A> to create or edit a feature tree.";
135 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewEntityWizard()
139 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {