Project

General

Profile

« Previous | Next » 

Revision 23b1c77b

Added by Patrick Plitzner almost 8 years ago

Saving files before refreshing line endings

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NomenclaturalAuthorSelectionDialog.java
1
// $Id$
2
/**
3
* Copyright (C) 2016 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 org.eclipse.swt.widgets.Shell;
13

  
14
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15
import eu.etaxonomy.cdm.api.service.IAgentService;
16
import eu.etaxonomy.cdm.model.agent.AgentBase;
17
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19

  
20
/**
21
 * @author k.luther
22
 * @date 25.05.2016
23
 *
24
 */
25
public class NomenclaturalAuthorSelectionDialog extends AgentSelectionDialog {
26

  
27

  
28
    /**
29
     * @param shell
30
     * @param conversation
31
     * @param title
32
     * @param multi
33
     * @param settings
34
     * @param agent
35
     */
36
    protected NomenclaturalAuthorSelectionDialog(Shell shell, ConversationHolder conversation, String title,
37
            boolean multi, String settings, AgentBase agent) {
38
        super(shell, conversation, title, multi, settings, agent);
39
        // TODO Auto-generated constructor stub
40
    }
41

  
42
    @Override
43
    protected void initModel() {
44
        model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(null, null, null);
45
    }
46

  
47
    /**
48
     * <p>select</p>
49
     *
50
     * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
51
     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
52
     * @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
53
     * @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
54
     */
55
    public static AgentBase select(Shell shell, ConversationHolder conversation, AgentBase entity) {
56
        NomenclaturalAuthorSelectionDialog dialog = new NomenclaturalAuthorSelectionDialog(shell, conversation,
57
                "Choose Agent", false, NomenclaturalAuthorSelectionDialog.class.getCanonicalName(), entity);
58
        return getSelectionFromDialog(dialog);
59
    }
60

  
61
    /**
62
     * <p>getTitle</p>
63
     *
64
     * @param cdmObject a T object.
65
     * @return a {@link java.lang.String} object.
66
     */
67
    @Override
68
    protected String getTitle(AgentBase cdmObject) {
69
        if(cdmObject == null){
70
            return "";
71
        }
72

  
73
        if (cdmObject instanceof TeamOrPersonBase) {
74
            return ((TeamOrPersonBase) cdmObject).getNomenclaturalTitle();
75
        } else if (cdmObject instanceof AgentBase){
76
            return ((TeamOrPersonBase) cdmObject).getTitleCache();
77
        }
78

  
79
        throw new IllegalArgumentException("Generic method only" +
80
                " supports cdmObject of type IIdentifiableEntity." +
81
                " Please implement specific method in subclass.");
82
    }
83

  
84
}
1
// $Id$
2
/**
3
* Copyright (C) 2016 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 org.eclipse.swt.widgets.Shell;
13

  
14
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
15
import eu.etaxonomy.cdm.api.service.IAgentService;
16
import eu.etaxonomy.cdm.model.agent.AgentBase;
17
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
18
import eu.etaxonomy.taxeditor.store.CdmStore;
19

  
20
/**
21
 * @author k.luther
22
 * @date 25.05.2016
23
 *
24
 */
25
public class NomenclaturalAuthorSelectionDialog extends AgentSelectionDialog {
26

  
27

  
28
    /**
29
     * @param shell
30
     * @param conversation
31
     * @param title
32
     * @param multi
33
     * @param settings
34
     * @param agent
35
     */
36
    protected NomenclaturalAuthorSelectionDialog(Shell shell, ConversationHolder conversation, String title,
37
            boolean multi, String settings, AgentBase agent) {
38
        super(shell, conversation, title, multi, settings, agent);
39
        // TODO Auto-generated constructor stub
40
    }
41

  
42
    @Override
43
    protected void initModel() {
44
        model = CdmStore.getService(IAgentService.class).getUuidAndAbbrevTitleCache(null, null, null);
45
    }
46

  
47
    /**
48
     * <p>select</p>
49
     *
50
     * @param shell a {@link org.eclipse.swt.widgets.Shell} object.
51
     * @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
52
     * @param entity a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
53
     * @return a {@link eu.etaxonomy.cdm.model.agent.AgentBase} object.
54
     */
55
    public static AgentBase select(Shell shell, ConversationHolder conversation, AgentBase entity) {
56
        NomenclaturalAuthorSelectionDialog dialog = new NomenclaturalAuthorSelectionDialog(shell, conversation,
57
                "Choose Agent", false, NomenclaturalAuthorSelectionDialog.class.getCanonicalName(), entity);
58
        return getSelectionFromDialog(dialog);
59
    }
60

  
61
    /**
62
     * <p>getTitle</p>
63
     *
64
     * @param cdmObject a T object.
65
     * @return a {@link java.lang.String} object.
66
     */
67
    @Override
68
    protected String getTitle(AgentBase cdmObject) {
69
        if(cdmObject == null){
70
            return "";
71
        }
72

  
73
        if (cdmObject instanceof TeamOrPersonBase) {
74
            return ((TeamOrPersonBase) cdmObject).getNomenclaturalTitle();
75
        } else if (cdmObject instanceof AgentBase){
76
            return ((TeamOrPersonBase) cdmObject).getTitleCache();
77
        }
78

  
79
        throw new IllegalArgumentException("Generic method only" +
80
                " supports cdmObject of type IIdentifiableEntity." +
81
                " Please implement specific method in subclass.");
82
    }
83

  
84
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SpecimenOrObservationBaseSelectionDialog.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 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

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

  
13
import java.util.UUID;
14

  
15
import org.eclipse.swt.widgets.Shell;
16

  
17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
19
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
20
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
21
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
22
import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

  
25
/**
26
 * @author pplitzner
27
 */
28
public class SpecimenOrObservationBaseSelectionDialog extends
29
		AbstractFilteredCdmResourceSelectionDialog<SpecimenOrObservationBase> {
30

  
31
	public static SpecimenOrObservationBase select(Shell shell, ConversationHolder conversation, SpecimenOrObservationBase observation){
32
		SpecimenOrObservationBaseSelectionDialog dialog = new SpecimenOrObservationBaseSelectionDialog(shell, conversation,
33
				"Choose field unit or derived unit", false, SpecimenOrObservationBaseSelectionDialog.class.getCanonicalName(), observation);
34
		return getSelectionFromDialog(dialog);
35
	}
36

  
37
	protected SpecimenOrObservationBaseSelectionDialog(Shell shell, ConversationHolder conversation,
38
			String title, boolean multi, String settings,
39
			SpecimenOrObservationBase cdmObject) {
40
		super(shell, conversation, title, multi, settings, cdmObject);
41
	}
42

  
43
	/** {@inheritDoc} */
44
	@Override
45
	protected SpecimenOrObservationBase getPersistentObject(UUID uuid) {
46
		Object object = CdmStore.getService(IOccurrenceService.class).load(uuid);
47
		return HibernateProxyHelper.deproxy(object, SpecimenOrObservationBase.class);
48
	}
49

  
50
	/** {@inheritDoc} */
51
	@Override
52
	protected void initModel() {
53
		model = CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache(null, null);
54
	}
55

  
56
	/** {@inheritDoc} */
57
	@Override
58
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
59
		return new NewDerivedUnitBaseWizard();
60
	}
61

  
62
	/** {@inheritDoc} */
63
	@Override
64
	protected String getNewWizardLinkText() {
65
		return String.format("Create a new <a>%1s</a>", "field unit/derived unit");
66
	}
67
}
1
// $Id$
2
/**
3
* Copyright (C) 2007 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

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

  
13
import java.util.UUID;
14

  
15
import org.eclipse.swt.widgets.Shell;
16

  
17
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
18
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
19
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
20
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
21
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
22
import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
23
import eu.etaxonomy.taxeditor.store.CdmStore;
24

  
25
/**
26
 * @author pplitzner
27
 */
28
public class SpecimenOrObservationBaseSelectionDialog extends
29
		AbstractFilteredCdmResourceSelectionDialog<SpecimenOrObservationBase> {
30

  
31
	public static SpecimenOrObservationBase select(Shell shell, ConversationHolder conversation, SpecimenOrObservationBase observation){
32
		SpecimenOrObservationBaseSelectionDialog dialog = new SpecimenOrObservationBaseSelectionDialog(shell, conversation,
33
				"Choose field unit or derived unit", false, SpecimenOrObservationBaseSelectionDialog.class.getCanonicalName(), observation);
34
		return getSelectionFromDialog(dialog);
35
	}
36

  
37
	protected SpecimenOrObservationBaseSelectionDialog(Shell shell, ConversationHolder conversation,
38
			String title, boolean multi, String settings,
39
			SpecimenOrObservationBase cdmObject) {
40
		super(shell, conversation, title, multi, settings, cdmObject);
41
	}
42

  
43
	/** {@inheritDoc} */
44
	@Override
45
	protected SpecimenOrObservationBase getPersistentObject(UUID uuid) {
46
		Object object = CdmStore.getService(IOccurrenceService.class).load(uuid);
47
		return HibernateProxyHelper.deproxy(object, SpecimenOrObservationBase.class);
48
	}
49

  
50
	/** {@inheritDoc} */
51
	@Override
52
	protected void initModel() {
53
		model = CdmStore.getService(IOccurrenceService.class).getUuidAndTitleCache(null, null);
54
	}
55

  
56
	/** {@inheritDoc} */
57
	@Override
58
	protected AbstractNewEntityWizard getNewEntityWizard(String parameter) {
59
		return new NewDerivedUnitBaseWizard();
60
	}
61

  
62
	/** {@inheritDoc} */
63
	@Override
64
	protected String getNewWizardLinkText() {
65
		return String.format("Create a new <a>%1s</a>", "field unit/derived unit");
66
	}
67
}

Also available in: Unified diff