Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 330379
Collapse All | Expand All

(-)a/runtime.rwt/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/WidgetManager.js (-5 / +8 lines)
Lines 36-46 qx.Class.define( "org.eclipse.swt.WidgetManager", { Link Here
36
36
37
    _onAppearFocus : function( evt ) {
37
    _onAppearFocus : function( evt ) {
38
      var widget = this;
38
      var widget = this;
39
      widget.focus();
39
      var target = evt.getTarget();
40
      evt.getTarget().removeEventListener( 
40
      setTimeout(function(){
41
        "appear", 
41
        widget.focus();
42
        org.eclipse.swt.WidgetManager._onAppearFocus, 
42
        target.removeEventListener(
43
        widget );
43
            "appear",
44
            org.eclipse.swt.WidgetManager._onAppearFocus,
45
            widget );
46
      }, 100);
44
    }
47
    }
45
  },
48
  },
46
49
(-)a/runtime.rwt/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/Shell.js (-1 / +1 lines)
Lines 17-23 qx.Class.define( "org.eclipse.swt.widgets.Shell", { Link Here
17
    this.base( arguments );
17
    this.base( arguments );
18
    this.setOverflow( qx.constant.Style.OVERFLOW_HIDDEN );
18
    this.setOverflow( qx.constant.Style.OVERFLOW_HIDDEN );
19
    // Note: This prevents a laoyut-glitch on the ipad:
19
    // Note: This prevents a laoyut-glitch on the ipad:
20
    this.setRestrictToPageOnOpen( false );
20
    //this.setRestrictToPageOnOpen( false );
21
    // TODO [rh] HACK to set mode on Label that shows the caption, _captionTitle
21
    // TODO [rh] HACK to set mode on Label that shows the caption, _captionTitle
22
    //      is a 'protected' field on class Window
22
    //      is a 'protected' field on class Window
23
    this._captionTitle.setMode( "html" );
23
    this._captionTitle.setMode( "html" );
24
   bug 330379 popup shell is not restricted to the page and scrolls the whole page
24
   bug 330379 popup shell is not restricted to the page and scrolls the whole page
25
   
25
   
26
   simple change to reproduce the problem:
26
   simple change to reproduce the problem:
27
   
27
   
28
   The Problem
28
   The Problem
29
   ===========
29
   ===========
30
   Open a new Shell and position it so, that it would not completely fit on
30
   Open a new Shell and position it so, that it would not completely fit on
31
   the page, e.g. by calling setLocation or making the browser window small.
31
   the page, e.g. by calling setLocation or making the browser window small.
32
   
32
   
33
   What should happen?
33
   What should happen?
34
   -------------------
34
   -------------------
35
   The shell should be moved in such a way, that it is fully (or partially)
35
   The shell should be moved in such a way, that it is fully (or partially)
36
   visible in the browser window.
36
   visible in the browser window.
37
   
37
   
38
   What happens?
38
   What happens?
39
   -------------
39
   -------------
40
   - the Shell is not restricted to the page
40
   - the Shell is not restricted to the page
41
   - the whole html body is scrolled so that the newly opened shell is
41
   - the whole html body is scrolled so that the newly opened shell is
42
     fully displayed.
42
     fully displayed.
43
     this is a serious problem, because the overflow for the body is hidden,
43
     this is a serious problem, because the overflow for the body is hidden,
44
     and there are no top level scrollbars. i.e., the user can not scroll
44
     and there are no top level scrollbars. i.e., the user can not scroll
45
     back to the top
45
     back to the top
46
   
46
   
47
   How to reproduce?
47
   How to reproduce?
48
   -----------------
48
   -----------------
49
   see the attached patch for the rap demo project.
49
   see the attached patch for the rap demo project.
(-)a/runtime.ui/org.eclipse.rap.demo/src/org/eclipse/rap/demo/controls/ShellTab.java (-1 / +1 lines)
Lines 349-355 public class ShellTab extends ExampleTab { Link Here
349
    Point result = getShell().getLocation();
349
    Point result = getShell().getLocation();
350
    int count = getShells().length % 12;
350
    int count = getShells().length % 12;
351
    result.x += 50 + count * 10;
351
    result.x += 50 + count * 10;
352
    result.y += 50 + count * 10;
352
    result.y += 650 + count * 10;
353
    return result ;
353
    return result ;
354
  }
354
  }
355
355
356
   fix git mirror of the rap cvs repository - add missing Scrollable.js file
356
   fix git mirror of the rap cvs repository - add missing Scrollable.js file
357
   
357
   
358
   unfortunately:
358
   unfortunately:
359
   https://bugs.eclipse.org/bugs/show_bug.cgi?id=330271
359
   https://bugs.eclipse.org/bugs/show_bug.cgi?id=330271
(-)a/runtime.rwt/org.eclipse.rap.rwt.q07/js/org/eclipse/swt/widgets/Scrollable.js (+245 lines)
Added Link Here
1
/*******************************************************************************
2
 *  Copyright: 2004-2010 1&1 Internet AG, Germany, http://www.1und1.de,
3
 *                       and EclipseSource
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the Eclipse Public License v1.0 which accompanies this
7
 * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 *  Contributors:
10
 *    1&1 Internet AG and others - original API and implementation
11
 *    EclipseSource - adaptation for the Eclipse Rich Ajax Platform
12
 ******************************************************************************/
13
14
qx.Class.define( "org.eclipse.swt.widgets.Scrollable", {
15
  extend : qx.ui.layout.CanvasLayout,
16
17
  construct : function( clientArea ) {
18
    this.base( arguments );
19
    this._clientArea = clientArea;
20
    this._horzScrollBar = new qx.ui.basic.ScrollBar( true );
21
    this._vertScrollBar = new qx.ui.basic.ScrollBar( false );
22
    this._blockScrolling = false;
23
    this._internalChangeFlag = false;
24
    this.add( this._clientArea );
25
    this.add( this._horzScrollBar );
26
    this.add( this._vertScrollBar );
27
    this._configureScrollBars();
28
    this._configureClientArea();
29
    this.__onscroll = qx.lang.Function.bindEvent( this._onscroll, this );
30
  },
31
  
32
  destruct : function() {
33
    var el = this._clientArea._getTargetNode();
34
    if( el ) {
35
      var eventUtil = qx.html.EventRegistration;
36
      eventUtil.removeEventListener( el, "scroll", this.__onscroll );
37
      delete this.__onscroll;
38
    }
39
    this._clientArea = null;
40
    this._horzScrollBar = null;
41
    this._vertScrollBar = null;
42
  },
43
  
44
  events : {
45
    "userScroll" : "qx.event.type.Event"
46
  },
47
48
  members : {
49
    
50
    /////////
51
    // Public
52
    
53
    setScrollBarsVisible : function( horizontal, vertical ) {
54
      this._horzScrollBar.setDisplay( horizontal );  
55
      this._vertScrollBar.setDisplay( vertical );
56
      var overflow = "hidden";
57
      if( horizontal && vertical ) {
58
        overflow = "scroll";
59
      } else if( horizontal ) {
60
        overflow = "scrollX";
61
      } else if( vertical ) {
62
        overflow = "scrollY";
63
      }
64
      this._clientArea.setOverflow( overflow );
65
      this._layoutX();
66
      this._layoutY();
67
    },
68
 
69
    setHBarSelection : function( value ) {
70
      this._internalChangeFlag = true;
71
      if( this._horzScrollBar.getMaximum() < value ) {
72
        // TODO [tb] : The ScrollBar should do that itself
73
        this._horzScrollBar.setMaximum( value );
74
      }
75
      this._horzScrollBar.setValue( value );
76
      this._internalChangeFlag = false;
77
    },
78
79
    setVBarSelection : function( value ) {
80
      this._internalChangeFlag = true;
81
      if( this._vertScrollBar.getMaximum() < value ) {
82
        // TODO [tb] : The ScrollBar should do that itself
83
        this._vertScrollBar.setMaximum( value );
84
      }
85
      this._vertScrollBar.setValue( value );
86
      this._internalChangeFlag = false;
87
    },
88
    
89
    setBlockScrolling : function( value ) {
90
      this._blockScrolling = value;
91
    },
92
 
93
    /////////
94
    // Layout
95
96
    _configureClientArea : function() {
97
      this._clientArea.setOverflow( "scroll" );
98
      this._clientArea.setLeft( 0 );
99
      this._clientArea.setTop( 0 );
100
      this._clientArea.addEventListener( "create", this._onClientCreate, this );
101
      this._clientArea.addEventListener( "appear", this._onClientAppear, this );
102
      // TOOD [tb] : Do this with an eventlistner after fixing Bug 327023 
103
      this._clientArea._layoutPost 
104
        = qx.lang.Function.bindEvent( this._onClientLayout, this );
105
    },
106
    
107
    _configureScrollBars : function() {
108
      var dragBlocker = function( event ) { event.stopPropagation(); };
109
      var preferredWidth = this._vertScrollBar.getPreferredBoxWidth();
110
      var preferredHeight = this._horzScrollBar.getPreferredBoxHeight();
111
      this._horzScrollBar.setLeft( 0 );
112
      this._horzScrollBar.setHeight( preferredHeight );
113
      this._horzScrollBar.addEventListener( "dragstart", dragBlocker );
114
      this._vertScrollBar.setTop( 0 );
115
      this._vertScrollBar.setWidth( preferredWidth );
116
      this._vertScrollBar.addEventListener( "dragstart", dragBlocker );
117
      this._horzScrollBar.addEventListener( "changeValue", 
118
                                            this._onHorzScrollBarChangeValue, 
119
                                            this );
120
      this._vertScrollBar.addEventListener( "changeValue", 
121
                                            this._onVertScrollBarChangeValue, 
122
                                            this );      
123
    },
124
125
    _applyWidth : function( newValue, oldValue ) {
126
      this.base( arguments, newValue, oldValue );
127
      this._layoutX();
128
    },
129
    
130
    _applyHeight : function( newValue, oldValue ) {
131
      this.base( arguments, newValue, oldValue );
132
      this._layoutY();
133
    },
134
    
135
    _applyBorder : function( newValue, oldValue ) {
136
      this.base( arguments, newValue, oldValue );
137
      this._layoutX();
138
      this._layoutY();
139
    },    
140
141
    _layoutX : function() {
142
      var clientWidth = this.getWidth() - this.getFrameWidth();
143
      if( this._vertScrollBar.getDisplay() ) {
144
        clientWidth -= this._vertScrollBar.getWidth();
145
      } 
146
      this._clientArea.setWidth( clientWidth );
147
      this._vertScrollBar.setLeft( clientWidth );
148
      this._horzScrollBar.setWidth( clientWidth );
149
    },
150
151
    _layoutY : function() {        
152
      var clientHeight = this.getHeight() - this.getFrameHeight();
153
      if( this._horzScrollBar.getDisplay() ) {
154
        clientHeight -= this._horzScrollBar.getHeight();
155
      } 
156
      this._clientArea.setHeight( clientHeight );
157
      this._vertScrollBar.setHeight( clientHeight );
158
      this._horzScrollBar.setTop( clientHeight );
159
    },
160
161
    _onClientCreate : function( evt ) {
162
      this._clientArea.prepareEnhancedBorder();
163
      var el = this._clientArea._getTargetNode();
164
      var eventUtil = qx.html.EventRegistration;
165
      eventUtil.addEventListener( el, "scroll", this.__onscroll );
166
    },
167
168
    _onClientLayout : function() {
169
      // TODO [tb] : _getScrollBarWidth should be a static function, it has 
170
      // nothing to do with the instance, which here is only used to call it
171
      var barWidth = this._horzScrollBar._getScrollBarWidth();
172
      var node = this._clientArea._getTargetNode();
173
      var el = this._clientArea.getElement();
174
      var overflow = this._clientArea.getOverflow();
175
      var width = parseInt( el.style.width );
176
      var height = parseInt( el.style.height );
177
      if( overflow === "scroll" || overflow === "scrollY" ) {
178
        width += barWidth;
179
      }
180
      if( overflow === "scroll" || overflow === "scrollX" ) {
181
        height += barWidth;
182
      }
183
      node.style.width = width
184
      node.style.height = height;
185
    },
186
    
187
    ////////////
188
    // Scrolling
189
   
190
    _onHorzScrollBarChangeValue : function() {
191
      if( this._isCreated ) {
192
        this._syncClientArea( true, false );
193
      }
194
      if( !this._internalChangeFlag ) {
195
        this.createDispatchEvent( "userScroll" );
196
      }
197
    }, 
198
199
    _onVertScrollBarChangeValue : function() {
200
      if( this._isCreated ) {
201
        this._syncClientArea( false, true );
202
      }
203
      if( !this._internalChangeFlag ) {
204
        this.createDispatchEvent( "userScroll" );
205
      }
206
    },
207
208
    _onClientAppear : function() {
209
      this._internalChangeFlag = true;
210
      this._syncClientArea( true, true );
211
      this._internalChangeFlag = false;
212
    },
213
     
214
    _onscroll : function( evt ) {
215
      if( !this._internalChangeFlag ) {
216
        org.eclipse.rwt.EventHandlerUtil.stopDomEvent( evt );
217
        var blockH = this._blockScrolling || !this._horzScrollBar.getDisplay();
218
        var blockV = this._blockScrolling || !this._vertScrollBar.getDisplay();
219
        this._internalChangeFlag = true;
220
        this._syncClientArea( blockH, blockV );        
221
        this._internalChangeFlag = false;
222
        this._syncScrollBars();
223
      }
224
    },
225
226
    _syncClientArea : function( horz, vert ) {
227
      if( horz ) {
228
        var scrollX = this._horzScrollBar.getValue();
229
        this._clientArea.setScrollLeft( scrollX );
230
      }
231
      if( vert ) {
232
        var scrollY = this._vertScrollBar.getValue();
233
        this._clientArea.setScrollTop( scrollY );
234
      }
235
    },
236
237
    _syncScrollBars : function() {
238
      var scrollX = this._clientArea.getScrollLeft();
239
      this._horzScrollBar.setValue( scrollX );
240
      var scrollY = this._clientArea.getScrollTop();
241
      this._vertScrollBar.setValue( scrollY );
242
    }
243
244
  }
245
} );

Return to bug 330379