Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 137975 Details for
Bug 278195
[Shell] Setting bounds must reset maximized state
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Test case + Bugfix
clipboard.txt (text/plain), 10.93 KB, created by
RĂ¼diger Herrmann
on 2009-06-02 05:52:35 EDT
(
hide
)
Description:
Test case + Bugfix
Filename:
MIME Type:
Creator:
RĂ¼diger Herrmann
Created:
2009-06-02 05:52:35 EDT
Size:
10.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt.q07 >Index: src/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java,v >retrieving revision 1.13 >diff -u -r1.13 DisplayLCA.java >--- src/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java 26 Feb 2009 18:02:48 -0000 1.13 >+++ src/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java 2 Jun 2009 09:53:34 -0000 >@@ -311,7 +311,6 @@ > } > > public void readData( final Display display ) { >- Rectangle oldBounds = display.getBounds(); > readBounds( display ); > readFocusControl( display ); > WidgetTreeVisitor visitor = new AllWidgetTreeVisitor() { >@@ -326,14 +325,11 @@ > Composite shell = shells[ i ]; > WidgetTreeVisitor.accept( shell, visitor ); > } >- >- // TODO: [fappel] since there is no possibility yet to determine whether >- // a shell is maximized, we use this hack to adjust >- // the bounds of a maximized shell in case of a document >- // resize event > for( int i = 0; i < shells.length; i++ ) { >- if( shells[ i ].getBounds().equals( oldBounds ) ) { >- shells[ i ].setBounds( display.getBounds() ); >+ if( shells[ i ].getMaximized() ) { >+ Object adapter = shells[ i ].getAdapter( IShellAdapter.class ); >+ IShellAdapter shellAdapter = ( IShellAdapter )adapter; >+ shellAdapter.setBounds( display.getBounds() ); > } > } > } >Index: src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt.q07/src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java,v >retrieving revision 1.11 >diff -u -r1.11 ShellLCA.java >--- src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java 27 Apr 2009 17:10:36 -0000 1.11 >+++ src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java 2 Jun 2009 09:53:34 -0000 >@@ -63,7 +63,7 @@ > Shell shell = ( Shell )widget; > // [if] Preserve the menu bounds before setting the new shell bounds. > preserveMenuBounds( shell ); >- ControlLCAUtil.readBounds( shell ); >+ readBounds( shell ); > readMode( shell ); > if( WidgetLCAUtil.wasEventSent( shell, JSConst.EVENT_SHELL_CLOSED ) ) { > shell.close(); >@@ -290,6 +290,13 @@ > ////////////////// > // Helping methods > >+ private static void readBounds( final Shell shell ) { >+ Rectangle bounds = WidgetLCAUtil.readBounds( shell, shell.getBounds() ); >+ Object adapter = shell.getAdapter( IShellAdapter.class ); >+ IShellAdapter shellAdapter = ( IShellAdapter )adapter; >+ shellAdapter.setBounds( bounds ); >+ } >+ > private static void readMode( final Shell shell ) { > final String value = WidgetLCAUtil.readPropertyValue( shell, "mode" ); > if( value != null ) { >#P org.eclipse.rap.rwt >Index: src/org/eclipse/swt/internal/widgets/IShellAdapter.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/widgets/IShellAdapter.java,v >retrieving revision 1.2 >diff -u -r1.2 IShellAdapter.java >--- src/org/eclipse/swt/internal/widgets/IShellAdapter.java 12 Jun 2008 13:12:13 -0000 1.2 >+++ src/org/eclipse/swt/internal/widgets/IShellAdapter.java 2 Jun 2009 09:53:36 -0000 >@@ -18,8 +18,9 @@ > public interface IShellAdapter { > > Control getActiveControl(); >- > void setActiveControl( Control control ); > > Rectangle getMenuBounds(); >+ >+ void setBounds( Rectangle bounds ); > } >Index: src/org/eclipse/swt/widgets/Shell.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Shell.java,v >retrieving revision 1.42 >diff -u -r1.42 Shell.java >--- src/org/eclipse/swt/widgets/Shell.java 28 Apr 2009 09:07:14 -0000 1.42 >+++ src/org/eclipse/swt/widgets/Shell.java 2 Jun 2009 09:53:36 -0000 >@@ -127,13 +127,13 @@ > > private Control lastActive; > private IShellAdapter shellAdapter; >- private String text = ""; >+ private String text; > private Image image; >- private int alpha = 0xFF; >+ private int alpha; > private Button defaultButton; > private Button saveDefault; > private Control savedFocus; // TODO [rh] move to Decorations when exist >- private int mode = MODE_NONE; >+ private int mode; > > private Shell( final Display display, > final Shell parent, >@@ -146,6 +146,9 @@ > } else { > this.display = Display.getCurrent(); > } >+ text = ""; >+ alpha = 0xFF; >+ mode = MODE_NONE; > this.style = checkStyle( style ); > state |= HIDDEN; > this.display.addShell( this ); >@@ -526,6 +529,11 @@ > Composite findDeferredControl() { > return layoutCount > 0 ? this : null; > } >+ >+ void updateMode() { >+ mode &= ~MODE_MAXIMIZED; >+ mode &= ~MODE_MINIMIZED; >+ } > > ///////////////////// > // Adaptable override >@@ -544,6 +552,9 @@ > public Rectangle getMenuBounds() { > return Shell.this.getMenuBounds(); > } >+ public void setBounds( final Rectangle bounds ) { >+ Shell.this.setBounds( bounds, false ); >+ } > }; > } > result = shellAdapter; >@@ -1157,7 +1168,7 @@ > * @see #setMaximized > */ > public boolean getMaximized() { >- return this.mode == MODE_MAXIMIZED; >+ return mode == MODE_MAXIMIZED; > } > > /////////////////// >Index: src/org/eclipse/swt/widgets/Control.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Control.java,v >retrieving revision 1.52 >diff -u -r1.52 Control.java >--- src/org/eclipse/swt/widgets/Control.java 29 May 2009 14:25:42 -0000 1.52 >+++ src/org/eclipse/swt/widgets/Control.java 2 Jun 2009 09:53:36 -0000 >@@ -798,14 +798,7 @@ > if( bounds == null ) { > SWT.error( SWT.ERROR_NULL_ARGUMENT ); > } >- Point oldLocation = getLocation(); >- Point oldSize = getSize(); >- this.bounds >- = new Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); >- this.bounds.width = Math.max( 0, this.bounds.width ); >- this.bounds.height = Math.max( 0, this.bounds.height ); >- notifyMove( oldLocation ); >- notifyResize( oldSize ); >+ setBounds( bounds, true ); > } > > /** >@@ -1784,8 +1777,26 @@ > return result; > } > >- ////////////////////////////////////////////////////// >- // Helping methods that throw move- and resize-events >+ //////////////////////////////// >+ // Helping methods for setBounds >+ >+ void setBounds( final Rectangle bounds, boolean updateMode ) { >+ Point oldLocation = getLocation(); >+ Point oldSize = getSize(); >+ this.bounds >+ = new Rectangle( bounds.x, bounds.y, bounds.width, bounds.height ); >+ this.bounds.width = Math.max( 0, this.bounds.width ); >+ this.bounds.height = Math.max( 0, this.bounds.height ); >+ if( updateMode ) { >+ updateMode(); >+ } >+ notifyMove( oldLocation ); >+ notifyResize( oldSize ); >+ } >+ >+ void updateMode() { >+ // subclasses may override >+ } > > void notifyResize( final Point oldSize ) { > if( !oldSize.equals( getSize() ) ) { >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/swt/widgets/Shell_Test.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/swt/widgets/Shell_Test.java,v >retrieving revision 1.13 >diff -u -r1.13 Shell_Test.java >--- src/org/eclipse/swt/widgets/Shell_Test.java 28 May 2009 12:01:46 -0000 1.13 >+++ src/org/eclipse/swt/widgets/Shell_Test.java 2 Jun 2009 09:53:41 -0000 >@@ -11,11 +11,15 @@ > > package org.eclipse.swt.widgets; > >+import java.util.ArrayList; >+ > import junit.framework.TestCase; > > import org.eclipse.rwt.lifecycle.PhaseId; > import org.eclipse.swt.RWTFixture; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.ControlAdapter; >+import org.eclipse.swt.events.ControlEvent; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.internal.widgets.IShellAdapter; >@@ -316,6 +320,80 @@ > assertEquals( shell.getBounds(), display.getBounds() ); > } > >+ public void testSetBoundsResetMaximized() { >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ shell.setBounds( 1, 2, 3, 4 ); >+ shell.setMaximized( true ); >+ Rectangle bounds = new Rectangle( 10, 10, 10, 10 ); >+ shell.setBounds( bounds ); >+ assertFalse( shell.getMaximized() ); >+ assertEquals( bounds, shell.getBounds() ); >+ } >+ >+ public void testSetLocationResetMaximized() { >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ shell.setBounds( 1, 2, 3, 4 ); >+ shell.setMaximized( true ); >+ shell.setLocation( 10, 10 ); >+ assertFalse( shell.getMaximized() ); >+ } >+ >+ public void testSetSizeResetMaximized() { >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ shell.setBounds( 1, 2, 3, 4 ); >+ shell.setMaximized( true ); >+ shell.setSize( 6, 6 ); >+ assertFalse( shell.getMaximized() ); >+ } >+ >+ public void testSetBoundsResetMaximizedEventOrder() { >+ final boolean[] maximized = { true }; >+ Display display = new Display(); >+ final Shell shell = new Shell( display ); >+ shell.setBounds( 1, 2, 3, 4 ); >+ shell.addControlListener( new ControlAdapter() { >+ public void controlResized( final ControlEvent event ) { >+ maximized[ 0 ] = shell.getMaximized(); >+ } >+ } ); >+ shell.setMaximized( true ); >+ shell.setSize( 6, 6 ); >+ assertFalse( maximized[ 0 ] ); >+ } >+ >+ public void testShellAdapterSetBounds() { >+ final java.util.List log = new ArrayList(); >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ shell.setBounds( 1, 2, 3, 4 ); >+ shell.setMaximized( true ); >+ shell.addControlListener( new ControlAdapter() { >+ public void controlResized( final ControlEvent event ) { >+ log.add( event ); >+ } >+ } ); >+ Object adapter = shell.getAdapter( IShellAdapter.class ); >+ IShellAdapter shellAdapter = ( IShellAdapter )adapter; >+ shellAdapter.setBounds( new Rectangle( 5,6, 7, 8 ) ); >+ assertEquals( new Rectangle( 5,6, 7, 8 ), shell.getBounds() ); >+ assertTrue( shell.getMaximized() ); >+ assertEquals( 1, log.size() ); >+ } >+ >+ public void testSetBoundsResetMinimized() { >+ Display display = new Display(); >+ Shell shell = new Shell( display ); >+ shell.setBounds( 1, 2, 3, 4 ); >+ shell.setMinimized( true ); >+ Rectangle bounds = new Rectangle( 10, 10, 10, 10 ); >+ shell.setBounds( bounds ); >+ assertFalse( shell.getMinimized() ); >+ assertEquals( bounds, shell.getBounds() ); >+ } >+ > protected void setUp() throws Exception { > RWTFixture.setUp(); > RWTFixture.fakePhase( PhaseId.PROCESS_ACTION );
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 278195
:
137466
|
137975
|
140422