4 package eu
.etaxonomy
.taxeditor
.editor
.descriptiontree
.detailpage
;
7 import java
.net
.URISyntaxException
;
9 import org
.eclipse
.swt
.SWT
;
10 import org
.eclipse
.swt
.events
.SelectionEvent
;
11 import org
.eclipse
.swt
.events
.SelectionListener
;
12 import org
.eclipse
.swt
.layout
.GridData
;
13 import org
.eclipse
.swt
.widgets
.Composite
;
15 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
16 import eu
.etaxonomy
.cdm
.model
.media
.ImageFile
;
17 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
18 import eu
.etaxonomy
.taxeditor
.forms
.ImageComposite
;
19 import eu
.etaxonomy
.taxeditor
.forms
.TextActionComposite
;
25 public class ImageDetailsSection
extends AbstractDescriptionDetailSection
implements SelectionListener
{
27 private TextActionComposite textAction
;
28 private ImageComposite imageComposite
;
29 private boolean changed
= false;
36 public ImageDetailsSection(Composite parent
,
37 AbstractDescriptionDetailsPage page
, int style
) {
38 super(parent
, page
, style
);
40 GridData layoutData
= (GridData
) getLayoutData();
41 layoutData
.verticalAlignment
= SWT
.FILL
;
42 layoutData
.grabExcessVerticalSpace
= true;
44 setText("Image Details"); //$NON-NLS-1$
46 textAction
= toolkit
.createTextActionComposite(getClient(), "Image Uri", null, SWT
.WRAP
);
47 textAction
.addSelectionListener(this);
49 imageComposite
= toolkit
.createImageComposite(getClient(), null, SWT
.WRAP
);
52 // imageMetadataComposite = FormFactory.createImageMetaDataComposite(getClient(), null, SWT.WRAP);
56 * @see eu.etaxonomy.taxeditor.editor.descriptiontree.detailpage.AbstractDescriptionDetailSection#updateSection()
59 public void updateSection() {
60 textAction
.setText(getImageFile().getUri());
62 imageComposite
.setImageUri(new URI(CdmUtils
.Nz(getImageFile().getUri())));
63 } catch (URISyntaxException e
) {
64 // TODO remove this once cdmlib returns URIs where it seems like it does so
67 internalUpdateSection(changed
);
71 private ImageFile
getImageFile(){
72 return (ImageFile
) page
.input
;
76 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
78 public void widgetSelected(SelectionEvent e
) {
80 // TODO simplify once cdmlib accepts URIs where it seems like it should
81 URI uri
= new URI(textAction
.getText());
82 getImageFile().setUri(uri
.toString());
84 } catch (URISyntaxException e1
) {
85 EditorUtil
.warningDialog("Given image URI is not valid", "The image URI " +
86 "'" + textAction
.getText() + "' is not valid. Please check the spelling.");
93 public void widgetDefaultSelected(SelectionEvent e
) {}