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
.dialog
.selection
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.jface
.wizard
.WizardDialog
;
18 import org
.eclipse
.swt
.SWT
;
19 import org
.eclipse
.swt
.widgets
.Composite
;
20 import org
.eclipse
.swt
.widgets
.Control
;
21 import org
.eclipse
.swt
.widgets
.Event
;
22 import org
.eclipse
.swt
.widgets
.Link
;
23 import org
.eclipse
.swt
.widgets
.Listener
;
24 import org
.eclipse
.swt
.widgets
.Shell
;
26 import eu
.etaxonomy
.cdm
.api
.conversation
.ConversationHolder
;
27 import eu
.etaxonomy
.cdm
.api
.service
.IFeatureTreeService
;
28 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
29 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
30 import eu
.etaxonomy
.taxeditor
.featuretree
.FeatureTreeEditorWizard
;
31 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
32 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
35 * <p>FilteredFeatureTreeSelectionDialog class.</p>
38 * @created Sep 17, 2010
41 public class FeatureTreeSelectionDialog
extends
42 AbstractFilteredCdmResourceSelectionDialog
<FeatureTree
> {
45 * Creates a filtered selection dialog to select a named area.
48 * The shell for displaying this widget
49 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
50 * @param featureTree a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
51 * @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
53 public static FeatureTree
select(Shell shell
, ConversationHolder conversation
, FeatureTree featureTree
) {
54 FeatureTreeSelectionDialog dialog
= new FeatureTreeSelectionDialog(shell
, conversation
,
55 "Choose a feature tree", false, featureTree
);
56 return getSelectionFromDialog(dialog
);
60 * <p>Constructor for FilteredFeatureTreeSelectionDialog.</p>
62 * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
63 * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
64 * @param title a {@link java.lang.String} object.
65 * @param multi a boolean.
66 * @param cdmObject a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
68 protected FeatureTreeSelectionDialog(Shell shell
,
69 ConversationHolder conversation
, String title
, boolean multi
,
70 FeatureTree cdmObject
) {
71 super(shell
, conversation
, title
, multi
, FeatureTreeSelectionDialog
.class.getCanonicalName(), cdmObject
);
75 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getPersistentObject(java.util.UUID)
79 protected FeatureTree
getPersistentObject(UUID uuid
) {
80 return CdmStore
.getService(IFeatureTreeService
.class).load(uuid
);
84 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#initModel()
88 protected void initModel() {
89 List
<FeatureTree
> featureTrees
= CdmStore
.getService(IFeatureTreeService
.class).list(FeatureTree
.class, null, null, null, null);
92 model
= new ArrayList
<UuidAndTitleCache
<FeatureTree
>>();
95 for(FeatureTree featureTree
: featureTrees
){
96 UuidAndTitleCache
<FeatureTree
> element
= new UuidAndTitleCache
<FeatureTree
>(FeatureTree
.class, featureTree
.getUuid(),featureTree
.getId(), featureTree
.getTitleCache());
102 * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
106 protected Control
createExtendedContentArea(Composite parent
) {
107 Link link
= new Link(parent
, SWT
.NONE
);
108 link
.setText(getNewWizardLinkText());
109 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
) {
127 protected String
getNewWizardLinkText() {
128 return String
.format("Create a new <a>%1s</a>" , "Feature tree ");
134 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {