Project

General

Profile

« Previous | Next » 

Revision a789364c

Added by Katja Luther about 7 years ago

fix #5216: merge grantedAuthority checks for existing grantedAuthority first and some other fixes for grantedAuthority handling in editor

View differences:

eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties
140 140
DeleteConfiguration_media_removeFromGallery=Remove the media from the image gallery but leave it in database
141 141
DeleteConfiguration_media_deleteIfUsedInTaxonDescription=Delete also if media is used in taxon description
142 142
DeleteConfiguration_media_deleteIfUsedInSpecimenDescription=Delete also if media is used in specimen description        
143
DeleteConfiguration_media_delete=Delete the media completely
143
DeleteConfiguration_media_delete=Delete the media completely
144

  
145
NewGrantedAuthority_AlreadyInDb=The granted authority already exists.
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
139 139
DeleteConfiguration_media_deleteIfUsedInTaxonDescription=L?sche das Medienobjekt, auch wenn es von einem Taxon verwendet wird
140 140
DeleteConfiguration_media_deleteIfUsedInSpecimenDescription=L?sche das Medienobjekt, auch wenn es von einem Specimen verwendet wird
141 141
DeleteConfiguration_media_delete=L?sche das Medienobjekt
142

  
143
NewGrantedAuthority_AlreadyInDb=Die GrantedAuthority ist bereits in der DB enthalten.
144

  
145

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java
149 149
	public static String DeleteConfiguration_media_deleteIfUsedInTaxonDescription;
150 150
	public static String DeleteConfiguration_media_deleteIfUsedInSpecimenDescription;
151 151
	public static String DeleteConfiguration_media_delete;
152
	public static String NewGrantedAuthority_AlreadyInDb;
152 153
	static {
153 154
        // initialize resource bundle
154 155
        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewGrantedAuthorityWizard.java
11 11

  
12 12
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
13 13
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
14
import eu.etaxonomy.taxeditor.Messages;
15
import eu.etaxonomy.taxeditor.model.MessagingUtils;
14 16
import eu.etaxonomy.taxeditor.store.CdmStore;
15 17
import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailWizardPage;
16 18

  
......
37 39
	 */
38 40
	@Override
39 41
	protected void saveEntity() {
40
	    CdmStore.getService(IGrantedAuthorityService.class).merge(getEntity(), true);
41
	   
42
	    try{
43
	        CdmStore.getService(IGrantedAuthorityService.class).merge(getEntity(), true);
44
	    }catch (Exception e){
45
	        MessagingUtils.info(Messages.NewGrantedAuthority_AlreadyInDb);
46
	    }
47

  
42 48
	}
43 49

  
44 50
	/* (non-Javadoc)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/grantedAuthority/GrantedAuthorityCollectionElement.java
1 1
/**
2 2
* Copyright (C) 2012 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
*/
......
12 12
import org.eclipse.swt.events.SelectionListener;
13 13

  
14 14
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
15
import eu.etaxonomy.cdm.model.common.Group;
15 16
import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
16 17
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
17 18
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
......
24 25
 *
25 26
 */
26 27
public class GrantedAuthorityCollectionElement extends AbstractEntityCollectionElement<GrantedAuthorityImpl> {
27
	
28

  
28 29
	private EntitySelectionElement<GrantedAuthorityImpl> selection_authority;
30
	private Group grantedAuthorityUser;
29 31

  
30 32

  
31 33
	public GrantedAuthorityCollectionElement(CdmFormFactory formFactory,
32
			AbstractFormSection section, GrantedAuthorityImpl entity,
34
			AbstractFormSection section, GrantedAuthorityImpl entity, Group group,
33 35
			SelectionListener removeListener, int style) {
34
		super(formFactory, section, entity, removeListener, null, style);		
36
		super(formFactory, section, entity, removeListener, null, style);
37
		this.grantedAuthorityUser = group;
35 38
		// TODO Auto-generated constructor stub
36 39
	}
37 40

  
......
40 43
	 */
41 44
	@Override
42 45
	public void setEntity(GrantedAuthorityImpl entity) {
43
		selection_authority.setEntity(entity);
44
		
46
		this.entity = entity;
47

  
45 48
	}
46 49

  
47 50
	/* (non-Javadoc)
......
59 62
	@Override
60 63
	public void handleEvent(Object eventSource) {
61 64
		if (eventSource == selection_authority) {
65
		    GrantedAuthorityImpl oldGrantedAuthority = entity;
66
		    grantedAuthorityUser.removeGrantedAuthority(entity);
67

  
62 68
			setEntity(selection_authority.getEntity());
69
			grantedAuthorityUser.addGrantedAuthority(entity);
70

  
63 71
		}
64 72
	}
65 73

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/grantedAuthority/GrantedAuthorityDetailElement.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
*/
......
10 10
package eu.etaxonomy.taxeditor.ui.section.grantedAuthority;
11 11

  
12 12
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
13
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
14 13
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
15 14
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
16 15
import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
......
25 24
public class GrantedAuthorityDetailElement extends AbstractCdmDetailElement<GrantedAuthorityImpl> {
26 25

  
27 26
	private TextWithLabelElement text_authority;
28
	
27

  
29 28
	/**
30 29
	 * @param formFactory
31 30
	 * @param formElement
......
38 37
	@Override
39 38
	protected void createControls(ICdmFormElement formElement,
40 39
			GrantedAuthorityImpl entity, int style) {
41
		
42
		String labelText = GrantedAuthorityLabelTextProvider.getText(entity);
43
		text_authority = formFactory.createTextWithLabelElement(formElement, "Authority", labelText, style);
44
		
40

  
41
		String labelText = null;
42
		if (entity.getAuthority() != null){
43
		    labelText = GrantedAuthorityLabelTextProvider.getText(entity);
44
		}
45
	    text_authority = formFactory.createTextWithLabelElement(formElement, "Authority", null, style);
46

  
45 47
	}
46 48

  
47 49
	@Override
......
49 51
		if(eventSource == text_authority){
50 52
			getEntity().setAuthority(text_authority.getText());
51 53
		}
52
		
54

  
53 55
	}
54 56

  
55 57

  
56
	
58

  
57 59
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/grantedAuthority/GrantedAuthorityDetailSection.java
119 119
     */
120 120
    @Override
121 121
    public GrantedAuthority addExisting() {
122
        System.err.println("Test");
122 123
        return null;
123 124
    }
124 125

  

Also available in: Unified diff