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
.swt
.widgets
.Shell
;
18 import eu
.etaxonomy
.cdm
.api
.service
.IFeatureTreeService
;
19 import eu
.etaxonomy
.cdm
.model
.description
.FeatureTree
;
20 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
21 import eu
.etaxonomy
.taxeditor
.newWizard
.AbstractNewEntityWizard
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 * @created Sep 17, 2010
29 public class FeatureTreeSelectionDialog
extends
30 AbstractFilteredCdmResourceSelectionDialog
<FeatureTree
> {
32 public static FeatureTree
select(Shell shell
, //ConversationHolder conversation,
33 FeatureTree featureTree
) {
34 FeatureTreeSelectionDialog dialog
= new FeatureTreeSelectionDialog(shell
, //conversation,
35 "Choose a feature tree", false, featureTree
);
36 return getSelectionFromDialog(dialog
);
39 protected FeatureTreeSelectionDialog(Shell shell
,//ConversationHolder conversation,
40 String title
, boolean multi
,
41 FeatureTree cdmObject
) {
42 super(shell
, //conversation,
43 title
, multi
, FeatureTreeSelectionDialog
.class.getCanonicalName(), cdmObject
);
48 protected FeatureTree
getPersistentObject(UUID uuid
) {
49 return CdmStore
.getService(IFeatureTreeService
.class).load(uuid
);
54 protected void callService(String pattern
) {
55 List
<FeatureTree
> featureTrees
= CdmStore
.getService(IFeatureTreeService
.class).list(FeatureTree
.class, null, null, null, null);
58 model
= new ArrayList
<UuidAndTitleCache
<FeatureTree
>>();
61 for(FeatureTree featureTree
: featureTrees
){
62 UuidAndTitleCache
<FeatureTree
> element
= new UuidAndTitleCache
<FeatureTree
>(FeatureTree
.class, featureTree
.getUuid(),featureTree
.getId(), featureTree
.getTitleCache());
63 if (element
.getTitleCache().matches(pattern
)) {
70 // /** {@inheritDoc} */
72 // protected Control createExtendedContentArea(Composite parent) {
73 // Link link = new Link(parent, SWT.NONE);
74 // link.setText(getNewWizardLinkText());
75 // link.addListener (SWT.Selection, new Listener () {
77 // public void handleEvent(Event event) {
79 // InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
80 // int status = input.open();
81 // if (status == IStatus.OK) {
82 // String label = input.getValue();
84 // FeatureTree featureTree = FeatureTree.NewInstance();
85 // featureTree.setTitleCache(label, false);
86 // CdmStore.getService(IFeatureTreeService.class).save(featureTree);
87 // UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
88 // model.add(uuidAndTitleCache);
89 // setPattern(featureTree);
99 protected String
[] getNewWizardText() {
100 return new String
[]{ "New Feature tree"};
106 protected AbstractNewEntityWizard
getNewEntityWizard(String parameter
) {