Project

General

Profile

« Previous | Next » 

Revision 8f5ccc1e

Added by Katja Luther almost 8 years ago

add nomenclatural author search for team members

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTeamWizard.java
24 24
 */
25 25
public class NewTeamWizard extends AbstractNewEntityWizard<Team> {
26 26

  
27
	
27
    private boolean isNomenclaturalTeam = false;
28

  
28 29
	public NewTeamWizard() {}
29
		
30

  
30 31
	public NewTeamWizard(boolean b) {
31
		//FIXME somethings needs to be done here
32
		setNomenclaturalTeam(b);
32 33
	}
33 34

  
34 35
	/** {@inheritDoc} */
35 36
	@Override
36 37
	public void addPages() {
37
		addPage(new TeamWizardPage(formFactory, getConversationHolder(), getEntity()));
38
		addPage(new TeamWizardPage(formFactory, getConversationHolder(), getEntity(), isNomenclaturalTeam));
38 39
	}
39 40

  
40 41
	/* (non-Javadoc)
......
60 61
	protected String getEntityName() {
61 62
		return "Team";
62 63
	}
64

  
65
    /**
66
     * @return the isNomenclaturalTeam
67
     */
68
    public boolean isNomenclaturalTeam() {
69
        return isNomenclaturalTeam;
70
    }
71

  
72
    /**
73
     * @param isNomenclaturalTeam the isNomenclaturalTeam to set
74
     */
75
    public void setNomenclaturalTeam(boolean isNomenclaturalTeam) {
76
        this.isNomenclaturalTeam = isNomenclaturalTeam;
77
    }
63 78
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/AgentSelectionDialog.java
41 41
	/**
42 42
	 *
43 43
	 */
44
	private static final String PERSON = "Person";
44
	protected static final String PERSON = "Person";
45 45
	/**
46 46
	 *
47 47
	 */
48
	private static final String TEAM = "Team";
48
	protected static final String TEAM = "Team";
49 49

  
50 50
	/**
51 51
	 * <p>select</p>
......
109 109
	@Override
110 110
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
111 111
		if(TEAM.equals(parameter)){
112
			return new NewTeamWizard(false);
112
			return new NewTeamWizard();
113 113
		}
114 114
		else if(PERSON.equals(parameter)){
115 115
			return new NewPersonWizard();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/CdmFilteredItemsSelectionDialog.java
131 131
 * dialog gets all items when opening the dialog and then apply the filter on all items.
132 132
 * In our case we need a possibility to filter the items already when getting them from the DB, so we adapt the
133 133
 * original class
134
 * the abstract method initMOdel was added and the method applyFilter was modified
134 135
 * original description:
135 136
 * Shows a list of items to the user with a text entry field for a string
136 137
 * pattern used to filter the list of items.
......
3416 3417
        }
3417 3418

  
3418 3419
        /**
3420
         * CDM IMPLEMENTATION
3419 3421
         * we have to call the initModel() method in the applyFilter method, so we had to add this abstract method (moved from AbstractFilteredCdmResourceSelectionDialog)
3420 3422
         * <p>initModel</p>
3421 3423
         */
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java
9 9
*/
10 10
package eu.etaxonomy.taxeditor.ui.dialog.selection;
11 11

  
12

  
13

  
14
import org.eclipse.swt.widgets.Control;
12 15
import org.eclipse.swt.widgets.Shell;
16
import org.eclipse.swt.widgets.Text;
13 17

  
14 18
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15 19
import eu.etaxonomy.cdm.api.service.IAgentService;
16 20
import eu.etaxonomy.cdm.model.agent.AgentBase;
17 21
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
22
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
23
import eu.etaxonomy.taxeditor.newWizard.NewPersonWizard;
24
import eu.etaxonomy.taxeditor.newWizard.NewTeamWizard;
18 25
import eu.etaxonomy.taxeditor.store.CdmStore;
19 26

  
20 27
/**
......
41 48

  
42 49
    @Override
43 50
    protected void initModel() {
44
        model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(null, null, null);
51
        Control control = getPatternControl();
52
        String pattern = null;
53
        if (control != null){
54
            pattern = ((Text)control).getText();
55
        }
56

  
57
        model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, null);
45 58
    }
46 59

  
60
    /** {@inheritDoc} */
61
    @Override
62
    protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
63
        if(TEAM.equals(parameter)){
64
            return new NewTeamWizard(true);
65
        }
66
        else if(PERSON.equals(parameter)){
67
            return new NewPersonWizard();
68
        }
69
        else{
70
            throw new IllegalArgumentException("Could not determine the desired wizard.");
71
        }
72
    }
