- section_mediaRepresentation = formFactory.createMediaRepresentationSection(getConversationHolder(), element, style);
- section_mediaRepresentation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
- }
-
- /** {@inheritDoc} */
- @Override
- public void setEntity(Media element) {
- this.entity = element;
- section_mediaRepresentation.setEntity(element);
- selection_artist.setEntity((TeamOrPersonBase) HibernateProxyHelper
- .deproxy(element.getArtist()));
-
- text_description.setLanguageString(element.getDescription(CdmStore
- .getDefaultLanguage()));
-
- LanguageString title = element.getTitle(CdmStore.getDefaultLanguage());
-
- if (title == null) {
- title = LanguageString.NewInstance("",
- CdmStore.getDefaultLanguage());
- }
-
- text_title.setLanguageString(title);
- }
-
- /*
- * (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);
- }
+ checkBoxShowAdvancedView = formFactory.createCheckbox(element, "Advanced Media View", false, style);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void setEntity(Media element) {
+ this.entity = element;
+ if(singleMediaRepresentationPart==null){
+ singleMediaRepresentationPart = MediaUtils.initFirstMediaRepresentationPart(element);
+ }
+ showAdvancedView(isAdvancedMediaView());
+
+ selection_artist.setEntity((TeamOrPersonBase<?>) HibernateProxyHelper
+ .deproxy(element.getArtist()));
+
+ text_description.setLanguageString(element.getDescription(CdmStore
+ .getDefaultLanguage()));
+
+ LanguageString title = element.getTitle(CdmStore.getDefaultLanguage());
+
+ if (title == null) {
+ title = LanguageString.NewInstance("", CdmStore.getDefaultLanguage());
+ }
+
+ text_title.setLanguageString(title);
+ }
+
+ /*
+ * (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());
+ try {
+ singleMediaRepresentationPart.setUri(textUri.getUri());
+ } catch (URISyntaxException e) {
+ textUri.setBackground(getColor(Resources.COLOR_PARSE_ERROR));
+ }
+ }
+ else if(eventSource==checkBoxShowAdvancedView){
+ showAdvancedView(checkBoxShowAdvancedView.getSelection());
+ }
+ }
+
+ /**
+ * @param showAdvancedView
+ */
+ private void showAdvancedView(boolean showAdvancedView) {
+ if(showAdvancedView){
+ if(textUri!=null){
+ removeElementsAndControls(textUri);
+ }
+ section_mediaRepresentation = formFactory.createMediaRepresentationSection(getConversationHolder(), parentFormElement, style);
+ section_mediaRepresentation.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
+ section_mediaRepresentation.setEntity(getEntity());
+ }
+ else{
+ if(section_mediaRepresentation!=null){
+ removeElementsAndControls(section_mediaRepresentation);
+ }
+ textUri = formFactory.createUriWithLabelElement(parentFormElement, "Media URI", null, style);
+ textUri.setUri(singleMediaRepresentationPart.getUri());
+ textUri.getLayoutComposite().layout();
+ }
+ }
+
+ private boolean isAdvancedMediaView(){
+ if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_ADVANCED_MEDIA_SECTION)){
+ return true;
+ }
+ Set<MediaRepresentation> representations = entity.getRepresentations();
+ if(representations.size()>1){
+ return true;
+ }
+ if(representations.size()==1){
+ List<MediaRepresentationPart> parts = representations.iterator().next().getParts();
+ if(parts.size()>1){
+ return true;
+ }
+ }
+ return false;
+ }
+