cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/2] cayenne git commit: Fix Win text field UI compilation on JDK 9 and 10
Date Mon, 26 Mar 2018 07:22:09 GMT
Repository: cayenne
Updated Branches:
  refs/heads/STABLE-4.0 ba750c5b2 -> 11206d6a9


Fix Win text field UI compilation on JDK 9 and 10

(cherry picked from commit a985d7b)


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/febbbb45
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/febbbb45
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/febbbb45

Branch: refs/heads/STABLE-4.0
Commit: febbbb45723e320caf28fc04a1bd5cd6c6b1772a
Parents: ba750c5
Author: stariy <stariy95@gmail.com>
Authored: Sat Mar 24 12:47:05 2018 +0300
Committer: stariy <stariy95@gmail.com>
Committed: Mon Mar 26 10:13:47 2018 +0300

----------------------------------------------------------------------
 .../modeler/win/WinCustomTextFieldUI.java       | 24 ++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/febbbb45/modeler/cayenne-modeler-win-ext/src/main/java/org/apache/cayenne/modeler/win/WinCustomTextFieldUI.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler-win-ext/src/main/java/org/apache/cayenne/modeler/win/WinCustomTextFieldUI.java
b/modeler/cayenne-modeler-win-ext/src/main/java/org/apache/cayenne/modeler/win/WinCustomTextFieldUI.java
index 3828e69..bb6a278 100644
--- a/modeler/cayenne-modeler-win-ext/src/main/java/org/apache/cayenne/modeler/win/WinCustomTextFieldUI.java
+++ b/modeler/cayenne-modeler-win-ext/src/main/java/org/apache/cayenne/modeler/win/WinCustomTextFieldUI.java
@@ -19,11 +19,11 @@
 
 package org.apache.cayenne.modeler.win;
 
+import java.lang.reflect.Constructor;
 import javax.swing.JComponent;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.basic.BasicTextFieldUI;
 
-import com.jgoodies.looks.windows.WindowsTextFieldUI;
 import org.apache.cayenne.modeler.util.combo.EditorTextField;
 
 /**
@@ -31,6 +31,19 @@ import org.apache.cayenne.modeler.util.combo.EditorTextField;
  */
 public class WinCustomTextFieldUI extends BasicTextFieldUI {
 
+    private static Constructor<? extends ComponentUI> winFieldUIConstructor;
+
+    static {
+        try {
+            @SuppressWarnings("unchecked")
+            Class<? extends ComponentUI> winFieldUIClass = (Class<? extends ComponentUI>)Class
+                    .forName("com.jgoodies.looks.windows.WindowsTextFieldUI");
+            winFieldUIConstructor = winFieldUIClass.getDeclaredConstructor();
+        } catch (ClassNotFoundException | NoSuchMethodException ex) {
+            winFieldUIConstructor = null;
+        }
+    }
+
     public WinCustomTextFieldUI() {
     }
 
@@ -38,7 +51,14 @@ public class WinCustomTextFieldUI extends BasicTextFieldUI {
         if(c instanceof EditorTextField) {
             c.putClientProperty("TextField.fullSizeBackground", Boolean.TRUE);
         }
-        return new WindowsTextFieldUI();
+        if(winFieldUIConstructor == null) {
+            return new BasicTextFieldUI();
+        }
+        try {
+            return winFieldUIConstructor.newInstance();
+        } catch (Exception ex) {
+            return new BasicTextFieldUI();
+        }
     }
 
 }


Mime
View raw message