73

  
74

  
47 75
    /**
48 76
     * <p>select</p>
49 77
     *
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorTeamSelectionDialog.java
12 12

  
13 13
import java.util.UUID;
14 14

  
15
import org.eclipse.swt.widgets.Control;
15 16
import org.eclipse.swt.widgets.Shell;
17
import org.eclipse.swt.widgets.Text;
16 18

  
17 19
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18 20
import eu.etaxonomy.cdm.api.service.IAgentService;
21
import eu.etaxonomy.cdm.model.agent.AgentBase;
19 22
import eu.etaxonomy.cdm.model.agent.Team;
20 23
import eu.etaxonomy.cdm.model.common.CdmBase;
21 24
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
......
30 33
 * @version 1.0
31 34
 */
32 35
public class NomenclaturalAuthorTeamSelectionDialog extends
33
	AbstractFilteredCdmResourceSelectionDialog<Team> {
36
	AbstractFilteredCdmResourceSelectionDialog<AgentBase> {
34 37

  
35 38
	/**
36 39
	 * <p>select</p>
......
43 46
	public static Team select(Shell shell, ConversationHolder conversation, Team team){
44 47
		NomenclaturalAuthorTeamSelectionDialog dialog = new NomenclaturalAuthorTeamSelectionDialog(shell, conversation,
45 48
				"Choose Author Team", false, NomenclaturalAuthorTeamSelectionDialog.class.getCanonicalName(), team);
46
		return getSelectionFromDialog(dialog);
49
		return (Team)getSelectionFromDialog(dialog);
47 50
	}
48 51

  
49 52
	/**
......
76 79
	/** {@inheritDoc} */
77 80
	@Override
78 81
	protected void initModel() {
79
		model = CdmStore.getService(IAgentService.class).getTeamUuidAndNomenclaturalTitle();
82
	    Control control = getPatternControl();
83
        String pattern = null;
84
        if (control != null){
85
            pattern = ((Text)control).getText();
86
        }
87

  
88
		model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(limitOfInitialElements, pattern, Team.class);
80 89
	}
81 90

  
82 91
	/** {@inheritDoc} */
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java
21 21
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
22 22
import eu.etaxonomy.cdm.model.common.Group;
23 23
import eu.etaxonomy.cdm.model.common.ICdmBase;
24
import eu.etaxonomy.cdm.model.common.TermType;
25 24
import eu.etaxonomy.cdm.model.common.User;
26 25
import eu.etaxonomy.cdm.model.description.Feature;
27 26
import eu.etaxonomy.cdm.model.description.FeatureTree;
......
43 42
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
44 43
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
45 44
import eu.etaxonomy.taxeditor.model.MessagingUtils;
46
import eu.etaxonomy.taxeditor.store.CdmStore;
47 45
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
48 46
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
49 47
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
......
94 92
		    return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
95 93
		}
96 94
		if(clazz.equals(Person.class) && parentElement instanceof TeamMemberElement){
97
		    return (T) NomenclaturalAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
95
		    return (T) NomenclaturalPersonAuthorSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
98 96
        }
99 97
		if(clazz.equals(AgentBase.class)){
100 98
			return (T) AgentSelectionDialog.select(shell, conversation, (AgentBase) currentSelection);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/element/CdmFormFactory.java
1967 1967
        return element;
1968 1968
    }
1969 1969

  
1970
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style){
1971
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style);
1970
    public TeamDetailElement createTeamDetailElement(ICdmFormElement parentElement, int style, boolean isNomenclatural){
1971
        TeamDetailElement element = new TeamDetailElement(this, parentElement, style, isNomenclatural);
1972 1972
        addAndAdaptElement(parentElement, element);
1973 1973
        return element;
1974 1974
    }
......
2164 2164
    }
2165 2165

  
2166 2166
    //--------EntityCollectionSection----------
2167
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style){
2168
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style);
2167
    public TeamMemberSection createTeamMemberSection(ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural){
2168
        TeamMemberSection section = new TeamMemberSection(this, conversation, parentElement, style, isNomenclatural);
2169 2169
        addAndAdaptSection(parentElement, section);
2170 2170
        return section;
2171 2171
    }
......
2443 2443

  
2444 2444
        if (entity instanceof Annotation) {
2445 2445
            element = new AnnotationElement(this, parentElement, (Annotation) entity, removeListener, style);
2446
        }else if (entity instanceof Person) {
2447
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style);
2446
        }else if (entity instanceof Person ) {
2447
            boolean isNomenclatural = false;
2448
            if (parentElement instanceof TeamMemberSection){
2449
                isNomenclatural = ((TeamMemberSection) parentElement).isNomenclaturalTeam();
2450
            }
2451
            element = new TeamMemberElement(this, parentElement, (Person) entity, removeListener, style, isNomenclatural);
2448 2452
        } else if (entity instanceof Credit) {
2449 2453
            element = new CreditElement(this, parentElement, (Credit) entity, removeListener, style);
2450 2454
        } else if (entity instanceof Extension) {
......
2703 2707
        return element;
2704 2708
    }
