Skip to content

Commit

Permalink
Merge pull request #92 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber authored Sep 28, 2023
2 parents bcc643c + d9e4263 commit 74f9ead
Show file tree
Hide file tree
Showing 16 changed files with 452 additions and 115 deletions.
3 changes: 3 additions & 0 deletions MooTool.l4j.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-Dswing.aatext=true
-XX:+UseZGC
-XX:+ZGenerational
115 changes: 62 additions & 53 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.luoboduner.moo.tool</groupId>
<artifactId>MooTool</artifactId>
<version>1.5.5</version>
<version>1.5.6</version>
<packaging>jar</packaging>

<name>MooTool</name>
Expand All @@ -15,16 +15,16 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>

<java.version>17</java.version>
<java.version>21</java.version>
<logback.version>1.4.6</logback.version>
<emoji-java.version>5.1.1</emoji-java.version>
<hutool-all.version>5.8.17</hutool-all.version>
<forms_rt.version>7.0.3</forms_rt.version>
<fastjson.version>2.0.27</fastjson.version>
<lombok.version>1.18.26</lombok.version>
<lombok.version>1.18.30</lombok.version>
<mybatis.version>3.5.13</mybatis.version>
<sqlite-jdbc.version>3.42.0.1</sqlite-jdbc.version>
<junit.version>4.13.2</junit.version>
Expand Down Expand Up @@ -250,7 +250,7 @@
<plugin>
<groupId>io.github.fvarrui</groupId>
<artifactId>javapackager</artifactId>
<version>1.7.2</version>
<version>1.7.4</version>
<configuration>
<bundleJre>true</bundleJre>
<mainClass>com.luoboduner.moo.tool.App</mainClass>
Expand All @@ -259,38 +259,41 @@
<vmArgs>--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</vmArgs>
</configuration>
<executions>
<!-- <execution>-->
<!-- <id>bundling-for-windows</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>package</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <platform>windows</platform>-->
<!-- <createZipball>true</createZipball>-->
<!-- <customizedJre>false</customizedJre>-->
<!-- <additionalModules>jdk.crypto.ec,jdk.charsets,com.jthemedetector</additionalModules>-->
<!-- <administratorRequired>true</administratorRequired>-->
<!-- <winConfig>-->

<!-- &lt;!&ndash; general properties &ndash;&gt;-->
<!-- <generateSetup>true</generateSetup>-->
<!-- <generateMsi>true</generateMsi>-->
<!-- <generateMsm>true</generateMsm>-->

<!-- &lt;!&ndash; setup generation properties &ndash;&gt;-->
<!-- <setupMode>installForAllUsers</setupMode>-->
<!-- <createDesktopIconTask>true</createDesktopIconTask>-->
<!-- <disableDirPage>false</disableDirPage>-->
<!-- <disableFinishedPage>false</disableFinishedPage>-->
<!-- <removeOldLibs>true</removeOldLibs>-->
<!-- <setupLanguages>-->
<!-- <english>compiler:Default.isl</english>-->
<!-- &lt;!&ndash; <spanish>compiler:Languages\Chinese.isl</spanish>&ndash;&gt;-->
<!-- </setupLanguages>-->
<!-- </winConfig>-->
<!-- </configuration>-->
<!-- </execution>-->
<execution>
<id>bundling-for-windows</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
<configuration>
<platform>windows</platform>
<createZipball>true</createZipball>
<customizedJre>false</customizedJre>
<additionalModules>jdk.crypto.ec,jdk.charsets,com.jthemedetector</additionalModules>
<additionalResources>
<additionalResource>${name}.l4j.ini</additionalResource>
</additionalResources>
<administratorRequired>true</administratorRequired>
<winConfig>

<!-- general properties -->
<generateSetup>true</generateSetup>
<generateMsi>true</generateMsi>
<generateMsm>true</generateMsm>

