Skip to content

Commit

Permalink
Merge pull request #89 from rememberber/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rememberber authored Sep 18, 2023
2 parents 4b8277c + 8a5651f commit 3e85693
Show file tree
Hide file tree
Showing 12 changed files with 411 additions and 296 deletions.
2 changes: 1 addition & 1 deletion 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.4</version>
<version>1.5.5</version>
<packaging>jar</packaging>

<name>MooTool</name>
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/luoboduner/moo/tool/ui/Init.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.luoboduner.moo.tool.App;
import com.luoboduner.moo.tool.ui.dialog.FontSizeAdjustDialog;
import com.luoboduner.moo.tool.ui.dialog.SettingDialog;
import com.luoboduner.moo.tool.ui.dialog.TranslationDialog;
import com.luoboduner.moo.tool.ui.form.func.*;
import com.luoboduner.moo.tool.ui.frame.ColorPickerFrame;
import com.luoboduner.moo.tool.ui.listener.FrameListener;
Expand Down Expand Up @@ -247,6 +248,7 @@ public static void initTray() {

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

openItem.addActionListener(e -> {
Expand All @@ -260,13 +262,19 @@ public static void initTray() {
ColorPickerFrame.showPicker();
}
});
translationItem.addActionListener(e -> {
TranslationDialog translationDialog = new TranslationDialog();
translationDialog.pack();
translationDialog.setVisible(true);
});
exitItem.addActionListener(e -> {
shutdown();
});

App.popupMenu.add(openItem);
App.popupMenu.addSeparator();
App.popupMenu.add(colorPickerItem);
App.popupMenu.add(translationItem);
App.popupMenu.addSeparator();
App.popupMenu.add(exitItem);

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.4";
public static final String APP_VERSION = "v1.5.5";

public static final int TABLE_ROW_HEIGHT = 30;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.tool.ui.dialog.TranslationDialog">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="48" y="54" width="436" height="297"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="e3588" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>
100 changes: 100 additions & 0 deletions src/main/java/com/luoboduner/moo/tool/ui/dialog/TranslationDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package com.luoboduner.moo.tool.ui.dialog;

import com.formdev.flatlaf.util.SystemInfo;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.luoboduner.moo.tool.ui.form.TranslationLayoutForm;
import com.luoboduner.moo.tool.util.ComponentUtil;
import com.luoboduner.moo.tool.util.SystemUtil;

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

public class TranslationDialog extends JFrame {
private JPanel contentPane;
private JPanel mainPanel;
private TranslationLayoutForm translationLayoutForm;

public TranslationDialog() {
// super(App.mainFrame, "翻译");
ComponentUtil.setPreferSizeAndLocateToCenter(this, 0.4, 0.64);
setContentPane(contentPane);

if (SystemUtil.isMacOs() && SystemInfo.isMacFullWindowContentSupported) {
this.getRootPane().putClientProperty("apple.awt.fullWindowContent", true);
this.getRootPane().putClientProperty("apple.awt.transparentTitleBar", true);
this.getRootPane().putClientProperty("apple.awt.fullscreenable", true);
this.getRootPane().putClientProperty("apple.awt.windowTitleVisible", false);
GridLayoutManager gridLayoutManager = (GridLayoutManager) contentPane.getLayout();
gridLayoutManager.setMargin(new Insets(28, 0, 0, 0));
}

// 半透明
// setUndecorated(true);
// setOpacity(0.95f);

mainPanel.setLayout(new BorderLayout());
// 设置四边距:10
mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
translationLayoutForm = new TranslationLayoutForm();
mainPanel.add(translationLayoutForm.getMainLayoutPanel());

translationLayoutForm.getSplitPane().setDividerLocation((this.getWidth() - 20) / 2);

// call onCancel() when cross is clicked
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
onCancel();
}
});

// call onCancel() on ESCAPE
contentPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onCancel();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}

private void onOK() {
// add your code here
dispose();
}

