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 202170 Details for
Bug 355709
Labels are cut off in certain circumstances (StackLayout, width hints)
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]
Proposed patch for v14_Maintenance branch
Bug-355709.patch (text/plain), 12.65 KB, created by
Ivan Furnadjiev
on 2011-08-25 14:23:03 EDT
(
hide
)
Description:
Proposed patch for v14_Maintenance branch
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2011-08-25 14:23:03 EDT
Size:
12.65 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.rwt >Index: src/org/eclipse/rwt/internal/textsize/MarkLayoutNeededVisitor.java >=================================================================== >RCS file: src/org/eclipse/rwt/internal/textsize/MarkLayoutNeededVisitor.java >diff -N src/org/eclipse/rwt/internal/textsize/MarkLayoutNeededVisitor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/rwt/internal/textsize/MarkLayoutNeededVisitor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 EclipseSource and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * EclipseSource - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.rwt.internal.textsize; >+ >+import org.eclipse.swt.internal.widgets.ICompositeAdapter; >+import org.eclipse.swt.internal.widgets.WidgetTreeVisitor.AllWidgetTreeVisitor; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Widget; >+ >+ >+class MarkLayoutNeededVisitor extends AllWidgetTreeVisitor { >+ >+ public boolean doVisit( Widget widget ) { >+ if( widget instanceof Composite ) { >+ Composite composite = ( Composite )widget; >+ getAdapter( composite ).markLayoutNeeded(); >+ } >+ return true; >+ } >+ >+ private static ICompositeAdapter getAdapter( Composite composite ) { >+ Object adapter = composite.getAdapter( ICompositeAdapter.class ); >+ return ( ICompositeAdapter )adapter; >+ } >+} >Index: src/org/eclipse/rwt/internal/textsize/TextSizeRecalculation.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/rwt/internal/textsize/TextSizeRecalculation.java,v >retrieving revision 1.3 >diff -u -r1.3 TextSizeRecalculation.java >--- src/org/eclipse/rwt/internal/textsize/TextSizeRecalculation.java 5 May 2011 07:43:11 -0000 1.3 >+++ src/org/eclipse/rwt/internal/textsize/TextSizeRecalculation.java 25 Aug 2011 18:21:13 -0000 >@@ -33,6 +33,7 @@ > Rectangle boundsBuffer = shell.getBounds(); > bufferScrolledCompositeOrigins( shell ); > clearLayoutBuffers( shell ); >+ markLayoutNeeded( shell ); > enlargeShell( shell ); > rePackControls( shell ); > enlargeScrolledCompositeContent( shell ); >@@ -49,6 +50,10 @@ > WidgetTreeVisitor.accept( shell, new ClearLayoutBuffersVisitor() ); > } > >+ private void markLayoutNeeded( Shell shell ) { >+ WidgetTreeVisitor.accept( shell, new MarkLayoutNeededVisitor() ); >+ } >+ > private void bufferScrolledCompositeOrigins( Shell shell ) { > WidgetTreeVisitor.accept( shell, new BufferScrolledCompositeOriginsVisitor() ); > } >@@ -60,7 +65,7 @@ > private void restoreScrolledCompositeOrigins( Shell shell ) { > WidgetTreeVisitor.accept( shell, new RestoreScrolledCompositeOriginsVisitor() ); > } >- >+ > private void restoreShellSize( Shell shell, Rectangle bufferedBounds ) { > setShellSize( shell, bufferedBounds ); > } >@@ -87,7 +92,7 @@ > IDisplayAdapter displayAdapter = ( IDisplayAdapter )adapter; > return displayAdapter.getShells(); > } >- >+ > private void setShellSize( Shell shell, Rectangle bounds ) { > getShellAdapter( shell ).setBounds( bounds ); > } >Index: src/org/eclipse/swt/internal/widgets/ICompositeAdapter.java >=================================================================== >RCS file: src/org/eclipse/swt/internal/widgets/ICompositeAdapter.java >diff -N src/org/eclipse/swt/internal/widgets/ICompositeAdapter.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/swt/internal/widgets/ICompositeAdapter.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 EclipseSource and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * EclipseSource - initial API and implementation >+ ******************************************************************************/ >+package org.eclipse.swt.internal.widgets; >+ >+ >+public interface ICompositeAdapter { >+ >+ void markLayoutNeeded(); >+ >+} >Index: src/org/eclipse/swt/widgets/Composite.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt/org.eclipse.rap.rwt/src/org/eclipse/swt/widgets/Composite.java,v >retrieving revision 1.28 >diff -u -r1.28 Composite.java >--- src/org/eclipse/swt/widgets/Composite.java 25 Aug 2011 08:41:02 -0000 1.28 >+++ src/org/eclipse/swt/widgets/Composite.java 25 Aug 2011 18:21:15 -0000 >@@ -15,6 +15,8 @@ > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.internal.SerializableCompatibility; >+import org.eclipse.swt.internal.widgets.ICompositeAdapter; > import org.eclipse.swt.widgets.ControlHolder.IControlHolderAdapter; > > /** >@@ -34,6 +36,7 @@ > */ > public class Composite extends Scrollable { > >+ private final ICompositeAdapter compositeAdapter; > private Layout layout; > int layoutCount; > private final ControlHolder controlHolder; >@@ -44,6 +47,7 @@ > // prevent instantiation from outside this package > super( parent ); > controlHolder = new ControlHolder(); >+ compositeAdapter = new CompositeAdapter(); > } > > /** >@@ -76,6 +80,7 @@ > public Composite( Composite parent, int style ) { > super( parent, style ); > controlHolder = new ControlHolder(); >+ compositeAdapter = new CompositeAdapter(); > } > > void initState() { >@@ -114,6 +119,8 @@ > Object result; > if( adapter == IControlHolderAdapter.class ) { > result = controlHolder; >+ } else if( adapter == ICompositeAdapter.class ) { >+ result = compositeAdapter; > } else { > result = super.getAdapter( adapter ); > } >@@ -832,7 +839,7 @@ > void notifyResize( Point oldSize ) { > // TODO [rh] revise this: the SWT code (method sendResize) first calls > // 'super' (fires resize events) and *then* does the layouting >- if( !oldSize.equals( getSize() ) ) { >+ if( !oldSize.equals( getSize() ) || isLayoutNeeded() ) { > ProcessActionRunner.add( new Runnable() { > public void run() { > if( !isDisposed() && layout != null ) { >@@ -845,6 +852,10 @@ > super.notifyResize( oldSize ); > } > >+ private boolean isLayoutNeeded() { >+ return ( state & LAYOUT_NEEDED ) != 0; >+ } >+ > /////////////////// > // Skinning support > >@@ -858,4 +869,15 @@ > } > } > } >+ >+ //////////////// >+ // Inner classes >+ >+ private final class CompositeAdapter implements ICompositeAdapter, SerializableCompatibility { >+ >+ public void markLayoutNeeded() { >+ Composite.this.markLayout( false, false ); >+ } >+ >+ } > } >\ No newline at end of file >#P org.eclipse.rap.rwt.test >Index: src/org/eclipse/rwt/internal/textsize/TextSizeRecalculation_Test.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.rwt.test/org.eclipse.rap.rwt.test/src/org/eclipse/rwt/internal/textsize/TextSizeRecalculation_Test.java,v >retrieving revision 1.3 >diff -u -r1.3 TextSizeRecalculation_Test.java >--- src/org/eclipse/rwt/internal/textsize/TextSizeRecalculation_Test.java 6 May 2011 07:57:05 -0000 1.3 >+++ src/org/eclipse/rwt/internal/textsize/TextSizeRecalculation_Test.java 25 Aug 2011 18:21:15 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * Frank Appel - initial API and implementation >+ * EclipseSource - ongoing development > ******************************************************************************/ > package org.eclipse.rwt.internal.textsize; > >@@ -21,7 +22,7 @@ > import org.eclipse.swt.events.ControlListener; > import org.eclipse.swt.graphics.*; > import org.eclipse.swt.internal.widgets.ControlUtil; >-import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.layout.*; > import org.eclipse.swt.widgets.*; > > >@@ -29,60 +30,63 @@ > private static final FontData FONT_DATA = new FontData( "arial", 23, SWT.BOLD ); > private static final String TEXT_TO_MEASURE = "textToMeasure"; > >+ private Display display; > private Shell shell; > private Composite scrolledCompositeContent; > private ResizeListener shellResizeListener; > private ResizeListener scrolledCompositeContentResizeListener; > private Label packedControl; >- >- >- private final class ResizeListener implements ControlListener { >- private int resizeCount; >- >- public void controlResized( ControlEvent e ) { >- resizeCount++; >- } > >- public void controlMoved( ControlEvent e ) { >- } >+ protected void setUp() throws Exception { >+ Fixture.setUp(); >+ display = new Display(); >+ shell = new Shell( display ); >+ } > >- public int resizeCount() { >- return resizeCount; >- } >+ protected void tearDown() throws Exception { >+ Fixture.tearDown(); > } >- >- >+ > public void testExecute() { > createWidgetTree(); > registerResizeListeners(); > turnOnImmediateResizeEventHandling(); > fakeMeasurementResults(); > TextSizeRecalculation recalculation = new TextSizeRecalculation(); >- >+ > recalculation.execute(); >- >+ > checkResizeTookPlace(); > checkRePackTookPlace(); > } >- >+ > public void testIControlAdapterIsPacked() { >- Display display = new Display(); > Shell control = new Shell( display ); > assertFalse( ControlUtil.getControlAdapter( control ).isPacked() ); >- >+ > control.pack(); > assertTrue( ControlUtil.getControlAdapter( control ).isPacked() ); >- >+ > control.setBounds( new Rectangle( 1, 1, 2, 2 ) ); > assertFalse( ControlUtil.getControlAdapter( control ).isPacked() ); > } > >- protected void setUp() throws Exception { >- Fixture.setUp(); >- } >- >- protected void tearDown() throws Exception { >- Fixture.tearDown(); >+ public void testLayoutOfCompositeWithFixedSize() { >+ turnOnImmediateResizeEventHandling(); >+ createShellWithLayout(); >+ Composite fixedSizeComposite = createFixedSizeComposite(); >+ Label label = new Label( fixedSizeComposite, SWT.NONE ); >+ label.setText( "text" ); >+ shell.pack(); >+ // simulate smaller size because of text estimation >+ label.setSize( 5, 5 ); >+ ResizeListener resizeListener = new ResizeListener(); >+ label.addControlListener( resizeListener ); >+ >+ TextSizeRecalculation recalculation = new TextSizeRecalculation(); >+ recalculation.execute(); >+ >+ assertEquals( 1, resizeListener.resizeCount() ); > } > > private void checkResizeTookPlace() { >@@ -91,7 +95,7 @@ > assertEquals( 2, shellResizeListener.resizeCount() ); > assertEquals( 2, scrolledCompositeContentResizeListener.resizeCount() ); > } >- >+ > private void checkRePackTookPlace() { > assertEquals( new Point( 100, 22 ), packedControl.getSize() ); > } >@@ -105,8 +109,7 @@ > } > > private void createWidgetTree() { >- Display display = new Display(); >- createShellWithLayout( display ); >+ createShellWithLayout(); > createScrolledCompositeWithContent(); > createPackedControl(); > } >@@ -124,9 +127,15 @@ > scrolledComposite.setContent( scrolledCompositeContent ); > } > >- private void createShellWithLayout( Display display ) { >- shell = new Shell( display ); >- shell.setLayout( new FillLayout() ); >+ private void createShellWithLayout() { >+ shell.setLayout( new GridLayout() ); >+ } >+ >+ private Composite createFixedSizeComposite() { >+ Composite result = new Composite( shell, SWT.NONE ); >+ result.setLayout( new GridLayout() ); >+ result.setLayoutData( new GridData( 200, SWT.DEFAULT ) ); >+ return result; > } > > private void registerResizeListeners() { >@@ -135,7 +144,7 @@ > shell.addControlListener( shellResizeListener ); > scrolledCompositeContent.addControlListener( scrolledCompositeContentResizeListener ); > } >- >+ > private void turnOnImmediateResizeEventHandling() { > Fixture.fakePhase( PhaseId.PROCESS_ACTION ); > } >@@ -145,4 +154,20 @@ > RWTFactory.getTextSizeStorage().storeFont( FONT_DATA ); > TextSizeStorageUtil.store( FONT_DATA, TEXT_TO_MEASURE, 0, new Point( 100, 20 ) ); > } >+ >+ private final class ResizeListener implements ControlListener { >+ private int resizeCount; >+ >+ public void controlResized( ControlEvent e ) { >+ resizeCount++; >+ } >+ >+ public void controlMoved( ControlEvent e ) { >+ } >+ >+ public int resizeCount() { >+ return resizeCount; >+ } >+ } >+ > } >\ No newline at end of file
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
Flags:
rsternberg
:
review+
Actions:
View
|
Diff
Attachments on
bug 355709
:
202089
|
202090
| 202170