jdk/src/java.desktop/windows/classes/sun/awt/windows/WScrollPanePeer.java
author prr
Sat, 19 Sep 2015 15:45:59 -0700
changeset 32865 f9cb6e427f9e
parent 30469 bac0a7ff7e1e
permissions -rw-r--r--
8136783: Run blessed-modifier-order script on java.desktop Reviewed-by: martin, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23654
64b640909fb0 8037377: Windows: compilation failed after the fix for 8033712
bagiras
parents: 23647
diff changeset
     1
/*
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28234
diff changeset
     2
 * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3938
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.awt.windows;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.AdjustmentEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.peer.ScrollPanePeer;
10097
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 5506
diff changeset
    30
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 5506
diff changeset
    31
import sun.awt.AWTAccessor;
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28234
diff changeset
    32
import sun.awt.AWTAccessor.ComponentAccessor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.awt.PeerEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2462
diff changeset
    35
import sun.util.logging.PlatformLogger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
    37
final class WScrollPanePeer extends WPanelPeer implements ScrollPanePeer {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2462
diff changeset
    39
    private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.windows.WScrollPanePeer");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    int scrollbarWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    int scrollbarHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    int prevx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    int prevy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    static native void initIDs();
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
    51
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    native void create(WComponentPeer parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    native int getOffset(int orient);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    WScrollPanePeer(Component target) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        super(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        scrollbarWidth = _getVScrollbarWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        scrollbarHeight = _getHScrollbarHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
    61
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    void initialize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        super.initialize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        setInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        Insets i = getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        setScrollPosition(-i.left,-i.top);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
    69
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public void setUnitIncrement(Adjustable adj, int p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        // The unitIncrement is grabbed from the target as needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
    74
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public Insets insets() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        return getInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    private native void setInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
    80
    @Override
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30469
diff changeset
    81
    public synchronized native void setScrollPosition(int x, int y);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
    83
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public int getHScrollbarHeight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        return scrollbarHeight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private native int _getHScrollbarHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
    89
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public int getVScrollbarWidth() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        return scrollbarWidth;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private native int _getVScrollbarWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public Point getScrollOffset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        int x = getOffset(Adjustable.HORIZONTAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        int y = getOffset(Adjustable.VERTICAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        return new Point(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * The child component has been resized.  The scrollbars must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * updated with the new sizes.  At the native level the sizes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * the actual windows may not have changed yet, so the size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * information from the java-level is passed down and used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     */
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
   107
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public void childResized(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        ScrollPane sp = (ScrollPane)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        Dimension vs = sp.getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        setSpans(vs.width, vs.height, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        setInsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30469
diff changeset
   115
    synchronized native void setSpans(int viewWidth, int viewHeight,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                                      int childWidth, int childHeight);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Called by ScrollPane's internal observer of the scrollpane's adjustables.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * This is called whenever a scroll position is changed in one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * of adjustables, whether it was modified externally or from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * native scrollbars themselves.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
   124
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public void setValue(Adjustable adj, int v) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        Component c = getScrollChild();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        if (c == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        Point p = c.getLocation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        switch(adj.getOrientation()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        case Adjustable.VERTICAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            setScrollPosition(-(p.x), v);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        case Adjustable.HORIZONTAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            setScrollPosition(v, -(p.y));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    private Component getScrollChild() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        ScrollPane sp = (ScrollPane)target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        Component child = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            child = sp.getComponent(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        } catch (ArrayIndexOutOfBoundsException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            // do nothing.  in this case we return null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        return child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Called from Windows in response to WM_VSCROLL/WM_HSCROLL message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    private void postScrollEvent(int orient, int type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                 int pos, boolean isAdjusting)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        Runnable adjustor = new Adjustor(orient, type, pos, isAdjusting);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        WToolkit.executeOnEventHandlerThread(new ScrollEvent(target, adjustor));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * Event that executes on the Java dispatch thread to move the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * scroll bar thumbs and paint the exposed area in one synchronous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     */
23647
41d22f2dbeb5 8033712: Fix more serial lint warnings in sun.awt
darcy
parents: 23328
diff changeset
   168
    @SuppressWarnings("serial") // JDK-implementation class
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    class ScrollEvent extends PeerEvent {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        ScrollEvent(Object source, Runnable runnable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            super(source, runnable, 0L);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
   174
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        public PeerEvent coalesceEvents(PeerEvent newEvent) {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 10097
diff changeset
   176
            if (log.isLoggable(PlatformLogger.Level.FINEST)) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2462
diff changeset
   177
                log.finest("ScrollEvent coalesced: " + newEvent);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            if (newEvent instanceof ScrollEvent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                return newEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Runnable for the ScrollEvent that performs the adjustment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    class Adjustor implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        int orient;             // selects scrollbar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        int type;               // adjustment type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        int pos;                // new position (only used for absolute)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        boolean isAdjusting;    // isAdjusting status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        Adjustor(int orient, int type, int pos, boolean isAdjusting) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            this.orient = orient;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            this.pos = pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            this.isAdjusting = isAdjusting;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
23272
0e0103e73d3c 8032435: Cleanup of sun.awt.windows package
serb
parents: 18178
diff changeset
   202
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            if (getScrollChild() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            ScrollPaneAdjustable adj = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            // ScrollPaneAdjustable made public in 1.4, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            // get[HV]Adjustable can't be declared to return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            // ScrollPaneAdjustable because it would break backward
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            // compatibility -- hence the cast
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            if (orient == Adjustable.VERTICAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                adj = (ScrollPaneAdjustable)sp.getVAdjustable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            } else if (orient == Adjustable.HORIZONTAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                adj = (ScrollPaneAdjustable)sp.getHAdjustable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            } else {
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 10097
diff changeset
   220
                if (log.isLoggable(PlatformLogger.Level.FINE)) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2462
diff changeset
   221
                    log.fine("Assertion failed: unknown orient");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            if (adj == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            int newpos = adj.getValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
              case AdjustmentEvent.UNIT_DECREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                  newpos -= adj.getUnitIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
              case AdjustmentEvent.UNIT_INCREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                  newpos += adj.getUnitIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
              case AdjustmentEvent.BLOCK_DECREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                  newpos -= adj.getBlockIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
              case AdjustmentEvent.BLOCK_INCREMENT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                  newpos += adj.getBlockIncrement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
              case AdjustmentEvent.TRACK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                  newpos = this.pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                  break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
              default:
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 10097
diff changeset
   247
                  if (log.isLoggable(PlatformLogger.Level.FINE)) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2462
diff changeset
   248
                      log.fine("Assertion failed: unknown type");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                  }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                  return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            // keep scroll position in acceptable range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            newpos = Math.max(adj.getMinimum(), newpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            newpos = Math.min(adj.getMaximum(), newpos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            // set value, this will synchronously fire an AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            adj.setValueIsAdjusting(isAdjusting);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            // Fix for 4075484 - consider type information when creating AdjustmentEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
10097
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 5506
diff changeset
   263
            AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 5506
diff changeset
   264
                                                                        newpos,
67449ffe5991 6642728: Use reflection to access ScrollPane's private method from within sun.awt package
serb
parents: 5506
diff changeset
   265
                                                                        type);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            // Paint the exposed area right away.  To do this - find
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            // the heavyweight ancestor of the scroll child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            Component hwAncestor = getScrollChild();
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28234
diff changeset
   270
            final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            while (hwAncestor != null
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28234
diff changeset
   272
                   && !(acc.getPeer(hwAncestor) instanceof WComponentPeer))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                hwAncestor = hwAncestor.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
18178
ee71c923891d 8016747: Replace deprecated PlatformLogger isLoggable(int) with isLoggable(Level)
chegar
parents: 10097
diff changeset
   276
            if (log.isLoggable(PlatformLogger.Level.FINE)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                if (hwAncestor == null) {
3938
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2462
diff changeset
   278
                    log.fine("Assertion (hwAncestor != null) failed, " +
ef327bd847c0 6879044: Eliminate the dependency on logging from the AWT/2D/Swing classes
mchung
parents: 2462
diff changeset
   279
                             "couldn't find heavyweight ancestor of scroll pane child");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            }
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 28234
diff changeset
   282
            WComponentPeer hwPeer = acc.getPeer(hwAncestor);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            hwPeer.paintDamagedAreaImmediately();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
}