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
.jface
.dialogs
.InputDialog
;
17 import org
.eclipse
.jface
.window
.Window
;
18 import org
.eclipse
.swt
.events
.SelectionAdapter
;
19 import org
.eclipse
.swt
.events
.SelectionEvent
;
20 import org
.eclipse
.swt
.events
.SelectionListener
;
21 import org
.eclipse
.swt
.widgets
.Shell
;
23 import eu
.etaxonomy
.cdm
.api
.service
.IFeatureTreeService
;
24 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
25 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
26 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
31 * @created Sep 17, 2010
34 public class FeatureTreeSelectionDialog
extends
35 AbstractFilteredCdmResourceSelectionDialog
<FeatureTree
> {
37 public static FeatureTree
select(Shell shell
, //ConversationHolder conversation,
38 FeatureTree featureTree
) {
39 FeatureTreeSelectionDialog dialog
= new FeatureTreeSelectionDialog(shell
, //conversation,
40 "Choose a feature tree", false, featureTree
);
41 return getSelectionFromDialog(dialog
);
44 protected FeatureTreeSelectionDialog(Shell shell
,//ConversationHolder conversation,
45 String title
, boolean multi
,
46 FeatureTree cdmObject
) {
47 super(shell
, //conversation,
48 title
, multi
, FeatureTreeSelectionDialog
.class.getCanonicalName(), cdmObject
);
53 protected FeatureTree
getPersistentObject(UUID uuid
) {
54 return CdmStore
.getService(IFeatureTreeService
.class).load(uuid
);
59 protected void search() {
60 List
<FeatureTree
> featureTrees
= CdmStore
.getService(IFeatureTreeService
.class).list(FeatureTree
.class, null, null, null, null);
63 model
= new ArrayList
<UuidAndTitleCache
<FeatureTree
>>();
66 for(FeatureTree featureTree
: featureTrees
){
67 UuidAndTitleCache
<FeatureTree
> element
= new UuidAndTitleCache
<FeatureTree
>(FeatureTree
.class, featureTree
.getUuid(),featureTree
.getId(), featureTree
.getTitleCache());
73 protected SelectionListener
getNewWizardButtonSelectionListener(){
74 return new SelectionAdapter() {
77 public void widgetSelected(SelectionEvent e
) {
78 InputDialog dialog
= new InputDialog(getShell(), "Feature tree label", "Enter label for feature tree", null, null);
79 if (dialog
.open() == Window
.OK
) {
80 // User clicked OK; update the label with the input
81 FeatureTree tree
= FeatureTree
.NewInstance();
82 CdmStore
.getService(IFeatureTreeService
.class).merge(tree
,true);
83 tree
.setTitleCache(dialog
.getValue(), true);
93 protected String
[] getNewWizardText() {
94 return new String
[]{ "Feature tree "};
100 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {