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
.eclipse
.swt
.widgets
.Composite
;
17 import org
.eclipse
.ui
.IEditorInput
;
18 import org
.eclipse
.ui
.IEditorSite
;
19 import org
.eclipse
.ui
.PartInitException
;
21 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
22 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
23 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
24 import eu
.etaxonomy
.taxeditor
.editor
.AbstractTaxonEditor
;
25 import eu
.etaxonomy
.taxeditor
.editor
.FreeTextElementFactory
;
26 import eu
.etaxonomy
.taxeditor
.editor
.GroupComposite
;
27 import eu
.etaxonomy
.taxeditor
.editor
.GroupedComposite
;
28 import eu
.etaxonomy
.taxeditor
.editor
.MultiPageTaxonEditor
;
29 import eu
.etaxonomy
.taxeditor
.model
.ImagesHelper
;
37 public class TaxonImageEditor
extends AbstractTaxonEditor
{
39 private static final String ID
= "eu.etaxonomy.taxeditor.taxonImageEditor";
41 private TaxonDescription emptyGallery
;
43 public TaxonImageEditor(MultiPageTaxonEditor editor
){
47 public void init(IEditorSite site
, IEditorInput input
)
48 throws PartInitException
{
50 super.init(site
, input
);
54 protected void createManagedForm(Composite composite
) {
56 super.createManagedForm(composite
);
58 Set
<TaxonDescription
> descriptions
= taxon
.getDescriptions();
59 Set
<DescriptionBase
<?
>> imageGalleries
= new HashSet
<DescriptionBase
<?
>>();
61 for(TaxonDescription description
: descriptions
){
62 if(description
.isImageGallery()){
63 imageGalleries
.add(description
);
68 if(imageGalleries
.size() == 0){
69 emptyGallery
= TaxonDescription
.NewInstance();
70 emptyGallery
.setImageGallery(true);
71 emptyGallery
.setTitleCache("");
72 descriptions
.add(emptyGallery
);
75 taxon
.addDescription(emptyGallery
);
78 firstGroupedComposite
= null;
80 for(DescriptionBase
<?
> description
: descriptions
){
81 if(description
.isImageGallery()){
83 Composite labelComposite
=
84 FreeTextElementFactory
.getDefault().createGalleryLabel(this, (TaxonDescription
) description
);
86 // Note whether this is the first label drawn
87 if (firstGroupedComposite
== null) {
88 firstGroupedComposite
= (GroupedComposite
) labelComposite
;
91 Set
<ImageFile
> imageFiles
= ImagesHelper
.getImages((TaxonDescription
) description
);
93 for(ImageFile imageFile
: imageFiles
){
94 FreeTextElementFactory
.getDefault().createImageElement(this, imageFile
);
106 public GroupComposite
getImageGroup() {
107 for(Composite c
: getGroupedComposites()){
108 if(c
instanceof ImagesGroupComposite
){
109 return (GroupComposite
) c
;
116 * @see eu.etaxonomy.taxeditor.editor.AbstractTaxonEditor#getID()
119 public String
getID() {
120 return TaxonImageEditor
.ID
;