Project

General

Profile

« Previous | Next » 

Revision f8c6c088

Added by Katja Luther about 8 years ago

add media bulk editor see #4730

View differences:

eu.etaxonomy.taxeditor.bulkeditor/OSGI-INF/l10n/messages.properties
6 6
BulkEditorInputType_5=Users
7 7
BulkEditorInputType_6=Groups
8 8
BulkEditorInputType_7=Taxa
9
BulkEditorInputType_8=Media
eu.etaxonomy.taxeditor.bulkeditor/OSGI-INF/l10n/messages_de.properties
6 6
BulkEditorInputType_5=Nutzer
7 7
BulkEditorInputType_6=Nutzergruppen
8 8
BulkEditorInputType_7=Taxa
9
BulkEditorInputType_8=Medien
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorLables.java
1
/**
2
	* Copyright (C) 2016 EDIT
3
	* European Distributed Institute of Taxonomy
4
	* http://www.e-taxonomy.eu
5
	*
6
	* The contents of this file are subject to the Mozilla Public License Version 1.1
7
	* See LICENSE.TXT at the top of this package for the full license terms.
8
	*/
9

  
10
package eu.etaxonomy.taxeditor.bulkeditor;
11
/**
12
 * @author kluther
13
 * @date 29 Feb 2016
14
 *
15
 */
16
public interface BulkEditorLables {
17
	
18

  
19

  
20
	    public static final String CONVERT_TEAM_2_PERSON_LABEL = "Convert Team to Person";
21
	    public static final String CONVERT_PERSON_2_TEAM_LABEL = "Convert Person to Team";
22
	    public static final String DELETE_LABEL = "Delete";
23
	    public static final String MERGE_GROUP_LABEL = "Merge Group";
24
	    public static final String REMOVE_MERGE_CANDIDATE_LABEL = "Remove from Merge Group";
25
	    public static final String SET_MERGE_CANDIDATE_LABEL = "Set as Merge Candidate";
26
	    public static final String SET_MERGE_TARGET_LABEL = "Set as Merge Target";
27

  
28
	    public static final String NO_CONVERT_PERSON_TO_TEAM_MESSAGE = "Can not convert Person into a Team.";
29
	    public static final String TRANSFORMATION_NOT_POSSIBLE_PERSON_PART_OF_TEAM_MESSAGE = "Person can not be transformed into team as it is already part of a team.";
30
	    public static final String NO_CONVERT_TEAM_TO_PERSON_MESSAGE = "Can not convert Team to Person";
31
	   
32
	   
33
	    public static final String UNSAVED_CHANGES_MESSAGE = "There are unsaved changes in the source taxon. Please save first.";
34
		public static final String SINGLE_PERSON_SELECTION_MESSAGE = "The chosen operation is available only for a single person";
35
		public static final String SINGLE_TEAM_SELECTION_MESSAGE = "The chosen operation is available only for a single team";
36
		public static final String NO_PERSON_SELECTION_MESSAGE = "No person selected for conversion";
37
		public static final String ONLY_PERSON_SELECTION_MESSAGE = "Only a person can be converted into a team.";
38
		public static final String NO_TEAM_SELECTION_MESSAGE = "No team selected for conversion";
39
		public static final String ONLY_TEAM_SELECTION_MESSAGE = "Only a team can be converted into a person.";
40
		public static final String ONLY_FOR_BULKEDITOR_MESSAGE = "You have to choose a line in the bulkeditor to perform this operation.";
41

  
42

  
43

  
44
	
45

  
46
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/BulkEditorPropertyTester.java
17 17
import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
18 18
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
19 19
import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
20
import eu.etaxonomy.taxeditor.bulkeditor.input.MediaEditorInput;
20 21
import eu.etaxonomy.taxeditor.bulkeditor.input.OccurrenceEditorInput;
21 22
import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
22 23

  
......
41 42
    public static final String IS_CONVERT_ENABLED = "isConvertingEnabled";
42 43
    public static final String IS_PERSON = "isPerson";
43 44
    public static final String IS_TEAM = "isTeam";
45
    public static final String IS_MEDIA_EDITOR = "isMediaEditor";
44 46
	/* (non-Javadoc)
45 47
	 * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
46 48
	 */
......
72 74
		}
73 75
        else if(IS_TAXON_EDITOR.equals(property)){
74 76
            return bulkEditor.getEditorInput() instanceof TaxonEditorInput;
77
        } else if(IS_MEDIA_EDITOR.equals(property)){
78
            return bulkEditor.getEditorInput() instanceof MediaEditorInput;
75 79
        }
76 80

  
77 81
//		if (("isPublishFlagEditingEnabled").equals(property)) {
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/command/OpenBulkEditorContributionItem.java
81 81
        contributionItems.add(new Separator(groupName));
82 82
        contributionItems.add(BulkEditorInputType.USER.createContributionItem());
83 83
        contributionItems.add(BulkEditorInputType.GROUP.createContributionItem());
84
        
84
        contributionItems.add(BulkEditorInputType.MEDIA.createContributionItem());
85 85
        return contributionItems.toArray(new IContributionItem[contributionItems.size()]);
86 86
    }
87 87

  
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/BulkEditorInputType.java
1 1
package eu.etaxonomy.taxeditor.bulkeditor.input;
2 2

  
3 3
import java.util.HashMap;
4
import java.util.Locale;
5 4
import java.util.Map;
6 5
import java.util.ResourceBundle;
7 6

  
......
14 13

  
15 14
import eu.etaxonomy.cdm.api.service.IAgentService;
16 15
import eu.etaxonomy.cdm.api.service.IGroupService;
16
import eu.etaxonomy.cdm.api.service.IMediaService;
17 17
import eu.etaxonomy.cdm.api.service.INameService;
18 18
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
19 19
import eu.etaxonomy.cdm.api.service.IReferenceService;
......
22 22
import eu.etaxonomy.cdm.model.agent.AgentBase;
23 23
import eu.etaxonomy.cdm.model.common.Group;
24 24
import eu.etaxonomy.cdm.model.common.User;
25
import eu.etaxonomy.cdm.model.media.Media;
25 26
import eu.etaxonomy.cdm.model.name.NameRelationship;
26 27
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
27 28
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
28 29
import eu.etaxonomy.cdm.model.reference.Reference;
29 30
import eu.etaxonomy.cdm.model.taxon.Taxon;
30 31
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorConstants;
31
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
32
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
33 32

  
34 33
public enum BulkEditorInputType {
35
	AGENT(Messages.BulkEditorInputType_0, AgentEditorInput.ID), 
36
	REFERENCE(Messages.BulkEditorInputType_1, ReferenceEditorInput.ID), 
37
	NAME(Messages.BulkEditorInputType_2, NameEditorInput.ID), 
38
	NAME_RELATIONSHIP(Messages.BulkEditorInputType_3, NameRelationshipEditorInput.ID), 
39
	OCCURRENCE(Messages.BulkEditorInputType_4, OccurrenceEditorInput.ID), 
40
	USER(Messages.BulkEditorInputType_5, UserEditorInput.ID), 
34
	AGENT(Messages.BulkEditorInputType_0, AgentEditorInput.ID),
35
	REFERENCE(Messages.BulkEditorInputType_1, ReferenceEditorInput.ID),
36
	NAME(Messages.BulkEditorInputType_2, NameEditorInput.ID),
37
	NAME_RELATIONSHIP(Messages.BulkEditorInputType_3, NameRelationshipEditorInput.ID),
38
	OCCURRENCE(Messages.BulkEditorInputType_4, OccurrenceEditorInput.ID),
39
	USER(Messages.BulkEditorInputType_5, UserEditorInput.ID),
41 40
	GROUP(Messages.BulkEditorInputType_6, GroupEditorInput.ID),
42
	TAXON(Messages.BulkEditorInputType_7, TaxonEditorInput.ID);
41
	TAXON(Messages.BulkEditorInputType_7, TaxonEditorInput.ID),
42
	MEDIA(Messages.BulkEditorInputType_8, MediaEditorInput.ID);
43 43

  
44 44
	public String id;
45 45
	public String label;
46
	public ResourceBundle resourceBundle; 
46
	public ResourceBundle resourceBundle;
47 47

  
48 48
	BulkEditorInputType(String label, String id) {
49 49
		this.id = id;
50 50
		this.label = label;
51 51
	}
52 52

  
53
	public IContributionItem createContributionItem(){ 
53
	public IContributionItem createContributionItem(){
54 54
		return createContributionItem(label, id);
55 55
	}
56
	
56

  
57 57
	/**
58 58
	 * @param key
59 59
	 * @param object
......
73 73

  
74 74
		return new CommandContributionItem(parameter);
75 75
	}
76
	
76

  
77 77
	public static BulkEditorInputType getById(String id) {
78 78

  
79 79
		for (BulkEditorInputType type : values()) {
......
102 102
			return USER;
103 103
		} else if (Taxon.class.isAssignableFrom(clazz)){
104 104
			return TAXON;
105
		}
105
		} else if (Media.class.isAssignableFrom(clazz)){
106
            return MEDIA;
107
        }
106 108
		return null;
107 109
	}
108 110

  
......
123 125
			return GROUP;
124 126
		} else if (input instanceof TaxonEditorInput){
125 127
			return TAXON;
126
		}
128
		}else if (input instanceof MediaEditorInput){
129
            return MEDIA;
130
        }
127 131
		return null;
128 132
	}
129 133

  
......
146 150
			return new GroupEditorInput();
147 151
		case TAXON:
148 152
			return new TaxonEditorInput();
153
		case MEDIA:
154
            return new MediaEditorInput();
149 155
		default:
150 156
			throw new IllegalStateException(
151 157
					"No input class for the given input type defined."); //$NON-NLS-1$
152 158
		}
153 159
	}
154
	
160

  
155 161
	public static Class getServiceClass(
156 162
			BulkEditorInputType inputType) {
157 163
		switch (inputType) {
......
171 177
			return IGroupService.class;
172 178
		case TAXON:
173 179
			return ITaxonService.class;
180
		case MEDIA:
181
            return IMediaService.class;
174 182
		default:
175 183
			throw new IllegalStateException(
176 184
					"No input class for the given input type defined."); //$NON-NLS-1$
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/MediaEditorInput.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.bulkeditor.input;
11

  
12
import java.util.List;
13

  
14
import eu.etaxonomy.cdm.api.service.IMediaService;
15
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
16
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
17
import eu.etaxonomy.cdm.model.media.Media;
18
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
19
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
20
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.MediaCreator;
21
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider;
22
import eu.etaxonomy.taxeditor.store.CdmStore;
23

  
24
/**
25
 * @author k.luther
26
 * @date 10.03.2016
27
 *
28
 */
29
public class MediaEditorInput extends AbstractBulkEditorInput<Media> {
30
    public static final String ID = "bulkeditor.input.media";
31

  
32
    private static MediaEditorInput instance;
33

  
34
    public static String getID() {
35
        return ID;
36
    }
37

  
38
    public static AbstractBulkEditorInput getInstance() {
39
        if (instance == null) {
40
            instance = new MediaEditorInput();
41
        }
42
        return instance;
43
    }
44

  
45
    @Override
46
    public String getName() {
47
        return BulkEditorInputType.MEDIA.label;
48
    }
49

  
50
    @Override
51
    public String getToolTipText() {
52
        return getName();
53
    }
54

  
55
    @Override
56
    public Media save(Media entity) {
57
        if(CdmStore.getCurrentSessionManager().isRemoting()) {
58
            return CdmStore.getService(IMediaService.class).merge(entity, true).getMergedEntity();
59
        } else {
60
            CdmStore.getService(IMediaService.class).saveOrUpdate(entity) ;
61
            return entity;
62
        }
63
    }
64

  
65
    @Override
66
    public boolean delete(Media entity) throws ReferencedObjectUndeletableException {
67
        return CdmStore.getService(IMediaService.class).delete(entity) != null;
68
    }
69

  
70
    @Override
71
    protected List<Media> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
72
        return CdmStore.getSearchManager().findMedia(configurator);
73
    }
74

  
75
    @Override
76
    protected IEntityCreator<Media> createEntityCreator() {
77
        return new MediaCreator();
78
    }
79

  
80
    @Override
81
    public void merge() {
82
        // TODO Auto-generated method stub
83

  
84
    }
85

  
86
    @Override
87
    public List<IBulkEditorSortProvider<Media>> getSortProviders() {
88
        List<IBulkEditorSortProvider<Media>> sortProviders = super.getSortProviders();
89

  
90
        sortProviders.add(0, new IdentifiableEntitySortProvider<Media>());
91

  
92
        return sortProviders;
93
    }
94
}
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/Messages.java
12 12
	public static String BulkEditorInputType_5;
13 13
	public static String BulkEditorInputType_6;
14 14
	public static String BulkEditorInputType_7;
15
	public static String BulkEditorInputType_8;
15 16
	static {
16 17
		// initialize resource bundle
17 18
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/entitycreator/MediaCreator.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.bulkeditor.input.entitycreator;
11

  
12
import java.util.HashMap;
13
import java.util.Map;
14

  
15
import eu.etaxonomy.cdm.model.media.Media;
16
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
17

  
18
/**
19
 * @author k.luther
20
 * @date 10.03.2016
21
 *
22
 */
23
public class MediaCreator implements IEntityCreator<Media> {
24

  
25
    /**
26
     * {@inheritDoc}
27
     */
28
    @Override
29
    public Media createEntity(String text) {
30
        Media result = Media.NewInstance();
31
        result.setTitleCache(text);
32
        return result;
33
    }
34

  
35
    /**
36
     * {@inheritDoc}
37
     */
38
    @Override
39
    public Media createEntity(Object key, String text) {
40
        if (key.equals(Media.class)){
41
            Media result = Media.NewInstance();
42
            result.setTitleCache(text);
43
            return result;
44
        }
45
        return null;
46
    }
47

  
48
    /**
49
     * {@inheritDoc}
50
     */
51
    @Override
52
    public Map<Object, String> getKeyLabelPairs() {
53
        Map<Object, String> result = new HashMap<Object, String>();
54
       result.put(Media.class, "Media");
55
        return result;
56
    }
57

  
58
    /**
59
     * {@inheritDoc}
60
     */
61
    @Override
62
    public boolean savesEntity() {
63
        // TODO Auto-generated method stub
64
        return false;
65
    }
66

  
67
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java
20 20

  
21 21
import eu.etaxonomy.cdm.api.service.IAgentService;
22 22
import eu.etaxonomy.cdm.api.service.IGroupService;
23
import eu.etaxonomy.cdm.api.service.IMediaService;
23 24
import eu.etaxonomy.cdm.api.service.INameService;
24 25
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
25 26
import eu.etaxonomy.cdm.api.service.IReferenceService;
......
35 36
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
36 37
import eu.etaxonomy.cdm.model.common.RelationshipBase;
37 38
import eu.etaxonomy.cdm.model.common.User;
39
import eu.etaxonomy.cdm.model.media.Media;
38 40
import eu.etaxonomy.cdm.model.name.NameRelationship;
39 41
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
40 42
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
......
244 246
		return NO_RESULTS;
245 247
	}
246 248

  
249
	public List findMedia(IIdentifiableEntityServiceConfigurator configurator) {
250
        if(checkLargeResult(CdmStore.getService(IMediaService.class).countByTitle(configurator))){
251
            List<Media> records = CdmStore.getService(IMediaService.class).findByTitle(configurator).getRecords();
252
            addUuidSearchResults(records, configurator, IMediaService.class);
253
            return records;
254
        }
255
        return NO_RESULTS;
256
    }
257

  
247 258

  
248 259
}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/AbstractEntityCollectionElement.java
58 58
	private final Composite box;
59 59

  
60 60
	private Button btnRemove;
61
    private Button btnChooseEntity;
61
    protected Button btnChooseEntity;
62 62

  
63 63
	private Color backgroundColor;
64 64

  
......
101 101
		if(isChoosableEntity){
102 102
		    btnChooseEntity = formFactory.createButton(box, null, SWT.PUSH);
103 103
		    addControl(btnChooseEntity);
104
		    
104 105
		    btnChooseEntity.setLayoutData(LayoutConstants.RIGHT());
105 106
		    btnChooseEntity.setImage(ImageResources.getImage(ImageResources.BROWSE_ICON));
106 107
		    btnChooseEntity.setToolTipText("Browse");
......
116 117
		                    ((AbstractEntityCollectionSection)getParentElement()).addElement(entity);
117 118
		                    ((AbstractEntityCollectionSection)getParentElement()).firePropertyChangeEvent(getParentElement());
118 119
		                }
120
		                
119 121
		            }
120 122
		        }
121 123
		    });
......
187 189
			return;
188 190
		}
189 191
		Object eventSource = event.getSource();
190
		if (getElements().contains(eventSource)) {
192
		if (getElements().contains(eventSource) || getControls().contains(eventSource)) {
191 193
			handleEvent(eventSource);
192 194
		}
193 195
	}
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/media/MediaMetaElement.java
3 3
 */
4 4
package eu.etaxonomy.taxeditor.ui.section.media;
5 5

  
6
import org.apache.commons.lang.StringUtils;
6 7
import org.eclipse.jface.action.IAction;
8
import org.eclipse.swt.SWT;
7 9
import org.eclipse.swt.events.SelectionAdapter;
8 10
import org.eclipse.swt.events.SelectionEvent;
9 11
import org.eclipse.swt.events.SelectionListener;
10 12
import org.eclipse.swt.widgets.Button;
13
import org.eclipse.swt.widgets.Event;
14
import org.eclipse.swt.widgets.Listener;
11 15

  
12 16
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
13 17
import eu.etaxonomy.cdm.model.agent.AgentBase;
......
25 29
import eu.etaxonomy.taxeditor.ui.element.SelectionArbitrator;
26 30
import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailSection;
27 31
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionElement;
32
import eu.etaxonomy.taxeditor.ui.section.AbstractEntityCollectionSection;
28 33
import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
29 34

  
30 35
/**
......
48 53
        if(cdmFormFactory.getSelectionProvider() != null){
49 54
            selectionArbitrator = cdmFormFactory.createSelectionArbitrator(this);
50 55
        }
56
       
57
       
51 58
    }
52 59

  
53 60
    /** {@inheritDoc} */
......
65 72
        });
66 73
        text_title = formFactory.createLanguageStringWithLabelElement(element, "Title", null, style);
67 74
        selection_artist = formFactory.createSelectionElement(AgentBase.class, getConversationHolder(), element, "Artist", null, EntitySelectionElement.ALL, style);
75
        addElement(selection_artist);
68 76
        text_description = formFactory.createLanguageStringWithLabelElement(element, "Description", null, 100, true, style);
69 77
        mediaDetailElement = formFactory.createMediaDetailElement(element);
78
        addElement(mediaDetailElement);
70 79
    }
71 80

  
72 81
    /** {@inheritDoc} */
......
84 93
        LanguageString title = element.getTitle(CdmStore.getDefaultLanguage());
85 94

  
86 95
        if (title == null) {
87
            title = LanguageString.NewInstance("", CdmStore.getDefaultLanguage());
96
            title = LanguageString.NewInstance(element.getTitleCache(), CdmStore.getDefaultLanguage());
88 97
        }
89 98

  
90 99
        text_title.setLanguageString(title);
100
        
91 101
    }
92 102

  
93 103
    @Override
94 104
    protected Media selectFromDialog() {
95
        return MediaSelectionDialog.select(AbstractUtility.getShell(), null, null);
105
    	
106
    	setEntity(MediaSelectionDialog.select(AbstractUtility.getShell(), null, null));
107
        return entity;
96 108
    }
97 109

  
98 110
    @Override
......
101 113
    }
102 114

  
103 115
    /** {@inheritDoc} */
104
    @Override
116
   @Override
105 117
    public void handleEvent(Object eventSource) {
106 118
        if (eventSource == selection_artist) {
107 119
            getEntity().setArtist(selection_artist.getSelection());

Also available in: Unified diff