• R/O
  • SSH

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Gradle/Mavenが持っているjarファイルのパスを表示するツール


Commit MetaInfo

修訂e1119e6c0edd153bdb547fbb9354a6f37b4a9e70 (tree)
時間2022-02-27 21:17:40
作者kemono7h
Commiterkemono7h

Log Message

jarファイルをエクスプローラーで表示できるようにした。

Change Summary

差異

diff -r 3a2754eed8a5 -r e1119e6c0edd src/jp/nanah/dnj/DokonanFrame.java
--- a/src/jp/nanah/dnj/DokonanFrame.java Sun Feb 27 11:02:47 2022 +0900
+++ b/src/jp/nanah/dnj/DokonanFrame.java Sun Feb 27 21:17:40 2022 +0900
@@ -116,6 +116,7 @@
116116 if (font != null) {
117117 resultArea.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
118118 }
119+
119120 JScrollPane scrollPane = new JScrollPane(resultArea);
120121 JPanel panel = new JPanel();
121122 panel.setBorder(new EmptyBorder(4,4,4,4));
diff -r 3a2754eed8a5 -r e1119e6c0edd src/jp/nanah/dnj/DokonanJarMain.java
--- a/src/jp/nanah/dnj/DokonanJarMain.java Sun Feb 27 11:02:47 2022 +0900
+++ b/src/jp/nanah/dnj/DokonanJarMain.java Sun Feb 27 21:17:40 2022 +0900
@@ -14,6 +14,8 @@
1414 import javax.swing.JButton;
1515 import javax.swing.event.ChangeEvent;
1616 import javax.swing.event.ChangeListener;
17+import javax.swing.event.HyperlinkEvent;
18+import javax.swing.event.HyperlinkListener;
1719
1820 import jp.nanah.dnj.util.FileUtils;
1921
@@ -93,6 +95,20 @@
9395 };
9496 thread.start();
9597 dokoFrame.setChangeListener(new TextChangeListener());
98+ dokoFrame.getResultArea().addHyperlinkListener(new HyperlinkListener() {
99+ @Override public void hyperlinkUpdate(HyperlinkEvent e) {
100+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
101+ try {
102+ //Windows Only
103+ String path = e.getURL().getPath().replaceAll("/", "\\\\");
104+ Runtime.getRuntime().exec("explorer.exe /select," + path);
105+ } catch (Throwable th) {
106+ System.out.println("フォルダ表示に失敗しました。");
107+ //th.printStackTrace();
108+ }
109+ }
110+ }
111+ });
96112 dokoFrame.getFrame().setVisible(true);
97113 }
98114
@@ -179,20 +195,15 @@
179195
180196 private String toPathText(File file, String[] texts) {
181197 String fullpath = file.getAbsolutePath();
182- int filenameIndex = fullpath.lastIndexOf(File.separator);
183- int lastFolderIndex = fullpath.lastIndexOf(File.separator, filenameIndex-1);
184- if (lastFolderIndex < 0) {
185- lastFolderIndex = filenameIndex;
186- }
187-
188- String lastFolder = fullpath.substring(lastFolderIndex, filenameIndex);
189- String beforeLastFolder = fullpath.substring(0, lastFolderIndex);
190- String filename = fullpath.substring(filenameIndex, fullpath.length()-4);
198+ int filenameIndex = fullpath.lastIndexOf(File.separator) + 1;
199+ String beforeLastFolder = fullpath.substring(0, filenameIndex);
200+ String filename = fullpath.substring(filenameIndex);
201+ String dispname = filename.substring(0, filename.length()-4);
191202
192203 for (int i=0; i<texts.length; i++) {
193- filename = filename.replaceAll(texts[i], "<b>"+texts[i]+"</b>");
204+ dispname = dispname.replaceAll(texts[i], "<b>"+texts[i]+"</b>");
194205 }
195- return beforeLastFolder + "<a href=\"" + beforeLastFolder + lastFolder + "\">" + lastFolder + "</a>" + filename + ".jar";
206+ return beforeLastFolder + "<a href='file:" + fullpath + "'>" + dispname + ".jar</a>";
196207 }
197208
198209 private String[] getSearchTexts(String path) {