Pārlūkot izejas kodu

Remove deprecation, some cleanups & formatting

Toni Helenius 6 gadi atpakaļ
vecāks
revīzija
62556706b0

+ 1 - 4
jme3-assetpack-support/src/com/jme3/gde/assetpack/online/MultiPartFormOutputStream.java

@@ -6,9 +6,6 @@ package com.jme3.gde.assetpack.online;
 
 import java.io.*;
 import java.net.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.netbeans.api.progress.ProgressHandle;
 
 /**
  * <code>MultiPartFormOutputStream</code> is used to write
@@ -70,7 +67,7 @@ public class MultiPartFormOutputStream {
      */
     public void writeField(String name, boolean value)
             throws java.io.IOException {
-        writeField(name, new Boolean(value).toString());
+        writeField(name, Boolean.toString(value));
     }
 
     /**

+ 17 - 14
jme3-assetpack-support/src/com/jme3/gde/assetpack/project/wizards/CreateProjectWizardIterator.java

@@ -41,7 +41,7 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
     private int index;
     private WizardDescriptor.Panel[] panels;
     private WizardDescriptor wiz;
-    private String name = "Create AssetPack Project";
+    private final String name = "Create AssetPack Project";
 
     public static CreateProjectWizardIterator createIterator() {
         return new CreateProjectWizardIterator();
@@ -68,7 +68,7 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
                     JComponent jc = (JComponent) c;
                     // Sets step number of a component
                     // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
-                    jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
+                    jc.putClientProperty("WizardPanel_contentSelectedIndex", i);
                     // Sets steps names for a panel
                     jc.putClientProperty("WizardPanel_contentData", steps);
                     // Turn on subtitle creation on each step
@@ -83,19 +83,23 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
         return panels;
     }
 
+    @Override
     public void addChangeListener(ChangeListener l) {
 //        throw new UnsupportedOperationException("Not supported yet.");
     }
 
+    @Override
     public void removeChangeListener(ChangeListener l) {
 //        throw new UnsupportedOperationException("Not supported yet.");
     }
 
+    @Override
     public void initialize(WizardDescriptor wizard) {
         wiz = wizard;
         getPanels();
     }
 
+    @Override
     public void uninitialize(WizardDescriptor wizard) {
 //        this.wiz.putProperty("projdir", null);
 //        this.wiz.putProperty("name", null);
@@ -103,8 +107,9 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
         panels = null;
     }
 
+    @Override
     public Set<FileObject> instantiate() throws IOException {
-        Set<FileObject> mySet = new LinkedHashSet<FileObject>();
+        Set<FileObject> mySet = new LinkedHashSet<>();
         //create folders
         File dirF = FileUtil.normalizeFile(new File((String) wiz.getProperty("folder")));
         dirF.mkdirs();
@@ -125,14 +130,17 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
         return mySet;
     }
 
+    @Override
     public boolean hasNext() {
         return index < panels.length - 1;
     }
 
+    @Override
     public boolean hasPrevious() {
         return index > 0;
     }
 
+    @Override
     public void nextPanel() {
         if (!hasNext()) {
             throw new NoSuchElementException();
@@ -140,6 +148,7 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
         index++;
     }
 
+    @Override
     public void previousPanel() {
         if (!hasPrevious()) {
             throw new NoSuchElementException();
@@ -147,16 +156,18 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
         index--;
     }
 
+    @Override
     public WizardDescriptor.Panel current() {
         return panels[index];
     }
 
+    @Override
     public String name() {
         return name;
     }
 
     private void unZipFile(InputStream source, FileObject projectRoot) throws IOException {
-        try {
+        try (source) {
             ZipInputStream str = new ZipInputStream(source);
             ZipEntry entry;
             while ((entry = str.getNextEntry()) != null) {
@@ -172,17 +183,12 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
                     }
                 }
             }
-        } finally {
-            source.close();
         }
     }
 
     private void writeFile(ZipInputStream str, FileObject fo) throws IOException {
-        OutputStream out = fo.getOutputStream();
-        try {
+        try (OutputStream out = fo.getOutputStream()) {
             FileUtil.copy(str, out);
-        } finally {
-            out.close();
         }
     }
 
@@ -198,11 +204,8 @@ public final class CreateProjectWizardIterator implements WizardDescriptor.Insta
             doc.getDocumentElement().setAttribute("name", (String) wiz.getProperty("name"));
             XMLUtil.findElement(doc.getDocumentElement(), "description", null).setTextContent((String) wiz.getProperty("description"));
             XMLUtil.findElement(doc.getDocumentElement(), "license", null).setTextContent((String) wiz.getProperty("license"));
-            OutputStream out = fo.getOutputStream();
-            try {
+            try (OutputStream out = fo.getOutputStream()) {
                 XMLUtil.write(doc, out, "UTF-8");
-            } finally {
-                out.close();
             }
         } catch (Exception ex) {
             Exceptions.printStackTrace(ex);

+ 5 - 3
jme3-ogretools/src/com/jme3/gde/ogretools/blender/InstallBlenderExporterPanel.java

@@ -17,7 +17,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import org.openide.filesystems.FileChooserBuilder;
 import org.openide.util.Exceptions;
-import org.openide.util.Utilities;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.prefs.Preferences;
@@ -35,12 +34,15 @@ import org.openide.NotifyDescriptor.Confirmation;
 @SuppressWarnings({"unchecked", "rawtypes"})
 public class InstallBlenderExporterPanel extends javax.swing.JDialog {
 
-    /** Creates new form InstallBlenderExporterPanel */
+    /** Creates new form InstallBlenderExporterPanel
+     * @param parent
+     * @param modal */
     public InstallBlenderExporterPanel(java.awt.Frame parent, boolean modal) {
         super(parent, modal);
         initComponents();
         java.awt.EventQueue.invokeLater(new Runnable() {
 
+            @Override
             public void run() {
                 jTextField1.setText(findBlenderFolder());
             }
@@ -210,7 +212,7 @@ public class InstallBlenderExporterPanel extends javax.swing.JDialog {
             // Should be: HKEY_CURRENT_USER\Volatile Environment, key NWUSERNAME
             final String subKey = "Volatile Environment";
 
-            Object[] objects1 = {toByteArray(subKey), new Integer(KEY_READ), new Integer(KEY_READ)};
+            Object[] objects1 = {toByteArray(subKey), KEY_READ, KEY_READ};
             Integer hSettings = (Integer) mOpenKey.invoke(userRoot,
                     objects1);
 

+ 17 - 14
jme3-templates/src/com/jme3/gde/templates/basic/BasicGameWizardIterator.java

@@ -86,8 +86,9 @@ public class BasicGameWizardIterator implements WizardDescriptor./*Progress*/Ins
                 };
     }
 
+    @Override
     public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException {
-        Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
+        Set<FileObject> resultSet = new LinkedHashSet<>();
         File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
         dirF.mkdirs();
 
@@ -114,6 +115,7 @@ public class BasicGameWizardIterator implements WizardDescriptor./*Progress*/Ins
         return resultSet;
     }
 
+    @Override
     public void initialize(WizardDescriptor wiz) {
         this.wiz = wiz;
         index = 0;
@@ -132,13 +134,14 @@ public class BasicGameWizardIterator implements WizardDescriptor./*Progress*/Ins
                 JComponent jc = (JComponent) c;
                 // Step #.
                 // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
-                jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
+                jc.putClientProperty("WizardPanel_contentSelectedIndex", i);
                 // Step name (actually the whole list for reference).
                 jc.putClientProperty("WizardPanel_contentData", steps);
             }
         }
     }
 
+    @Override
     public void uninitialize(WizardDescriptor wiz) {
         this.wiz.putProperty("projdir", null);
         this.wiz.putProperty("name", null);
@@ -146,19 +149,23 @@ public class BasicGameWizardIterator implements WizardDescriptor./*Progress*/Ins
         panels = null;
     }
 
+    @Override
     public String name() {
         return MessageFormat.format("{0} of {1}",
-                new Object[]{new Integer(index + 1), new Integer(panels.length)});
+                new Object[]{index + 1, panels.length});
     }
 
+    @Override
     public boolean hasNext() {
         return index < panels.length - 1;
     }
 
+    @Override
     public boolean hasPrevious() {
         return index > 0;
     }
 
+    @Override
     public void nextPanel() {
         if (!hasNext()) {
             throw new NoSuchElementException();
@@ -166,6 +173,7 @@ public class BasicGameWizardIterator implements WizardDescriptor./*Progress*/Ins
         index++;
     }
 
+    @Override
     public void previousPanel() {
         if (!hasPrevious()) {
             throw new NoSuchElementException();
@@ -173,19 +181,22 @@ public class BasicGameWizardIterator implements WizardDescriptor./*Progress*/Ins
         index--;
     }
 
+    @Override
     public WizardDescriptor.Panel current() {
         return panels[index];
     }
 
     // If nothing unusual changes in the middle of the wizard, simply:
+    @Override
     public final void addChangeListener(ChangeListener l) {
     }
 
+    @Override
     public final void removeChangeListener(ChangeListener l) {
     }
 
     private static void unZipFile(InputStream source, FileObject projectRoot) throws IOException {
-        try {
+        try (source) {
             ZipInputStream str = new ZipInputStream(source);
             ZipEntry entry;
             while ((entry = str.getNextEntry()) != null) {
@@ -201,17 +212,12 @@ public class BasicGameWizardIterator implements WizardDescriptor./*Progress*/Ins
                     }
                 }
             }
-        } finally {
-            source.close();
         }
     }
 
     private static void writeFile(ZipInputStream str, FileObject fo) throws IOException {
-        OutputStream out = fo.getOutputStream();
-        try {
+        try (OutputStream out = fo.getOutputStream()) {
             FileUtil.copy(str, out);
-        } finally {
-            out.close();
         }
     }
 
@@ -233,11 +239,8 @@ public class BasicGameWizardIterator implements WizardDescriptor./*Progress*/Ins
                     }
                 }
             }
-            OutputStream out = fo.getOutputStream();
-            try {
+            try (OutputStream out = fo.getOutputStream()) {
                 XMLUtil.write(doc, out, "UTF-8");
-            } finally {
-                out.close();
             }
         } catch (Exception ex) {
             Exceptions.printStackTrace(ex);

+ 17 - 14
jme3-tests-template/src/com/jme3/gde/templates/tests/testsandroid/JME3TestsAndroidWizardIterator.java

@@ -86,8 +86,9 @@ public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progre
                 };
     }
 
+    @Override
     public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException {
-        Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
+        Set<FileObject> resultSet = new LinkedHashSet<>();
         File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
         dirF.mkdirs();
 
@@ -114,6 +115,7 @@ public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progre
         return resultSet;
     }
 
+    @Override
     public void initialize(WizardDescriptor wiz) {
         this.wiz = wiz;
         index = 0;
@@ -132,13 +134,14 @@ public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progre
                 JComponent jc = (JComponent) c;
                 // Step #.
                 // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
-                jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
+                jc.putClientProperty("WizardPanel_contentSelectedIndex", i);
                 // Step name (actually the whole list for reference).
                 jc.putClientProperty("WizardPanel_contentData", steps);
             }
         }
     }
 
+    @Override
     public void uninitialize(WizardDescriptor wiz) {
         this.wiz.putProperty("projdir", null);
         this.wiz.putProperty("name", null);
@@ -146,19 +149,23 @@ public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progre
         panels = null;
     }
 
+    @Override
     public String name() {
         return MessageFormat.format("{0} of {1}",
-                new Object[]{new Integer(index + 1), new Integer(panels.length)});
+                new Object[]{index + 1, panels.length});
     }
 
+    @Override
     public boolean hasNext() {
         return index < panels.length - 1;
     }
 
+    @Override
     public boolean hasPrevious() {
         return index > 0;
     }
 
+    @Override
     public void nextPanel() {
         if (!hasNext()) {
             throw new NoSuchElementException();
@@ -166,6 +173,7 @@ public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progre
         index++;
     }
 
+    @Override
     public void previousPanel() {
         if (!hasPrevious()) {
             throw new NoSuchElementException();
@@ -173,19 +181,22 @@ public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progre
         index--;
     }
 
+    @Override
     public WizardDescriptor.Panel current() {
         return panels[index];
     }
 
     // If nothing unusual changes in the middle of the wizard, simply:
+    @Override
     public final void addChangeListener(ChangeListener l) {
     }
 
+    @Override
     public final void removeChangeListener(ChangeListener l) {
     }
 
     private static void unZipFile(InputStream source, FileObject projectRoot) throws IOException {
-        try {
+        try (source) {
             ZipInputStream str = new ZipInputStream(source);
             ZipEntry entry;
             while ((entry = str.getNextEntry()) != null) {
@@ -201,17 +212,12 @@ public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progre
                     }
                 }
             }
-        } finally {
-            source.close();
         }
     }
 
     private static void writeFile(ZipInputStream str, FileObject fo) throws IOException {
-        OutputStream out = fo.getOutputStream();
-        try {
+        try (OutputStream out = fo.getOutputStream()) {
             FileUtil.copy(str, out);
-        } finally {
-            out.close();
         }
     }
 
@@ -233,11 +239,8 @@ public class JME3TestsAndroidWizardIterator implements WizardDescriptor./*Progre
                     }
                 }
             }
-            OutputStream out = fo.getOutputStream();
-            try {
+            try (OutputStream out = fo.getOutputStream()) {
                 XMLUtil.write(doc, out, "UTF-8");
-            } finally {
-                out.close();
             }
         } catch (Exception ex) {
             Exceptions.printStackTrace(ex);

+ 17 - 14
jme3-tests-template/src/com/jme3/gde/templates/tests/testsdesktop/JmeTestsWizardIterator.java

@@ -59,8 +59,9 @@ public class JmeTestsWizardIterator implements WizardDescriptor./*Progress*/Inst
                 };
     }
 
