Refactor code into packages and extract StringUtils class.
This commit is contained in:
parent
88484c1e47
commit
dc2d218969
13 changed files with 75 additions and 41 deletions
|
@ -70,5 +70,5 @@ def jarPackage(artifactName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
archives jarPackage("info.augendre.caps_extractor", "0.1.0", "MainWindow")
|
archives jarPackage("info.augendre.caps_extractor", "0.1.0", "CapsExtractorApp")
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package info.augendre.caps_extractor;
|
||||||
|
|
||||||
|
import info.augendre.caps_extractor.gui.MainWindow;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created on 05/06/15.
|
||||||
|
*
|
||||||
|
* @author gaugendre
|
||||||
|
*/
|
||||||
|
public class CapsExtractorApp {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(
|
||||||
|
UIManager.getSystemLookAndFeelClassName());
|
||||||
|
} catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace(System.err);
|
||||||
|
}
|
||||||
|
new MainWindow();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
package info.augendre.caps_extractor;
|
package info.augendre.caps_extractor.actions;
|
||||||
|
|
||||||
|
import info.augendre.caps_extractor.util.I18nSupport;
|
||||||
|
import info.augendre.caps_extractor.gui.AboutDialog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
|
@ -1,4 +1,7 @@
|
||||||
package info.augendre.caps_extractor;
|
package info.augendre.caps_extractor.actions;
|
||||||
|
|
||||||
|
import info.augendre.caps_extractor.util.I18nSupport;
|
||||||
|
import info.augendre.caps_extractor.gui.HelpDialog;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="info.augendre.caps_extractor.AboutDialog">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="info.augendre.caps_extractor.gui.AboutDialog">
|
||||||
<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">
|
<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"/>
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
<constraints>
|
<constraints>
|
|
@ -1,13 +1,15 @@
|
||||||
package info.augendre.caps_extractor;
|
package info.augendre.caps_extractor.gui;
|
||||||
|
|
||||||
import com.intellij.uiDesigner.core.GridConstraints;
|
import com.intellij.uiDesigner.core.GridConstraints;
|
||||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||||
import com.intellij.uiDesigner.core.Spacer;
|
import com.intellij.uiDesigner.core.Spacer;
|
||||||
|
import info.augendre.caps_extractor.util.I18nSupport;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.ResourceBundle;
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
|
||||||
public class AboutDialog extends JDialog {
|
public class AboutDialog extends JDialog {
|
||||||
private JPanel contentPane;
|
private JPanel contentPane;
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="info.augendre.caps_extractor.HelpDialog">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="info.augendre.caps_extractor.gui.HelpDialog">
|
||||||
<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">
|
<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"/>
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
<constraints>
|
<constraints>
|
|
@ -1,8 +1,9 @@
|
||||||
package info.augendre.caps_extractor;
|
package info.augendre.caps_extractor.gui;
|
||||||
|
|
||||||
import com.intellij.uiDesigner.core.GridConstraints;
|
import com.intellij.uiDesigner.core.GridConstraints;
|
||||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||||
import com.intellij.uiDesigner.core.Spacer;
|
import com.intellij.uiDesigner.core.Spacer;
|
||||||
|
import info.augendre.caps_extractor.util.I18nSupport;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="info.augendre.caps_extractor.MainPanel">
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="info.augendre.caps_extractor.gui.MainPanel">
|
||||||
<grid id="27dc6" binding="contentPanel" default-binding="true" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="27dc6" binding="contentPanel" default-binding="true" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="10" left="10" bottom="10" right="10"/>
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
<constraints>
|
<constraints>
|
|
@ -1,8 +1,9 @@
|
||||||
package info.augendre.caps_extractor;
|
package info.augendre.caps_extractor.gui;
|
||||||
|
|
||||||
import com.intellij.uiDesigner.core.GridConstraints;
|
import com.intellij.uiDesigner.core.GridConstraints;
|
||||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||||
import com.intellij.uiDesigner.core.Spacer;
|
import com.intellij.uiDesigner.core.Spacer;
|
||||||
|
import info.augendre.caps_extractor.util.StringUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
@ -33,7 +34,7 @@ public class MainPanel {
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent e) {
|
public void keyReleased(KeyEvent e) {
|
||||||
if (parse) {
|
if (parse) {
|
||||||
outputField.setText(extractUpperCase(inputField.getText()));
|
outputField.setText(StringUtils.extractUpperCase(inputField.getText()));
|
||||||
} else {
|
} else {
|
||||||
char key = e.getKeyChar();
|
char key = e.getKeyChar();
|
||||||
if (Character.isUpperCase(key)) {
|
if (Character.isUpperCase(key)) {
|
||||||
|
@ -50,23 +51,6 @@ public class MainPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts the upper case characters from the given string.
|
|
||||||
* @param s The string where to extract upper case characters.
|
|
||||||
* @return The upper case characters found in the given string.
|
|
||||||
*/
|
|
||||||
public String extractUpperCase(String s) {
|
|
||||||
String upperCase = "";
|
|
||||||
for (int i = 0; i < s.length(); i++) {
|
|
||||||
char current = s.charAt(i);
|
|
||||||
if (Character.isUpperCase(current)) {
|
|
||||||
upperCase += current;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return upperCase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JPanel getContentPanel() {
|
public JPanel getContentPanel() {
|
||||||
return contentPanel;
|
return contentPanel;
|
||||||
}
|
}
|
|
@ -1,4 +1,8 @@
|
||||||
package info.augendre.caps_extractor;
|
package info.augendre.caps_extractor.gui;
|
||||||
|
|
||||||
|
import info.augendre.caps_extractor.actions.AboutAction;
|
||||||
|
import info.augendre.caps_extractor.actions.HelpAction;
|
||||||
|
import info.augendre.caps_extractor.util.I18nSupport;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
@ -32,14 +36,4 @@ public class MainWindow extends JFrame {
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
try {
|
|
||||||
UIManager.setLookAndFeel(
|
|
||||||
UIManager.getSystemLookAndFeelClassName());
|
|
||||||
} catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace(System.err);
|
|
||||||
}
|
|
||||||
new MainWindow();
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package info.augendre.caps_extractor;
|
package info.augendre.caps_extractor.util;
|
||||||
|
|
||||||
import com.jgoodies.common.internal.StringLocalizer;
|
import com.jgoodies.common.internal.StringLocalizer;
|
||||||
import org.jetbrains.annotations.NonNls;
|
import org.jetbrains.annotations.NonNls;
|
|
@ -0,0 +1,25 @@
|
||||||
|
package info.augendre.caps_extractor.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created on 05/06/15.
|
||||||
|
*
|
||||||
|
* @author gaugendre
|
||||||
|
*/
|
||||||
|
public class StringUtils {
|
||||||
|
/**
|
||||||
|
* Extracts the upper case characters from the given string.
|
||||||
|
* @param s The string where to extract upper case characters.
|
||||||
|
* @return The upper case characters found in the given string.
|
||||||
|
*/
|
||||||
|
public static String extractUpperCase(String s) {
|
||||||
|
String upperCase = "";
|
||||||
|
for (int i = 0; i < s.length(); i++) {
|
||||||
|
char current = s.charAt(i);
|
||||||
|
if (Character.isUpperCase(current)) {
|
||||||
|
upperCase += current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return upperCase;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue