Merge
authorddehaven
Tue, 04 Aug 2015 11:31:19 -0700
changeset 32135 36d881124ca1
parent 32134 91e37aced110 (current diff)
parent 32133 5d1adcc1c3e6 (diff)
child 32136 aa92c5a39f90
child 32278 04d6c3238172
Merge
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextFieldUI.java	Mon Aug 03 16:33:06 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextFieldUI.java	Tue Aug 04 11:31:19 2015 -0700
@@ -97,12 +97,7 @@
             String kind = elem.getName();
             if (kind != null) {
                 if (kind.equals(AbstractDocument.ContentElementName)) {
-                    return new GlyphView(elem) {
-                        @Override
-                        public int getResizeWeight(int axis) {
-                            return 0;
-                        }
-                    };
+                    return new GlyphView(elem);
                 } else if (kind.equals(AbstractDocument.ParagraphElementName)) {
                     return new I18nFieldView(elem);
                 }
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Mon Aug 03 16:33:06 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Tue Aug 04 11:31:19 2015 -0700
@@ -940,7 +940,7 @@
                 rootView.setSize(d.width - i.left - i.right -
                         caretMargin, d.height - i.top - i.bottom);
             }
-            else if (d.width == 0 || d.height == 0) {
+            else if (d.width <= 0 || d.height <= 0) {
                 // Probably haven't been layed out yet, force some sort of
                 // initial sizing.
                 rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java	Mon Aug 03 16:33:06 2015 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java	Tue Aug 04 11:31:19 2015 -0700
@@ -538,17 +538,6 @@
     }
 
     /**
-     * {@inheritDoc}
-     */
-    @Override
-    public int getResizeWeight(int axis) {
-        if (axis == View.X_AXIS) {
-            return 1;
-        }
-        return 0;
-    }
-
-    /**
      * Determines the minimum span for this view along an axis.
      *
      * <p>This implementation returns the longest non-breakable area within
@@ -561,11 +550,13 @@
      */
     @Override
     public float getMinimumSpan(int axis) {
+        int w = getResizeWeight(axis);
+        if (w == 0) {
+            // can't resize
+            return getPreferredSpan(axis);
+        }
         switch (axis) {
             case View.X_AXIS:
-                if (getResizeWeight(X_AXIS) == 0) {
-                    return getPreferredSpan(X_AXIS);
-                }
                 if (minimumSpan < 0) {
                     minimumSpan = 0;
                     int p0 = getStartOffset();
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRDrawImage.java	Mon Aug 03 16:33:06 2015 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/java2d/xr/XRDrawImage.java	Tue Aug 04 11:31:19 2015 -0700
@@ -46,24 +46,28 @@
         SurfaceData dstData = sg.surfaceData;
         SurfaceData srcData = dstData.getSourceSurfaceData(img,
                 SunGraphics2D.TRANSFORM_GENERIC, sg.imageComp, bgColor);
-        int compRule = ((AlphaComposite) sg.composite).getRule();
-        float extraAlpha = ((AlphaComposite) sg.composite).getAlpha();
 
-        if (srcData != null && !isBgOperation(srcData, bgColor)
+        if (sg.composite instanceof AlphaComposite) {
+            int compRule = ((AlphaComposite) sg.composite).getRule();
+            float extraAlpha = ((AlphaComposite) sg.composite).getAlpha();
+
+            if (srcData != null && !isBgOperation(srcData, bgColor)
                 && interpType <= AffineTransformOp.TYPE_BILINEAR
                 && (XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(compRule))
-                        || (XRUtils.isTransformQuadrantRotated(tx)) && extraAlpha == 1.0f))
-                         {
-            SurfaceType srcType = srcData.getSurfaceType();
-            SurfaceType dstType = dstData.getSurfaceType();
+                    || (XRUtils.isTransformQuadrantRotated(tx))
+                    && extraAlpha == 1.0f))
+            {
+                SurfaceType srcType = srcData.getSurfaceType();
+                SurfaceType dstType = dstData.getSurfaceType();
 
-            TransformBlit blit = TransformBlit.getFromCache(srcType,
-                    sg.imageComp, dstType);
-            if (blit != null) {
-                blit.Transform(srcData, dstData, sg.composite,
-                        sg.getCompClip(), tx, interpType, sx1, sy1, 0, 0, sx2
+                TransformBlit blit = TransformBlit.getFromCache(srcType,
+                        sg.imageComp, dstType);
+                if (blit != null) {
+                    blit.Transform(srcData, dstData, sg.composite,
+                          sg.getCompClip(), tx, interpType, sx1, sy1, 0, 0, sx2
                                 - sx1, sy2 - sy1);
                     return;
+                }
             }
         }
 
--- a/jdk/test/java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java	Mon Aug 03 16:33:06 2015 -0700
+++ b/jdk/test/java/awt/image/DrawImage/IncorrectClipXorModeSurface2Surface.java	Tue Aug 04 11:31:19 2015 -0700
@@ -40,7 +40,7 @@
 
 /**
  * @test
- * @bug 8061831
+ * @bug 8061831 8130400
  * @summary Tests drawing volatile image to volatile image using different
  *          clips + xor mode. Results of the blit compatibleImage to
  *          compatibleImage is used for comparison.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/4058433/TestBeanInfoPriority.java	Tue Aug 04 11:31:19 2015 -0700
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+import java.awt.event.ActionListener;
+import java.awt.event.MouseListener;
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.beans.BeanProperty;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.JavaBean;
+import java.beans.MethodDescriptor;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+import javax.swing.SwingContainer;
+import java.util.Arrays;
+
+/**
+ * @test
+ * @bug 4058433 8131055
+ * @summary Check if the user-defined bean info
+ *          is not overridden with the annotated one.
+ * @author a.stepanov
+ */
+
+
+public class TestBeanInfoPriority {
+
+    // ========== test bean (annotations must be ignored!) ==========
+
+    @JavaBean(
+            description = "annotation-description",
+            defaultProperty = "other",
+            defaultEventSet = "mouse")
+    @SwingContainer(value = false)
+    public static class TestClass {
+
+        private int    value;
+        private double other;
+
+        @BeanProperty(
+                bound     = false,
+                expert    = false,
+                hidden    = false,
+                preferred = false,
+                required  = false,
+                visualUpdate = false,
+                description = "annotation-value",
+                enumerationValues = {
+                    "javax.swing.SwingConstants.NORTH"}
+                )
+        public void setValue(int v) { value = v; }
+        public  int getValue()      { return value; }
+
+
+        @BeanProperty(
+            bound     = true,
+            expert    = true,
+            hidden    = true,
+            preferred = true,
+            required  = true,
+            visualUpdate = true,
+            description = "annotation-other",
+            enumerationValues = {
+                "javax.swing.SwingConstants.LEFT",
+                "javax.swing.SwingConstants.RIGHT",
+                "javax.swing.SwingConstants.CENTER"}
+            )
+        public   void setOther(double o) { other = o; }
+        public double getOther()         { return other; }
+
+        public void addActionListener(ActionListener l) {}
+        public void removeActionListener(ActionListener l) {}
+
+        public void addMouseListener(MouseListener l) {}
+        public void removeMouseListener(MouseListener l) {}
+    }
+
+    // ========== user-defined bean info ==========
+
+    public static class TestClassBeanInfo extends SimpleBeanInfo {
+
+        private static final int iOther = 0;
+        private static final int iValue = 1;
+
+        private static final int iAction = 0;
+        private static final int iMouse  = 1;
+
+
+        @Override
+        public BeanDescriptor getBeanDescriptor() {
+
+            BeanDescriptor bd = new BeanDescriptor(TestClass.class, null);
+            bd.setShortDescription("user-defined-description");
+            bd.setValue("isContainer", true);
+            bd.setValue("containerDelegate", "user-defined-delegate");
+
+            return bd;
+        }
+
+        @Override
+        public PropertyDescriptor[] getPropertyDescriptors() {
+
+            PropertyDescriptor[] p = new PropertyDescriptor[2];
+
+            try {
+
+                // value
+                PropertyDescriptor pdValue = new PropertyDescriptor(
+                    "value", TestClass.class, "getValue", "setValue");
+                pdValue.setBound(true);
+                pdValue.setConstrained(true);
+                pdValue.setExpert(true);
+                pdValue.setHidden(true);
+                pdValue.setPreferred(true);
+                pdValue.setValue("required", true);
+                pdValue.setValue("visualUpdate", true);
+                pdValue.setShortDescription("user-defined-value");
+                pdValue.setValue("enumerationValues", new Object[]{
+                        "EAST", 3, "javax.swing.SwingConstants.EAST",
+                        "WEST", 7, "javax.swing.SwingConstants.WEST"});
+                p[iValue] = pdValue;
+
+                // other
+                PropertyDescriptor pdOther = new PropertyDescriptor(
+                        "other", TestClass.class, "getOther", "setOther");
+                pdOther.setBound(false);
+                pdOther.setConstrained(false);
+                pdOther.setExpert(false);
+                pdOther.setHidden(false);
+                pdOther.setPreferred(false);
+                pdOther.setValue("required", false);
+                pdOther.setValue("visualUpdate", false);
+                pdOther.setShortDescription("user-defined-other");
+                pdOther.setValue("enumerationValues", new Object[]{
+                        "TOP", 1, "javax.swing.SwingConstants.TOP"});
+                p[iOther] = pdOther;
+
+            } catch(IntrospectionException e) {
+                e.printStackTrace();
+            }
+
+            return p;
+        }
+
+        @Override
+        public EventSetDescriptor[] getEventSetDescriptors() {
+            EventSetDescriptor[] es = new EventSetDescriptor[2];
+            try {
+                es[iAction] = new EventSetDescriptor(
+                        TestClass.class,
+                        "actionListener",
+                        java.awt.event.ActionListener.class,
+                        new String[] {"actionPerformed"},
+                        "addActionListener",
+                        "removeActionListener");
+                es[iMouse] = new EventSetDescriptor(
+                        TestClass.class,
+                        "mouseListener",
+                        java.awt.event.MouseListener.class,
+                        new String[] {"mouseClicked", "mousePressed", "mouseReleased", "mouseEntered", "mouseExited"},
+                        "addMouseListener",
+                        "removeMouseListener");
+            } catch(IntrospectionException e) {
+                e.printStackTrace();
+            }
+            return es;
+        }
+
+        @Override
+        public MethodDescriptor[] getMethodDescriptors() {
+            MethodDescriptor[] m = new MethodDescriptor[0];
+            return m;
+        }
+
+        @Override
+        public int getDefaultPropertyIndex() { return iValue; } // default: value
+
+        @Override
+        public int getDefaultEventIndex() { return iAction; } // default: action
+
+        @Override
+        public java.awt.Image getIcon(int iconKind) { return null; }
+    }
+
+    // ========== auxiliary functions ==========
+
+    static void checkEq(String what, Object v, Object ref) throws Exception {
+
+        if ((v != null) && v.equals(ref)) {
+            System.out.println(what + ": ok (" + ref.toString() + ")");
+        } else {
+            throw new Exception(
+                "invalid " + what + ", expected: \"" + ref + "\", got: \"" + v + "\"");
+        }
+    }
+
+    static void checkEnumEq(String what, Object v, Object ref[]) throws Exception {
+
+        what = "\"" + what + "\"";
+        if (v == null) {
+            throw new Exception("null " + what + " enumeration values");
+        }
+
+        String msg = "invalid " + what + " enumeration values";
+        if (!(v instanceof Object[])) { throw new Exception(msg); }
+
+        if (Arrays.equals((Object []) v, ref)) {
+            System.out.println(what + " enumeration values: ok");
+        } else { throw new Exception(msg); }
+    }
+
+
+    // ========== test ==========
+
+
+    public static void main(String[] args) throws Exception {
+
+        BeanInfo i = Introspector.getBeanInfo(TestClass.class, Object.class);
+        BeanDescriptor bd = i.getBeanDescriptor();
+
+        checkEq("description", bd.getShortDescription(), "user-defined-description");
+        checkEq("default property index", i.getDefaultPropertyIndex(), 1);
+        checkEq("default event index", i.getDefaultEventIndex(), 0);
+
+        checkEq("isContainer", i.getBeanDescriptor().getValue("isContainer"), true);
+        checkEq("containerDelegate",
+            i.getBeanDescriptor().getValue("containerDelegate"), "user-defined-delegate");
+        System.out.println("");
+
+        PropertyDescriptor[] pds = i.getPropertyDescriptors();
+        for (PropertyDescriptor pd: pds) {
+            String name = pd.getName();
+            switch (name) {
+                case "value":
+                    checkEq("\"value\" isBound",       pd.isBound(),       true);
+                    checkEq("\"value\" isConstrained", pd.isConstrained(), true);
+                    checkEq("\"value\" isExpert",      pd.isExpert(),      true);
+                    checkEq("\"value\" isHidden",      pd.isHidden(),      true);
+                    checkEq("\"value\" isPreferred",   pd.isPreferred(),   true);
+                    checkEq("\"value\" required",      pd.getValue("required"),     true);
+                    checkEq("\"value\" visualUpdate",  pd.getValue("visualUpdate"), true);
+
+                    checkEq("\"value\" description",   pd.getShortDescription(), "user-defined-value");
+
+                    checkEnumEq(pd.getName(), pd.getValue("enumerationValues"),
+                        new Object[]{
+                        "EAST", 3, "javax.swing.SwingConstants.EAST",
+                        "WEST", 7, "javax.swing.SwingConstants.WEST"});
+                    System.out.println("");
+                    break;
+                case "other":
+                    checkEq("\"other\" isBound",       pd.isBound(),       false);
+                    checkEq("\"other\" isConstrained", pd.isConstrained(), false);
+                    checkEq("\"other\" isExpert",      pd.isExpert(),      false);
+                    checkEq("\"other\" isHidden",      pd.isHidden(),      false);
+                    checkEq("\"other\" isPreferred",   pd.isPreferred(),   false);
+                    checkEq("\"other\" required",      pd.getValue("required"),     false);
+                    checkEq("\"other\" visualUpdate",  pd.getValue("visualUpdate"), false);
+
+                    checkEq("\"other\" description",   pd.getShortDescription(), "user-defined-other");
+
+                    checkEnumEq(pd.getName(), pd.getValue("enumerationValues"),
+                        new Object[]{"TOP", 1, "javax.swing.SwingConstants.TOP"});
+                    System.out.println("");
+                    break;
+                default:
+                    throw new Exception("invalid property descriptor: " + name);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTextPane/JTextPaneDocumentAlignment.java	Tue Aug 04 11:31:19 2015 -0700
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 8132136
+   @summary [PIT] RTL orientation in JEditorPane is broken
+   @author Semyon Sadetsky
+  */
+
+import javax.swing.*;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import java.awt.*;
+
+public class JTextPaneDocumentAlignment {
+
+    private static JFrame frame;
+    private static JTextPane jTextPane;
+    private static int position;
+
+    public static void main(String[] args) throws Exception{
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                frame = new JFrame();
+                frame.setUndecorated(true);
+                frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+                frame.setSize(200, 200);
+                jTextPane = new JTextPane();
+                jTextPane.setContentType("text/html");
+                jTextPane.setText(
+                        "<html><body><b id='test'>Test</b></body></html>");
+                SimpleAttributeSet right = new SimpleAttributeSet();
+                StyleConstants.setAlignment(right, StyleConstants.ALIGN_RIGHT);
+                jTextPane.getStyledDocument()
+                        .setParagraphAttributes(0, 10, right, true);
+                frame.getContentPane().add(jTextPane);
+                frame.setVisible(true);
+            }
+        });
+        Robot robot = new Robot();
+        robot.waitForIdle();
+        robot.delay(200);
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    position = jTextPane.modelToView(1).x;
+                    SimpleAttributeSet center = new SimpleAttributeSet();
+                    StyleConstants.setAlignment(center,
+                            StyleConstants.ALIGN_CENTER);
+                    jTextPane.getStyledDocument()
+                            .setParagraphAttributes(0, 10, center, true);
+                } catch (BadLocationException e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        if(position < 100) {
+            throw  new RuntimeException("Text is not right aligned " + position);
+        }
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    position = jTextPane.modelToView(1).x;
+                } catch (BadLocationException e) {
+                    e.printStackTrace();
+                }
+                frame.dispose();
+            }
+        });
+        if(position < 20) {
+            throw  new RuntimeException("Text is not center aligned " + position);
+        }
+        System.out.println("ok");
+    }
+}