From e86dd190a6158cdf9ea8471e8e387ad3f58ff4aa Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 11 Nov 2021 14:46:58 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-60789=E3=80=90=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E8=80=85=E9=A2=84=E8=A7=88=E6=94=AF=E6=8C=81=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=B8=83=E5=B1=80=E3=80=91=E6=96=B0=E8=87=AA?= =?UTF-8?q?=E9=80=82=E5=BA=94-=E6=9C=AC=E5=9C=B0=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E8=BF=9B=E5=85=A5=E5=BC=80=E5=8F=91=E8=80=85?= =?UTF-8?q?=E8=B0=83=E8=AF=95=EF=BC=8C=E8=B7=AF=E5=BE=84=E5=A4=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=B7=B2=E9=94=81=E5=AE=9A=E4=BD=86=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E4=B8=8A=E6=B2=A1=E6=9C=89=E9=94=81=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=EF=BC=8C=E8=BF=9C=E7=A8=8B=E4=B8=8B=E6=98=AF=E6=9C=89?= =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/FileTreeIcon.java | 11 +++-- .../com/fr/design/icon/LocalFileIcon.java | 42 ++++++++++++++++++ .../java/com/fr/design/icon/LockIcon.java | 5 ++- .../com/fr/design/images/gui/file_lock.png | Bin 0 -> 225 bytes 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/icon/LocalFileIcon.java create mode 100644 designer-base/src/main/resources/com/fr/design/images/gui/file_lock.png diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index e0515fe81..b2956b70f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -2,6 +2,7 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.icon.LocalFileIcon; import com.fr.design.icon.LockIcon; import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.file.filetree.FileNode; @@ -19,6 +20,8 @@ public class FileTreeIcon { private FileTreeIcon() { } + public static final String FILE_LOCKED_ICON_PATH = "/com/fr/design/images/gui/file_lock.png"; + public static final Icon BLANK_IMAGE_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/blank.gif"); public static final Icon FOLDER_IMAGE_ICON = BaseUtils.readIcon("/com/fr/design/images/gui/folder.png"); @@ -153,7 +156,7 @@ public class FileTreeIcon { if (node.isDirectory()) { return FileTreeIcon.FOLDER_IMAGE_ICON; } - return getLocalFileIcon(path); + return getLocalFileIcon(path, isShowLock); } } if (node.isDirectory()) { @@ -163,12 +166,12 @@ public class FileTreeIcon { } } - private static Icon getLocalFileIcon(String path) { - Icon icon = getExtraIcon(path, false); + private static Icon getLocalFileIcon(String path, boolean isShowLock) { + Icon icon = getExtraIcon(path, isShowLock); if (icon != null) { return icon; } - return FileSystemView.getFileSystemView().getSystemIcon(new File(path)); + return new LocalFileIcon(FileSystemView.getFileSystemView().getSystemIcon(new File(path)), isShowLock); } private static Icon getRemoteFileIcon(FileNode node, boolean isShowLock) { diff --git a/designer-base/src/main/java/com/fr/design/icon/LocalFileIcon.java b/designer-base/src/main/java/com/fr/design/icon/LocalFileIcon.java new file mode 100644 index 000000000..e80af21c6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/icon/LocalFileIcon.java @@ -0,0 +1,42 @@ +package com.fr.design.icon; + +import com.fr.base.BaseUtils; +import com.fr.design.gui.itree.filetree.FileTreeIcon; + +import javax.swing.Icon; +import java.awt.Component; +import java.awt.Graphics; + +/** + * Created by kerry on 2021/11/11 + */ +public class LocalFileIcon implements Icon { + private static final Icon FILE_LOCKED_ICON = BaseUtils.readIcon(FileTreeIcon.FILE_LOCKED_ICON_PATH); + private static final int OFFSET_X = 9; + private static final int OFFSET_Y = 8; + private final Icon mainIcon; + private final boolean showLock; + + public LocalFileIcon(Icon mainIcon, boolean showLock) { + this.mainIcon = mainIcon; + this.showLock = showLock; + } + + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + mainIcon.paintIcon(c, g, x, y); + if (showLock) { + FILE_LOCKED_ICON.paintIcon(c, g, OFFSET_X, OFFSET_Y); + } + } + + @Override + public int getIconWidth() { + return mainIcon.getIconWidth(); + } + + @Override + public int getIconHeight() { + return mainIcon.getIconHeight(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/icon/LockIcon.java b/designer-base/src/main/java/com/fr/design/icon/LockIcon.java index 7ebffbdb7..e7c400020 100644 --- a/designer-base/src/main/java/com/fr/design/icon/LockIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/LockIcon.java @@ -1,6 +1,7 @@ package com.fr.design.icon; import com.fr.base.BaseUtils; +import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.log.FineLoggerFactory; import javax.swing.GrayFilter; @@ -12,7 +13,7 @@ import java.awt.MediaTracker; import java.awt.image.ImageObserver; public class LockIcon extends ImageIcon { - private final static Image lockImage = BaseUtils.readImage("/com/fr/design/images/gui/locked.gif"); + private final static Image lockImage = BaseUtils.readImage(FileTreeIcon.FILE_LOCKED_ICON_PATH); private Image mainImage = null; @@ -107,4 +108,4 @@ public class LockIcon extends ImageIcon { { loadImage(lockImage); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/resources/com/fr/design/images/gui/file_lock.png b/designer-base/src/main/resources/com/fr/design/images/gui/file_lock.png new file mode 100644 index 0000000000000000000000000000000000000000..a0b08e6e27b150fb4c8ebbb3624d9a6abf6b2a13 GIT binary patch literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)H!3HEvS)PI@#^NA%Cx&(BWL^R}E~ycoX}-P; zS|C*njP02WEFdL7ECs|249p7{8JK}IBS>rk6I_;k0W+M<0a6&u=FtwMyggkULpWrU zfBgTypGzQ_flVQSQBdJSM4aHEhDi!nc?@*>pNJ%!`EOvR?7