OSDN Git Service

JDK1.7対応
authorOlyutorskii <olyutorskii@users.osdn.me>
Fri, 17 Jun 2016 15:09:04 +0000 (00:09 +0900)
committerOlyutorskii <olyutorskii@users.osdn.me>
Fri, 17 Jun 2016 15:09:04 +0000 (00:09 +0900)
18 files changed:
pom.xml
src/main/java/jp/sfjp/jindolf/Jindolf.java
src/main/java/jp/sfjp/jindolf/JindolfJre17.java [moved from src/main/java/jp/sfjp/jindolf/JindolfJre16.java with 97% similarity]
src/main/java/jp/sfjp/jindolf/JindolfMain.java
src/main/java/jp/sfjp/jindolf/JreChecker.java
src/main/java/jp/sfjp/jindolf/dxchg/CsvExporter.java
src/main/java/jp/sfjp/jindolf/dxchg/FaceIconSet.java
src/main/java/jp/sfjp/jindolf/glyph/FontChooser.java
src/main/java/jp/sfjp/jindolf/glyph/FontListModel.java
src/main/java/jp/sfjp/jindolf/glyph/FontSelectList.java
src/main/java/jp/sfjp/jindolf/net/ProxyChooser.java
src/main/java/jp/sfjp/jindolf/summary/DaySummary.java
src/main/java/jp/sfjp/jindolf/summary/VillageDigest.java
src/main/java/jp/sfjp/jindolf/util/Monodizer.java
src/main/java/jp/sfjp/jindolf/view/AccountPanel.java
src/main/java/jp/sfjp/jindolf/view/FindPanel.java
src/main/java/jp/sfjp/jindolf/view/PeriodView.java
src/test/java/jp/sfjp/jindolf/JreCheckerTest.java

diff --git a/pom.xml b/pom.xml
index a0a08f7..ccdef48 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -81,8 +81,8 @@
     <properties>
         <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
 
-        <maven.compiler.source>1.6</maven.compiler.source>
-        <maven.compiler.target>1.6</maven.compiler.target>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
 
         <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
         <maven.compiler.showWarnings>true</maven.compiler.showWarnings>
                             <version>[3.3,)</version>
                         </requireMavenVersion>
                         <requireJavaVersion>
-                            <version>[1.6,)</version>
+                            <version>[1.7,)</version>
                         </requireJavaVersion>
                     </rules>
                 </configuration>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>3.5.1</version>
                 <configuration>
-                    <source>1.6</source>  <!-- for NetBeans IDE -->
-                    <target>1.6</target>
+                    <source>1.7</source>  <!-- for NetBeans IDE -->
+                    <target>1.7</target>
                     <showDeprecation>true</showDeprecation>
                     <showWarnings>true</showWarnings>
                     <compilerArguments>