private void onCancel() {
// add your code here if necessary
dispose();
}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
contentPane = new JPanel();
contentPane.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
contentPane.add(mainPanel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return contentPane;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.luoboduner.moo.tool.ui.form.TranslationLayoutForm">
<grid id="27dc6" binding="mainLayoutPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="b4cf3" layout-manager="GridLayoutManager" row-count="1" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="2ea0c" class="javax.swing.JComboBox" binding="comboBox1" default-binding="true">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
<item value="自动检测"/>
<item value="中文(简体)"/>
<item value="英语"/>
</model>
</properties>
</component>
<hspacer id="6053b">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="5e074" class="javax.swing.JButton" binding="exchangeButton">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="2a689" class="javax.swing.JComboBox" binding="comboBox2" default-binding="true">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
<item value="中文(简体)"/>
<item value="英语"/>
</model>
</properties>
</component>
</children>
</grid>
<splitpane id="dfc38" binding="splitPane">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="200" height="200"/>
</grid>
</constraints>
<properties>
<continuousLayout value="true"/>
<dividerLocation value="224"/>
</properties>
<border type="none"/>
<children>
<grid id="46f68" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="left"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="4cd66">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="3dad6" class="javax.swing.JTextArea" binding="textArea1" default-binding="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
<grid id="e3173" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<splitpane position="right"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<scrollpane id="b3e56">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="82e1a" class="javax.swing.JTextArea" binding="textArea2" default-binding="true">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
</children>
</splitpane>
</children>
</grid>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.luoboduner.moo.tool.ui.form;

import com.formdev.flatlaf.extras.FlatSVGIcon;
import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import lombok.Getter;

import javax.swing.*;
import java.awt.*;

@Getter
public class TranslationLayoutForm {
private JComboBox comboBox1;
private JButton exchangeButton;
private JComboBox comboBox2;
private JTextArea textArea1;
private JTextArea textArea2;
private JPanel mainLayoutPanel;
private JSplitPane splitPane;

public TranslationLayoutForm() {
exchangeButton.setIcon(new FlatSVGIcon("icon/exchange.svg"));
textArea1.setText("施工中,敬请期待...");
}

{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
$$$setupUI$$$();
}

/**
* Method generated by IntelliJ IDEA GUI Designer
* >>> IMPORTANT!! <<<
* DO NOT edit this method OR call it in your code!
*
* @noinspection ALL
*/
private void $$$setupUI$$$() {
mainLayoutPanel = new JPanel();
mainLayoutPanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(1, 4, new Insets(0, 0, 0, 0), -1, -1));
mainLayoutPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
comboBox1 = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel1 = new DefaultComboBoxModel();
defaultComboBoxModel1.addElement("自动检测");
defaultComboBoxModel1.addElement("中文(简体)");
defaultComboBoxModel1.addElement("英语");
comboBox1.setModel(defaultComboBoxModel1);
panel1.add(comboBox1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer1 = new Spacer();
panel1.add(spacer1, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
exchangeButton = new JButton();
exchangeButton.setText("");
panel1.add(exchangeButton, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
comboBox2 = new JComboBox();
final DefaultComboBoxModel defaultComboBoxModel2 = new DefaultComboBoxModel();
defaultComboBoxModel2.addElement("中文(简体)");
defaultComboBoxModel2.addElement("英语");
comboBox2.setModel(defaultComboBoxModel2);
panel1.add(comboBox2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
splitPane = new JSplitPane();
splitPane.setContinuousLayout(true);
splitPane.setDividerLocation(224);
mainLayoutPanel.add(splitPane, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(200, 200), null, 0, false));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
splitPane.setLeftComponent(panel2);
final JScrollPane scrollPane1 = new JScrollPane();
panel2.add(scrollPane1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
textArea1 = new JTextArea();
scrollPane1.setViewportView(textArea1);
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
splitPane.setRightComponent(panel3);
final JScrollPane scrollPane2 = new JScrollPane();
panel3.add(scrollPane2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
textArea2 = new JTextArea();
scrollPane2.setViewportView(textArea2);
}

/**
* @noinspection ALL
*/
public JComponent $$$getRootComponent$$$() {
return mainLayoutPanel;
}

}
Loading

0 comments on commit 3e85693

Please sign in to comment.