Project

General

Profile

Download (2.88 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11

    
12
import java.util.UUID;
13

    
14
import org.eclipse.jface.dialogs.InputDialog;
15
import org.eclipse.jface.window.Window;
16
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionListener;
19
import org.eclipse.swt.widgets.Shell;
20

    
21
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
22
import eu.etaxonomy.cdm.model.description.FeatureTree;
23
import eu.etaxonomy.taxeditor.l10n.Messages;
24
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26

    
27
/**
28
 * @author n.hoffmann
29
 * @created Sep 17, 2010
30
 */
31
public class FeatureTreeSelectionDialog extends
32
		AbstractFilteredCdmResourceSelectionDialog<FeatureTree> {
33

    
34
	public static FeatureTree select(Shell shell,
35
	        FeatureTree featureTree) {
36
		FeatureTreeSelectionDialog dialog = new FeatureTreeSelectionDialog(shell,
37
				Messages.FeatureTreeSelectionDialog_CHOOSE_TREE, false, featureTree);
38
		return getSelectionFromDialog(dialog);
39
	}
40

    
41
	protected FeatureTreeSelectionDialog(Shell shell,
42
			 String title, boolean multi,
43
			FeatureTree cdmObject) {
44
		super(shell,
45
		        title, multi, FeatureTreeSelectionDialog.class.getCanonicalName(), cdmObject);
46
	}
47

    
48
	@Override
49
	protected FeatureTree getPersistentObject(UUID uuid) {
50
		return CdmStore.getService(IFeatureTreeService.class).load(uuid);
51
	}
52

    
53
	@Override
54
	protected void callService(String pattern) {
55
        model = CdmStore.getService(IFeatureTreeService.class).getUuidAndTitleCache(FeatureTree.class, limitOfInitialElements, pattern);
56
	}
57

    
58
	@Override
59
    protected SelectionListener getNewWizardButtonSelectionListener(){
60
        return new SelectionAdapter() {
61

    
62
            @Override
63
            public void widgetSelected(SelectionEvent e) {
64
                InputDialog dialog = new InputDialog(getShell(), Messages.FeatureTreeSelectionDialog_TREE_LABEL, Messages.FeatureTreeSelectionDialog_ENTER_LABEL, null, null);
65
                if (dialog.open() == Window.OK) {
66
                    // User clicked OK; update the label with the input
67
                    FeatureTree tree = FeatureTree.NewInstance();
68
                    CdmStore.getService(IFeatureTreeService.class).merge(tree,true);
69
                    tree.setTitleCache(dialog.getValue(), true);
70
                    refresh();
71
                    setPattern(tree);
72
                  }
73
            }
74
        };
75
    }
76

    
77
	@Override
78
	protected String[] getNewWizardText() {
79
		return new String[]{ Messages.FeatureTreeSelectionDialog_NEW_TREE};
80
	}
81

    
82
	@Override
83
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
84
		return null;
85
	}
86
}
(15-15/44)