• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

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


Commit MetaInfo

Revisão2d78ccb058c5325c2c7e5db5b9dff21aa4fa1848 (tree)
Hora2022-08-28 09:50:08
Autorkemono7h
Commiterkemono7h

Mensagem de Log

出力先ディレクトリもExplorerで開けるようにした

Mudança Sumário

Diff

diff -r 3c6720599dd7 -r 2d78ccb058c5 src/jp/nanah/dnj/DokonanFrame.java
--- a/src/jp/nanah/dnj/DokonanFrame.java Sun Apr 10 07:34:05 2022 +0900
+++ b/src/jp/nanah/dnj/DokonanFrame.java Sun Aug 28 09:50:08 2022 +0900
@@ -15,6 +15,7 @@
1515 import javax.swing.JPanel;
1616 import javax.swing.JScrollPane;
1717 import javax.swing.JTextField;
18+import javax.swing.JToolTip;
1819 import javax.swing.LayoutFocusTraversalPolicy;
1920 import javax.swing.border.EmptyBorder;
2021 import javax.swing.event.ChangeEvent;
@@ -68,7 +69,7 @@
6869 frame = new JFrame();
6970 frame.setSize(600, 300);
7071 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
71- frame.setTitle("DokonanJar - Gradle/MavenのJarファイルを探す");
72+ frame.setTitle("DokonanJar - Gradle/MavenのJarファイルを探してコピー");
7273
7374 Font font = (fontName == null) ? frame.getFont() : new Font(fontName, Font.PLAIN, 12);
7475
@@ -77,6 +78,9 @@
7778 topPanel.setBorder(new EmptyBorder(0,4,0,4));
7879 topPanel.setLayout(new BorderLayout());
7980 frame.getContentPane().add(topPanel, BorderLayout.NORTH);
81+ JPanel editPanel = new JPanel();
82+ editPanel.setLayout(new BorderLayout());
83+ topPanel.add(editPanel, BorderLayout.NORTH);
8084
8185 //チェックボックス
8286 {
@@ -90,7 +94,7 @@
9094 panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
9195 panel.add(cbGradle);
9296 panel.add(cbMaven);
93- topPanel.add(panel, BorderLayout.NORTH);
97+ editPanel.add(panel, BorderLayout.CENTER);
9498
9599 CheckBoxActionListener cbActionListener = new CheckBoxActionListener();
96100 cbGradle.addActionListener(cbActionListener);
@@ -128,12 +132,19 @@
128132
129133 //コピーボタン
130134 {
131- copyButton = new JButton("コピー");
135+ copyButton = new JButton("出力先にコピー") {
136+ @Override
137+ public JToolTip createToolTip() {
138+ JToolTip toolTip = new JToolTip();
139+ toolTip.setFont(font);
140+ return toolTip;
141+ }
142+ };
132143 JPanel panel = new JPanel();
133144 panel.setBorder(new EmptyBorder(4,4,4,4));
134145 panel.setLayout(new BorderLayout());
135146 panel.add(copyButton);
136- frame.getContentPane().add(panel, BorderLayout.SOUTH);
147+ editPanel.add(panel, BorderLayout.EAST);
137148
138149 }
139150
diff -r 3c6720599dd7 -r 2d78ccb058c5 src/jp/nanah/dnj/DokonanJarMain.java
--- a/src/jp/nanah/dnj/DokonanJarMain.java Sun Apr 10 07:34:05 2022 +0900
+++ b/src/jp/nanah/dnj/DokonanJarMain.java Sun Aug 28 09:50:08 2022 +0900
@@ -2,6 +2,8 @@
22
33 import java.awt.event.ActionEvent;
44 import java.awt.event.ActionListener;
5+import java.awt.event.MouseAdapter;
6+import java.awt.event.MouseEvent;
57 import java.io.File;
68 import java.io.FileInputStream;
79 import java.util.ArrayList;
@@ -83,7 +85,9 @@
8385 public void initFrame() {
8486 dokoFrame.initComponent();
8587 JButton button = dokoFrame.getCopyButton();
88+ button.setToolTipText("表示中のjarを [" + FileUtils.getFullPath(outputDir) + "] にコピー。右クリックで出力先を開きます");
8689 button.addActionListener(new CopyButtonActionListener());
90+ button.addMouseListener(new DokonanMouseListener());
8791 Thread thread = new Thread(){
8892 @Override
8993 public void run(){
@@ -99,14 +103,8 @@
99103 dokoFrame.getResultArea().addHyperlinkListener(new HyperlinkListener() {
100104 @Override public void hyperlinkUpdate(HyperlinkEvent e) {
101105 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
102- try {
103- //Windows Only
104- String path = e.getURL().getPath().replaceAll("/", "\\\\");
105- Runtime.getRuntime().exec("explorer.exe /select," + path);
106- } catch (Throwable th) {
107- System.out.println("フォルダ表示に失敗しました。");
108- //th.printStackTrace();
109- }
106+ String path = e.getURL().getPath().replaceAll("/", "\\\\");
107+ FileUtils.openFiler(path, true);
110108 }
111109 }
112110 });
@@ -168,6 +166,15 @@
168166 }
169167 }
170168
169+ private class DokonanMouseListener extends MouseAdapter {
170+ @Override
171+ public void mousePressed(MouseEvent e) {
172+ if (e.getButton() == MouseEvent.BUTTON3) {
173+ FileUtils.openFiler(FileUtils.getFullPath(outputDir), false);
174+ }
175+ }
176+ }
177+
171178 public void searchFiles(String path) {
172179 String[] texts = getSearchTexts(path);
173180 List<File> allList = new ArrayList<File>();
@@ -195,7 +202,7 @@
195202 }
196203
197204 private String toPathText(File file, String[] texts) {
198- String fullpath = file.getAbsolutePath();
205+ String fullpath = FileUtils.getFullPath(file);
199206 int filenameIndex = fullpath.lastIndexOf(File.separator) + 1;
200207 String beforeLastFolder = fullpath.substring(0, filenameIndex);
201208 String filename = fullpath.substring(filenameIndex);
diff -r 3c6720599dd7 -r 2d78ccb058c5 src/jp/nanah/dnj/util/FileUtils.java
--- a/src/jp/nanah/dnj/util/FileUtils.java Sun Apr 10 07:34:05 2022 +0900
+++ b/src/jp/nanah/dnj/util/FileUtils.java Sun Aug 28 09:50:08 2022 +0900
@@ -288,4 +288,27 @@
288288 file.delete();
289289 }
290290
291+ //---------------------------------------------
292+ // パス処理
293+ //---------------------------------------------
294+
295+ public static String getFullPath(File file) {
296+ try {
297+ return file.getCanonicalPath();
298+ } catch (IOException e) {
299+ return file.getAbsolutePath();
300+ }
301+ }
302+
303+ public static void openFiler(String path, boolean isFile) {
304+ try {
305+
306+ //Windows Only
307+ String args = isFile ? "/select," : "";
308+ Runtime.getRuntime().exec("explorer.exe "+args + path);
309+ } catch (Throwable th) {
310+ System.out.println("フォルダ表示に失敗しました。");
311+ //th.printStackTrace();
312+ }
313+ }
291314 }
\ No newline at end of file
diff -r 3c6720599dd7 -r 2d78ccb058c5 src/jp/nanah/dnj/util/JarUtils.java
--- a/src/jp/nanah/dnj/util/JarUtils.java Sun Apr 10 07:34:05 2022 +0900
+++ b/src/jp/nanah/dnj/util/JarUtils.java Sun Aug 28 09:50:08 2022 +0900
@@ -20,23 +20,10 @@
2020
2121 while ((zipEntry = zistr.getNextEntry()) != null) {
2222 String name = zipEntry.getName();
23- System.out.println(name);
2423 if (name.endsWith(".class")) {
2524 return true;
2625 }
27- //classList
28-// File uncompressFile = new File(zipEntry.getName());
29-// System.out.println("");
30- //
31-// if (zipEntry.isDirectory()) {
32-// uncompressFile.mkdirs();
33-// } else {
34-// BufferedOutputStream bostr = new BufferedOutputStream(new FileOutputStream(uncompressFile));
35-// while ((len = zistr.read(buf)) != -1) {
36-// bostr.write(buf, 0, len);
37-// }
38-// bostr.close();
39-// }
26+
4027 }
4128 } catch (IOException ex) {
4229 ex.printStackTrace();