--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.view.media;
+
+import java.io.InputStream;
+import java.net.URI;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+import eu.etaxonomy.cdm.common.UriUtils;
+import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.cdm.model.media.MediaRepresentation;
+import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+
+/**
+ * @author k.luther
+ * @date 11.10.2017
+ *
+ */
+public class MediaViewLabelProvider extends LabelProvider implements IStyledLabelProvider {
+
+ @Override
+ public StyledString getStyledText(Object element) {
+ if (element instanceof IdentifiableEntity) {
+ IdentifiableEntity identifiableEntity= (IdentifiableEntity) element;
+ StyledString styledString = new StyledString(identifiableEntity.getTitleCache());
+
+ return styledString;
+ }
+ return null;
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ Image image = null;
+ if (element instanceof Media && PreferencesUtil.isShowMediaPreview()){
+ Set<MediaRepresentation> representations = ((Media)element).getRepresentations();
+ if(representations.iterator().hasNext()){
+ MediaRepresentation rep = representations.iterator().next();
+ List<MediaRepresentationPart> parts = rep.getParts();
+ URI uri = parts.get(0).getUri();
+ if (uri == null){
+ return null;
+ }
+ InputStream imageStream;
+ try {
+ imageStream = UriUtils.getInputStream(uri);
+ image = new Image(Display.getCurrent(), imageStream);
+ int height = image.getBounds().height;
+ int width = image.getBounds().width;
+ int scale = 50;
+ if (height>width){
+ width = width/(height/scale);
+ height = scale;
+ }else{
+ height = height/(width/scale);
+ width = scale;
+ }
+ Image scaled = new Image(Display.getDefault(), scale, scale);
+
+ GC gc = new GC(scaled);
+ gc.setAntialias(SWT.ON);
+ gc.setInterpolation(SWT.HIGH);
+
+
+ gc.drawImage(image, 0, 0,
+ image.getBounds().width, image.getBounds().height,
+ 0, 0, width, height);
+
+ gc.dispose();
+ image.dispose(); // don't forget about me!
+ return scaled;
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ return null;
+ }
+
+ }
+
+ }
+ return image;
+ }
+
+ @Override
+ public void dispose() {
+ // garbage collection system resources
+
+ }
+
+
+
+}
import eu.etaxonomy.taxeditor.editor.view.concept.e4.ConceptViewPartE4;
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
import eu.etaxonomy.taxeditor.editor.view.media.MediaContentProvider;
-import eu.etaxonomy.taxeditor.editor.view.media.MediaLabelProvider;
+import eu.etaxonomy.taxeditor.editor.view.media.MediaViewLabelProvider;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
| SWT.V_SCROLL | SWT.FULL_SELECTION));
treeViewer.setContentProvider(new MediaContentProvider());
- treeViewer.setLabelProvider(new MediaLabelProvider());
+ treeViewer.setLabelProvider(new MediaViewLabelProvider());
+
+// TreeViewerColumn imagePreview = new TreeViewerColumn(treeViewer, SWT.NONE);
+// imagePreview.setLabelProvider(new DelegatingStyledCellLabelProvider(
+// new MediaViewLabelProvider(createImageDescriptor())));
+
treeViewer.setAutoExpandLevel(2);
viewer = treeViewer;
return Messages.MediaViewPart_MEDIA;
}
+
+
}
public static final String CHECKLIST_SYMBOL = "eu.etaxonomy.taxeditor.checklist.checklistSymbol";
public static final String CHECKLIST_SHOW_RANK = "eu.etaxonomy.taxeditor.checklist.checklistShowRank";
- public static final String SHOW_ADVANCED_MEDIA_SECTION = "eu.etaxonomy.taxeditor.media.showAdvancedMedia";
+
public static final String SHOW_SIMPLE_NAME_DETAILS_SECTION = "eu.etaxonomy.taxeditor.name.showSimpleName";
public static final String SHOW_SIMPLE_NAME_DETAILS_TAXON = "eu.etaxonomy.taxeditor.name.showNameTaxon";
public static final String SHOW_NAME_DETAILS_SECTION_LSID = "eu.etaxonomy.taxeditor.name.showNameLsid";
public static final String BIOCASE_PROVIDER_LIST = "eu.etaxonomy.taxeditor.abcd_import.biocaseProviderList";
+ public static final String SHOW_ADVANCED_MEDIA_SECTION = "eu.etaxonomy.taxeditor.media.showAdvancedMedia";
+ public static final String SHOW_MEDIA_PREVIEW = "eu.etaxonomy.taxeditor.media.showMediaPreview";
+