<!-- setup generation properties -->
<setupMode>installForAllUsers</setupMode>
<createDesktopIconTask>true</createDesktopIconTask>
<disableDirPage>false</disableDirPage>
<disableFinishedPage>false</disableFinishedPage>
<removeOldLibs>true</removeOldLibs>
<setupLanguages>
<english>compiler:Default.isl</english>
<!-- <spanish>compiler:Languages\Chinese.isl</spanish>-->
</setupLanguages>
</winConfig>
</configuration>
</execution>
<!-- <execution>-->
<!-- <id>bundling-for-linux</id>-->
<!-- <phase>package</phase>-->
Expand All @@ -300,23 +303,29 @@
<!-- <configuration>-->
<!-- <platform>linux</platform>-->
<!-- <createTarball>true</createTarball>-->
<!-- <customizedJre>false</customizedJre>-->
<!-- <additionalModules>jdk.crypto.ec,jdk.charsets</additionalModules>-->
<!-- <customizedJre>false</customizedJre>-->
<!-- <additionalModules>jdk.crypto.ec,jdk.charsets</additionalModules>-->
<!-- <additionalResources>-->
<!-- <additionalResource>${name}.l4j.ini</additionalResource>-->
<!-- </additionalResources>-->
<!-- </configuration>-->
<!-- </execution>-->
<execution>
<id>bundling-for-mac</id>
<phase>package</phase>
<goals>
<goal>package</goal>
</goals>
<configuration>
<platform>mac</platform>
<customizedJre>false</customizedJre>
<createTarball>true</createTarball>
<additionalModules>jdk.crypto.ec,jdk.charsets</additionalModules>
</configuration>
</execution>
<!-- <execution>-->
<!-- <id>bundling-for-mac</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>package</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <platform>mac</platform>-->
<!-- <customizedJre>false</customizedJre>-->
<!-- <createTarball>true</createTarball>-->
<!-- <additionalModules>jdk.crypto.ec,jdk.charsets</additionalModules>-->
<!-- <additionalResources>-->
<!-- <additionalResource>${name}.l4j.ini</additionalResource>-->
<!-- </additionalResources>-->
<!-- </configuration>-->
<!-- </execution>-->
</executions>
</plugin>
</plugins>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/luoboduner/moo/tool/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class App {

public static TrayIcon trayIcon;

public static PopupMenu popupMenu;
public static JPopupMenu popupMenu;

public static void main(String[] args) {

Expand Down
42 changes: 11 additions & 31 deletions src/main/java/com/luoboduner/moo/tool/ui/Init.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.formdev.flatlaf.themes.FlatMacLightLaf;
import com.jthemedetecor.OsThemeDetector;
import com.luoboduner.moo.tool.App;
import com.luoboduner.moo.tool.ui.component.JPopupMenuMouseAdapter;
import com.luoboduner.moo.tool.ui.dialog.FontSizeAdjustDialog;
import com.luoboduner.moo.tool.ui.dialog.SettingDialog;
import com.luoboduner.moo.tool.ui.dialog.TranslationDialog;
Expand All @@ -27,8 +28,6 @@
import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Collections;
import java.util.Enumeration;
import java.util.concurrent.ScheduledThreadPoolExecutor;
Expand Down Expand Up @@ -243,13 +242,13 @@ public static void initTray() {
if (SystemTray.isSupported() && App.tray == null) {
App.tray = SystemTray.getSystemTray();

App.popupMenu = new PopupMenu();
App.popupMenu.setFont(App.mainFrame.getContentPane().getFont());
App.popupMenu = new JPopupMenu();
// App.popupMenu.setFont(App.mainFrame.getContentPane().getFont());

MenuItem openItem = new MenuItem("MooTool");
MenuItem colorPickerItem = new MenuItem("取色器");
MenuItem translationItem = new MenuItem("翻译");
MenuItem exitItem = new MenuItem("Quit");
JMenuItem openItem = new JMenuItem("MooTool");
JMenuItem colorPickerItem = new JMenuItem("取色器");
JMenuItem translationItem = new JMenuItem("翻译");
JMenuItem exitItem = new JMenuItem("Quit");

openItem.addActionListener(e -> {
showMainFrame();
Expand Down Expand Up @@ -278,36 +277,17 @@ public static void initTray() {
App.popupMenu.addSeparator();
App.popupMenu.add(exitItem);

App.trayIcon = new TrayIcon(UiConsts.IMAGE_LOGO_64, "MooTool", App.popupMenu);
App.trayIcon = new TrayIcon(UiConsts.IMAGE_LOGO_64, "MooTool");
App.trayIcon.setImageAutoSize(true);

App.trayIcon.addActionListener(e -> {
App.mainFrame.setVisible(true);
App.mainFrame.setExtendedState(JFrame.NORMAL);
App.mainFrame.requestFocus();
});
App.trayIcon.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
switch (e.getButton()) {
case MouseEvent.BUTTON1: {
showMainFrame();
break;
}
case MouseEvent.BUTTON2: {
logger.debug("托盘图标中键事件");
break;
}
case MouseEvent.BUTTON3: {
logger.debug("托盘图标右键事件");
break;
}
default: {
break;
}
}
}
});

JPopupMenuMouseAdapter jPopupMenuMouseAdapter = new JPopupMenuMouseAdapter(App.popupMenu);
App.trayIcon.addMouseListener(jPopupMenuMouseAdapter);

try {
App.tray.add(App.trayIcon);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/luoboduner/moo/tool/ui/UiConsts.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class UiConsts {
* 软件名称,版本
*/
public static final String APP_NAME = "MooTool";
public static final String APP_VERSION = "v1.5.5";
public static final String APP_VERSION = "v1.5.6";

public static final int TABLE_ROW_HEIGHT = 30;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.luoboduner.moo.tool.ui.component;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.luoboduner.moo.tool.App;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class JPopupMenuMouseAdapter extends MouseAdapter {

private static final Log logger = LogFactory.get();

private JPopupMenu popupMenu;

public JPopupMenuMouseAdapter(JPopupMenu popupMenu) {
this.popupMenu = popupMenu;
}

@Override
public void mouseReleased(MouseEvent e) {
maybeShowPopup(e);
}

@Override
public void mousePressed(MouseEvent e) {
maybeShowPopup(e);
}

@Override
public void mouseClicked(MouseEvent e) {
switch (e.getButton()) {
case MouseEvent.BUTTON1: {
showMainFrame();
break;
}
case MouseEvent.BUTTON2: {
logger.debug("托盘图标中键事件");
break;
}
case MouseEvent.BUTTON3: {
logger.debug("托盘图标右键事件");
break;
}
default: {
break;
}
}
}

private void maybeShowPopup(MouseEvent e) {
if (e.isPopupTrigger()) {
Dimension size = popupMenu.getPreferredSize();
popupMenu.setLocation(e.getX() - size.width, e.getY() - size.height);
popupMenu.setInvoker(popupMenu);
popupMenu.setVisible(true);
}
}

public static void showMainFrame() {
App.mainFrame.setVisible(true);
if (App.mainFrame.getExtendedState() == Frame.ICONIFIED) {
App.mainFrame.setExtendedState(Frame.NORMAL);
} else if (App.mainFrame.getExtendedState() == 7) {
App.mainFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
}
App.mainFrame.requestFocus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ private void fontSizeChanged(ActionEvent actionEvent) {

FlatAnimatedLafChange.hideSnapshotWithAnimation();

JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功",
JOptionPane.INFORMATION_MESSAGE);
// JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功",
// JOptionPane.INFORMATION_MESSAGE);

initFontSizeMenu();

Expand Down Expand Up @@ -372,8 +372,8 @@ public void fontFamilyChanged(ActionEvent actionEvent) {

FlatAnimatedLafChange.hideSnapshotWithAnimation();

JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功",
JOptionPane.INFORMATION_MESSAGE);
// JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功",
// JOptionPane.INFORMATION_MESSAGE);

initFontFamilyMenu();

Expand All @@ -390,8 +390,8 @@ private void themeChanged(ActionEvent actionEvent) {

changeTheme(selectedThemeName);

JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功",
JOptionPane.INFORMATION_MESSAGE);
// JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "部分细节重启应用后生效!\n\n", "成功",
// JOptionPane.INFORMATION_MESSAGE);

} catch (Exception e1) {
JOptionPane.showMessageDialog(MainWindow.getInstance().getMainPanel(), "保存失败!\n\n" + e1.getMessage(), "失败",
Expand Down
Loading

0 comments on commit 74f9ead

Please sign in to comment.