- /*
- * (non-Javadoc)
- *
- * @see
- * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
- * (java.lang.Object)
- */
- /** {@inheritDoc} */
- @Override
- public void handleEvent(Object eventSource) {
- if (eventSource == selection_artist) {
- getEntity().setArtist(selection_artist.getSelection());
- } else if (eventSource == text_description) {
- getEntity().addDescription(text_description.getLanguageString());
- } else if (eventSource == text_title) {
- getEntity().putTitle(text_title.getLanguageString());
- if (getParentElement() instanceof AbstractCdmDetailSection) {
- ((AbstractCdmDetailSection) getParentElement()).updateTitle();
- }
- }
- firePropertyChangeEvent(this);
- }
+ MediaRepresentationPart firstMediaRepresentationPart = getFirstMediaRepresentationPart();
+ if(firstMediaRepresentationPart!=null){
+ textUri.setUri(firstMediaRepresentationPart.getUri());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * eu.etaxonomy.taxeditor.section.AbstractEntityCollectionElement#handleEvent
+ * (java.lang.Object)
+ */
+ /** {@inheritDoc} */
+ @Override
+ public void handleEvent(Object eventSource) {
+ if (eventSource == selection_artist) {
+ getEntity().setArtist(selection_artist.getSelection());
+ } else if (eventSource == text_description) {
+ getEntity().addDescription(text_description.getLanguageString());
+ } else if (eventSource == text_title) {
+ getEntity().putTitle(text_title.getLanguageString());
+ if (getParentElement() instanceof AbstractCdmDetailSection) {
+ ((AbstractCdmDetailSection) getParentElement()).updateTitle();
+ }
+ }
+ else if (eventSource == textUri){
+ textUri.setBackground(getPersistentBackground());
+ MediaRepresentationPart firstMediaRepresentationPart = getFirstMediaRepresentationPart();
+ URI uri;
+ try {
+ uri = textUri.getUri();
+ if(firstMediaRepresentationPart!=null){
+ firstMediaRepresentationPart.setUri(uri);
+ }
+ else{
+ Set<MediaRepresentation> representations = getEntity().getRepresentations();
+ if(representations.size()>=1){
+ representations.iterator().next().addRepresentationPart(MediaRepresentationPart.NewInstance(uri, null));
+ }
+ else{
+ MediaRepresentation mediaRepresentation = MediaRepresentation.NewInstance();
+ mediaRepresentation.addRepresentationPart(MediaRepresentationPart.NewInstance(uri, null));
+ getEntity().addRepresentation(mediaRepresentation);
+ }
+ }
+ } catch (URISyntaxException e) {
+ textUri.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
+ }
+ }
+ }