-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed language system, Changed additional stuff.
- Loading branch information
1 parent
cd633f4
commit 2f12e7e
Showing
12 changed files
with
751 additions
and
139 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.mokkachocolata.util.LanguageChange"> | ||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="10" left="10" bottom="10" right="10"/> | ||
<constraints> | ||
<xy x="48" y="54" width="436" height="151"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="0" left="0" bottom="0" right="0"/> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<hspacer id="98af6"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
</hspacer> | ||
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="0" left="0" bottom="0" right="0"/> | ||
<constraints> | ||
<grid row="0" column="1" 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="e7465" class="javax.swing.JButton" binding="buttonOK"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<enabled value="true"/> | ||
<text value="OK"/> | ||
</properties> | ||
</component> | ||
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel"> | ||
<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="Cancel"/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</children> | ||
</grid> | ||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" 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> | ||
<component id="da6d5" class="javax.swing.JComboBox" binding="LanguageSelector"> | ||
<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/> | ||
</component> | ||
<component id="e9beb" class="javax.swing.JLabel" binding="LanguageCurrent"> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<text value="Current language: "/> | ||
</properties> | ||
</component> | ||
<component id="23d84" class="javax.swing.JLabel" binding="RestartText"> | ||
<constraints> | ||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<enabled value="true"/> | ||
<text value="A restart of the program is required to change the language."/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</children> | ||
</grid> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.mokkachocolata.util; | ||
|
||
import com.mokkachocolata.enums.Languages; | ||
import com.mokkachocolata.exception.JarNotFoundException; | ||
|
||
import javax.swing.*; | ||
import java.awt.event.*; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
|
||
public class LanguageChange extends JDialog { | ||
private JPanel contentPane; | ||
private JButton buttonOK; | ||
private JButton buttonCancel; | ||
Localization localization = new Localization(); | ||
private JComboBox<String> LanguageSelector; | ||
private JLabel LanguageCurrent; | ||
private JLabel RestartText; | ||
|
||
private int choiceToLanguage(int index) { | ||
return switch (index) { | ||
case 0 -> Languages.EN_US; | ||
case 1 -> Languages.ID_ID; | ||
default -> 0; | ||
}; | ||
} | ||
|
||
public LanguageChange() { | ||
setContentPane(contentPane); | ||
setModal(true); | ||
getRootPane().setDefaultButton(buttonOK); | ||
LanguageSelector.addItem("American English"); | ||
LanguageSelector.addItem("Indonesian"); | ||
buttonOK.setEnabled(false); | ||
RestartText.setVisible(false); | ||
LanguageSelector.addActionListener(e -> { | ||
if (LanguageSelector.getSelectedIndex() != localization.getCurrentLanguage()) { | ||
buttonOK.setEnabled(true); | ||
RestartText.setVisible(true); | ||
} else { | ||
buttonOK.setEnabled(false); | ||
RestartText.setVisible(false); | ||
} | ||
}); | ||
|
||
LanguageCurrent.setText(localization.languageToString(localization.getCurrentLanguage())); | ||
buttonOK.addActionListener(e -> { | ||
try { | ||
onOK(); | ||
} catch (JarNotFoundException | IOException | URISyntaxException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
}); | ||
|
||
buttonCancel.addActionListener(e -> onCancel()); | ||
|
||
// 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(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); | ||
} | ||
|
||
private void onOK() throws JarNotFoundException, URISyntaxException, IOException { | ||
// add your code here | ||
localization.setCurrentLanguageToPreferences(choiceToLanguage(LanguageSelector.getSelectedIndex())); | ||
System.exit(2); | ||
} | ||
|
||
private void onCancel() { | ||
// add your code here if necessary | ||
dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.