2705 2709

  
2706
    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2707
            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2708
            int mode, int style) {
2709
        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2710
                conversation, parentElement, labelString, selection, mode, style);
2711
        adapt(element);
2712
        parentElement.addElement(element);
2713
        return element;
2714
    }
2710
//    public NomenclaturalAuthorTeamSelectionElement createNomenclaturalAuthorTeamSelectionElement(
2711
//            ConversationHolder conversation, ICdmFormElement parentElement, String labelString, Team selection,
2712
//            int mode, int style) {
2713
//        NomenclaturalAuthorTeamSelectionElement element = new NomenclaturalAuthorTeamSelectionElement(this,
2714
//                conversation, parentElement, labelString, selection, mode, style);
2715
//        adapt(element);
2716
//        parentElement.addElement(element);
2717
//        return element;
2718
//    }
2715 2719

  
2716 2720
    /** {@inheritDoc} */
2717 2721
    public LabelElement createLabel(ICdmFormElement parentElement, String text) {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamDetailElement.java
38 38
	private CheckboxElement hasAdditionalMembers;
39 39

  
40 40
	private TeamMemberSection section_teamMembers;
41
	private final boolean isNomenclaturalTeam;
41 42

  
42 43
	/**
43 44
	 * <p>
......
54 55
	 *            a int.
55 56
	 */
56 57
	public TeamDetailElement(CdmFormFactory cdmFormFactory,
57
			ICdmFormElement formElement, int style) {
58
			ICdmFormElement formElement, int style, boolean isNomenclatural) {
58 59
		super(cdmFormFactory, formElement);
60
		this.isNomenclaturalTeam = isNomenclatural;
59 61
	}
60 62

  
61 63
	/** {@inheritDoc} */
......
65 67
        toggleable_cache = formFactory.createToggleableTextField(formElement, "Title Cache", entity.getTitleCache(), entity.isProtectedTitleCache(), style);
66 68
        toggleable_nomenclaturalTitleCache = formFactory.createToggleableTextField(formElement, "Abbrev. Title", entity.getNomenclaturalTitle(), entity.isProtectedNomenclaturalTitleCache(), style);
67 69
        hasAdditionalMembers = formFactory.createCheckbox(formElement, "Additional Members", entity.isHasMoreMembers(), style);
68
        section_teamMembers = formFactory.createTeamMemberSection(getConversationHolder(), formElement, ExpandableComposite.EXPANDED);
70
        section_teamMembers = formFactory.createTeamMemberSection(getConversationHolder(), formElement, ExpandableComposite.EXPANDED, isNomenclaturalTeam);
69 71
        section_teamMembers.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
70 72
    }
71 73

  
......
116 118

  
117 119
	        getEntity().setNomenclaturalTitle(toggleable_nomenclaturalTitleCache.getText(), pushedState);
118 120
	        setIrrelevant(pushedState, Arrays.asList(new Object[] { toggleable_cache }));
119
	        
121

  
120 122
        if (!getEntity().isProtectedNomenclaturalTitleCache()) {
121 123
            toggleable_nomenclaturalTitleCache.setText(getEntity().getNomenclaturalTitle());
122 124
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamDetailSection.java
28 28
 */
29 29
public class TeamDetailSection extends AbstractCdmDetailSection<Team>{
30 30

  
31
    private boolean isNomenclaturalTeam;
32

  
31 33
	/**
32 34
	 * <p>Constructor for TeamDetailSection.</p>
33 35
	 *
......
53 55
	 */
54 56
	@Override
55 57
	protected AbstractCdmDetailElement<Team> createCdmDetailElement(AbstractCdmDetailSection<Team> parentElement, int style) {
56
	    return formFactory.createTeamDetailElement(parentElement, style);
58
	    return formFactory.createTeamDetailElement(parentElement, style, isNomenclaturalTeam);
59
	}
60

  
61
	public boolean isNomenclaturalTeam(){
62
	    return isNomenclaturalTeam;
63
	}
64

  
65
	public void setIsNomenclaturalTeam(boolean isNomenclaturalTeam){
66
	    this.isNomenclaturalTeam = isNomenclaturalTeam;
57 67
	}
58 68
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamMemberElement.java
29 29
public class TeamMemberElement extends AbstractEntityCollectionElement<Person> {
30 30

  
31 31
	private EntitySelectionElement<Person> selection_person;
32
	private final boolean isNomenclatural;
32 33

  
33 34
	public TeamMemberElement(CdmFormFactory cdmFormFactory,
34 35
			AbstractFormSection section, Person entity,
35
			SelectionListener removeListener, int style) {
36
			SelectionListener removeListener, int style, boolean isNomenclatural) {
36 37
		super(cdmFormFactory, section, entity, removeListener, null, style);
38
		this.isNomenclatural =isNomenclatural;
39

  
37 40
	}
38 41

  
39 42
	/** {@inheritDoc} */
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamMemberSection.java
28 28
 */
29 29
public class TeamMemberSection extends AbstractUnboundEntityCollectionSection<Team, Person> {
30 30

  
31
    private boolean isNomenclaturalTeam = false;
32

  
31 33
	/**
32 34
	 * <p>Constructor for TeamMemberSection.</p>
33 35
	 *
......
36 38
	 * @param parentElement a {@link eu.etaxonomy.taxeditor.ui.element.ICdmFormElement} object.
37 39
	 * @param style a int.
38 40
	 */
39
	public TeamMemberSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style) {
41
	public TeamMemberSection(CdmFormFactory cdmFormFactory, ConversationHolder conversation, ICdmFormElement parentElement, int style, boolean isNomenclatural) {
40 42
		super(cdmFormFactory, conversation, parentElement, null, style);
43
		isNomenclaturalTeam = isNomenclatural;
41 44
	}
42 45

  
43 46
	/** {@inheritDoc} */
......
81 84
        return getEntity().getTeamMembers();
82 85
    }
83 86

  
87
    /**
88
     * @return
89
     */
90
    public boolean isNomenclaturalTeam() {
91
       return isNomenclaturalTeam;
92
    }
93

  
84 94

  
85 95
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/agent/TeamWizardPage.java
30 30
 */
31 31
public class TeamWizardPage extends AbstractCdmEntityWizardPage<Team> {
32 32

  
33
    private boolean isNomenclaturalTeam = false;
34

  
33 35
	/**
34 36
	 * <p>
35 37
	 * Constructor for TeamWizardPage.
......
45 47
	 *            a {@link eu.etaxonomy.cdm.model.agent.Team} object.
46 48
	 */
47 49
	public TeamWizardPage(CdmFormFactory formFactory,
48
			ConversationHolder conversation, Team entity) {
50
			ConversationHolder conversation, Team entity, boolean isNomenclaturalTeam) {
49 51
		super(formFactory, conversation, entity);
50 52
		setTitle("Team");
53
		setIsNomenclaturalTeam(isNomenclaturalTeam);
51 54
	}
52 55

  
53 56
	/** {@inheritDoc} */
54 57
	@Override
55 58
	public AbstractCdmDetailElement<Team> createElement(
56 59
			ICdmFormElement rootElement) {
57
		TeamDetailElement teamElement = formFactory.createTeamDetailElement(rootElement, SWT.NULL);
60
		TeamDetailElement teamElement = formFactory.createTeamDetailElement(rootElement, SWT.NULL, isNomenclaturalTeam);
58 61
		teamElement.setEntity(entity);
59 62
		return teamElement;
60 63
	}
64

  
65
    /**
66
     * @return the isNomenclaturalTeam
67
     */
68
    public boolean isNomenclaturalTeam() {
69
        return isNomenclaturalTeam;
70
    }
71

  
72
    public void setIsNomenclaturalTeam(boolean isNomenclaturalTeam){
73
        this.isNomenclaturalTeam = isNomenclaturalTeam;
74
    }
61 75
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/EditFromSelectionWizard.java
103 103
			addPage(new ReferenceWizardPage(formFactory,
104 104
					selectionElement.getConversationHolder(),
105 105
					(HibernateProxyHelper.deproxy(rootElement, Reference.class))));
106
		} else if (rootElement.isInstanceOf(Team.class)) {
106
		} else if (rootElement.isInstanceOf(Team.class) && selectionElement instanceof EntitySelectionElementWithAbbreviatedTitle<?>) {
107 107
			addPage(new TeamWizardPage(formFactory,
108
					selectionElement.getConversationHolder(), HibernateProxyHelper.deproxy(rootElement, Team.class)));
109
		} else if (rootElement.isInstanceOf(Person.class)) {
108
					selectionElement.getConversationHolder(), HibernateProxyHelper.deproxy(rootElement, Team.class), true));
109
		} else if (rootElement.isInstanceOf(Team.class) && !(selectionElement instanceof EntitySelectionElementWithAbbreviatedTitle<?>)) {
110
            addPage(new TeamWizardPage(formFactory,
111
                    selectionElement.getConversationHolder(), HibernateProxyHelper.deproxy(rootElement, Team.class), false));
112
        } else if (rootElement.isInstanceOf(Person.class)) {
110 113
			addPage(new PersonWizardPage(formFactory,
111 114
					selectionElement.getConversationHolder(), HibernateProxyHelper.deproxy(rootElement, Person.class)));
112 115
		} else if (rootElement.isInstanceOf(NonViralName.class)) {

Also available in: Unified diff