+    @Override
     public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException {
-        Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
+        Set<FileObject> resultSet = new LinkedHashSet<>();
         File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
         dirF.mkdirs();
 
@@ -87,6 +88,7 @@ public class JmeTestsWizardIterator implements WizardDescriptor./*Progress*/Inst
         return resultSet;
     }
 
+    @Override
     public void initialize(WizardDescriptor wiz) {
         this.wiz = wiz;
         index = 0;
@@ -105,13 +107,14 @@ public class JmeTestsWizardIterator implements WizardDescriptor./*Progress*/Inst
                 JComponent jc = (JComponent) c;
                 // Step #.
                 // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*:
-                jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i));
+                jc.putClientProperty("WizardPanel_contentSelectedIndex", i);
                 // Step name (actually the whole list for reference).
                 jc.putClientProperty("WizardPanel_contentData", steps);
             }
         }
     }
 
+    @Override
     public void uninitialize(WizardDescriptor wiz) {
         this.wiz.putProperty("projdir", null);
         this.wiz.putProperty("name", null);
@@ -119,19 +122,23 @@ public class JmeTestsWizardIterator implements WizardDescriptor./*Progress*/Inst
         panels = null;
     }
 
+    @Override
     public String name() {
         return MessageFormat.format("{0} of {1}",
-                new Object[]{new Integer(index + 1), new Integer(panels.length)});
+                new Object[]{index + 1, panels.length});
     }
 
+    @Override
     public boolean hasNext() {
         return index < panels.length - 1;
     }
 
+    @Override
     public boolean hasPrevious() {
         return index > 0;
     }
 
+    @Override
     public void nextPanel() {
         if (!hasNext()) {
             throw new NoSuchElementException();
@@ -139,6 +146,7 @@ public class JmeTestsWizardIterator implements WizardDescriptor./*Progress*/Inst
         index++;
     }
 
+    @Override
     public void previousPanel() {
         if (!hasPrevious()) {
             throw new NoSuchElementException();
@@ -146,19 +154,22 @@ public class JmeTestsWizardIterator implements WizardDescriptor./*Progress*/Inst
         index--;
     }
 
+    @Override
     public WizardDescriptor.Panel current() {
         return panels[index];
     }
 
     // If nothing unusual changes in the middle of the wizard, simply:
+    @Override
     public final void addChangeListener(ChangeListener l) {
     }
 
+    @Override
     public final void removeChangeListener(ChangeListener l) {
     }
 
     private static void unZipFile(InputStream source, FileObject projectRoot) throws IOException {
-        try {
+        try (source) {
             ZipInputStream str = new ZipInputStream(source);
             ZipEntry entry;
             while ((entry = str.getNextEntry()) != null) {
@@ -174,17 +185,12 @@ public class JmeTestsWizardIterator implements WizardDescriptor./*Progress*/Inst
                     }
                 }
             }
-        } finally {
-            source.close();
         }
     }
 
     private static void writeFile(ZipInputStream str, FileObject fo) throws IOException {
-        OutputStream out = fo.getOutputStream();
-        try {
+        try (OutputStream out = fo.getOutputStream()) {
             FileUtil.copy(str, out);
-        } finally {
-            out.close();
         }
     }
 
@@ -206,11 +212,8 @@ public class JmeTestsWizardIterator implements WizardDescriptor./*Progress*/Inst
                     }
                 }
             }
-            OutputStream out = fo.getOutputStream();
-            try {
+            try (OutputStream out = fo.getOutputStream()) {
                 XMLUtil.write(doc, out, "UTF-8");
-            } finally {
-                out.close();
             }
         } catch (Exception ex) {
             Exceptions.printStackTrace(ex);