index a8bd145..7daf019 100644 (file)
@@ -29,7 +29,7 @@ public final class Jindolf {
     /**
      * Jindolf のスタートアップエントリ。
      * <p>互換性検査が行われた後、
-     * JRE1.6解除版エントリ{@link JindolfJre16}
+     * JRE1.7解除版エントリ{@link JindolfJre17}
      * に制御を渡す。
      * @param args コマンドライン引数
      */
@@ -39,7 +39,7 @@ public final class Jindolf {
         exitCode = JreChecker.checkJre();
         if(exitCode != 0) System.exit(exitCode);
 
-        exitCode = JindolfJre16.main(args);
+        exitCode = JindolfJre17.main(args);
         if(exitCode != 0) System.exit(exitCode);
 
         // デーモンスレッドがいなければ、(アプリ画面が出ていなければ)
@@ -15,13 +15,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import javax.swing.JOptionPane;
 
 /**
- * JRE1.6の利用が解禁されたJindolfエントリ。
+ * JRE1.7の利用が解禁されたJindolfエントリ。
  * <p>起動クラスJindolfの下請けとしての機能が想定される。
  * <p>必ずしも必要ないが、異常系切り分けに有用な、
  * 実行環境やビルドの成否に関する各種診断を行う。
  * <p>各種診断を通過した後、JindolfMainに制御を渡す。
  */
-public final class JindolfJre16 {
+public final class JindolfJre17 {
 
     /** GUI環境に接続できないときの終了コード。 */
     public static final int EXIT_CODE_HEADLESS = 1;
@@ -69,7 +69,7 @@ public final class JindolfJre16 {
     /**
      * 隠しコンストラクタ。
      */
-    private JindolfJre16(){
+    private JindolfJre17(){
         assert false;
     }
 
@@ -192,7 +192,7 @@ public final class JindolfJre16 {
 
     /**
      * Jindolf のスタートアップエントリ。
-     * <p>ここからJRE1.6の利用が解禁される。
+     * <p>ここからJRE1.7の利用が解禁される。
      * <p>最終的に{@link JindolfMain}へ制御が渡される。
      * @param args コマンドライン引数
      * @return 起動に成功すれば0。失敗したら0以外。
index de0a526..cf12c1c 100644 (file)
@@ -34,7 +34,7 @@ import jp.sfjp.jindolf.view.WindowManager;
 
 /**
  * Jindolf スタートアップクラス。
- * <p>{@link JindolfJre16}の下請けとして本格的なJindolf起動処理に入る。
+ * <p>{@link JindolfJre17}の下請けとして本格的なJindolf起動処理に入る。
  */
 public final class JindolfMain {
 
index 6cf9f76..772f709 100644 (file)
@@ -30,7 +30,7 @@ import javax.swing.JOptionPane;
 public final class JreChecker {
 
     /** Jindolfが実行時に必要とするJREの版。 */
-    public static final String REQUIRED_JRE_VER = "1.6";
+    public static final String REQUIRED_JRE_VER = "1.7";
 
     /** 互換性エラーの終了コード。 */
     public static final int EXIT_CODE_INCOMPAT_JRE = 1;
@@ -143,7 +143,19 @@ public final class JreChecker {
         return result;
     }
 
-    // TODO JRE1.7,1.8 対応
+    /**
+     * JRE 1.7 相当のランタイムライブラリが提供されているか判定する。
+     * @return 提供されているならtrue
+     * @see java.lang.AutoCloseable
+     */
+    public static boolean has17Runtime(){
+        boolean result;
+        if(has16Runtime()) result = hasClass("java.lang.AutoCloseable");
+        else               result = false;
+        return result;
+    }
+
+    // TODO JRE1.8 対応
 
     /**
      * JREもしくは<code>java.lang</code>パッケージの
@@ -257,12 +269,12 @@ public final class JreChecker {
     }
 
     /**
-     * JRE環境をチェックする。(JRE1.6)
+     * JRE環境をチェックする。(JRE1.7)
      * <p>もしJREの非互換性が検出されたらエラーメッセージを報告する。
      * @return 互換性があれば0、無ければ非0
      */
     public static int checkJre(){
-        if(has16Runtime()) return 0;
+        if(has17Runtime()) return 0;
 
         String message = buildErrMessage();
         STDERR.println(message);
index 0cd254f..2110ca4 100644 (file)
@@ -78,7 +78,7 @@ public final class CsvExporter{
 
     private static final List<Charset> CHARSET_LIST = buildCharsetList();
     private static final FileFilter CSV_FILTER = new CsvFileFilter();
-    private static final JComboBox encodeBox = new JComboBox();
+    private static final JComboBox<Charset> encodeBox = new JComboBox<>();
     private static final JFileChooser chooser = buildChooser();
     // TODO staticなGUIパーツってどうなんだ…
 
@@ -115,7 +115,7 @@ public final class CsvExporter{
      * @return 日本語Charset一覧
      */
     private static List<Charset> buildCharsetList(){
-        List<Charset> csList = new LinkedList<Charset>();
+        List<Charset> csList = new LinkedList<>();
         for(String name : ENCNAMES){
             if( ! Charset.isSupported(name) ) continue;
             Charset cs = Charset.forName(name);
index ea4e195..31f542b 100644 (file)
@@ -19,7 +19,7 @@ public class FaceIconSet{
     private final String caption;
     private final String author;
     private final String urlText;
-    private final Map<Avatar, String> wikiMap = new HashMap<Avatar, String>();
+    private final Map<Avatar, String> wikiMap = new HashMap<>();
 
     /**
      * コンストラクタ。
index ce078f9..4eee6b2 100644 (file)
@@ -61,7 +61,7 @@ public class FontChooser extends JPanel
     private FontInfo lastFontInfo;
 
     private final FontSelectList familySelector;
-    private final JComboBox sizeSelector;
+    private final JComboBox<Integer> sizeSelector;
     private final JCheckBox isBoldCheck;
     private final JCheckBox isItalicCheck;
     private final JCheckBox useTextAntiAliaseCheck;
@@ -99,7 +99,7 @@ public class FontChooser extends JPanel
 
         this.familySelector = new FontSelectList();
 
-        this.sizeSelector = new JComboBox();
+        this.sizeSelector = new JComboBox<>();
         this.sizeSelector.setEditable(true);
         for(int size : POINT_SIZES){
             this.sizeSelector.addItem(size);
@@ -344,7 +344,7 @@ public class FontChooser extends JPanel
         this.familySelector.setSelectedFamily(defaultFamily);
 
         // サイズ指定コンボボックス
-        Integer selectedInteger = Integer.valueOf(currentFont.getSize());
+        Integer selectedInteger = currentFont.getSize();
         this.sizeSelector.setSelectedItem(selectedInteger);
         int sizeItems = this.sizeSelector.getItemCount();
         for(int index = 0; index < sizeItems; index++){
index 9f03099..ec5a73e 100644 (file)
@@ -22,11 +22,11 @@ import javax.swing.AbstractListModel;
  * 基本的にスレッド間競合の問題はEDTで解決すること。
  */
 @SuppressWarnings("serial")
-public class FontListModel extends AbstractListModel {
+public class FontListModel extends AbstractListModel<String> {
 
     private static final FontEnv DEFAULT_FONTENV = FontEnv.DEFAULT;
 
-    private final List<String> familyList = new LinkedList<String>();
+    private final List<String> familyList = new LinkedList<>();
 
     /**
      * コンストラクタ。
@@ -63,8 +63,8 @@ public class FontListModel extends AbstractListModel {
      * @return {@inheritDoc}
      */
     @Override
-    public Object getElementAt(int index){
-        Object result = this.familyList.get(index);
+    public String getElementAt(int index){
+        String result = this.familyList.get(index);
         return result;
     }
 
index d6e8f2a..d93cbf0 100644 (file)
@@ -18,7 +18,7 @@ import javax.swing.event.ListDataListener;
  * <p>フォント一覧の遅延読み込みに対応。
  */
 @SuppressWarnings("serial")
-public class FontSelectList extends JList
+public class FontSelectList extends JList<String>
         implements ListDataListener {
 
     private String selectedFamily = null;
@@ -30,7 +30,7 @@ public class FontSelectList extends JList
     public FontSelectList(){
         super();
 
-        ListModel fontListModel = new FontListModel();
+        ListModel<String> fontListModel = new FontListModel();
         setModelImpl(fontListModel);
         setVisibleRowCount(-1);
         setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
@@ -43,8 +43,8 @@ public class FontSelectList extends JList
      * 与えられたモデルの更新は監視対象となる。
      * @param model リストモデル
      */
-    private void setModelImpl(ListModel model){
-        ListModel oldModel = getModel();
+    private void setModelImpl(ListModel<String> model){
+        ListModel<String> oldModel = getModel();
         if(oldModel != null){
             oldModel.removeListDataListener(this);
         }
@@ -62,7 +62,7 @@ public class FontSelectList extends JList
      * @param model {@inheritDoc}
      */
     @Override
-    public void setModel(ListModel model){
+    public void setModel(ListModel<String> model){
         setModelImpl(model);
         return;
     }
index 30e758a..68fdcdb 100644 (file)
@@ -50,7 +50,7 @@ public class ProxyChooser extends JPanel implements ItemListener{
     private final ButtonGroup buttonGroup = new ButtonGroup();
 
     private final JTextField hostname = new JTextField();
-    private final JComboBox port = new JComboBox();
+    private final JComboBox<Integer> port = new JComboBox<>();
     private final JComponent serverInfo = buildServerPanel();
 
 
@@ -102,14 +102,14 @@ public class ProxyChooser extends JPanel implements ItemListener{
      * ポート番号選択肢を生成する。
      * @return ポート番号選択肢
      */
-    private static ComboBoxModel buildPortRecommender(){
-        DefaultComboBoxModel model = new DefaultComboBoxModel();
-        model.addElement("80");
-        model.addElement("1080");
-        model.addElement("3128");
-        model.addElement("8000");
-        model.addElement("8080");
-        model.addElement("10080");
+    private static ComboBoxModel<Integer> buildPortRecommender(){
+        DefaultComboBoxModel<Integer> model = new DefaultComboBoxModel<>();
+        model.addElement(80);
+        model.addElement(1080);
+        model.addElement(3128);
+        model.addElement(8000);
+        model.addElement(8080);
+        model.addElement(10080);
         return model;
     }
 
index ea5b052..7693571 100644 (file)
@@ -80,7 +80,7 @@ public class DaySummary extends JDialog
     private final TableColumn avatarColumn;
 
     private final JTable tableComp;
-    private final JComboBox typeSelector = new JComboBox();
+    private final JComboBox<String> typeSelector = new JComboBox<>();
     private final JButton closeButton = new JButton("閉じる");
     private final JLabel caption = new JLabel();
     private final JLabel totalSum = new JLabel();
@@ -267,10 +267,10 @@ public class DaySummary extends JDialog
 
         if(this.period == null) return;
 
-        SortedSet<Avatar> avatarSet = new TreeSet<Avatar>();
-        Map<Avatar, Integer> talkCount  = new HashMap<Avatar, Integer>();
-        Map<Avatar, Integer> totalChars = new HashMap<Avatar, Integer>();
-        Map<Avatar, Talk> lastTalk = new HashMap<Avatar, Talk>();
+        SortedSet<Avatar> avatarSet = new TreeSet<>();
+        Map<Avatar, Integer> talkCount  = new HashMap<>();
+        Map<Avatar, Integer> totalChars = new HashMap<>();
+        Map<Avatar, Talk> lastTalk = new HashMap<>();
 
         List<Topic> topicList = this.period.getTopicList();
         for(Topic topic : topicList){
index 1a16ede..305639f 100644 (file)
@@ -71,9 +71,9 @@ public class VillageDigest
 
     private final JLabel faceLabel = new JLabel();
     private final ImageIcon faceIcon = new ImageIcon();
-    private final JComboBox playerBox = new JComboBox();
-    private final DefaultComboBoxModel playerListModel =
-            new DefaultComboBoxModel();
+    private final JComboBox<Avatar> playerBox = new JComboBox<>();
+    private final DefaultComboBoxModel<Avatar> playerListModel =
+            new DefaultComboBoxModel<>();
     private final JButton prevPlayer = new JButton("↑");
     private final JButton nextPlayer = new JButton("↓");
     private final JLabel roleLabel = new JLabel();
@@ -84,9 +84,9 @@ public class VillageDigest
     private final WebButton urlLine = new WebButton();
     private final JComponent playerPanel = buildPlayerPanel();
 
-    private final JComboBox iconSetBox = new JComboBox();
-    private final DefaultComboBoxModel iconSetListModel =
-            new DefaultComboBoxModel();
+    private final JComboBox<FaceIconSet> iconSetBox = new JComboBox<>();
+    private final DefaultComboBoxModel<FaceIconSet> iconSetListModel =
+            new DefaultComboBoxModel<>();
     private final JLabel authorLabel = new JLabel();
     private final JLabel authorUrlLabel = new JLabel();
     private final WebButton iconCatalog = new WebButton();
index e5b40fe..1dced96 100644 (file)
@@ -104,7 +104,7 @@ public final class Monodizer implements PropertyChangeListener{
             JTextComponent textComp = (JTextComponent) comp;
             modifyTextComponent(textComp);
         }else if(comp instanceof JComboBox){
-            JComboBox combo = (JComboBox) comp;
+            JComboBox<?> combo = (JComboBox) comp;
             modifyComboBox(combo);
         }
 
@@ -128,7 +128,7 @@ public final class Monodizer implements PropertyChangeListener{
      * コンボボックスのエディタを等幅化する。
      * @param comboBox コンボボックス
      */
-    private static void modifyComboBox(JComboBox comboBox){
+    private static void modifyComboBox(JComboBox<?> comboBox){
         ComboBoxEditor editor = comboBox.getEditor();
         if(editor == null) return;
 
index 27c991d..ec46a0b 100644 (file)
@@ -56,11 +56,11 @@ public class AccountPanel
 
 
     private final Map<Land, String> landUserIDMap =
-            new HashMap<Land, String>();
+            new HashMap<>();
     private final Map<Land, char[]> landPasswordMap =
-            new HashMap<Land, char[]>();
+            new HashMap<>();
 
-    private final JComboBox landBox = new JComboBox();
+    private final JComboBox<Land> landBox = new JComboBox<>();
     private final JTextField idField = new JTextField(15);
     private final JPasswordField pwField = new JPasswordField(15);
     private final JButton loginButton = new JButton("ログイン");
index ef3adb0..65e4cca 100644 (file)
@@ -76,7 +76,7 @@ public class FindPanel extends JDialog
     private static final String LABEL_REENTER = "再入力";
     private static final String LABEL_IGNORE = "無視して検索をキャンセル";
 
-    private final JComboBox findBox = new JComboBox();
+    private final JComboBox<Object> findBox = new JComboBox<>();
     private final JButton searchButton = new JButton("検索");
     private final JButton clearButton = new JButton("クリア");
     private final JCheckBox capitalSwitch =
@@ -494,7 +494,7 @@ public class FindPanel extends JDialog
         result.putValue("history", array);
 
         List<RegexPattern> history = this.model.getOriginalHistoryList();
-        history = new ArrayList<RegexPattern>(history);
+        history = new ArrayList<>(history);
         Collections.reverse(history);
         for(RegexPattern regex : history){
             JsObject obj = RegexPattern.encodeJson(regex);
@@ -564,7 +564,7 @@ public class FindPanel extends JDialog
          */
         @Override
         public Component getListCellRendererComponent(
-                JList list,
+                JList<?> list,
                 Object value,
                 int index,
                 boolean isSelected,
@@ -602,14 +602,14 @@ public class FindPanel extends JDialog
     /**
      * コンボボックスの独自データモデル。
      */
-    private static class CustomModel implements ComboBoxModel{
+    private static class CustomModel implements ComboBoxModel<Object>{
 
         private static final int HISTORY_MAX = 7;
         private static final RegexPattern INITITEM =
             new RegexPattern(
                 "", false, RegexPattern.IGNORECASEFLAG | Pattern.DOTALL);
         private static final List<RegexPattern> PREDEF_PATTERN_LIST =
-                new LinkedList<RegexPattern>();
+                new LinkedList<>();
 
         static{
             PREDEF_PATTERN_LIST.add(
@@ -630,7 +630,7 @@ public class FindPanel extends JDialog
         }
 
         private final List<RegexPattern> history =
-                new LinkedList<RegexPattern>();
+                new LinkedList<>();
         private final JSeparator separator1st = new JSeparator();
         private final JSeparator separator2nd = new JSeparator();
         private Object selected;
index a6f6229..107b233 100644 (file)
@@ -56,8 +56,9 @@ public class PeriodView extends JPanel implements ItemListener{
     private final JScrollPane scroller = new JScrollPane();
     private final JLabel caption = new JLabel();
     private final JLabel limit = new JLabel();
-    private final JComboBox talkSelector = new JComboBox();
-    private final DefaultComboBoxModel model = new DefaultComboBoxModel();
+    private final JComboBox<Talk> talkSelector = new JComboBox<>();
+    private final DefaultComboBoxModel<Talk> model =
+            new DefaultComboBoxModel<>();
 
     private DialogPref dialogPref = new DialogPref();
 
@@ -208,7 +209,7 @@ public class PeriodView extends JPanel implements ItemListener{
         this.limit.setText("更新時刻 " + limitCaption);
 
         this.model.removeAllElements();
-        this.model.addElement(" ");
+        this.model.addElement(null);
         List<Topic> topicList = this.period.getTopicList();
         for(Topic topic : topicList){
             if( ! (topic instanceof Talk) ) continue;
@@ -348,13 +349,13 @@ public class PeriodView extends JPanel implements ItemListener{
          */
         @Override
         public Component getListCellRendererComponent(
-                JList list,
+                JList<?> list,
                 Object value,
                 int index,
                 boolean isSelected,
                 boolean cellHasFocus ){
             Talk talk = null;
-            Object newValue = value;
+            Object newValue;
             if(value instanceof Talk){
                 talk = (Talk) value;
                 newValue = new StringBuilder()
@@ -362,6 +363,8 @@ public class PeriodView extends JPanel implements ItemListener{
                           .append(' ')
                           .append(talk.getAvatar().getName())
                           .toString();
+            }else{
+                newValue=" ";
             }
 
             Component superResult =
index fa36a74..e886be4 100644 (file)
@@ -9,9 +9,10 @@ package jp.sfjp.jindolf;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
+
 import static org.junit.Assert.*;
-import org.junit.BeforeClass;
 
 /**
  *
@@ -107,9 +108,17 @@ public class JreCheckerTest {
     @Test
     public void testHas16Runtime() {
         System.out.println("has16Runtime");
+        assertTrue(JreChecker.has16Runtime());
+        return;
+    }
 
-        boolean result = JreChecker.has16Runtime();
-
+    /**
+     * Test of has17Runtime method, of class JreChecker.
+     */
+    @Test
+    public void testHas17Runtime() {
+        System.out.println("has17Runtime");
+        assertTrue(JreChecker.has17Runtime());
         return;
     }
 
@@ -199,9 +208,7 @@ public class JreCheckerTest {
     public void testCheckJre() {
         System.out.println("checkJre");
 
-        if(false){
-            JreChecker.checkJre();
-        }
+        JreChecker.checkJre();
 
         return;
     }