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 140422 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]
Updated patch
clipboard.txt (text/plain), 13.15 KB, created by
RĂ¼diger Herrmann
on 2009-06-29 15:14:31 EDT
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
RĂ¼diger Herrmann
Created:
2009-06-29 15:14:31 EDT
Size:
13.15 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt >Index: src/org/eclipse/swt/internal/graphics/TextSizeDeterminationHandler.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/internal/graphics/TextSizeDeterminationHandler.java,v >retrieving revision 1.10 >diff -u -r1.10 TextSizeDeterminationHandler.java >--- src/org/eclipse/swt/internal/graphics/TextSizeDeterminationHandler.java 4 Jun 2009 11:48:51 -0000 1.10 >+++ src/org/eclipse/swt/internal/graphics/TextSizeDeterminationHandler.java 29 Jun 2009 19:16:05 -0000 >@@ -22,8 +22,10 @@ > import org.eclipse.rwt.service.ISessionStore; > import org.eclipse.swt.custom.ScrolledComposite; > import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.internal.graphics.TextSizeDetermination.ICalculationItem; > import org.eclipse.swt.internal.graphics.TextSizeProbeStore.IProbe; >+import org.eclipse.swt.internal.widgets.IShellAdapter; > import org.eclipse.swt.internal.widgets.WidgetTreeVisitor; > import org.eclipse.swt.internal.widgets.WidgetTreeVisitor.AllWidgetTreeVisitor; > import org.eclipse.swt.widgets.*; >@@ -73,7 +75,8 @@ > Shell[] shells = display.getShells(); > for( int i = 0; i < shells.length; i++ ) { > // TODO [fappel]: Think about a lighter recalculation trigger. >- Point buffer = shells[ i ].getSize(); >+ Shell shell = shells[ i ]; >+ Rectangle bufferedBounds = shell.getBounds(); > AllWidgetTreeVisitor clearLayout = new AllWidgetTreeVisitor() { > public boolean doVisit( final Widget widget ) { > if( widget instanceof Composite ) { >@@ -124,12 +127,18 @@ > return true; > } > }; >- WidgetTreeVisitor.accept( shells[ i ], saveSCOrigins ); >- WidgetTreeVisitor.accept( shells[ i ], clearLayout ); >- shells[ i ].setSize( buffer.x + 1000, buffer.y + 1000 ); >- WidgetTreeVisitor.accept( shells[ i ], clearLayout ); >- shells[ i ].setSize( buffer ); >- WidgetTreeVisitor.accept( shells[ i ], restoreSCOrigins ); >+ WidgetTreeVisitor.accept( shell, saveSCOrigins ); >+ WidgetTreeVisitor.accept( shell, clearLayout ); >+ IShellAdapter shellAdapter >+ = ( IShellAdapter )shell.getAdapter( IShellAdapter.class ); >+ Rectangle bounds1000 = new Rectangle( bufferedBounds.x, >+ bufferedBounds.y, >+ bufferedBounds.width + 1000, >+ bufferedBounds.height + 1000 ); >+ shellAdapter.setBounds( bounds1000 ); >+ WidgetTreeVisitor.accept( shell, clearLayout ); >+ shellAdapter.setBounds( bufferedBounds ); >+ WidgetTreeVisitor.accept( shell, restoreSCOrigins ); > } > } > if( event.getPhaseId() == PhaseId.RENDER ) { >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 29 Jun 2009 19:16:05 -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.43 >diff -u -r1.43 Shell.java >--- src/org/eclipse/swt/widgets/Shell.java 4 Jun 2009 11:48:51 -0000 1.43 >+++ src/org/eclipse/swt/widgets/Shell.java 29 Jun 2009 19:16:07 -0000 >@@ -128,13 +128,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, >@@ -147,6 +147,9 @@ > } else { > this.display = Display.getCurrent(); > } >+ text = ""; >+ alpha = 0xFF; >+ mode = MODE_NONE; > this.style = checkStyle( style ); > state |= HIDDEN; > this.display.addShell( this ); >@@ -527,6 +530,11 @@ > Composite findDeferredControl() { > return layoutCount > 0 ? this : null; > } >+ >+ void updateMode() { >+ mode &= ~MODE_MAXIMIZED; >+ mode &= ~MODE_MINIMIZED; >+ } > > ///////////////////// > // Adaptable override >@@ -545,6 +553,9 @@ > public Rectangle getMenuBounds() { > return Shell.this.getMenuBounds(); > } >+ public void setBounds( final Rectangle bounds ) { >+ Shell.this.setBounds( bounds, false ); >+ } > }; > } > result = shellAdapter; >@@ -1158,7 +1169,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.53 >diff -u -r1.53 Control.java >--- src/org/eclipse/swt/widgets/Control.java 4 Jun 2009 11:48:51 -0000 1.53 >+++ src/org/eclipse/swt/widgets/Control.java 29 Jun 2009 19:16:06 -0000 >@@ -799,14 +799,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 ); > } > > /** >@@ -1785,8 +1778,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.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.15 >diff -u -r1.15 DisplayLCA.java >--- src/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java 5 Jun 2009 08:14:28 -0000 1.15 >+++ src/org/eclipse/swt/internal/widgets/displaykit/DisplayLCA.java 29 Jun 2009 19:16:11 -0000 >@@ -329,7 +329,9 @@ > > for( int i = 0; i < shells.length; i++ ) { > if( shells[ i ].getMaximized() ) { >- shells[ i ].setBounds( display.getBounds() ); >+ 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.12 >diff -u -r1.12 ShellLCA.java >--- src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java 4 Jun 2009 11:48:55 -0000 1.12 >+++ src/org/eclipse/swt/internal/widgets/shellkit/ShellLCA.java 29 Jun 2009 19:16:11 -0000 >@@ -64,7 +64,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(); >@@ -291,6 +291,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.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.15 >diff -u -r1.15 Shell_Test.java >--- src/org/eclipse/swt/widgets/Shell_Test.java 4 Jun 2009 14:53:23 -0000 1.15 >+++ src/org/eclipse/swt/widgets/Shell_Test.java 29 Jun 2009 19:16:13 -0000 >@@ -18,8 +18,7 @@ > import org.eclipse.rwt.lifecycle.PhaseId; > import org.eclipse.swt.RWTFixture; > import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.ShellAdapter; >-import org.eclipse.swt.events.ShellEvent; >+import org.eclipse.swt.events.*; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.internal.widgets.IShellAdapter; >@@ -366,6 +365,82 @@ > 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