Project

General

Profile

Revision 5aeccadc

ID5aeccadc9ccec37d8617256e1a8d1bf0147d70d4
Parent 7ae437e8
Child 686d4023

Added by Katja Luther almost 2 years ago

e4 migration of selection dialogs

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AbstractFilteredCdmResourceSelectionDialog.java
10 10
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11 11

  
12 12
import java.text.Collator;
13
import java.util.ArrayList;
13 14
import java.util.Collections;
14 15
import java.util.Comparator;
15 16
import java.util.HashSet;
......
33 34
import org.eclipse.swt.events.SelectionEvent;
34 35
import org.eclipse.swt.events.SelectionListener;
35 36
import org.eclipse.swt.graphics.Cursor;
37
import org.eclipse.swt.widgets.Button;
36 38
import org.eclipse.swt.widgets.Composite;
37
import org.eclipse.swt.widgets.Control;
38
import org.eclipse.swt.widgets.Link;
39 39
import org.eclipse.swt.widgets.Shell;
40 40

  
41 41
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
......
228 228
    protected void fillContentProvider(IProgressMonitor progressMonitor)
229 229
		throws CoreException {
230 230
		try {
231
		    if (model == null){
232
		        model = new ArrayList<UuidAndTitleCache<T>>();
233
		    }
231 234
			if(model != null){
232 235
			    if (progressMonitor != null){
233 236
			        progressMonitor.beginTask("Looking for entities", model.size());
......
250 253
				}
251 254
				this.refresh();
252 255
			}else{
256

  
253 257
				MessagingUtils.warn(getClass(), "Model for Filtered Selection is null:" + this.getClass().getSimpleName());
254 258
			}
255 259
		}
......
348 352
	 *
349 353
	 * @return a {@link java.lang.String} object.
350 354
	 */
351
	protected abstract String getNewWizardLinkText();
355
	protected abstract String[] getNewWizardText();
352 356

  
353 357
	/**
354 358
	 * <p>getNewEntityWizard</p>
......
377 381
	*/
378 382
	/** {@inheritDoc} */
379 383

  
384
//	@Override
385
//    protected Control createExtendedContentArea(Composite parent) {
386
//		String newWizardLinkText = getNewWizardLinkText();
387
////        if(newWizardLinkText != null){
388
////            newButton1 = this.createButton(this.getShell(), new_id, newWizardLinkText, false);
389
////
390
////            newButton1.addSelectionListener(getNewWizardLinkSelectionListener());
391
////			return newButton1;
392
////		}
393
//		return null;
394
//	}
395

  
380 396
	@Override
381
    protected Control createExtendedContentArea(Composite parent) {
382
		String newWizardLinkText = getNewWizardLinkText();
383
        if(newWizardLinkText != null){
384
			Link link = new Link(parent, SWT.NONE);
385
			link.setText(newWizardLinkText);
386
			link.addSelectionListener(getNewWizardLinkSelectionListener());
387
			return link;
388
		}
389
		return null;
390
	}
397
    protected void createButtonsForButtonBar(Composite parent) {
398
	    String[] newButtonText = getNewWizardText();
399
	    if (newButtonText!= null){
400
	        this.newButton1 = createButton(parent, this.new_id, newButtonText[0], false);
401
	        newButton1.addSelectionListener(getNewWizardButtonSelectionListener());
402
	        if (newButtonText.length > 1){
403
	            newButton2 = createButton(parent, this.new_id2, newButtonText[1], false);
404
	            newButton2.addSelectionListener(getNewWizardButtonSelectionListener());
405
	        }
406
	    }
407

  
408
        super.createButtonsForButtonBar(parent);
409
    }
391 410

  
392
	protected SelectionListener getNewWizardLinkSelectionListener(){
411
	protected SelectionListener getNewWizardButtonSelectionListener(){
393 412
		return new SelectionAdapter() {
394 413

  
395 414
			/* (non-Javadoc)
......
397 416
			 */
398 417
			@Override
399 418
			public void widgetSelected(SelectionEvent e) {
400

  
401
			    AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
419
			    Object source = e.getSource();
420
			    String text = null;
421
			    if (source instanceof Button){
422
			        Button sourceButton = (Button) source;
423
			        text = sourceButton.getText();
424
			    }
425
			    AbstractNewEntityWizard wizard = getNewEntityWizard(text);
402 426
			    if(wizard!=null){
403 427
			        wizard.init(null, null);
404 428
			        if(wizard.getEntity() != null) {
......
457 481
			model.remove(uuidAndTitleCacheToRemove);
458 482
		}
459 483
	}
484
	@Override
485
	void createFilterButton(Composite searchAndFilter){
486
	    //as default no filter button available
487
	}
460 488
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AgentSelectionDialog.java
41 41
	/**
42 42
	 *
43 43
	 */
44
	protected static final String PERSON = "Person";
44
	protected static final String PERSON = "new Person";
45 45
	/**
46 46
	 *
47 47
	 */
48
	protected static final String TEAM = "Team";
48
	protected static final String TEAM = "new Team";
49 49

  
50 50
	protected static boolean selectTeamMember;
51 51

  
......
124 124

  
125 125
	/** {@inheritDoc} */
126 126
	@Override
127
	protected String getNewWizardLinkText() {
127
	protected String[] getNewWizardText() {
128
	    String[] result;
128 129
		if (this.selectTeamMember){
129
			return String.format("Create a new <a>%1s</a>", PERSON);
130
		    result = new String[1];
131
		    result[0] = PERSON;
132

  
133
		}else{
134
		    result = new String[2];
135
            result[0] = PERSON;
136
            result[1] = TEAM;
130 137
		}
131
		return String.format("Create a new <a>%1s</a> or <a>%2s</a>", TEAM, PERSON);
138
		return result;
132 139
	}
133 140

  
134 141
	/* (non-Javadoc)
135 142
	 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkSelectionListener()
136 143
	 */
137 144
	@Override
138
	protected SelectionListener getNewWizardLinkSelectionListener() {
139
		return super.getNewWizardLinkSelectionListener();
145
	protected SelectionListener getNewWizardButtonSelectionListener() {
146
		return super.getNewWizardButtonSelectionListener();
140 147
	}
141 148

  
142 149
	/** {@inheritDoc} */
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AmplificationSelectionDialog.java
82 82

  
83 83
    /** {@inheritDoc} */
84 84
    @Override
85
    protected String getNewWizardLinkText() {
86
        return String.format("Create a new <a>%1s</a>", "Amplification ");
85
    protected String[] getNewWizardText() {
86
        String[] result = new String[1];
87
        result[0] = "Amplification";
88
        return result;
87 89
    }
88 90
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ClassificationSelectionDialog.java
11 11

  
12 12
import java.util.UUID;
13 13

  
14
import org.eclipse.swt.widgets.Composite;
15 14
import org.eclipse.swt.widgets.Control;
16 15
import org.eclipse.swt.widgets.Shell;
17 16
import org.eclipse.swt.widgets.Text;
......
79 78
		super(shell, conversation, title, multi, settings, classification);
80 79
	}
81 80

  
82
	/*
83
	 * (non-Javadoc)
84
	 *
85
	 * @see
86
	 * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
87
	 * (org.eclipse.swt.widgets.Composite)
88
	 */
89
	/** {@inheritDoc} */
90
	@Override
91
	protected Control createExtendedContentArea(Composite parent) {
92
		return null;
93
	}
81
//	/*
82
//	 * (non-Javadoc)
83
//	 *
84
//	 * @see
85
//	 * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
86
//	 * (org.eclipse.swt.widgets.Composite)
87
//	 */
88
//	/** {@inheritDoc} */
89
//	@Override
90
//	protected Control createExtendedContentArea(Composite parent) {
91
//		return null;
92
//	}
94 93

  
95 94
	/*
96 95
	 * (non-Javadoc)
......
137 136

  
138 137
	/** {@inheritDoc} */
139 138
	@Override
140
	protected String getNewWizardLinkText() {
139
	protected String[] getNewWizardText() {
141 140
		return null;
142 141
	}
143 142
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/CollectionSelectionDialog.java
83 83
	 */
84 84
	/** {@inheritDoc} */
85 85
	@Override
86
	protected String getNewWizardLinkText() {
87
        return String.format("Create a new <a>%1s</a>", "Collection ");
86
	protected String[] getNewWizardText() {
87
        return new String[]{ "Collection "};
88 88
	}
89 89

  
90 90
	/* (non-Javadoc)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/DerivedUnitSelectionDialog.java
90 90

  
91 91
	/** {@inheritDoc} */
92 92
	@Override
93
	protected String getNewWizardLinkText() {
94
		return String.format("Create a new <a>%1s</a>", "Unit ");
93
	protected String[] getNewWizardText() {
94
		return new String[]{ "Unit "};
95 95
	}
96 96
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ExtReferenceSelectionDialog.java
250 250

  
251 251
        /** {@inheritDoc} */
252 252
        @Override
253
        protected String getNewWizardLinkText() {
254
            return String.format("Create a new <a>%1s</a>", "Reference ");
253
        protected String[] getNewWizardText() {
254
            return new String[]{"Reference "};
255 255
        }
256 256

  
257 257
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureSelectionDialog.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
36 36
				"Choose Feature", false, FeatureSelectionDialog.class.getCanonicalName(), feature);
37 37
		return getSelectionFromDialog(dialog);
38 38
	}
39
	
39

  
40 40
	/**
41 41
	 * @param shell
42 42
	 * @param conversation
......
53 53

  
54 54
	@Override
55 55
	protected Feature getPersistentObject(UUID uuid) {
56
		
56

  
57 57
		DefinedTermBase<?> term = CdmStore.getService(ITermService.class).load(uuid);
58
		
58

  
59 59
		if(term instanceof Feature){
60 60
			return (Feature) term;
61 61
		}
62
		
62

  
63 63
		return null;
64 64
	}
65 65

  
66 66
	@Override
67 67
	protected void search() {
68 68
		List<Feature> features = CdmStore.getService(ITermService.class).list(Feature.class, null, null, null, null);
69
		
69

  
70 70
		List<UuidAndTitleCache<Feature>> featureUuidAndTitleCache = new ArrayList<UuidAndTitleCache<Feature>>();
71
		
71

  
72 72
		for(Feature feature : features){
73 73
			UuidAndTitleCache<Feature> uuidAndTitleCache = new UuidAndTitleCache<Feature>(Feature.class, feature.getUuid(), feature.getId(), feature.getTitleCache());
74 74
			featureUuidAndTitleCache.add(uuidAndTitleCache);
75 75
		}
76
		
76

  
77 77
		model =  featureUuidAndTitleCache;
78 78
	}
79 79

  
......
81 81
	 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
82 82
	 */
83 83
	@Override
84
	protected String getNewWizardLinkText() {
84
	protected String[] getNewWizardText() {
85 85
		return null;
86 86
	}
87 87

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureTreeSelectionDialog.java
13 13
import java.util.List;
14 14
import java.util.UUID;
15 15

  
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.jface.dialogs.InputDialog;
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 16
import org.eclipse.swt.widgets.Shell;
25 17

  
26 18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
......
71 63
		}
72 64
	}
73 65

  
74
	/** {@inheritDoc} */
75
	@Override
76
	protected Control createExtendedContentArea(Composite parent) {
77
		Link link = new Link(parent, SWT.NONE);
78
		link.setText(getNewWizardLinkText());
79
		link.addListener (SWT.Selection, new Listener () {
80
			@Override
81
            public void handleEvent(Event event) {
82

  
83
			    InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
84
				int status = input.open();
85
				if (status == IStatus.OK) {
86
				    String label = input.getValue();
87
				    if(label!=null){
88
				        FeatureTree featureTree = FeatureTree.NewInstance();
89
				        featureTree.setTitleCache(label, false);
90
				        CdmStore.getService(IFeatureTreeService.class).save(featureTree);
91
			            UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
92
			            model.add(uuidAndTitleCache);
93
			            setPattern(featureTree);
94
				    }
95
				}
96
			}
97
		});
98
		return link;
99
	}
66
//	/** {@inheritDoc} */
67
//	@Override
68
//	protected Control createExtendedContentArea(Composite parent) {
69
//		Link link = new Link(parent, SWT.NONE);
70
//		link.setText(getNewWizardLinkText());
71
//		link.addListener (SWT.Selection, new Listener () {
72
//			@Override
73
//            public void handleEvent(Event event) {
74
//
75
//			    InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
76
//				int status = input.open();
77
//				if (status == IStatus.OK) {
78
//				    String label = input.getValue();
79
//				    if(label!=null){
80
//				        FeatureTree featureTree = FeatureTree.NewInstance();
81
//				        featureTree.setTitleCache(label, false);
82
//				        CdmStore.getService(IFeatureTreeService.class).save(featureTree);
83
//			            UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
84
//			            model.add(uuidAndTitleCache);
85
//			            setPattern(featureTree);
86
//				    }
87
//				}
88
//			}
89
//		});
90
//		return link;
91
//	}
100 92

  
101 93
	/** {@inheritDoc} */
102 94
	@Override
103
	protected String getNewWizardLinkText() {
104
		return String.format("Create a new <a>%1s</a>" , "Feature tree ");
95
	protected String[] getNewWizardText() {
96
		return new String[]{ "Feature tree "};
105 97
	}
106 98

  
107 99

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FieldUnitSelectionDialog.java
97 97

  
98 98
	/** {@inheritDoc} */
99 99
	@Override
100
	protected String getNewWizardLinkText() {
101
		return String.format("Create a new <a>%1s</a>", "Field Unit ");
100
	protected String[] getNewWizardText() {
101
		return new String[]{"Field Unit "};
102 102
	}
103 103
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FilterDialog.java
1
// $Id$
2
/**
3
* Copyright (C) 2017 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11

  
12
import java.util.ArrayList;
13
import java.util.List;
14

  
15
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.events.SelectionListener;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.layout.GridLayout;
21
import org.eclipse.swt.widgets.Button;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Shell;
25

  
26
import eu.etaxonomy.cdm.api.service.IVocabularyService;
27
import eu.etaxonomy.cdm.model.common.TermType;
28
import eu.etaxonomy.cdm.model.common.TermVocabulary;
29
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
30
import eu.etaxonomy.taxeditor.store.CdmStore;
31

  
32
/**
33
 * @author k.luther
34
 * @date 21.11.2017
35
 *
36
 */
37
public class FilterDialog extends Dialog {
38

  
39
    List<TermVocabulary> vocabularies = new ArrayList<TermVocabulary>();
40

  
41
    List<TermVocabulary> selectedVocabularies = new ArrayList<TermVocabulary>();
42

  
43
    Object preferenceId;
44

  
45
    /**
46
     * @param parentShell
47
     */
48
    protected FilterDialog(Shell parentShell, Object preferenceId, List<TermVocabulary> selectedVocabularies) {
49
        super(parentShell);
50
        vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
51
        this.preferenceId = preferenceId;
52
        List<TermVocabulary> tempSelectedVocabularies = new ArrayList<>();
53
        this.selectedVocabularies = selectedVocabularies;
54

  
55
    }
56

  
57
    @Override
58
    protected Control createDialogArea(Composite parent) {
59
        Composite dialogArea = new Composite(parent, SWT.NULL);
60
        dialogArea.setLayout(new GridLayout(1, false));
61
        for (TermVocabulary voc: vocabularies){
62
            Button btnCheckButton = new Button(dialogArea, SWT.CHECK);
63
            btnCheckButton.setText(voc.getLabel());
64
            btnCheckButton.setData(voc);
65
            if (selectedVocabularies.contains(voc)){
66
                btnCheckButton.setSelection(true);
67
            }else {
68
                btnCheckButton.setSelection(false);
69
            }
70

  
71
            btnCheckButton.addSelectionListener(new SelectionListener(){
72

  
73
                @Override
74
                public void widgetSelected(SelectionEvent e) {
75
                   if (btnCheckButton.getSelection()){
76
                       Object obj = btnCheckButton.getData();
77
                       if (!selectedVocabularies.contains(btnCheckButton.getData())){
78
                           selectedVocabularies.add((TermVocabulary)btnCheckButton.getData());
79
                       }
80
                   }else{
81
                       if (selectedVocabularies.contains(btnCheckButton.getData())){
82
                           selectedVocabularies.remove(btnCheckButton.getData());
83
                       }
84
                   }
85

  
86
                }
87

  
88
                @Override
89
                public void widgetDefaultSelected(SelectionEvent e) {
90
                    // TODO Auto-generated method stub
91

  
92
                }
93

  
94
            });
95
        }
96

  
97
        GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1);
98
        gd_table.heightHint = 231;
99
        gd_table.widthHint = 543;
100

  
101
        return dialogArea;
102

  
103
    }
104

  
105
    @Override
106
    protected void okPressed(){
107
        for (TermVocabulary voc: vocabularies){
108
            if (selectedVocabularies.contains(voc)){
109
                PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), false);
110
            } else{
111
                PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), true);
112
            }
113
        }
114
        super.okPressed();
115
    }
116

  
117
    private String getPrefKey(TermVocabulary vocabulary){
118
        return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceId;
119
    }
120

  
121
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GrantedAuthoritySelectionDialog.java
64 64
		model = new ArrayList<UuidAndTitleCache<GrantedAuthorityImpl>>();
65 65

  
66 66
		for(GrantedAuthorityImpl authority : authorities){
67
			
67

  
68 68
			model.add(new UuidAndTitleCache<GrantedAuthorityImpl>(GrantedAuthorityImpl.class, authority.getUuid(), authority.getId(), String.format("%s", GrantedAuthorityLabelTextProvider.getText(authority))));
69 69
		}
70 70
	}
......
73 73
	 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
74 74
	 */
75 75
	@Override
76
	protected String getNewWizardLinkText() {
77
		return String.format("Create a new <a>%1s</a>", "GrantedAuthority ");
76
	protected String[] getNewWizardText() {
77
		return new String[]{"GrantedAuthority "};
78 78
	}
79 79

  
80 80
	@Override
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/GroupSelectionDialog.java
69 69
	 * @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
70 70
	 */
71 71
	@Override
72
	protected String getNewWizardLinkText() {
73
		return String.format("Create a new <a>%1s</a>", "Group ");
72
	protected String[] getNewWizardText() {
73
		return new String[]{"Group "};
74 74
	}
75 75

  
76 76
	/* (non-Javadoc)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/InstitutionSelectionDialog.java
74 74
	 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
75 75
	 */
76 76
	@Override
77
	protected String getNewWizardLinkText() {
78
		return String.format("Create a new <a>%1s</a>", "Institution ");
77
	protected String[] getNewWizardText() {
78
		return new String[]{"Institution "};
79 79
	}
80 80

  
81 81
	/* (non-Javadoc)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/MediaSelectionDialog.java
81 81

  
82 82
    /** {@inheritDoc} */
83 83
    @Override
84
    protected String getNewWizardLinkText() {
85
        return "";
84
    protected String[] getNewWizardText() {
85
        return null;
86 86
    }
87 87
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NameSelectionDialog.java
68 68

  
69 69
	/** {@inheritDoc} */
70 70
	@Override
71
	protected String getNewWizardLinkText() {
72
		return String.format("Create a new <a>%1s</a>", "Name ");
71
	protected String[] getNewWizardText() {
72
		return new String[]{"Name "};
73 73
	}
74 74
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java
16 16
import org.eclipse.core.runtime.CoreException;
17 17
import org.eclipse.jface.action.Action;
18 18
import org.eclipse.jface.action.IAction;
19
import org.eclipse.jface.action.IMenuManager;
19
import org.eclipse.jface.dialogs.Dialog;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.events.SelectionEvent;
22
import org.eclipse.swt.events.SelectionListener;
23
import org.eclipse.swt.widgets.Button;
20 24
import org.eclipse.swt.widgets.Composite;
21 25
import org.eclipse.swt.widgets.Control;
22 26
import org.eclipse.swt.widgets.Shell;
23 27
import org.eclipse.swt.widgets.Text;
28
import org.eclipse.wb.swt.ResourceManager;
24 29

  
25 30
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
26 31
import eu.etaxonomy.cdm.api.service.ITermService;
......
62 67
			}
63 68
			PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), !isChecked());
64 69
			search();
65
			try {
66
                fillContentProvider(null);
67
            } catch (CoreException coreException) {
68
                // TODO Auto-generated catch block
69
                coreException.printStackTrace();
70
            }
71 70
		}
72 71
	}
73 72

  
74 73
	protected List<TermVocabulary> selectedVocabularies;
75 74
    protected ArrayList<TermVocabulary> preselectedVocabularies;
76
    private Object preferenceID;
75

  
77 76

  
78 77

  
79 78
	/**
......
103 102
			TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
104 103
			preselectedVocabularies.add(preselectedVocabulary);
105 104
		}
106
		List<TermVocabulary> tempSelectedVocabularies = new ArrayList<>();
107
		for(TermVocabulary vocabulary:selectedVocabularies){
105

  
106

  
107
		selectedVocabularies = createSelectedVocabularies();;
108
//		search;//re-init to consider pre-selected vocabularies
109
	}
110

  
111
    private List<TermVocabulary> createSelectedVocabularies() {
112
        List<TermVocabulary> tempSelectedVocabularies = new ArrayList<TermVocabulary>();
113
        for(TermVocabulary vocabulary:selectedVocabularies){
108 114
			if(preselectedVocabularies.contains(vocabulary)
109 115
					|| !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
110 116
				tempSelectedVocabularies.add(vocabulary);
111 117
			}
112 118
		}
113
		selectedVocabularies = tempSelectedVocabularies;
114
//		search;//re-init to consider pre-selected vocabularies
115
	}
119
        return tempSelectedVocabularies;
120
    }
116 121

  
117 122
	/** {@inheritDoc} */
118
	@Override
119
	protected void fillViewMenu(IMenuManager menuManager) {
120

  
121
//		super.fillViewMenu(menuManager);
122

  
123
		for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
124
			IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
125
			menuManager.add(action);
126
			if(preselectedVocabularies.contains(vocabulary)) {
127
			    action.setChecked(true);
128
			}
129
			else{
130
				action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
131
			}
132
		}
133
	}
123
//	@Override
124
//	protected void fillViewMenu(IMenuManager menuManager) {
125
//
126
////		super.fillViewMenu(menuManager);
127
//
128
//		for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
129
//			IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
130
//			menuManager.add(action);
131
//			if(preselectedVocabularies.contains(vocabulary)) {
132
//			    action.setChecked(true);
133
//			}
134
//			else{
135
//				action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
136
//			}
137
//		}
138
//	}
134 139

  
135 140
	private String getPrefKey(TermVocabulary vocabulary){
136 141
		return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceID;
......
175 180
        }else{
176 181
            model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage());
177 182
        }
178

  
183
       try {
184
           fillContentProvider(null);
185
        } catch (CoreException e) {
186
            // TODO Auto-generated catch block
187
            e.printStackTrace();
188
        }
179 189
//		Set<NamedArea> terms = new HashSet<NamedArea>();
180 190
//		for(TermVocabulary<NamedArea> vocabulary : selectedVocabularies){
181 191
//			terms.addAll(vocabulary.getTermsOrderedByLabels(CdmStore.getDefaultLanguage()));
......
192 202
//		}
193 203
	}
194 204

  
195
	/** {@inheritDoc} */
196
	@Override
197
	protected Control createExtendedContentArea(Composite parent) {
198
		return null;
199
	}
205
//	/** {@inheritDoc} */
206
//	@Override
207
//	protected Control createExtendedContentArea(Composite parent) {
208
//		return null;
209
//	}
200 210

  
201 211
	/** {@inheritDoc} */
202 212
	@Override
......
218 228

  
219 229
	/** {@inheritDoc} */
220 230
	@Override
221
	protected String getNewWizardLinkText() {
231
	protected String[] getNewWizardText() {
222 232
		return null;
223 233
	}
234

  
235
	@Override
236
    void createFilterButton(Composite searchAndFilter)
237
	    {
238
            filterButton = new Button(searchAndFilter, SWT.NONE);
239
//            filterButton.setText("Filter");
240
            filterButton.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/funnel-icon.png"));
241
//            SelectionListener filterSelectionListener = new FilterSelectionListener(preferenceID, this);
242
            filterButton.addSelectionListener(new SelectionListener(){
243
                @Override
244
                public void widgetSelected(SelectionEvent e) {
245

  
246
                        Object source = e.getSource();
247
                        String text = null;
248
                        if (source instanceof Button){
249
                            Shell shell = ((Button)source).getShell();
250
                            Dialog dialog = new FilterDialog(getShell(), preferenceID, selectedVocabularies);
251
                            if(dialog!=null){
252
                                dialog.open();
253
                            }
254
                            createSelectedVocabularies();
255
                        }
256

  
257

  
258

  
259

  
260
                }
261

  
262
                @Override
263
                public void widgetDefaultSelected(SelectionEvent e) {
264
                    // TODO Auto-generated method stub
265

  
266
                }
267

  
268

  
269
            });
270

  
271
        }
272

  
273
    /**
274
     *
275
     */
276
    public void setSelectedVocabularies() {
277
        // TODO Auto-generated method stub
278

  
279
    }
280

  
224 281
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorTeamSelectionDialog.java
71 71

  
72 72
	/** {@inheritDoc} */
73 73
	@Override
74
	protected String getNewWizardLinkText() {
75
		return String.format("Create a new <a>%1s</a>", "Team ");
74
	protected String[] getNewWizardText() {
75
		return new String[]{"Team "};
76 76
	}
77 77

  
78 78
	/** {@inheritDoc} */
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/PersonSelectionDialog.java
87 87

  
88 88
	/** {@inheritDoc} */
89 89
	@Override
90
	protected String getNewWizardLinkText() {
91
		return String.format("Create a new <a>%1s</a>", "Person ");
90
	protected String[] getNewWizardText() {
91
		return new String[]{"Person"};
92 92
	}
93 93
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/PolytomousKeySelectionDialog.java
67 67
	 * @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
68 68
	 */
69 69
	@Override
70
	protected String getNewWizardLinkText() {
70
	protected String[] getNewWizardText() {
71 71
		return null;
72 72
	}
73 73

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/PrimerSelectionDialog.java
82 82

  
83 83
    /** {@inheritDoc} */
84 84
    @Override
85
    protected String getNewWizardLinkText() {
86
        return String.format("Create a new <a>%1s</a>", "Primer ");
85
    protected String[] getNewWizardText() {
86
        return new String[]{"Primer "};
87 87
    }
88 88
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ReferenceSelectionDialog.java
158 158

  
159 159
	/** {@inheritDoc} */
160 160
	@Override
161
	protected String getNewWizardLinkText() {
162
		return String.format("Create a new <a>%1s</a>", "Reference ");
161
	protected String[] getNewWizardText() {
162
		return new String[]{"Reference "};
163 163
	}
164 164

  
165 165
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/RightsSelectionDialog.java
64 64
     * {@inheritDoc}
65 65
     */
66 66
    @Override
67
    protected String getNewWizardLinkText() {
68
        // TODO Auto-generated method stub
67
    protected String[] getNewWizardText() {
68

  
69 69
        return null;
70 70
    }
71 71

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SearchDialog.java
17 17
import java.util.Comparator;
18 18
import java.util.List;
19 19

  
20
import org.eclipse.core.commands.AbstractHandler;
21
import org.eclipse.core.commands.ExecutionEvent;
22
import org.eclipse.core.commands.IHandler;
23 20
import org.eclipse.core.runtime.Assert;
24 21
import org.eclipse.core.runtime.CoreException;
25 22
import org.eclipse.core.runtime.IProgressMonitor;
......
27 24
import org.eclipse.core.runtime.ListenerList;
28 25
import org.eclipse.core.runtime.Status;
29 26
import org.eclipse.core.runtime.jobs.Job;
30
import org.eclipse.jface.action.IMenuManager;
31 27
import org.eclipse.jface.action.LegacyActionTools;
32 28
import org.eclipse.jface.action.MenuManager;
33 29
import org.eclipse.jface.dialogs.Dialog;
......
54 50
import org.eclipse.swt.accessibility.AccessibleEvent;
55 51
import org.eclipse.swt.events.ModifyEvent;
56 52
import org.eclipse.swt.events.ModifyListener;
57
import org.eclipse.swt.events.SelectionAdapter;
58
import org.eclipse.swt.events.SelectionEvent;
59 53
import org.eclipse.swt.events.TraverseEvent;
60 54
import org.eclipse.swt.events.TraverseListener;
61 55
import org.eclipse.swt.graphics.Color;
......
65 59
import org.eclipse.swt.graphics.Rectangle;
66 60
import org.eclipse.swt.layout.GridData;
67 61
import org.eclipse.swt.layout.GridLayout;
62
import org.eclipse.swt.widgets.Button;
68 63
import org.eclipse.swt.widgets.Composite;
69 64
import org.eclipse.swt.widgets.Control;
70 65
import org.eclipse.swt.widgets.Display;
71 66
import org.eclipse.swt.widgets.Event;
72 67
import org.eclipse.swt.widgets.Label;
73
import org.eclipse.swt.widgets.Menu;
74 68
import org.eclipse.swt.widgets.Shell;
75 69
import org.eclipse.swt.widgets.Table;
76 70
import org.eclipse.swt.widgets.Text;
77 71
import org.eclipse.swt.widgets.ToolBar;
78
import org.eclipse.swt.widgets.ToolItem;
79 72
import org.eclipse.ui.IWorkbenchPreferenceConstants;
80 73
import org.eclipse.ui.PlatformUI;
81 74
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
82
import org.eclipse.ui.handlers.IHandlerService;
83 75
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
84 76
import org.eclipse.ui.internal.WorkbenchImages;
85 77
import org.eclipse.ui.internal.WorkbenchMessages;
......
101 93
        private TableViewer list;
102 94
        private Text searchField;
103 95
        private String title;
96
        protected Button newButton1;
97

  
98

  
99
        protected Button newButton2;
100
        protected Button filterButton;
104 101
        private StructuredSelection currentSelection;
105 102

  
106 103
        // message to show user
......
112 109
        private final RefreshCacheJob refreshCacheJob;
113 110

  
114 111
        private ToolBar toolBar;
115
        private ToolItem toolItem;
116 112
        private MenuManager menuManager;
113

  
114
        protected Object preferenceID;
115

  
116
        protected final int new_id = 4;
117
        protected final int new_id2 = 5;
117 118
        // Need to keep our own list of listeners
118 119
        private final ListenerList listeners = new ListenerList();
119 120

  
......
126 127
            contentProvider = new ContentProvider();
127 128
            refreshCacheJob = new RefreshCacheJob();
128 129

  
130

  
129 131
        }
130 132

  
131 133

  
......
144 146

  
145 147
            final Label headerLabel = createHeader(container);
146 148

  
147
            searchField = new Text(container, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
149
            Composite searchAndFilter = new Composite(container, container.getStyle());
150
//            GridData gd_searchAndFilter = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
151
            GridData gd_searchAndFilter =new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
152
//            gd_searchAndFilter.widthHint = 576;
153
            searchAndFilter.setLayoutData(gd_searchAndFilter);
154
            GridLayout searchAndFilterLayout = new GridLayout();
155
            searchAndFilterLayout.numColumns = 2;
156
            searchAndFilter.setLayout(searchAndFilterLayout);
157
            searchField = new Text(searchAndFilter, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
148 158
            searchField.getAccessible().addAccessibleListener(new AccessibleAdapter() {
149 159
                @Override
150 160
                public void getName(AccessibleEvent e) {
......
164 174
                    }
165 175
                }
166 176
            });
167
            gd_1 = new GridData(GridData.FILL_HORIZONTAL);
168
            gd_1.horizontalIndent = 2;
169
            gd_1.horizontalAlignment = SWT.CENTER;
170
            gd_1.widthHint = 575;
177
            gd_1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
178

  
179
//            gd_1.horizontalIndent = 2;
180
//            gd_1.horizontalAlignment = SWT.CENTER;
181
//            gd_1.grabExcessHorizontalSpace = true;
182
//            gd_1.widthHint = 500;
171 183
            searchField.setLayoutData(gd_1);
172 184

  
185
            createFilterButton(searchAndFilter);
173 186
            setList(new TableViewer(container,  SWT.SINGLE
174 187
                    | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL));
175 188

  
......
191 204
                    okPressed();
192 205
                }
193 206
            });
194
            createExtendedContentArea(container);
207
//            createExtendedContentArea(container);
208
            new Label(container, SWT.NONE);
195 209

  
196 210
            return container;
197 211
        }
198 212

  
213

  
214
        abstract void createFilterButton(Composite searchAndFilter) ;
215

  
199 216
        protected abstract void search();
200 217

  
201 218
        /**
......
205 222
         *            parent to create the dialog widgets in
206 223
         * @return an extra content area
207 224
         */
208
        protected abstract Control createExtendedContentArea(Composite parent);
225
//        protected abstract Control createExtendedContentArea(Composite parent);
209 226

  
210 227
        /**
211 228
         * Sets the title for this dialog.
......
225 242
         */
226 243
        private Label createHeader(Composite parent) {
227 244
            Composite header = new Composite(parent, SWT.NONE);
228
            GridData gd_header = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
245
            GridData gd_header = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1);
229 246
            gd_header.widthHint = 575;
230 247
            header.setLayoutData(gd_header);
231 248

  
......
234 251
            layout.marginWidth = 0;
235 252
            layout.marginHeight = 0;
236 253
            header.setLayout(layout);
237

  
238
            createViewMenu(header);
239

  
254
            new Label(header, SWT.NONE);
240 255
            Label headerLabel = new Label(header, SWT.NONE);
241 256
            headerLabel.setText((getMessage() != null && getMessage().trim()
242 257
                    .length() > 0) ? getMessage()
......
256 271
            gd_headerLabel.verticalAlignment = SWT.BOTTOM;
257 272
            gd_headerLabel.minimumHeight = 10;
258 273
            headerLabel.setLayoutData(gd_headerLabel);
259
            new Label(header, SWT.NONE);
260

  
261 274
            return headerLabel;
262 275
        }
263 276

  
......
285 298
            }
286 299
            return itemsListLabelProvider;
287 300
        }
288
        private void createViewMenu(Composite parent) {
289
            toolBar = new ToolBar(parent, SWT.FLAT);
290
            toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
291

  
292
            GridData data = new GridData();
293
            data.horizontalAlignment = GridData.END;
294
            data.grabExcessHorizontalSpace = true;
295
            toolBar.setLayoutData(data);
296

  
297
//            toolBar.addMouseListener(new MouseAdapter() {
301
//        private void createViewMenu(Composite parent) {
302
//            toolBar = new ToolBar(parent, SWT.FLAT);
303
//
304
//            GridData data = new GridData();
305
//            data.horizontalAlignment = GridData.END;
306
//            data.grabExcessHorizontalSpace = true;
307
//            toolBar.setLayoutData(data);
308
//
309
//            menuManager = new MenuManager();
310
//
311
//            fillViewMenu(menuManager);
312
//
313
//            IHandlerService service = PlatformUI.getWorkbench()
314
//                    .getService(IHandlerService.class);
315
//            IHandler handler = new AbstractHandler() {
298 316
//                @Override
299
//                public void mouseDown(MouseEvent e) {
317
//                public Object execute(ExecutionEvent event) {
300 318
//                    showViewMenu();
319
//                    return null;
301 320
//                }
302
//            });
321
//            };
322
//        }
323

  
324
//        /**
325
//         * Fills the menu of the dialog.
326
//         *
327
//         * @param menuManager
328
//         *            the menu manager
329
//         */
330
//        protected void fillViewMenu(IMenuManager menuManager) {
331
//
332
//        }
333

  
334
//        private void showViewMenu() {
335
//            Menu menu = menuManager.createContextMenu(getShell());
336
//            Rectangle bounds = toolItem.getBounds();
337
//            Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
338
//            topLeft = toolBar.toDisplay(topLeft);
339
//            menu.setLocation(topLeft.x, topLeft.y);
340
//            menu.setVisible(true);
341
//        }
303 342

  
304
            toolItem.setImage(WorkbenchImages
305
                    .getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU));
306
            toolItem
307
                    .setToolTipText(WorkbenchMessages.FilteredItemsSelectionDialog_menu);
308
            toolItem.addSelectionListener(new SelectionAdapter() {
309
                @Override
310
                public void widgetSelected(SelectionEvent e) {
311
                    showViewMenu();
312
                }
313
            });
343
        public TableViewer getList() {
344
            return list;
345
        }
314 346

  
315
            menuManager = new MenuManager();
347
        public void setList(TableViewer list) {
348
            this.list = list;
349
            Table table = list.getTable();
350
            GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1);
351
            gd_table.heightHint = 231;
352
            gd_table.widthHint = 543;
353
            table.setLayoutData(gd_table);
354
        }
316 355

  
317
            fillViewMenu(menuManager);
356
        public Button getNewButton1() {
357
            return newButton1;
358
        }
318 359

  
319
            IHandlerService service = PlatformUI.getWorkbench()
320
                    .getService(IHandlerService.class);
321
            IHandler handler = new AbstractHandler() {
322
                @Override
323
                public Object execute(ExecutionEvent event) {
324
                    showViewMenu();
325
                    return null;
326
                }
327
            };
360

  
361
        public void setNewButton1(Button newButton1) {
362
            this.newButton1 = newButton1;
328 363
        }
329 364

  
330
        /**
331
         * Fills the menu of the dialog.
332
         *
333
         * @param menuManager
334
         *            the menu manager
335
         */
336
        protected void fillViewMenu(IMenuManager menuManager) {
337 365

  
366
        public Button getNewButton2() {
367
            return newButton2;
338 368
        }
339 369

  
340
        private void showViewMenu() {
341
            Menu menu = menuManager.createContextMenu(getShell());
342
            Rectangle bounds = toolItem.getBounds();
343
            Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
344
            topLeft = toolBar.toDisplay(topLeft);
345
            menu.setLocation(topLeft.x, topLeft.y);
346
            menu.setVisible(true);
370

  
371
        public void setNewButton2(Button newButton2) {
372
            this.newButton2 = newButton2;
347 373
        }
348 374

  
349
        public TableViewer getList() {
350
            return list;
375

  
376
        public Button getFilterButton() {
377
            return filterButton;
351 378
        }
352 379

  
353
        public void setList(TableViewer list) {
354
            this.list = list;
355
            Table table = list.getTable();
356
            GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1);
357
            gd_table.heightHint = 231;
358
            gd_table.widthHint = 543;
359
            table.setLayoutData(gd_table);
380

  
381
        public void setFilterButton(Button filterButton) {
382
            this.filterButton = filterButton;
360 383
        }
361 384

  
362 385
        /**
......
796 819
        return new Point(593, 399);
797 820
    }
798 821

  
822

  
823

  
799 824
}
800 825

  
801 826

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java
171 171
		return null;
172 172
	}
173 173

  
174
	public static <T extends ICdmBase> T getSelectionFromExtDialog(Class<T> clazz, Shell shell, ConversationHolder conversation, ICdmFormElement parentElement){
175
	    return (T) ExtReferenceSelectionDialog.select(shell, conversation, null);
176
	}
177

  
178

  
174 179
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionViewMenu.java
1
// $Id$
2
/**
3
* Copyright (C) 2017 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11

  
12
import java.util.List;
13

  
14
import org.eclipse.e4.ui.di.AboutToShow;
15
import org.eclipse.e4.ui.model.application.commands.MCommand;
16
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
17
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
18
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
19
import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
20
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
21

  
22
import eu.etaxonomy.cdm.model.common.TermVocabulary;
23
import eu.etaxonomy.cdm.model.location.NamedArea;
24
import eu.etaxonomy.taxeditor.l10n.Messages;
25

  
26
/**
27
 * @author k.luther
28
 * @date 20.11.2017
29
 *
30
 */
31
public class SelectionViewMenu {
32

  
33
    public static final String COMMAND_ID = "taxeditor-selection.command.selectViewMenu"; //$NON-NLS-1$
34
    public static final String COMMAND_PARAMETER_VOCABULARY = COMMAND_ID+".vocabulary"; //$NON-NLS-1$
35
    public static final String COMMAND_PARAMETER_VOCABULARY_STATE = COMMAND_ID+".state"; //$NON-NLS-1$
36

  
37
    @AboutToShow
38
    public void aboutToShow(List<MMenuElement> items, List<TermVocabulary> vocabularies) {
39

  
40
        MMenu menu = MMenuFactory.INSTANCE.createMenu();
41
        menu.setLabel(Messages.SelectionViewMenu_selectVocabulary);
42
        items.add(menu);
43
        for(TermVocabulary<NamedArea> vocabulary: vocabularies){
44
            createMenuItem(menu, vocabulary);
45
        }
46
    }
47

  
48

  
49
    private void createMenuItem(MMenu menu, final TermVocabulary<NamedArea> vocabulary) {
50

  
51
        MMenu subMenu = MMenuFactory.INSTANCE.createMenu();
52
        subMenu.setLabel(String.format(Messages.SelectionViewMenu_SET_FLAG, vocabulary.getLabel()));
53
        menu.getChildren().add(subMenu);
54

  
55
        MHandledMenuItem subMenuItemYes = MMenuFactory.INSTANCE.createHandledMenuItem();
56
        subMenuItemYes.setLabel(Messages.SelectionViewMenu_4_YES);
57
        MCommand mCommandYes = MCommandsFactory.INSTANCE.createCommand();
58
        mCommandYes.setElementId(COMMAND_ID);
59
        //set params
60
        subMenuItemYes.getTransientData().put(COMMAND_PARAMETER_VOCABULARY, vocabulary);
61
        subMenuItemYes.getTransientData().put(COMMAND_PARAMETER_VOCABULARY_STATE, true);
62
        subMenuItemYes.setCommand(mCommandYes);
63
        subMenu.getChildren().add(subMenuItemYes);
64

  
65
        MHandledMenuItem subMenuItemNo = MMenuFactory.INSTANCE.createHandledMenuItem();
66
        subMenuItemNo.setLabel(Messages.SelectionViewMenu_NO);
67
        MCommand mCommandNo = MCommandsFactory.INSTANCE.createCommand();
68
        mCommandNo.setElementId(COMMAND_ID);
69
//        //set params
70
//        subMenuItemNo.getTransientData().put(COMMAND_PARAMETER_MARKER_TYPE, markerType);
71
//        subMenuItemNo.getTransientData().put(COMMAND_PARAMETER_MARKER_STATE, false);
72
//        subMenuItemNo.setCommand(mCommandNo);
73
//        subMenu.getChildren().add(subMenuItemNo);
74
    }
75
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SpecimenOrObservationBaseSelectionDialog.java
60 60

  
61 61
	/** {@inheritDoc} */
62 62
	@Override
63
	protected String getNewWizardLinkText() {
64
		return String.format("Create a new <a>%1s</a>", "field unit/derived unit");
63
	protected String[] getNewWizardText() {
64
		return new String[]{"field unit/derived unit"};
65 65
	}
66 66
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonBaseSelectionDialog.java
93 93

  
94 94
    /** {@inheritDoc} */
95 95
    @Override
96
    protected String getNewWizardLinkText() {
97
        return String.format("Create a new <a>%1s</a>", "Taxon ");
96
    protected String[] getNewWizardText() {
97
        return new String[]{"Taxon "};
98 98
    }
99 99
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TaxonNodeSelectionDialog.java
8 8
import java.util.List;
9 9
import java.util.UUID;
10 10

  
11
import org.eclipse.core.runtime.CoreException;
11 12
import org.eclipse.jface.viewers.ILabelProvider;
12 13
import org.eclipse.swt.SWT;
13 14
import org.eclipse.swt.events.SelectionEvent;
......
63 64
		if(classification != null){
64 65
			selectedClassification = classification;
65 66
		}
66
		search();
67

  
68
		fillClassifications();
69
		createClassificationSelectionCombo(shell);
67 70
	}
68 71

  
69 72
	/** {@inheritDoc} */
70 73
	@Override
71
	protected Control createExtendedContentArea(Composite parent) {
72
		return createClassificationSelectionCombo(parent);
74
	protected Control createDialogArea(Composite parent) {
75
	    Composite container = (Composite) super.createDialogArea(parent);
76
		return createClassificationSelectionCombo(container);
73 77
	}
74 78

  
75 79
	/*
......
134 138
        }
135 139

  
136 140

  
137
		if(classifications == null){
141
//		fillClassifications();
142
		if (pattern == null || pattern.equals("?")){
143
		    model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), null, null);
144
		}else{
145
		    model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), limitOfInitialElements, pattern);
146
		}
147
		try {
148
            fillContentProvider(null);
149
        } catch (CoreException e) {
150
            // TODO Auto-generated catch block
151
            e.printStackTrace();
152
        }
153
	}
154

  
155
    private void fillClassifications() {
156
        if(classifications == null){
138 157
			classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
139 158
			Collections.sort(classifications, new Comparator<Classification>() {
140 159

  
......
156 175
			    selectedClassification = this.cdmBaseToBeFiltered.getClassification();
157 176
			}
158 177
		}
159
		if (pattern == null || pattern.equals("?")){
160
		    model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(),  limitOfInitialElements, pattern);
161
		}else{
162
		    model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(),  null, null);
163
		}
164
	}
178
    }
165 179

  
166 180
	/** {@inheritDoc} */
167 181
	@Override
......
171 185

  
172 186
	/** {@inheritDoc} */
173 187
	@Override
174
	protected String getNewWizardLinkText() {
188
	protected String[] getNewWizardText() {
175 189
		return null;
176 190
	}
177 191

  
......
181 195
		selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
182 196

  
183 197
//		refresh();
184
		setPattern(null);
198
		if (getSearchField().getText() != null){
199
		    search();
200
		}
185 201
	}
186 202

  
187 203
	/** {@inheritDoc} */
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)