Project

General

Profile

Revision de69ffd8

IDde69ffd8c36d72e685649bf2a1e8bf09c84dbbfa
Parent 2fe68f38
Child 80d9861f

Added by Patrick Plitzner 4 months ago

ref #8146 Restrict "add term wizard" by termType

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/TermChooseWizard.java
13 13

  
14 14
import org.eclipse.jface.wizard.Wizard;
15 15

  
16
import eu.etaxonomy.cdm.model.common.TermType;
16 17
import eu.etaxonomy.cdm.persistence.dto.TermDto;
17 18

  
18 19
/**
......
27 28

  
28 29
	private List<TermDto> selectedTerms;
29 30

  
30
	public TermChooseWizard(){
31
    private TermType termType;
32

  
33
	public TermChooseWizard(TermType termType){
34
	    this.termType = termType;
31 35
	}
32 36

  
33 37
    public List<TermDto> getSelectedTerms() {
......
36 40

  
37 41
	@Override
38 42
	public void addPages() {
39
		page = new TermChooseWizardPage();
43
		page = new TermChooseWizardPage(termType);
40 44
		addPage(page);
41 45
	}
42 46

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/TermChooseWizardPage.java
30 30
public class TermChooseWizardPage extends WizardPage {
31 31

  
32 32
    private TermSearchController controller;
33
    private TermType termType;
33 34

  
34
	protected TermChooseWizardPage() {
35
	protected TermChooseWizardPage(TermType termType) {
35 36
		super("Term Choose Wizard");
36 37
		setTitle("Term Choose Wizard");
37 38
		setDescription("Please search and select the terms you want to add to the tree.");
39
		this.termType = termType;
38 40
	}
39 41

  
40 42
	@Override
41 43
	public void createControl(Composite parent) {
42 44
        SearchComposite searchComposite = new SearchComposite(parent, SWT.NONE);
43
        controller = new TermSearchController(searchComposite, TermType.Feature);
45
        controller = new TermSearchController(searchComposite, termType);
44 46
		setControl(searchComposite);
45 47
	}
46 48

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AddChildFeatureHandler.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.featuretree.e4.handler;
10 10

  
11
import java.util.Collection;
11
import java.util.List;
12 12

  
13 13
import javax.inject.Named;
14 14

  
......
24 24
import org.eclipse.jface.wizard.WizardDialog;
25 25
import org.eclipse.swt.widgets.Shell;
26 26

  
27
import eu.etaxonomy.cdm.model.description.Feature;
28 27
import eu.etaxonomy.cdm.model.description.FeatureNode;
29
import eu.etaxonomy.taxeditor.featuretree.AvailableFeaturesWizard;
28
import eu.etaxonomy.cdm.persistence.dto.TermDto;
29
import eu.etaxonomy.taxeditor.featuretree.TermChooseWizard;
30 30
import eu.etaxonomy.taxeditor.featuretree.e4.IFeatureTreeEditor;
31 31
import eu.etaxonomy.taxeditor.featuretree.e4.operation.AddFeatureOperation;
32 32
import eu.etaxonomy.taxeditor.model.AbstractUtility;
......
48 48
        if (StoreUtil.promptCheckIsDirty(editor)) {
49 49
            return;
50 50
        }
51
        FeatureNode parent = (FeatureNode)selection.getFirstElement();
51 52

  
52
        AvailableFeaturesWizard wizard = new AvailableFeaturesWizard();
53
        TermChooseWizard wizard = new TermChooseWizard(parent.getTermType());
53 54
        WizardDialog dialog = new WizardDialog(shell, wizard);
54 55

  
55
        Object next = selection.getFirstElement();
56
        if (dialog.open() == IStatus.OK && next instanceof FeatureNode) {
57
            FeatureNode parent = (FeatureNode)next;
58
            Collection<Feature> additionalFeatures = wizard.getAdditionalFeatures();
59
            for (Feature feature : additionalFeatures) {
60
                AddFeatureOperation operation = new AddFeatureOperation(feature.getUuid(), parent, editor, editor);
56
        if (dialog.open() == IStatus.OK) {
57
            List<TermDto> selectedTerms = wizard.getSelectedTerms();
58
            for (TermDto termDto: selectedTerms) {
59
                AddFeatureOperation operation = new AddFeatureOperation(termDto.getUuid(), parent, editor, editor);
61 60
                AbstractUtility.executeOperation(operation, sync);
62 61
            }
63 62
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/handler/AddFeatureHandler.java
44 44
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
45 45
            @Named(IServiceConstants.ACTIVE_PART)MPart thisPart, UISynchronize sync) {
46 46
        IFeatureTreeEditor editor = ((IFeatureTreeEditor) thisPart.getObject());
47

  
48 47
        if (StoreUtil.promptCheckIsDirty(editor)) {
49 48
            return;
50 49
        }
50
        FeatureTree tree = (FeatureTree) selection.getFirstElement();
51 51

  
52

  
53
        TermChooseWizard wizard = new TermChooseWizard();
54
        //      AvailableFeaturesWizard wizard = new AvailableFeaturesWizard();
52
        TermChooseWizard wizard = new TermChooseWizard(tree.getTermType());
55 53
        WizardDialog dialog = new WizardDialog(shell, wizard);
56 54

  
57 55
        if (dialog.open() == IStatus.OK) {
58
            FeatureTree tree = (FeatureTree) selection.getFirstElement();
59 56
            List<TermDto> selectedTerms = wizard.getSelectedTerms();
60 57
            for (TermDto termDto: selectedTerms) {
61 58
                AddFeatureOperation operation = new AddFeatureOperation(termDto.getUuid(), tree.getRoot(), editor, editor);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)