diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java index 03eee25..0a62786 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java @@ -192,7 +192,7 @@ public class FileModel extends BaseModelData implements Serializable { if (!this.isDirectory()) { //IS FILE if(this.getType()!=null) - absImgPr = Resources.getIconByType(this.getType()); + absImgPr = Resources.getIconByType(this.getName(), this.getType()); else absImgPr = Resources.getIconByFolderItemType(this.getGXTFolderItemType()); diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java index f17b011..e5f993f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Icons.java @@ -38,9 +38,6 @@ public interface Icons extends ClientBundle { @Source("icons/mime/ico_htm.gif") ImageResource html(); - @Source("icons/mime/java.gif") - ImageResource java(); - @Source("icons/mime/doc.gif") ImageResource doc(); @@ -400,5 +397,11 @@ public interface Icons extends ClientBundle { @Source("icons/zip.gif") ImageResource zip(); + + @Source("icons/archive-icon.png") + ImageResource archive(); + + @Source("icons/java.gif") + ImageResource java(); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java index 754c5b8..1946f84 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/resources/Resources.java @@ -42,10 +42,18 @@ public class Resources { private static final String ODP = "vnd.oasis.opendocument.presentation"; private static final String XTEX = "x-tex"; private static final String ZIP = "zip"; + private static final String SEVEN_ZIP = "x-7z-compressed"; private static final String POSTSCRIPT = "postscript"; private static final String DVI = "x-dvi"; private static final String X_SH = "x-sh"; private static final String X_SHELLSCRIPT = "x-shellscript"; + + private static final String X_BZIP = "x-bzip"; + private static final String RAR = "x-rar-compressed"; + private static final String GZIP = "gzip"; + + private static final String WAR ="x-tika-java-web-archive"; + /** * Gets the cloud drive icon. * @@ -147,6 +155,17 @@ public class Resources { return AbstractImagePrototype.create(ICONS.undo()); } + + /** + * Gets the icon archive. + * + * @return the icon archive + */ + public static AbstractImagePrototype getIconArchive(){ + + return AbstractImagePrototype.create(ICONS.archive()); + } + /** * Gets the icon link. * @@ -1274,13 +1293,15 @@ public class Resources { } + /** * Gets the icon by media type name. * + * @param name the name * @param mediaTypeName the media type name * @return the icon by media type name */ - public static AbstractImagePrototype getIconByMediaTypeName(String mediaTypeName) { + public static AbstractImagePrototype getIconByMediaTypeName(String name, String mediaTypeName) { if (MPEG.equals(mediaTypeName) || SWF.equals(mediaTypeName) || FLV.equals(mediaTypeName) || AVI.equals(mediaTypeName)) { return Resources.getIconMovie(); @@ -1316,7 +1337,12 @@ public class Resources { return Resources.getIconOdp(); }else if (mediaTypeName.contains(EXCEL) || mediaTypeName.contains(XSLX)) { return Resources.getIconExcel(); - }else if (mediaTypeName.contains(ZIP)) { + }else if (mediaTypeName.contains(ZIP) || mediaTypeName.contains(SEVEN_ZIP)) { + int fe = name.lastIndexOf("."); + String fileExtension = name.substring(fe+1, name.length()); + if(fileExtension.compareTo("jar")==0) + return Resources.getIconJava(); + return Resources.getIconZip(); }else if (mediaTypeName.contains(DVI)) { return Resources.getIconDvi(); @@ -1326,6 +1352,10 @@ public class Resources { return Resources.getIconXTex(); }else if (mediaTypeName.contains(POSTSCRIPT)) { return Resources.getIconPostscript(); + }else if (mediaTypeName.contains(RAR) || mediaTypeName.contains(GZIP) || mediaTypeName.contains(X_BZIP)) { + return Resources.getIconArchive(); + }else if (mediaTypeName.contains(WAR)) { + return Resources.getIconJava(); } return Resources.getIconTable(); } @@ -1384,13 +1414,15 @@ public class Resources { return Resources.getIconTable(); } + /** * Gets the icon by type. * + * @param name the name * @param type the type * @return the icon by type */ - public static AbstractImagePrototype getIconByType(String type){ + public static AbstractImagePrototype getIconByType(String name, String type){ if(type.equals(GXTFolderItemTypeEnum.FOLDER.toString())) return Resources.getIconFolder(); @@ -1398,7 +1430,8 @@ public class Resources { //RECOVERING "mediat type name" from type / media type name [+suffix] int sl = type.indexOf("/"); String mediaTypeName = type.substring(sl+1, type.length()); - return Resources.getIconByMediaTypeName(mediaTypeName); + + return Resources.getIconByMediaTypeName(name, mediaTypeName); } } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/archive-icon.png b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/archive-icon.png new file mode 100644 index 0000000..1c81c0a Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/archive-icon.png differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/java.gif b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/java.gif new file mode 100644 index 0000000..a72a208 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/java.gif differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/mime/java.gif b/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/mime/java.gif deleted file mode 100644 index e3ef556..0000000 Binary files a/src/main/java/org/gcube/portlets/user/workspace/client/resources/icons/mime/java.gif and /dev/null differ diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java index 47a112a..0f6bc4c 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/view/tree/AsyncTreePanel.java @@ -145,7 +145,7 @@ public class AsyncTreePanel extends LayoutContainer { // model.setIcon(); if (!model.isDirectory()) { if(model.getType()!=null) - return Resources.getIconByType(model.getType()); + return Resources.getIconByType(model.getName(), model.getType()); return Resources.getIconByFolderItemType(model.getGXTFolderItemType()); }