3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.editor
.images
;
13 import java
.util
.HashSet
;
16 import org
.apache
.log4j
.Logger
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
18 import org
.eclipse
.ui
.IEditorInput
;
19 import org
.eclipse
.ui
.IEditorSite
;
20 import org
.eclipse
.ui
.PartInitException
;
22 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
23 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
24 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
25 import eu
.etaxonomy
.taxeditor
.editor
.AbstractTaxonEditor
;
26 import eu
.etaxonomy
.taxeditor
.editor
.FreeTextElementFactory
;
27 import eu
.etaxonomy
.taxeditor
.editor
.GroupComposite
;
28 import eu
.etaxonomy
.taxeditor
.editor
.GroupedComposite
;
29 import eu
.etaxonomy
.taxeditor
.editor
.MultiPageTaxonEditor
;
30 import eu
.etaxonomy
.taxeditor
.store
.model
.ImagesUtil
;
38 public class TaxonImageEditor
extends AbstractTaxonEditor
{
39 private static final Logger logger
= Logger
40 .getLogger(TaxonImageEditor
.class);
42 private static final String ID
= "eu.etaxonomy.taxeditor.taxonImageEditor";
44 private TaxonDescription emptyGallery
;
46 public TaxonImageEditor(MultiPageTaxonEditor editor
){
50 public void init(IEditorSite site
, IEditorInput input
)
51 throws PartInitException
{
53 super.init(site
, input
);
57 protected void createManagedForm(Composite composite
) {
59 super.createManagedForm(composite
);
61 Set
<TaxonDescription
> descriptions
= taxon
.getDescriptions();
62 Set
<DescriptionBase
> imageGalleries
= new HashSet
<DescriptionBase
>();
64 for(TaxonDescription description
: descriptions
){
65 if(description
.isImageGallery()){
66 imageGalleries
.add(description
);
71 if(imageGalleries
.size() == 0){
72 emptyGallery
= TaxonDescription
.NewInstance();
73 emptyGallery
.setImageGallery(true);
74 emptyGallery
.setTitleCache("");
75 descriptions
.add(emptyGallery
);
78 taxon
.addDescription(emptyGallery
);
81 firstGroupedComposite
= null;
83 for(DescriptionBase description
: descriptions
){
84 if(description
.isImageGallery()){
86 Composite labelComposite
=
87 FreeTextElementFactory
.getDefault().createGalleryLabel(this, (TaxonDescription
) description
);
89 // Note whether this is the first label drawn
90 if (firstGroupedComposite
== null) {
91 firstGroupedComposite
= (GroupedComposite
) labelComposite
;
94 Set
<ImageFile
> imageFiles
= ImagesUtil
.getImages((TaxonDescription
) description
);
96 for(ImageFile imageFile
: imageFiles
){
97 FreeTextElementFactory
.getDefault().createImageElement(this, imageFile
);
109 public GroupComposite
getImageGroup() {
110 for(Composite c
: getAllComposites()){
111 if(c
instanceof ImagesGroupComposite
){
112 return (GroupComposite
) c
;
119 * @see eu.etaxonomy.taxeditor.editor.AbstractTaxonEditor#getID()
122 public String
getID() {
123 return TaxonImageEditor
.ID
;