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 160332 Details for
Bug 303731
Adopt Forms 3.6
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]
Draft
Bug-303731.patch (text/plain), 140.44 KB, created by
Ivan Furnadjiev
on 2010-02-26 11:41:49 EST
(
hide
)
Description:
Draft
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2010-02-26 11:41:49 EST
Size:
140.44 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.ui.forms >Index: src/org/eclipse/ui/forms/IManagedForm.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/IManagedForm.java,v >retrieving revision 1.1 >diff -u -r1.1 IManagedForm.java >--- src/org/eclipse/ui/forms/IManagedForm.java 16 Apr 2008 09:44:27 -0000 1.1 >+++ src/org/eclipse/ui/forms/IManagedForm.java 26 Feb 2010 16:36:21 -0000 >@@ -1,11 +1,11 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2007 IBM Corporation 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 >+ * Copyright (c) 2003, 2008 IBM Corporation 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: >+ * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.forms; >@@ -28,6 +28,8 @@ > * > * @see ManagedForm > * @since 1.0 >+ * @noimplement This interface is not intended to be implemented by clients. >+ * @noextend This interface is not intended to be extended by clients. > */ > public interface IManagedForm { > /** >Index: src/org/eclipse/ui/forms/MasterDetailsBlock.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/MasterDetailsBlock.java,v >retrieving revision 1.1 >diff -u -r1.1 MasterDetailsBlock.java >--- src/org/eclipse/ui/forms/MasterDetailsBlock.java 16 Apr 2008 09:44:27 -0000 1.1 >+++ src/org/eclipse/ui/forms/MasterDetailsBlock.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Roland Tepp (roland@videobet.com) - patch (see Bugzilla #107197) > *******************************************************************************/ > package org.eclipse.ui.forms; > >@@ -141,16 +142,25 @@ > */ > public void createContent(IManagedForm managedForm) { > final ScrolledForm form = managedForm.getForm(); >+ createContent(managedForm, form.getBody()); >+ } >+ >+ /** >+ * Creates the content of the master/details block inside the parent composite. >+ * This method should be called as late as possible inside the parent part. >+ * >+ * @param managedForm >+ * the managed form to create the block in >+ */ >+ public void createContent(IManagedForm managedForm, Composite parent) { >+ final ScrolledForm form = managedForm.getForm(); > FormToolkit toolkit = managedForm.getToolkit(); >- GridLayout layout = new GridLayout(); >- layout.marginWidth = 0; >- layout.marginHeight = 0; >- form.getBody().setLayout(layout); >- sashForm = new MDSashForm(form.getBody(), SWT.NULL); >+ applyLayout(parent); >+ sashForm = new MDSashForm(parent, SWT.NULL); > sashForm.setData("form", managedForm); //$NON-NLS-1$ > toolkit.adapt(sashForm, false, false); >- sashForm.setMenu(form.getBody().getMenu()); >- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ sashForm.setMenu(parent.getMenu()); >+ applyLayoutData(sashForm); > createMasterPart(managedForm, sashForm); > createDetailsPart(managedForm, sashForm); > hookResizeListener(); >@@ -158,6 +168,44 @@ > form.updateToolBar(); > } > >+ /** >+ * Applies layout data to the sash form containing master and detail parts >+ * of the master/details block. >+ * >+ * <p>The default implementation fills the whole parent composite area. >+ * Override this method if master/details block is to be placed on a form >+ * along with other components.</p> >+ * >+ * <p>Implementations that override this method should also override >+ * <code>applyLayout(Composite)</code> method implementation.</p> >+ * >+ * @param sashForm The sash form to be laid out on the parent composite. >+ * @see #applyLayout(Composite) >+ */ >+ protected void applyLayoutData(SashForm sashForm) { >+ sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); >+ } >+ >+ /** >+ * Applies layout to the parent composite of the master/details block. >+ * >+ * <p>The default implementation fills the whole parent composite area. >+ * Override this method if master/details block is to be placed on a form >+ * along with other components.</p> >+ * >+ * <p>Implementations that override this method should also override >+ * <code>applyLayoutData(SashForm)</code> method implementation.</p> >+ * >+ * @param parent parent composite for the master/details block >+ * @see #applyLayoutData(SashForm) >+ */ >+ protected void applyLayout(final Composite parent) { >+ GridLayout layout = new GridLayout(); >+ layout.marginWidth = 0; >+ layout.marginHeight = 0; >+ parent.setLayout(layout); >+ } >+ > private void hookResizeListener() { > Listener listener = ((MDSashForm)sashForm).listener; > Control [] children = sashForm.getChildren(); >Index: src/org/eclipse/ui/forms/FormColors.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/FormColors.java,v >retrieving revision 1.1 >diff -u -r1.1 FormColors.java >--- src/org/eclipse/ui/forms/FormColors.java 16 Apr 2008 09:44:25 -0000 1.1 >+++ src/org/eclipse/ui/forms/FormColors.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -14,6 +14,9 @@ > import java.util.Map; > > import org.eclipse.rwt.graphics.Graphics; >+ >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.jface.resource.LocalResourceManager; > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.RGB; >@@ -94,6 +97,8 @@ > > protected Map colorRegistry = new HashMap(10); > >+ private LocalResourceManager resources; >+ > protected Color background; > > protected Color foreground; >@@ -206,7 +211,14 @@ > * @return the allocated color object > */ > public Color createColor(String key, RGB rgb) { >- return createColor(key, rgb.red, rgb.green, rgb.blue); >+ // RAP [rh] changes due to missing Color constructor >+// Color c = getResourceManager().createColor(rgb); >+// Color prevC = (Color) colorRegistry.get(key); >+// if (prevC != null && !prevC.isDisposed()) >+// getResourceManager().destroyColor(prevC.getRGB()); >+ Color c = Graphics.getColor(rgb); >+ colorRegistry.put(key, c); >+ return c; > } > > /** >@@ -249,17 +261,7 @@ > * @return the allocated color object > */ > public Color createColor(String key, int r, int g, int b) { >-// RAP [rh] changes due to missing Color constructor >-// Color c = new Color(display, r, g, b); >-// Color prevC = (Color) colorRegistry.get(key); >-// if (prevC != null) >-// prevC.dispose(); >-// colorRegistry.put(key, c); >- >- Color c = Graphics.getColor(r, g, b); >- colorRegistry.put(key, c); >- >- return c; >+ return createColor(key, new RGB(r,g,b)); > } > > /** >@@ -365,10 +367,9 @@ > * Disposes all the colors in the registry. > */ > public void dispose() { >- // RAP [rh] changes due to missing Color#dispose() >-// Iterator e = colorRegistry.values().iterator(); >-// while (e.hasNext()) >-// ((Color) e.next()).dispose(); >+ if (resources != null) >+ resources.dispose(); >+ resources = null; > colorRegistry = null; > } > >@@ -730,4 +731,10 @@ > createColor(IFormColors.H_HOVER_LIGHT, light); > createColor(IFormColors.H_HOVER_FULL, full); > } >+ >+ private LocalResourceManager getResourceManager() { >+ if (resources == null) >+ resources = new LocalResourceManager(JFaceResources.getResources()); >+ return resources; >+ } > } >Index: src/org/eclipse/ui/forms/HyperlinkGroup.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/HyperlinkGroup.java,v >retrieving revision 1.3 >diff -u -r1.3 HyperlinkGroup.java >--- src/org/eclipse/ui/forms/HyperlinkGroup.java 20 Mar 2009 10:45:47 -0000 1.3 >+++ src/org/eclipse/ui/forms/HyperlinkGroup.java 26 Feb 2010 16:36:21 -0000 >@@ -12,6 +12,8 @@ > > import java.util.ArrayList; > >+import org.eclipse.ui.forms.internal.widgets.IHyperlinkAdapter; >+ > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.widgets.Display; >@@ -19,7 +21,6 @@ > import org.eclipse.swt.widgets.Listener; > import org.eclipse.ui.forms.events.HyperlinkEvent; > import org.eclipse.ui.forms.events.IHyperlinkListener; >-import org.eclipse.ui.forms.internal.widgets.IHyperlinkAdapter; > import org.eclipse.ui.forms.widgets.Hyperlink; > > /** >@@ -143,8 +144,8 @@ > if (getHyperlinkUnderlineMode() == UNDERLINE_ALWAYS) > link.setUnderlined(true); > hook(link); >- // RAP [rh] Provides information to handle hover effect on the client-side >- updateHyperlinkSettings(); >+ // RAP [rh] Provides information to handle hover effect on the client-side >+ updateHyperlinkSettings(); > } > > /** >@@ -157,8 +158,8 @@ > super.setActiveBackground(newActiveBackground); > // RAP [rh] Obsolete, as mouse events are missing > // isActiveBackgroundSet = true; >- // RAP [rh] Provides information to handle hover effect on the client-side >- updateHyperlinkSettings(); >+ // RAP [rh] Provides information to handle hover effect on the client-side >+ updateHyperlinkSettings(); > } > > /** >@@ -171,8 +172,8 @@ > super.setActiveForeground(newActiveForeground); > // RAP [rh] Obsolete, as mouse events are missing > // isActiveForegroundSet = true; >- // RAP [rh] Provides information to handle hover effect on the client-side >- updateHyperlinkSettings(); >+ // RAP [rh] Provides information to handle hover effect on the client-side >+ updateHyperlinkSettings(); > } > > // RAP [rh] Update information to handle hover effect on the client-side >Index: src/org/eclipse/ui/forms/HyperlinkSettings.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/HyperlinkSettings.java,v >retrieving revision 1.2 >diff -u -r1.2 HyperlinkSettings.java >--- src/org/eclipse/ui/forms/HyperlinkSettings.java 16 Sep 2008 16:26:21 -0000 1.2 >+++ src/org/eclipse/ui/forms/HyperlinkSettings.java 26 Feb 2010 16:36:21 -0000 >@@ -1,11 +1,11 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation 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 >+ * Copyright (c) 2000, 2008 IBM Corporation 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: >+ * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.forms; >@@ -16,10 +16,11 @@ > import org.eclipse.ui.internal.forms.widgets.*; > /** > * Manages color and underline mode settings for a group of hyperlinks. The >- * class is extended by HyperlinkGroup but is otwerwise not intended to be >+ * class is extended by HyperlinkGroup but is otherwise not intended to be > * subclassed. > * > * @since 1.0 >+ * @noextend This class is not intended to be subclassed by clients. > */ > public class HyperlinkSettings { > /** >Index: src/org/eclipse/ui/forms/DetailsPart.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/DetailsPart.java,v >retrieving revision 1.1 >diff -u -r1.1 DetailsPart.java >--- src/org/eclipse/ui/forms/DetailsPart.java 16 Apr 2008 09:44:27 -0000 1.1 >+++ src/org/eclipse/ui/forms/DetailsPart.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -65,9 +65,6 @@ > page.dispose(); > page=null; > } >- public boolean isDisposed() { >- return page==null; >- } > public boolean isFixed() { > return fixed; > } >Index: src/org/eclipse/ui/forms/IMessageManager.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/IMessageManager.java,v >retrieving revision 1.2 >diff -u -r1.2 IMessageManager.java >--- src/org/eclipse/ui/forms/IMessageManager.java 25 Feb 2010 09:59:54 -0000 1.2 >+++ src/org/eclipse/ui/forms/IMessageManager.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation 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 >@@ -7,7 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >- ******************************************************************************/ >+ *******************************************************************************/ > > package org.eclipse.ui.forms; > >@@ -48,6 +48,8 @@ > * @since 1.0 > * @see IMessageProvider > * @see IManagedForm >+ * @noimplement This interface is not intended to be implemented by clients. >+ * @noextend This interface is not intended to be extended by clients. > */ > > public interface IMessageManager { >Index: src/org/eclipse/ui/forms/ManagedForm.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/ManagedForm.java,v >retrieving revision 1.1 >diff -u -r1.1 ManagedForm.java >--- src/org/eclipse/ui/forms/ManagedForm.java 16 Apr 2008 09:44:27 -0000 1.1 >+++ src/org/eclipse/ui/forms/ManagedForm.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -13,8 +13,8 @@ > import java.util.Vector; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.swt.widgets.Composite; >-import org.eclipse.ui.forms.widgets.*; >-import org.eclipse.ui.internal.forms.MessageManager; >+import org.eclipse.ui.forms.widgets.FormToolkit; >+import org.eclipse.ui.forms.widgets.ScrolledForm; > > /** > * Managed form wraps a form widget and adds life cycle methods for form parts. >@@ -47,8 +47,6 @@ > > private boolean initialized; > >- private MessageManager messageManager; >- > private Vector parts = new Vector(); > > /** >@@ -328,8 +326,6 @@ > * @see org.eclipse.ui.forms.IManagedForm#getMessageManager() > */ > public IMessageManager getMessageManager() { >- if (messageManager == null) >- messageManager = new MessageManager(form); >- return messageManager; >+ return form.getMessageManager(); > } > } >Index: src/org/eclipse/ui/forms/widgets/AbstractHyperlink.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/AbstractHyperlink.java,v >retrieving revision 1.3 >diff -u -r1.3 AbstractHyperlink.java >--- src/org/eclipse/ui/forms/widgets/AbstractHyperlink.java 14 Jan 2010 11:06:16 -0000 1.3 >+++ src/org/eclipse/ui/forms/widgets/AbstractHyperlink.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Izzet Safer (isafer@ca.ibm.com) - patch (see Bugzilla #250505) > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; > >@@ -31,6 +32,11 @@ > * processing mouse and keyboard events, and converting them into unified > * hyperlink events. Subclasses are responsible for rendering the hyperlink in > * the client area. >+ * <p> >+ * <dl> >+ * <dt><b>Styles:</b></dt> >+ * <dd>None</dd> >+ * </dl> > * > * @since 1.0 > */ >@@ -227,8 +233,6 @@ > // disarm link, back to normal state > // RAP [rh] Unused code: was used by MouseUp/MouseDown listener code > // armed = false; >-// RAP [rh] missing accessibility support >-// getAccessible().setFocus(ACC.CHILDID_SELF); > if (listeners == null) > return; > int size = listeners.size(); >@@ -244,8 +248,15 @@ > // RAP [if] Cursor is managed on the client side > // if (!isDisposed()) > // setCursor(FormsResources.getHandCursor()); >+// RAP [if] missing accessibility support >+// triggerAccessible(); > } > >+// RAP [if] missing accessibility support >+// void triggerAccessible() { >+// getAccessible().setFocus(ACC.CHILDID_SELF); >+// } >+ > /** > * Sets the object associated with this hyperlink. Concrete implementation > * of this class can use if to store text, URLs or model objects that need >@@ -349,7 +360,9 @@ > */ > > public void setEnabled (boolean enabled) { >+ boolean needsRedraw = enabled != getEnabled(); > super.setEnabled(enabled); >- redraw(); >+ if (needsRedraw) >+ redraw(); > } > } >Index: src/org/eclipse/ui/forms/widgets/FormText.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/FormText.java,v >retrieving revision 1.4 >diff -u -r1.4 FormText.java >--- src/org/eclipse/ui/forms/widgets/FormText.java 25 Feb 2010 13:53:11 -0000 1.4 >+++ src/org/eclipse/ui/forms/widgets/FormText.java 26 Feb 2010 16:36:22 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Martin Donnelly (m2a3@eircom.net) - patch (see Bugzilla #145997) > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; > >@@ -16,6 +17,7 @@ > import java.util.Hashtable; > > import org.eclipse.core.runtime.ListenerList; >+ > import org.eclipse.swt.SWT; > import org.eclipse.swt.SWTException; > // RAP [if] accessibility not supported >@@ -94,7 +96,8 @@ > * on the fly. > * <p> > * When configured to use formatting XML, the control requires the root element >- * <code>form</code> to be used. The following tags can be children of the >+ * <code>form</code> to be used and requires any ampersand (&) characters in the text to >+ * be replaced by the entity <b>&amp;</b>. The following tags can be children of the > * <code>form</code> element: > * </p> > * <ul> >@@ -197,8 +200,7 @@ > // RAP [if] Need to instruct LCA to relayout the segments to the client > private boolean hasLayoutChanged = false; > >- // private fields >- //TODO We should remove the dependency on Platform >+ // private fields > private static final boolean DEBUG_TEXT = false;//"true".equalsIgnoreCase(Platform.getDebugOption(FormUtil.DEBUG_TEXT)); > private static final boolean DEBUG_TEXTSIZE = false;//"true".equalsIgnoreCase(Platform.getDebugOption(FormUtil.DEBUG_TEXTSIZE)); > >@@ -293,12 +295,11 @@ > int pwidth = 0; > for (int j = 0; j < segments.length; j++) { > ParagraphSegment segment = segments[j]; >- segment.advanceLocator(gc, wHint, loc, resourceTable, >- false); >+ segment.advanceLocator(gc, wHint, loc, resourceTable, false); > if (wHint != SWT.DEFAULT) { > width = Math.max(width, loc.width); > } else { >- pwidth += loc.width; >+ pwidth = Math.max(pwidth, loc.width); > } > if (segment instanceof IFocusSelectable) > selectableInTheLastRow = true; >@@ -342,7 +343,6 @@ > Locator loc = new Locator(); > loc.marginWidth = marginWidth; > loc.marginHeight = marginHeight; >- loc.x = marginWidth; > loc.y = marginHeight; > FontMetrics fm = gc.getFontMetrics(); > int lineHeight = fm.getHeight(); >@@ -370,6 +370,9 @@ > /** > * Contructs a new form text widget in the provided parent and using the > * styles. >+ * <p> >+ * The only valid style bit for <code>FormText</code> is <code>SWT.NO_FOCUS</code>. >+ * This will cause the widget to always refuse focus. > * > * @param parent > * form text parent control >@@ -1374,7 +1377,10 @@ > SelectionEvent selEvent = new SelectionEvent( event ); > selEvent.processEvent(); > // RAP [if] accessibility not supported >-// getAccessible().selectionChanged(); >+// // A listener could have caused the widget to be disposed >+// if (!isDisposed()) { >+// getAccessible().selectionChanged(); >+// } > } > > // RAP [if] MouseMoveListener not supported >@@ -1403,9 +1409,7 @@ > setFocus(); > } > model.selectLink(segmentUnder); >-// RAP [if] MouseEvent#stateMask not implemented >-// enterLink(segmentUnder, e.stateMask); >- enterLink(segmentUnder, SWT.NULL); >+ enterLink(segmentUnder, e.stateMask); > // RAP [if] paintFocusTransfer unnecessary > // paintFocusTransfer(oldLink, segmentUnder); > } >@@ -1418,12 +1422,11 @@ > } else { > if (e.button == 1) { > endSelection(e); >+ if (isDisposed()) return; > IHyperlinkSegment segmentUnder = model > .findHyperlinkAt(e.x, e.y); > if (segmentUnder != null && armed == segmentUnder && selData == null) { >-// RAP [if] MouseEvent#stateMask not implemented >-// activateLink(segmentUnder, e.stateMask); >- activateLink(segmentUnder, SWT.NULL); >+ activateLink(segmentUnder, e.stateMask); > armed = null; > } > } >@@ -1554,21 +1557,21 @@ > break; > valid = setControlFocus(advance, selectable); > } >- if (selectable == null) >- setFocusToNextSibling(this, true); >- else >+ if (selectable != null) > ensureVisible(selectable); > if (selectable instanceof IHyperlinkSegment) { > enterLink((IHyperlinkSegment) selectable, SWT.NULL); >-// RAP [if] >+// RAP [if] paint not supported > // paintFocusTransfer(null, (IHyperlinkSegment) selectable); > } > } > } else { >-// RAP [if] >+// RAP [if] paint not supported > // paintFocusTransfer(getSelectedLink(), null); > model.selectLink(null); > } >+ if (!model.hasFocusSegments()) >+ redraw(); > } > > private void enterLink(IHyperlinkSegment link, int stateMask) { >@@ -1746,7 +1749,9 @@ > } else { > size = new Point(wHint, hHint); > } >- Rectangle trim = computeTrim(0, 0, size.x, size.y); >+ // RAP [if] Last line of text is cutoff - increase the height with 2px >+ // TODO: Find proper solution >+ Rectangle trim = computeTrim(0, 0, size.x, size.y + 2 ); > if (DEBUG_TEXTSIZE) > System.out.println("FormText Computed size: "+trim); //$NON-NLS-1$ > return new Point(trim.width, trim.height); >@@ -1795,8 +1800,10 @@ > * @see org.eclipse.swt.widgets.Control#setFocus() > */ > public boolean setFocus() { >+ mouseFocus = true; > FormUtil.setFocusScrollingEnabled(this, false); > boolean result = super.setFocus(); >+ mouseFocus = false; > FormUtil.setFocusScrollingEnabled(this, true); > return result; > } >Index: src/org/eclipse/ui/forms/widgets/Form.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/Form.java,v >retrieving revision 1.3 >diff -u -r1.3 Form.java >--- src/org/eclipse/ui/forms/widgets/Form.java 25 Feb 2010 09:39:37 -0000 1.3 >+++ src/org/eclipse/ui/forms/widgets/Form.java 26 Feb 2010 16:36:22 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -27,7 +27,9 @@ > import org.eclipse.swt.widgets.Menu; > import org.eclipse.ui.forms.IFormColors; > import org.eclipse.ui.forms.IMessage; >+import org.eclipse.ui.forms.IMessageManager; > import org.eclipse.ui.forms.events.IHyperlinkListener; >+import org.eclipse.ui.internal.forms.MessageManager; > import org.eclipse.ui.internal.forms.widgets.FormHeading; > import org.eclipse.ui.internal.forms.widgets.FormUtil; > >@@ -86,6 +88,9 @@ > * desired layout manager explicitly. > * <p> > * Although the class is not final, it should not be subclassed. >+ * >+ * @since 1.0 >+ * @noextend This class is not intended to be subclassed by clients. > */ > public class Form extends Composite { > private FormHeading head; >@@ -97,6 +102,8 @@ > private SizeCache headCache = new SizeCache(); > > private FormText selectionText; >+ >+ private MessageManager messageManager; > > private class FormLayout extends Layout implements ILayoutExtension { > public int computeMinimumWidth(Composite composite, boolean flushCache) { >@@ -758,4 +765,16 @@ > } > this.selectionText = text; > } >+ >+ /** >+ * Returns the message manager that will keep track of messages in this >+ * form. >+ * >+ * @return the message manager instance >+ */ >+ public IMessageManager getMessageManager() { >+ if (messageManager == null) >+ messageManager = new MessageManager(this); >+ return messageManager; >+ } > } >\ No newline at end of file >Index: src/org/eclipse/ui/forms/widgets/ImageHyperlink.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/ImageHyperlink.java,v >retrieving revision 1.1 >diff -u -r1.1 ImageHyperlink.java >--- src/org/eclipse/ui/forms/widgets/ImageHyperlink.java 16 Apr 2008 09:44:36 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/ImageHyperlink.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -12,7 +12,12 @@ > package org.eclipse.ui.forms.widgets; > > import org.eclipse.swt.SWT; >-import org.eclipse.swt.graphics.*; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Event; > >@@ -42,6 +47,9 @@ > private Image hoverImage; > > private Image activeImage; >+ >+// RAP [if] unused >+// private Image disabledImage; > > private int state; > >@@ -64,6 +72,13 @@ > public ImageHyperlink(Composite parent, int style) { > super(parent, removeAlignment(style)); > extractAlignment(style); >+// RAP [if] unused >+// addDisposeListener(new DisposeListener() { >+// public void widgetDisposed(DisposeEvent e) { >+// if (disabledImage != null) >+// disabledImage.dispose(); >+// } >+// }); > } > > //RAP [rh] Disabled because of disabled AbstractHyperlink#paintHyperlink() >@@ -234,6 +249,11 @@ > */ > public void setImage(Image image) { > this.image = image; >+// RAP [if] unused >+// if (disabledImage != null) >+// disabledImage.dispose(); >+// if (!isEnabled() && image != null && !image.isDisposed()) >+// disabledImage = new Image(image.getDevice(), image, SWT.IMAGE_DISABLE); > } > > private Point computeMaxImageSize() { >@@ -288,4 +308,16 @@ > horizontalAlignment = SWT.RIGHT; > } > } >+ >+ public void setEnabled(boolean enabled) { >+// RAP [if] unused >+// if (!enabled && (disabledImage == null || disabledImage.isDisposed()) && image != null && !image.isDisposed()) { >+// disabledImage = new Image(image.getDevice(), image, SWT.IMAGE_DISABLE); >+// } >+ super.setEnabled(enabled); >+// if (enabled && disabledImage != null) { >+// disabledImage.dispose(); >+// disabledImage = null; >+// } >+ } > } >Index: src/org/eclipse/ui/forms/widgets/ExpandableComposite.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java,v >retrieving revision 1.7 >diff -u -r1.7 ExpandableComposite.java >--- src/org/eclipse/ui/forms/widgets/ExpandableComposite.java 25 Feb 2010 13:53:11 -0000 1.7 >+++ src/org/eclipse/ui/forms/widgets/ExpandableComposite.java 26 Feb 2010 16:36:22 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * Kai Nacke - Fix for Bug 202382 >+ * Bryan Hunt - Fix for Bug 245457 > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; > >@@ -16,8 +17,8 @@ > import org.eclipse.swt.SWT; > //import org.eclipse.swt.events.FocusEvent; > //import org.eclipse.swt.events.FocusListener; >-//import org.eclipse.swt.events.KeyAdapter; >-//import org.eclipse.swt.events.KeyEvent; >+import org.eclipse.swt.events.KeyAdapter; >+import org.eclipse.swt.events.KeyEvent; > //import org.eclipse.swt.events.PaintEvent; > //import org.eclipse.swt.events.PaintListener; > //import org.eclipse.swt.events.TraverseEvent; >@@ -53,12 +54,10 @@ > * The widget can be instantiated as-is, or subclassed to modify some aspects of > * it. * > * <p> >- * <!-- RAP [rh] no key events > * Since 3.1, left/right arrow keys can be used to control the expansion state. > * If several expandable composites are created in the same parent, up/down > * arrow keys can be used to traverse between them. Expandable text accepts > * mnemonics and mnemonic activation will toggle the expansion state. >- * --> > * > * <p> > * While expandable composite recognize that different styles can be used to >@@ -132,6 +131,13 @@ > * be positioned after the text control and vertically centered with it. > */ > public static final int LEFT_TEXT_CLIENT_ALIGNMENT = 1 << 13; >+ >+ /** >+ * By default, a focus box is painted around the title when it receives focus. >+ * If this style is used, the focus box will not be painted. This style does >+ * not apply when FOCUS_TITLE is used. >+ */ >+ public static final int NO_TITLE_FOCUS_BOX = 1 << 14; > > /** > * Width of the margin that will be added around the control (default is 0). >@@ -266,9 +272,11 @@ > size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); > if (twidth < size.x + IGAP + tcsize.x) { > twidth -= IGAP; >- if (textLabel instanceof Label) >- size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x)))); >- else >+ if (textLabel instanceof Label) { >+ GC gc = new GC(textLabel); >+ size = FormUtil.computeWrapSize(gc, ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x)))); >+ gc.dispose(); >+ } else > size = textLabelCache.computeSize(Math.round(twidth*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT); > tcsize = textClientCache.computeSize(twidth-size.x, SWT.DEFAULT); > } >@@ -406,9 +414,11 @@ > size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT); > if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) { > innertHint -= IGAP; >- if (textLabel instanceof Label) >- size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x)))); >- else >+ if (textLabel instanceof Label) { >+ GC gc = new GC(textLabel); >+ size = FormUtil.computeWrapSize(gc, ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x)))); >+ gc.dispose(); >+ } else > size = textLabelCache.computeSize(Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT); > tcsize = textClientCache.computeSize(innertHint-size.x, SWT.DEFAULT); > } >@@ -555,7 +565,7 @@ > toggleState(); > } > }); >-// RAP [rh] missing paint and key events >+// RAP [rh] missing paint > // toggle.addPaintListener(new PaintListener() { > // public void paintControl(PaintEvent e) { > // if (textLabel instanceof Label && !isFixedStyle()) >@@ -564,17 +574,17 @@ > // : getTitleBarForeground()); > // } > // }); >-// toggle.addKeyListener(new KeyAdapter() { >-// public void keyPressed(KeyEvent e) { >-// if (e.keyCode == SWT.ARROW_UP) { >-// verticalMove(false); >-// e.doit = false; >-// } else if (e.keyCode == SWT.ARROW_DOWN) { >-// verticalMove(true); >-// e.doit = false; >-// } >-// } >-// }); >+ toggle.addKeyListener(new KeyAdapter() { >+ public void keyPressed(KeyEvent e) { >+ if (e.keyCode == SWT.ARROW_UP) { >+ verticalMove(false); >+ e.doit = false; >+ } else if (e.keyCode == SWT.ARROW_DOWN) { >+ verticalMove(true); >+ e.doit = false; >+ } >+ } >+ }); > // RAP [rh] Unnecessary to add focus listener, focus-border must be handled > // on the client-side > // if ((getExpansionStyle()&FOCUS_TITLE)==0) { >@@ -1018,8 +1028,10 @@ > * the title bar foreground > */ > public void setTitleBarForeground(Color color) { >- titleBarForeground = color; >- textLabel.setForeground(color); >+ if (hasTitleBar()) >+ titleBarForeground = color; >+ if (textLabel != null) >+ textLabel.setForeground(color); > } > > /** >@@ -1057,33 +1069,32 @@ > } > } > >-// RAP [rh] Obsolete, as there are no mouse events >-// private void verticalMove(boolean down) { >-// Composite parent = getParent(); >-// Control[] children = parent.getChildren(); >-// for (int i = 0; i < children.length; i++) { >-// Control child = children[i]; >-// if (child == this) { >-// ExpandableComposite sibling = getSibling(children, i, down); >-// if (sibling != null && sibling.toggle != null) { >-// sibling.setFocus(); >-// } >-// break; >-// } >-// } >-// } >-// >-// private ExpandableComposite getSibling(Control[] children, int index, >-// boolean down) { >-// int loc = down ? index + 1 : index - 1; >-// while (loc >= 0 && loc < children.length) { >-// Control c = children[loc]; >-// if (c instanceof ExpandableComposite && c.isVisible()) >-// return (ExpandableComposite) c; >-// loc = down ? loc + 1 : loc - 1; >-// } >-// return null; >-// } >+ private void verticalMove(boolean down) { >+ Composite parent = getParent(); >+ Control[] children = parent.getChildren(); >+ for (int i = 0; i < children.length; i++) { >+ Control child = children[i]; >+ if (child == this) { >+ ExpandableComposite sibling = getSibling(children, i, down); >+ if (sibling != null && sibling.toggle != null) { >+ sibling.setFocus(); >+ } >+ break; >+ } >+ } >+ } >+ >+ private ExpandableComposite getSibling(Control[] children, int index, >+ boolean down) { >+ int loc = down ? index + 1 : index - 1; >+ while (loc >= 0 && loc < children.length) { >+ Control c = children[loc]; >+ if (c instanceof ExpandableComposite && c.isVisible()) >+ return (ExpandableComposite) c; >+ loc = down ? loc + 1 : loc - 1; >+ } >+ return null; >+ } > > private void programmaticToggleState() { > if (toggle != null) >Index: src/org/eclipse/ui/forms/widgets/ToggleHyperlink.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/ToggleHyperlink.java,v >retrieving revision 1.1 >diff -u -r1.1 ToggleHyperlink.java >--- src/org/eclipse/ui/forms/widgets/ToggleHyperlink.java 16 Apr 2008 09:44:36 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/ToggleHyperlink.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -9,7 +9,7 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; >-//import org.eclipse.swt.SWT; >+import org.eclipse.swt.SWT; > //import org.eclipse.swt.accessibility.*; > import org.eclipse.swt.graphics.*; > import org.eclipse.swt.widgets.*; >@@ -22,6 +22,11 @@ > * This is an abstract class. Subclasses are responsible for rendering the > * control using decoration and hover decoration color. Control should be > * rendered based on the current expansion state. >+ * <p> >+ * <dl> >+ * <dt><b>Styles:</b></dt> >+ * <dd>None</dd> >+ * </dl> > * > * @since 1.0 > */ >@@ -42,10 +47,10 @@ > */ > public ToggleHyperlink(Composite parent, int style) { > super(parent, style); >-// RAP [rh] Mouse and key events missing >-// Listener listener = new Listener() { >-// public void handleEvent(Event e) { >-// switch (e.type) { >+// RAP [rh] Mouse events missing >+ Listener listener = new Listener() { >+ public void handleEvent(Event e) { >+ switch (e.type) { > // case SWT.MouseEnter: > // hover=true; > // redraw(); >@@ -54,15 +59,15 @@ > // hover = false; > // redraw(); > // break; >-// case SWT.KeyDown: >-// onKeyDown(e); >-// break; >-// } >-// } >-// }; >+ case SWT.KeyDown: >+ onKeyDown(e); >+ break; >+ } >+ } >+ }; > // addListener(SWT.MouseEnter, listener); > // addListener(SWT.MouseExit, listener); >-// addListener(SWT.KeyDown, listener); >+ addListener(SWT.KeyDown, listener); > addHyperlinkListener(new HyperlinkAdapter() { > public void linkActivated(HyperlinkEvent e) { > setExpanded(!isExpanded()); >@@ -157,8 +162,6 @@ > */ > public void setExpanded(boolean expanded) { > this.expanded = expanded; >-// RAP [rh] accessibility not implemented >-// getAccessible().selectionChanged(); > redraw(); > } > // RAP [rh] accessibility not implemented >@@ -224,22 +227,28 @@ > // } > // }); > // } >- >-// RAP [rh] Key events missing >-// private void onKeyDown(Event e) { >-// if (e.keyCode==SWT.ARROW_RIGHT) { >-// // expand if collapsed >-// if (!isExpanded()) { >-// handleActivate(e); >-// } >-// e.doit=false; >-// } >-// else if (e.keyCode==SWT.ARROW_LEFT) { >-// // collapse if expanded >-// if (isExpanded()) { >-// handleActivate(e); >-// } >-// e.doit=false; >-// } >+// // set bogus childIDs on link activation to ensure state is read on expand/collapse >+// void triggerAccessible() { >+// getAccessible().setFocus(getAccessibleChildID()); > // } >+// private int getAccessibleChildID() { >+// return ToggleHyperlink.this.isExpanded() ? 1 : 2; >+// } >+ >+ private void onKeyDown(Event e) { >+ if (e.keyCode==SWT.ARROW_RIGHT) { >+ // expand if collapsed >+ if (!isExpanded()) { >+ handleActivate(e); >+ } >+ e.doit=false; >+ } >+ else if (e.keyCode==SWT.ARROW_LEFT) { >+ // collapse if expanded >+ if (isExpanded()) { >+ handleActivate(e); >+ } >+ e.doit=false; >+ } >+ } > } >Index: src/org/eclipse/ui/forms/widgets/TableWrapLayout.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/TableWrapLayout.java,v >retrieving revision 1.1 >diff -u -r1.1 TableWrapLayout.java >--- src/org/eclipse/ui/forms/widgets/TableWrapLayout.java 16 Apr 2008 09:44:36 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/TableWrapLayout.java 26 Feb 2010 16:36:23 -0000 >@@ -1,11 +1,11 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation 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 >+ * Copyright (c) 2000, 2009 IBM Corporation 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: >+ * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; >@@ -108,15 +108,12 @@ > > int row; > >- int column; >- > int height; > > int totalHeight; > > public RowSpan(Control child, int column, int row) { > this.child = child; >- this.column = column; > this.row = row; > } > >Index: src/org/eclipse/ui/forms/widgets/TreeNode.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/TreeNode.java,v >retrieving revision 1.1 >diff -u -r1.1 TreeNode.java >--- src/org/eclipse/ui/forms/widgets/TreeNode.java 16 Apr 2008 09:44:36 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/TreeNode.java 26 Feb 2010 16:36:23 -0000 >@@ -1,11 +1,11 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation 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 >+ * Copyright (c) 2000, 2008 IBM Corporation 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: >+ * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; >@@ -22,6 +22,11 @@ > * The control is rendered as box with a '+' or '-' sign, depending on the > * expansion state. Focus indication is rendered around the box when the > * control has keyboard focus. >+ * <p> >+ * <dl> >+ * <dt><b>Styles:</b></dt> >+ * <dd>None</dd> >+ * </dl> > * > * @see Twistie > * @since 1.0 >Index: src/org/eclipse/ui/forms/widgets/FormToolkit.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/FormToolkit.java,v >retrieving revision 1.5 >diff -u -r1.5 FormToolkit.java >--- src/org/eclipse/ui/forms/widgets/FormToolkit.java 25 Feb 2010 09:59:53 -0000 1.5 >+++ src/org/eclipse/ui/forms/widgets/FormToolkit.java 26 Feb 2010 16:36:22 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -18,9 +18,8 @@ > import org.eclipse.swt.custom.ScrolledComposite; > import org.eclipse.swt.events.FocusAdapter; > import org.eclipse.swt.events.FocusEvent; >-// RAP [rh] Key events missing >-//import org.eclipse.swt.events.KeyAdapter; >-//import org.eclipse.swt.events.KeyEvent; >+import org.eclipse.swt.events.KeyAdapter; >+import org.eclipse.swt.events.KeyEvent; > import org.eclipse.swt.events.MouseAdapter; > import org.eclipse.swt.events.MouseEvent; > // RAP [rh] Paint events missing >@@ -98,13 +97,14 @@ > private BoldFontHolder boldFontHolder; > > private HyperlinkGroup hyperlinkGroup; >+ >+ private boolean isDisposed = false; > > /* default */ > VisibilityHandler visibilityHandler; > > /* default */ >-// RAP [rh] Key events missing >-// KeyboardHandler keyboardHandler; >+ KeyboardHandler keyboardHandler; > > // RAP [rh] Paint events missing > // private class BorderPainter implements PaintListener { >@@ -177,16 +177,15 @@ > } > } > >- // RAP [rh] key events missing >-// private static class KeyboardHandler extends KeyAdapter { >-// public void keyPressed(KeyEvent e) { >-// Widget w = e.widget; >-// if (w instanceof Control) { >-// if (e.doit) >-// FormUtil.processKey(e.keyCode, (Control) w); >-// } >-// } >-// } >+ private static class KeyboardHandler extends KeyAdapter { >+ public void keyPressed(KeyEvent e) { >+ Widget w = e.widget; >+ if (w instanceof Control) { >+ if (e.doit) >+ FormUtil.processKey(e.keyCode, (Control) w); >+ } >+ } >+ } > > private class BoldFontHolder { > private Font normalFont; >@@ -222,6 +221,9 @@ > > /** > * Creates a toolkit that is self-sufficient (will manage its own colors). >+ * <p> >+ * Clients that call this method must call {@link #dispose()} when they >+ * are finished using the toolkit. > * > */ > public FormToolkit(Display display) { >@@ -232,6 +234,9 @@ > * Creates a toolkit that will use the provided (shared) colors. The toolkit > * will dispose the colors if and only if they are <b>not</b> marked as > * shared via the <code>markShared()</code> method. >+ * <p> >+ * Clients that call this method must call {@link #dispose()} when they >+ * are finished using the toolkit. > * > * @param colors > * the shared colors >@@ -366,8 +371,7 @@ > if (text != null) > hyperlink.setText(text); > hyperlink.addFocusListener(visibilityHandler); >-// RAP [rh] Key events missing >-// hyperlink.addKeyListener(keyboardHandler); >+ hyperlink.addKeyListener(keyboardHandler); > hyperlinkGroup.add(hyperlink); > return hyperlink; > } >@@ -386,8 +390,7 @@ > ImageHyperlink hyperlink = new ImageHyperlink(parent, style > | orientation); > hyperlink.addFocusListener(visibilityHandler); >-// RAP [rh] Key events missing >-// hyperlink.addKeyListener(keyboardHandler); >+ hyperlink.addKeyListener(keyboardHandler); > hyperlinkGroup.add(hyperlink); > return hyperlink; > } >@@ -443,24 +446,21 @@ > if (ec.toggle != null) { > if (trackFocus) > ec.toggle.addFocusListener(visibilityHandler); >-// RAP [rh] Key events missing >-// if (trackKeyboard) >-// ec.toggle.addKeyListener(keyboardHandler); >+ if (trackKeyboard) >+ ec.toggle.addKeyListener(keyboardHandler); > } > if (ec.textLabel != null) { > if (trackFocus) > ec.textLabel.addFocusListener(visibilityHandler); >-// RAP [rh] Key events missing >-// if (trackKeyboard) >-// ec.textLabel.addKeyListener(keyboardHandler); >+ if (trackKeyboard) >+ ec.textLabel.addKeyListener(keyboardHandler); > } > return; > } > if (trackFocus) > control.addFocusListener(visibilityHandler); >-// RAP [rh] Key events missing >-// if (trackKeyboard) >-// control.addKeyListener(keyboardHandler); >+ if (trackKeyboard) >+ control.addKeyListener(keyboardHandler); > } > > /** >@@ -476,7 +476,8 @@ > ((Control) e.widget).setFocus(); > } > }); >- composite.setMenu(composite.getParent().getMenu()); >+ if (composite.getParent() != null) >+ composite.setMenu(composite.getParent().getMenu()); > } > > /** >@@ -518,9 +519,10 @@ > section.setTitleBarBackground(colors.getColor(IFormColors.TB_BG)); > section.setTitleBarBorderColor(colors > .getColor(IFormColors.TB_BORDER)); >- section.setTitleBarForeground(colors >- .getColor(IFormColors.TB_TOGGLE)); > } >+ // call setTitleBarForeground regardless as it also sets the label color >+ section.setTitleBarForeground(colors >+ .getColor(IFormColors.TB_TOGGLE)); > return section; > } > >@@ -714,6 +716,10 @@ > * Disposes the toolkit. > */ > public void dispose() { >+ if (isDisposed) { >+ return; >+ } >+ isDisposed = true; > if (colors.isShared() == false) { > colors.dispose(); > colors = null; >@@ -866,8 +872,7 @@ > hyperlinkGroup = new HyperlinkGroup(colors.getDisplay()); > hyperlinkGroup.setBackground(colors.getBackground()); > visibilityHandler = new VisibilityHandler(); >-// RAP [rh] Key events missing >-// keyboardHandler = new KeyboardHandler(); >+ keyboardHandler = new KeyboardHandler(); > boldFontHolder = new BoldFontHolder(); > } > >Index: src/org/eclipse/ui/forms/widgets/Hyperlink.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/Hyperlink.java,v >retrieving revision 1.3 >diff -u -r1.3 Hyperlink.java >--- src/org/eclipse/ui/forms/widgets/Hyperlink.java 20 Mar 2009 10:45:47 -0000 1.3 >+++ src/org/eclipse/ui/forms/widgets/Hyperlink.java 26 Feb 2010 16:36:22 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2007 IBM Corporation and others. >+ * Copyright (c) 2004, 2008 IBM Corporation 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 >@@ -10,13 +10,13 @@ > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; > >-import org.eclipse.rwt.graphics.Graphics; > import org.eclipse.swt.SWT; > //import org.eclipse.swt.accessibility.*; > import org.eclipse.swt.graphics.*; > import org.eclipse.swt.widgets.Composite; >+//import org.eclipse.ui.forms.FormColors; >+import org.eclipse.ui.internal.forms.widgets.*; > import org.eclipse.ui.forms.internal.widgets.IHyperlinkAdapter; >-//import org.eclipse.ui.internal.forms.widgets.*; > > /** > * Hyperlink is a concrete implementation of the abstract base class that draws >@@ -25,6 +25,11 @@ > * for all the hyperlinks that belong to it. > * <p> > * Hyperlink can be extended. >+ * <p> >+ * <dl> >+ * <dt><b>Styles:</b></dt> >+ * <dd>SWT.WRAP</dd> >+ * </dl> > * > * @see org.eclipse.ui.forms.HyperlinkGroup > */ >@@ -306,20 +311,17 @@ > // } > > protected Point computeTextSize(int wHint, int hHint) { >-// RAP [rh] Changed text size calculation due to missing GC > Point extent; >-// GC gc = new GC(this); >-// gc.setFont(getFont()); >+ GC gc = new GC(this); >+ gc.setFont(getFont()); > if ((getStyle() & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) { >-// extent = FormUtil.computeWrapSize(gc, getText(), wHint); >- extent = Graphics.textExtent( getFont(), getText(), wHint ); >+ extent = FormUtil.computeWrapSize(gc, getText(), wHint); > } else { >-// extent = gc.textExtent(getText()); >- extent = Graphics.stringExtent( getFont(), getText() ); >+ extent = gc.textExtent(getText()); > if ((getStyle() & SWT.WRAP)==0 && wHint!=SWT.DEFAULT) > extent.x = wHint; > } >-// gc.dispose(); >+ gc.dispose(); > return extent; > } > } >Index: src/org/eclipse/ui/forms/widgets/Twistie.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/Twistie.java,v >retrieving revision 1.1 >diff -u -r1.1 Twistie.java >--- src/org/eclipse/ui/forms/widgets/Twistie.java 16 Apr 2008 09:44:36 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/Twistie.java 26 Feb 2010 16:36:23 -0000 >@@ -1,11 +1,11 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation 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 >+ * Copyright (c) 2000, 2008 IBM Corporation 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: >+ * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; >@@ -24,6 +24,11 @@ > * <p> > * The control is rendered as a triangle that points to the right in the > * collapsed and down in the expanded state. Triangle color can be changed. >+ * <p> >+ * <dl> >+ * <dt><b>Styles:</b></dt> >+ * <dd>None</dd> >+ * </dl> > * > * @see TreeNode > * @since 1.0 >Index: src/org/eclipse/ui/forms/widgets/ColumnLayout.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/ColumnLayout.java,v >retrieving revision 1.1 >diff -u -r1.1 ColumnLayout.java >--- src/org/eclipse/ui/forms/widgets/ColumnLayout.java 16 Apr 2008 09:44:36 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/ColumnLayout.java 26 Feb 2010 16:36:22 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -8,6 +8,7 @@ > * Contributors: > * IBM Corporation - initial API and implementation > * dinko.ivanov@sap.com - patch #70790 >+ * RasmussenJamie@comcast.net - patch for Bug 184345 > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; > import org.eclipse.swt.SWT; >@@ -185,7 +186,7 @@ > cwidth = Math.max(cwidth, sizes[i].x); > cheight += sizes[i].y; > } >- int ncolumns = (carea.width - leftMargin - rightMargin - horizontalSpacing) / (cwidth + horizontalSpacing); >+ int ncolumns = (carea.width - leftMargin - rightMargin + horizontalSpacing) / (cwidth + horizontalSpacing); > ncolumns = Math.min(ncolumns, children.length); > ncolumns = Math.max(ncolumns, minNumColumns); > ncolumns = Math.min(ncolumns, maxNumColumns); >Index: src/org/eclipse/ui/forms/widgets/TableWrapData.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/TableWrapData.java,v >retrieving revision 1.1 >diff -u -r1.1 TableWrapData.java >--- src/org/eclipse/ui/forms/widgets/TableWrapData.java 16 Apr 2008 09:44:36 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/TableWrapData.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -14,7 +14,7 @@ > import org.eclipse.swt.graphics.Point; > > /** >- * Layout data used in conjunction with <code>HTMLTableLayout</code>. >+ * Layout data used in conjunction with <code>TableWrapLayout</code>. > * Children in a composite that uses this layout should call <samp>setLayoutData > * </samp> and pass an instance of this class to control physical placement in > * the parent. >Index: src/org/eclipse/ui/forms/widgets/ScrolledForm.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/ScrolledForm.java,v >retrieving revision 1.1 >diff -u -r1.1 ScrolledForm.java >--- src/org/eclipse/ui/forms/widgets/ScrolledForm.java 16 Apr 2008 09:44:35 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/ScrolledForm.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -12,12 +12,15 @@ > > import org.eclipse.jface.action.IToolBarManager; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.ui.forms.IMessage; >+import org.eclipse.ui.forms.IMessageManager; > > /** > * ScrolledForm is a control that is capable of scrolling an instance of the >@@ -43,9 +46,12 @@ > * Although the class is not final, it is not expected to be be extended. > * > * @since 1.0 >+ * @noextend This class is not intended to be subclassed by clients. > */ > public class ScrolledForm extends SharedScrolledComposite { > private Form content; >+ >+ private boolean customMenu; > > public ScrolledForm(Composite parent) { > this(parent, SWT.V_SCROLL | SWT.H_SCROLL); >@@ -63,6 +69,12 @@ > content = new Form(this, SWT.NULL); > super.setContent(content); > content.setMenu(getMenu()); >+ addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ if (!customMenu) >+ setMenu(null); >+ } >+ }); > } > > /** >@@ -71,6 +83,7 @@ > * @param menu > */ > public void setMenu(Menu menu) { >+ customMenu = true; > super.setMenu(menu); > if (content != null) > content.setMenu(menu); >@@ -253,11 +266,14 @@ > reflow(true); > } > >- /* >- * (non-Javadoc) >+ /** >+ * Sets the form message. > * >- * @see org.eclipse.ui.forms.IMessageContainer#setMessage(java.lang.String, >- * int) >+ * @param newMessage >+ * the message text or <code>null</code> to reset. >+ * @param newType >+ * as defined in >+ * {@link org.eclipse.jface.dialogs.IMessageProvider}. > */ > public void setMessage(String newMessage, int newType) { > this.setMessage(newMessage, newType, null); >@@ -280,4 +296,14 @@ > public int getMessageType() { > return content.getMessageType(); > } >+ >+ /** >+ * Returns the message manager that will keep track of messages in this >+ * form. >+ * >+ * @return the message manager instance >+ */ >+ public IMessageManager getMessageManager() { >+ return content.getMessageManager(); >+ } > } >Index: src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java,v >retrieving revision 1.1 >diff -u -r1.1 SharedScrolledComposite.java >--- src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java 16 Apr 2008 09:44:36 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java 26 Feb 2010 16:36:23 -0000 >@@ -1,12 +1,14 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation 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 >+ * Copyright (c) 2000, 2009 IBM Corporation 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: >+ * Contributors: > * IBM Corporation - initial API and implementation >+ * Wojciech Galanciak - fix for Bug 294868 - [Forms] Problem with text >+ * wrapping in SharedScrolledComposite: > *******************************************************************************/ > package org.eclipse.ui.forms.widgets; > >@@ -48,7 +50,7 @@ > > private boolean reflowPending = false; > >- private boolean delayedReflow = true; >+ private boolean delayedReflow = false; > > /** > * Creates the new instance. >@@ -179,43 +181,44 @@ > Rectangle clientArea = getClientArea(); > if (c == null) > return; >+// RAP [if] No scrollbars >+// if (clientArea.width == getSize().x) { >+// ScrollBar bar = getVerticalBar(); >+// if (bar != null) { >+// clientArea.width -= bar.getSize().x; >+// } >+// } > > contentCache.setControl(c); > if (flushCache) { > contentCache.flush(); > } >- try { >- setRedraw(false); >- Point newSize = contentCache.computeSize(FormUtil.getWidthHint( >- clientArea.width, c), FormUtil.getHeightHint(clientArea.height, >- c)); >+ Point newSize = contentCache.computeSize(FormUtil.getWidthHint( >+ clientArea.width, c), FormUtil.getHeightHint(clientArea.height, >+ c)); > >- // Point currentSize = c.getSize(); >- if (!(expandHorizontal && expandVertical)) { >- c.setSize(newSize); >- } >+ if (!(expandHorizontal && expandVertical)) { >+ c.setSize(newSize); >+ } > >- setMinSize(newSize); >- FormUtil.updatePageIncrement(this); >+ setMinSize(newSize); >+ FormUtil.updatePageIncrement(this); > >- // reduce vertical scroll increment if necessary >+ // reduce vertical scroll increment if necessary > // RAP [rh] Scrollbar#setIncrement() missing >-// ScrollBar vbar = getVerticalBar(); >-// if (vbar != null) { >-// if (getClientArea().height - 5 < V_SCROLL_INCREMENT) >-// getVerticalBar().setIncrement(getClientArea().height - 5); >-// else >-// getVerticalBar().setIncrement(V_SCROLL_INCREMENT); >-// } >+// ScrollBar vbar = getVerticalBar(); >+// if (vbar != null) { >+// if (getClientArea().height - 5 < V_SCROLL_INCREMENT) >+// getVerticalBar().setIncrement(getClientArea().height - 5); >+// else >+// getVerticalBar().setIncrement(V_SCROLL_INCREMENT); >+// } > >- ignoreLayouts = false; >- layout(flushCache); >- ignoreLayouts = true; >+ ignoreLayouts = false; >+ layout(flushCache); >+ ignoreLayouts = true; > >- contentCache.layoutIfNecessary(); >- } finally { >- setRedraw(true); >- } >+ contentCache.layoutIfNecessary(); > } > > private void updateSizeWhilePending() { >@@ -230,14 +233,14 @@ > updateSizeWhilePending(); > return; > } >+ reflowPending = true; > getDisplay().asyncExec(new Runnable() { > public void run() { >+ reflowPending = false; > if (!isDisposed()) > reflow(flushCache); >- reflowPending = false; > } > }); >- reflowPending = true; > } else > reflow(flushCache); > } >@@ -268,8 +271,8 @@ > * Sets the delayed reflow feature. When used, > * it will schedule a reflow on resize requests > * and reject subsequent reflows until the >- * scheduled one is performed. This improves >- * performance by >+ * scheduled one is performed. >+ * > * @param delayedReflow > * The delayedReflow to set. > */ >Index: src/org/eclipse/ui/forms/widgets/Section.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/Section.java,v >retrieving revision 1.12 >diff -u -r1.12 Section.java >--- src/org/eclipse/ui/forms/widgets/Section.java 18 Jan 2010 10:12:58 -0000 1.12 >+++ src/org/eclipse/ui/forms/widgets/Section.java 26 Feb 2010 16:36:23 -0000 >@@ -1,11 +1,11 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation 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 >+ * Copyright (c) 2000, 2009 IBM Corporation 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: >+ * Contributors: > * IBM Corporation - initial API and implementation > * Michael Williamson (eclipse-bugs@magnaworks.com) - patch (see Bugzilla #92545) > * >@@ -27,6 +27,7 @@ > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Listener; >+import org.eclipse.swt.widgets.Shell; > import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.internal.forms.widgets.FormImages; > //import org.eclipse.ui.internal.forms.widgets.FormUtil; >@@ -130,7 +131,7 @@ > while (c != null) { > c.setRedraw(false); > c = c.getParent(); >- if (c instanceof SharedScrolledComposite) { >+ if (c instanceof SharedScrolledComposite || c instanceof Shell) { > break; > } > } >@@ -147,7 +148,7 @@ > while (c != null) { > c.setRedraw(true); > c = c.getParent(); >- if (c instanceof SharedScrolledComposite) { >+ if (c instanceof SharedScrolledComposite || c instanceof Shell) { > break; > } > } >Index: src/org/eclipse/ui/forms/widgets/ColumnLayoutData.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/widgets/ColumnLayoutData.java,v >retrieving revision 1.1 >diff -u -r1.1 ColumnLayoutData.java >--- src/org/eclipse/ui/forms/widgets/ColumnLayoutData.java 16 Apr 2008 09:44:33 -0000 1.1 >+++ src/org/eclipse/ui/forms/widgets/ColumnLayoutData.java 26 Feb 2010 16:36:22 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -37,11 +37,11 @@ > */ > public static final int LEFT = 1; > /** >- * Horizontal alignment constant - control will be aligned to the right. >+ * Horizontal alignment constant - control will be centered. > */ > public static final int CENTER = 2; > /** >- * Horizontal alignment constant - control will be centered. >+ * Horizontal alignment constant - control will be aligned to the right. > */ > public static final int RIGHT = 3; > /** >Index: src/org/eclipse/ui/internal/forms/widgets/Paragraph.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/Paragraph.java,v >retrieving revision 1.3 >diff -u -r1.3 Paragraph.java >--- src/org/eclipse/ui/internal/forms/widgets/Paragraph.java 25 Feb 2010 13:53:11 -0000 1.3 >+++ src/org/eclipse/ui/internal/forms/widgets/Paragraph.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -12,6 +12,7 @@ > > import java.io.*; > import java.util.ArrayList; >+import java.util.Arrays; > import java.util.Hashtable; > import java.util.Vector; > >@@ -23,7 +24,7 @@ > * @author > */ > public class Paragraph { >- public static final String HTTP = "http://"; //$NON-NLS-1$ >+ public static final String[] PROTOCOLS = {"http://", "https://", "ftp://"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > > private Vector segments; > >@@ -67,7 +68,7 @@ > if (text.length() == 0) > return; > if (expandURLs) { >- int loc = text.indexOf(HTTP); >+ int loc = findUrl(text,0); > > if (loc == -1) > addSegment(new TextSegment(text, fontId, colorId, wrapAllowed)); >@@ -92,7 +93,7 @@ > fontId); > break; > } >- loc = text.indexOf(HTTP, textLoc); >+ loc = findUrl(text,textLoc); > } > if (textLoc < text.length()) { > addSegment(new TextSegment(text.substring(textLoc), fontId, >@@ -103,6 +104,17 @@ > addSegment(new TextSegment(text, fontId, colorId, wrapAllowed)); > } > } >+ >+ private int findUrl(String text, int startIndex) { >+ int[] locs = new int[PROTOCOLS.length]; >+ for (int i = 0; i < PROTOCOLS.length; i++) >+ locs[i] = text.indexOf(PROTOCOLS[i], startIndex); >+ Arrays.sort(locs); >+ for (int i = 0; i < PROTOCOLS.length; i++) >+ if (locs[i] != -1) >+ return locs[i]; >+ return -1; >+ } > > private void addHyperlinkSegment(String text, HyperlinkSettings settings, > String fontId) { >@@ -121,10 +133,9 @@ > ArrayList heights = new ArrayList(); > hloc.heights = heights; > hloc.rowCounter = 0; >- int innerWidth = width - loc.marginWidth*2; > for (int j = 0; j < segments.length; j++) { > ParagraphSegment segment = segments[j]; >- segment.advanceLocator(gc, innerWidth, hloc, resourceTable, true); >+ segment.advanceLocator(gc, width, hloc, resourceTable, true); > } > hloc.collectHeights(); > loc.heights = heights; >Index: src/org/eclipse/ui/internal/forms/widgets/TextHyperlinkSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/TextHyperlinkSegment.java,v >retrieving revision 1.2 >diff -u -r1.2 TextHyperlinkSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/TextHyperlinkSegment.java 16 Mar 2009 10:12:31 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/TextHyperlinkSegment.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >Index: src/org/eclipse/ui/internal/forms/widgets/FormImages.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormImages.java,v >retrieving revision 1.1 >diff -u -r1.1 FormImages.java >--- src/org/eclipse/ui/internal/forms/widgets/FormImages.java 16 Apr 2008 09:44:27 -0000 1.1 >+++ src/org/eclipse/ui/internal/forms/widgets/FormImages.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation 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 >@@ -7,16 +7,22 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Wang Yizhuo (wangyizhuo@gmail.com) - patch (see Bugzilla #239178) > *******************************************************************************/ > package org.eclipse.ui.internal.forms.widgets; > > //import java.util.Arrays; > import java.util.HashMap; > >+import org.eclipse.jface.resource.ImageDescriptor; >+//import org.eclipse.jface.resource.JFaceResources; >+//import org.eclipse.jface.resource.LocalResourceManager; > import org.eclipse.swt.graphics.Color; >+//import org.eclipse.swt.graphics.Device; > //import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.widgets.Display; >+//import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.graphics.RGB; > > public class FormImages { > private static FormImages instance; >@@ -27,30 +33,32 @@ > return instance; > } > >- private HashMap images; >- private HashMap ids; >+// private LocalResourceManager resources; >+ private HashMap descriptors; > > private FormImages() { > } > >- private abstract class ImageIdentifier { >- Display fDisplay; >- Color[] fColors; >+ private abstract class AbstractImageDescriptor extends ImageDescriptor { >+ RGB[] fRGBs; > int fLength; > >- ImageIdentifier(Display display, Color[] colors, int length) { >- fDisplay = display; >- fColors = colors; >+ AbstractImageDescriptor(Color[] colors, int length) { >+ fRGBs = new RGB[colors.length]; >+ for (int i = 0; i < colors.length; i++) { >+ Color color = colors[i]; >+ fRGBs[i] = color == null ? null : color.getRGB(); >+ } > fLength = length; > } > > public boolean equals(Object obj) { >- if (obj instanceof ImageIdentifier) { >- ImageIdentifier id = (ImageIdentifier)obj; >- if (id.fColors.length == fColors.length) { >- boolean result = id.fDisplay.equals(fDisplay) && id.fLength == fLength; >- for (int i = 0; i < fColors.length && result; i++) { >- result = result && id.fColors[i].equals(fColors[i]); >+ if (obj instanceof AbstractImageDescriptor) { >+ AbstractImageDescriptor id = (AbstractImageDescriptor)obj; >+ if (id.fRGBs.length == fRGBs.length) { >+ boolean result = id.fLength == fLength; >+ for (int i = 0; i < fRGBs.length && result; i++) { >+ result = result && id.fRGBs[i].equals(fRGBs[i]); > } > return result; > } >@@ -59,29 +67,29 @@ > } > > public int hashCode() { >- int hash = fDisplay.hashCode(); >- for (int i = 0; i < fColors.length; i++) >- hash = hash * 7 + fColors[i].hashCode(); >+ int hash = 0; >+ for (int i = 0; i < fRGBs.length; i++) >+ hash = hash * 7 + fRGBs[i].hashCode(); > hash = hash * 7 + fLength; > return hash; > } > } >- >-// RAP [rh] Unused code: was used by getGradient >-// private class SimpleImageIdentifier extends ImageIdentifier{ >+ >+// RAP [if] Unused code: was used by getGradient >+// private class SimpleImageDescriptor extends AbstractImageDescriptor{ > // private int fTheight; > // private int fMarginHeight; > // >-// SimpleImageIdentifier (Display display, Color color1, Color color2, >+// SimpleImageDescriptor (Color color1, Color color2, > // int realtheight, int theight, int marginHeight) { >-// super(display, new Color[] {color1, color2}, realtheight); >+// super(new Color[] {color1, color2}, realtheight); > // fTheight = theight; > // fMarginHeight = marginHeight; > // } > // > // public boolean equals(Object obj) { >-// if (obj instanceof SimpleImageIdentifier) { >-// SimpleImageIdentifier id = (SimpleImageIdentifier) obj; >+// if (obj instanceof SimpleImageDescriptor) { >+// SimpleImageDescriptor id = (SimpleImageDescriptor) obj; > // if (super.equals(obj) && > // id.fTheight == fTheight && id.fMarginHeight == fMarginHeight) > // return true; >@@ -95,28 +103,49 @@ > // hash = hash * 7 + new Integer(fMarginHeight).hashCode(); > // return hash; > // } >+// >+// public ImageData getImageData() { >+// return null; >+// } >+// >+// public Image createImage(boolean returnMissingImageOnError, Device device) { >+// Image image = new Image(device, 1, fLength); >+// Color color1 = new Color(device, fRGBs[0]); >+// Color color2 = new Color(device, fRGBs[1]); >+// image.setBackground(color1); >+// GC gc = new GC(image); >+// gc.setBackground(color1); >+// gc.fillRectangle(0, 0, 1, fLength); >+// gc.setForeground(color2); >+// gc.setBackground(color1); >+// gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true); >+// gc.dispose(); >+// color1.dispose(); >+// color2.dispose(); >+// return image; >+// } > // } >-// >-// private class ComplexImageIdentifier extends ImageIdentifier { >-// Color fBg; >+ >+// private class ComplexImageDescriptor extends AbstractImageDescriptor { >+// RGB fBgRGB; > // boolean fVertical; > // int[] fPercents; > // >-// public ComplexImageIdentifier(Display display, Color[] colors, int length, >+// public ComplexImageDescriptor(Color[] colors, int length, > // int[] percents, boolean vertical, Color bg) { >-// super(display, colors, length); >-// fBg = bg; >+// super(colors, length); >+// fBgRGB = bg == null ? null : bg.getRGB(); > // fVertical = vertical; > // fPercents = percents; > // } > // > // public boolean equals(Object obj) { >-// if (obj instanceof ComplexImageIdentifier) { >-// ComplexImageIdentifier id = (ComplexImageIdentifier) obj; >+// if (obj instanceof ComplexImageDescriptor) { >+// ComplexImageDescriptor id = (ComplexImageDescriptor) obj; > // if (super.equals(obj) && > // id.fVertical == fVertical && Arrays.equals(id.fPercents, fPercents)) { >-// if ((id.fBg == null && fBg == null) || >-// (id.fBg != null && id.fBg.equals(fBg))) >+// if ((id.fBgRGB == null && fBgRGB == null) || >+// (id.fBgRGB != null && id.fBgRGB.equals(fBgRGB))) > // return true; > // // if the only thing that isn't the same is the background color > // // still return true if it does not matter (percents add up to 100) >@@ -137,168 +166,138 @@ > // hash = hash * 7 + new Integer(fPercents[i]).hashCode(); > // return hash; > // } >+// >+// public ImageData getImageData() { >+// return null; >+// } >+// >+// public Image createImage(boolean returnMissingImageOnError, Device device) { >+// int width = fVertical ? 1 : fLength; >+// int height = fVertical ? fLength : 1; >+// Image gradient = new Image(device, Math.max(width, 1), Math >+// .max(height, 1)); >+// GC gc = new GC(gradient); >+// Color[] colors = new Color[fRGBs.length]; >+// for (int i = 0; i < colors.length; i++) >+// colors[i] = new Color(device, fRGBs[i]); >+// Color bg = fBgRGB == null ? null : new Color(device, fBgRGB); >+// drawTextGradient(gc, width, height, colors, fPercents, fVertical, bg); >+// gc.dispose(); >+// for (int i = 0; i < colors.length; i++) >+// colors[i].dispose(); >+// if (bg != null) >+// bg.dispose(); >+// return gradient; >+// } >+// >+// private void drawTextGradient(GC gc, int width, int height, Color[] colors, >+// int[] percents, boolean vertical, Color bg) { >+// final Color oldBackground = gc.getBackground(); >+// if (colors.length == 1) { >+// if (colors[0] != null) >+// gc.setBackground(colors[0]); >+// gc.fillRectangle(0, 0, width, height); >+// } else { >+// final Color oldForeground = gc.getForeground(); >+// Color lastColor = colors[0]; >+// if (lastColor == null) >+// lastColor = oldBackground; >+// int pos = 0; >+// for (int i = 0; i < percents.length; ++i) { >+// gc.setForeground(lastColor); >+// lastColor = colors[i + 1]; >+// if (lastColor == null) >+// lastColor = oldBackground; >+// gc.setBackground(lastColor); >+// if (vertical) { >+// int gradientHeight = percents[i] * height / 100; >+// >+// gc.fillGradientRectangle(0, pos, width, gradientHeight, >+// true); >+// pos += gradientHeight; >+// } else { >+// int gradientWidth = percents[i] * width / 100; >+// >+// gc.fillGradientRectangle(pos, 0, gradientWidth, height, >+// false); >+// pos += gradientWidth; >+// } >+// } >+// if (vertical && pos < height) { >+// if (bg != null) >+// gc.setBackground(bg); >+// gc.fillRectangle(0, pos, width, height - pos); >+// } >+// if (!vertical && pos < width) { >+// if (bg != null) >+// gc.setBackground(bg); >+// gc.fillRectangle(pos, 0, width - pos, height); >+// } >+// gc.setForeground(oldForeground); >+// } >+// } > // } > >- private class ImageReference { >- private Image fImage; >- private int fCount; >- >- public ImageReference(Image image) { >- fImage = image; >- fCount = 1; >- } >- >- public Image getImage() { >- return fImage; >- } >- // returns a boolean indicating if all clients of this image are finished >- // a true result indicates the underlying image should be disposed >- public boolean decCount() { >- return --fCount == 0; >- } >- public void incCount() { >- fCount++; >- } >- } >- >-// RAP [rh] missing Image-GC >-// public Image getGradient(Display display, Color color1, Color color2, >+// public Image getGradient(Color color1, Color color2, > // int realtheight, int theight, int marginHeight) { >-// checkHashMaps(); >-// ImageIdentifier id = new SimpleImageIdentifier(display, color1, color2, realtheight, theight, marginHeight); >-// ImageReference result = (ImageReference) images.get(id); >-// if (result != null && !result.getImage().isDisposed()) { >-// result.incCount(); >-// return result.getImage(); >-// } >-// Image image = createGradient(display, color1, color2, realtheight, theight, marginHeight); >-// images.put(id, new ImageReference(image)); >-// ids.put(image, id); >-// return image; >+// if (color1 == null || color1.isDisposed() || color2 == null || color2.isDisposed()) >+// return null; >+// AbstractImageDescriptor desc = new SimpleImageDescriptor(color1, color2, realtheight, theight, marginHeight); >+// return getGradient(desc); > // } >-// >-// public Image getGradient(Display display, Color[] colors, int[] percents, >+ >+// public Image getGradient(Color[] colors, int[] percents, > // int length, boolean vertical, Color bg) { >+// if (colors.length == 0) >+// return null; >+// for (int i = 0; i < colors.length; i++) >+// if (colors[i] == null || colors[i].isDisposed()) >+// return null; >+// if (bg != null && bg.isDisposed()) >+// return null; >+// AbstractImageDescriptor desc = new ComplexImageDescriptor(colors, length, percents, vertical, bg); >+// return getGradient(desc); >+// } >+ >+// private synchronized Image getGradient(AbstractImageDescriptor desc) { > // checkHashMaps(); >-// ImageIdentifier id = new ComplexImageIdentifier(display, colors, length, percents, vertical, bg); >-// ImageReference result = (ImageReference) images.get(id); >-// if (result != null && !result.getImage().isDisposed()) { >-// result.incCount(); >-// return result.getImage(); >-// } >-// Image image = createGradient(display, colors, percents, length, vertical, bg); >-// images.put(id, new ImageReference(image)); >-// ids.put(image, id); >-// return image; >+// Image result = getResourceManager().createImage(desc); >+// descriptors.put(result, desc); >+// return result; > // } > >- public boolean markFinished(Image image) { >+ public synchronized boolean markFinished(Image image) { > checkHashMaps(); >- ImageIdentifier id = (ImageIdentifier)ids.get(image); >- if (id != null) { >- ImageReference ref = (ImageReference) images.get(id); >- if (ref != null) { >- if (ref.decCount()) { >- images.remove(id); >- ids.remove(ref.getImage()); >-// RAP [rh] no Image#dispose() API >-// ref.getImage().dispose(); >- validateHashMaps(); >- } >- return true; >- } >+ AbstractImageDescriptor desc = (AbstractImageDescriptor)descriptors.get(image); >+ if (desc != null) { >+// RAP [if] unnecessary to destroy image >+// getResourceManager().destroyImage(desc); >+// if (getResourceManager().find(desc) == null) { >+ descriptors.remove(image); >+ validateHashMaps(); >+// } >+ return true; > } > // if the image was not found, dispose of it for the caller >-// RAP [rh] no Image#dispose() API >+// RAP [if] unnecessary > // image.dispose(); > return false; > } > >+// RAP [if] unused >+// private LocalResourceManager getResourceManager() { >+// if (resources == null) >+// resources = new LocalResourceManager(JFaceResources.getResources()); >+// return resources; >+// } >+ > private void checkHashMaps() { >- if (images == null) >- images = new HashMap(); >- if (ids == null) >- ids = new HashMap(); >+ if (descriptors == null) >+ descriptors = new HashMap(); > } > > private void validateHashMaps() { >- if (images.size() == 0) >- images = null; >- if (ids.size() == 0) >- ids = null; >+ if (descriptors.size() == 0) >+ descriptors = null; > } >- >-// RAP [rh] Disabled unused code, called by getGradient >-// private Image createGradient(Display display, Color color1, Color color2, >-// int realtheight, int theight, int marginHeight) { >-// Image image = new Image(display, 1, realtheight); >-// image.setBackground(color1); >-// GC gc = new GC(image); >-// gc.setBackground(color1); >-// gc.fillRectangle(0, 0, 1, realtheight); >-// gc.setForeground(color2); >-// gc.setBackground(color1); >-// gc.fillGradientRectangle(0, marginHeight + 2, 1, theight - 2, true); >-// gc.dispose(); >-// return image; >-// } >-// >-// private Image createGradient(Display display, Color[] colors, int[] percents, >-// int length, boolean vertical, Color bg) { >-// int width = vertical ? 1 : length; >-// int height = vertical ? length : 1; >-// Image gradient = new Image(display, Math.max(width, 1), Math >-// .max(height, 1)); >-// GC gc = new GC(gradient); >-// drawTextGradient(gc, width, height, colors, percents, vertical, bg); >-// gc.dispose(); >-// return gradient; >-// } >-// >-// private void drawTextGradient(GC gc, int width, int height, Color[] colors, >-// int[] percents, boolean vertical, Color bg) { >-// final Color oldBackground = gc.getBackground(); >-// if (colors.length == 1) { >-// if (colors[0] != null) >-// gc.setBackground(colors[0]); >-// gc.fillRectangle(0, 0, width, height); >-// } else { >-// final Color oldForeground = gc.getForeground(); >-// Color lastColor = colors[0]; >-// if (lastColor == null) >-// lastColor = oldBackground; >-// int pos = 0; >-// for (int i = 0; i < percents.length; ++i) { >-// gc.setForeground(lastColor); >-// lastColor = colors[i + 1]; >-// if (lastColor == null) >-// lastColor = oldBackground; >-// gc.setBackground(lastColor); >-// if (vertical) { >-// int gradientHeight = percents[i] * height / 100; >-// >-// gc.fillGradientRectangle(0, pos, width, gradientHeight, >-// true); >-// pos += gradientHeight; >-// } else { >-// int gradientWidth = percents[i] * height / 100; >-// >-// gc.fillGradientRectangle(pos, 0, gradientWidth, height, >-// false); >-// pos += gradientWidth; >-// } >-// } >-// if (vertical && pos < height) { >-// if (bg != null) >-// gc.setBackground(bg); >-// gc.fillRectangle(0, pos, width, height - pos); >-// } >-// if (!vertical && pos < width) { >-// if (bg != null) >-// gc.setBackground(bg); >-// gc.fillRectangle(pos, 0, width - pos, height); >-// } >-// gc.setForeground(oldForeground); >-// } >-// } > } >Index: src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java,v >retrieving revision 1.3 >diff -u -r1.3 ObjectSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java 25 Feb 2010 13:53:11 -0000 1.3 >+++ src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -57,14 +57,14 @@ > iwidth = objectSize.x + (isSelectable()?2:0); > iheight = objectSize.y + (isSelectable()?2:0); > } >- if (wHint != SWT.DEFAULT && !nowrap && loc.x + iwidth > wHint) { >+ if (wHint != SWT.DEFAULT && !nowrap && loc.x + iwidth + loc.marginWidth > wHint) { > // new line > if (computeHeightOnly) > loc.collectHeights(); >- loc.x = loc.indent; >+ loc.resetCaret(); > loc.x += iwidth; > loc.y += loc.rowHeight; >- loc.width = loc.indent + iwidth; >+ loc.width = loc.x; > loc.rowHeight = iheight; > loc.leading = 0; > newLine = true; >@@ -126,7 +126,7 @@ > return; > loc.width = objWidth; > >- if (!nowrap && loc.x + objWidth > width) { >+ if (!nowrap && loc.x + objWidth + loc.marginWidth > width) { > // new row > loc.newLine(); > loc.rowCounter++; >Index: src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java,v >retrieving revision 1.3 >diff -u -r1.3 TitleRegion.java >--- src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java 25 Feb 2010 13:53:11 -0000 1.3 >+++ src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java 26 Feb 2010 16:36:24 -0000 >@@ -10,9 +10,10 @@ > *******************************************************************************/ > package org.eclipse.ui.internal.forms.widgets; > >+import org.eclipse.rwt.graphics.Graphics; >+ > import org.eclipse.jface.action.IMenuManager; > import org.eclipse.jface.action.MenuManager; >-import org.eclipse.rwt.graphics.Graphics; > import org.eclipse.swt.SWT; > import org.eclipse.swt.dnd.DragSource; > import org.eclipse.swt.dnd.DragSourceEffect; >Index: src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java,v >retrieving revision 1.4 >diff -u -r1.4 AggregateHyperlinkSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java 25 Feb 2010 13:53:11 -0000 1.4 >+++ src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java 26 Feb 2010 16:36:23 -0000 >@@ -15,9 +15,9 @@ > > // RAP [if] unnecessary > //import org.eclipse.swt.graphics.Color; >-import org.eclipse.rwt.Adaptable; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.rwt.Adaptable; > import org.eclipse.ui.forms.internal.widgets.IAggregateHyperlinkSegmentAdapter; > > /** >Index: src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java,v >retrieving revision 1.2 >diff -u -r1.2 FormTextModel.java >--- src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java 16 Mar 2009 10:12:31 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -26,10 +26,28 @@ > import org.w3c.dom.NamedNodeMap; > import org.w3c.dom.Node; > import org.w3c.dom.NodeList; >+import org.xml.sax.ErrorHandler; > import org.xml.sax.InputSource; > import org.xml.sax.SAXException; >+import org.xml.sax.SAXParseException; > > public class FormTextModel { >+ >+ /* >+ * This class prevents parse errors from being written to standard output >+ */ >+ public class ParseErrorHandler implements ErrorHandler { >+ >+ public void error(SAXParseException arg0) throws SAXException { >+ } >+ >+ public void fatalError(SAXParseException arg0) throws SAXException { >+ } >+ >+ public void warning(SAXParseException arg0) throws SAXException { >+ } >+ } >+ > private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory > .newInstance(); > >@@ -105,13 +123,14 @@ > try { > DocumentBuilder parser = documentBuilderFactory > .newDocumentBuilder(); >+ parser.setErrorHandler(new ParseErrorHandler()); > InputSource source = new InputSource(is); > Document doc = parser.parse(source); > processDocument(doc, expandURLs); > } catch (ParserConfigurationException e) { >- SWT.error(SWT.ERROR_INVALID_ARGUMENT, e); >+ SWT.error(SWT.ERROR_INVALID_ARGUMENT, e, " " + e.getMessage()); //$NON-NLS-1$ > } catch (SAXException e) { >- SWT.error(SWT.ERROR_INVALID_ARGUMENT, e); >+ SWT.error(SWT.ERROR_INVALID_ARGUMENT, e, " " + e.getMessage()); //$NON-NLS-1$ > } catch (IOException e) { > SWT.error(SWT.ERROR_IO, e); > } >Index: src/org/eclipse/ui/internal/forms/widgets/BusyIndicator.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/BusyIndicator.java,v >retrieving revision 1.1 >diff -u -r1.1 BusyIndicator.java >--- src/org/eclipse/ui/internal/forms/widgets/BusyIndicator.java 16 Apr 2008 09:44:28 -0000 1.1 >+++ src/org/eclipse/ui/internal/forms/widgets/BusyIndicator.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2009 IBM Corporation 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 >@@ -18,160 +18,36 @@ > import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; > import org.eclipse.jface.resource.ImageDescriptor; >-//import org.eclipse.swt.SWT; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.DisposeEvent; >+import org.eclipse.swt.events.DisposeListener; > //import org.eclipse.swt.events.PaintEvent; > //import org.eclipse.swt.events.PaintListener; > //import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; >-//import org.eclipse.swt.graphics.ImageData; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >-import org.eclipse.swt.widgets.*; >+import org.eclipse.swt.widgets.Label; >+import org.eclipse.swt.widgets.Composite; >+//import org.eclipse.swt.widgets.Display; > import org.osgi.framework.Bundle; > > // RAP [rh] Changed class hierarchy: now extends Label instead of Canvas > // public final class BusyIndicator extends Canvas { > public final class BusyIndicator extends Label { > >-// class BusyThread extends Thread { >-// Rectangle bounds; >-// Display display; >-// GC offScreenImageGC; >-// Image offScreenImage; >-// Image timage; >-// boolean stop; >-// >-// private BusyThread(Rectangle bounds, Display display, GC offScreenImageGC, Image offScreenImage) { >-// this.bounds = bounds; >-// this.display = display; >-// this.offScreenImageGC = offScreenImageGC; >-// this.offScreenImage = offScreenImage; >-// } >-// >-// public void run() { >-// try { >-// /* >-// * Create an off-screen image to draw on, and fill it with >-// * the shell background. >-// */ >-// FormUtil.setAntialias(offScreenImageGC, SWT.ON); >-// display.syncExec(new Runnable() { >-// public void run() { >-// if (!isDisposed()) >-// drawBackground(offScreenImageGC, 0, 0, >-// bounds.width, >-// bounds.height); >-// } >-// }); >-// if (isDisposed()) >-// return; >-// >-// /* >-// * Create the first image and draw it on the off-screen >-// * image. >-// */ >-// int imageDataIndex = 0; >-// ImageData imageData; >-// synchronized (BusyIndicator.this) { >-// timage = getImage(imageDataIndex); >-// imageData = timage.getImageData(); >-// offScreenImageGC.drawImage(timage, 0, 0, >-// imageData.width, imageData.height, imageData.x, >-// imageData.y, imageData.width, imageData.height); >-// } >-// >-// /* >-// * Now loop through the images, creating and drawing >-// * each one on the off-screen image before drawing it on >-// * the shell. >-// */ >-// while (!stop && !isDisposed() && timage != null) { >-// >-// /* >-// * Fill with the background color before >-// * drawing. >-// */ >-// final ImageData fimageData = imageData; >-// display.syncExec(new Runnable() { >-// public void run() { >-// if (!isDisposed()) { >-// drawBackground(offScreenImageGC, fimageData.x, >-// fimageData.y, fimageData.width, >-// fimageData.height); >-// } >-// } >-// }); >-// >-// synchronized (BusyIndicator.this) { >-// imageDataIndex = (imageDataIndex + 1) % IMAGE_COUNT; >-// timage = getImage(imageDataIndex); >-// imageData = timage.getImageData(); >-// offScreenImageGC.drawImage(timage, 0, 0, >-// imageData.width, imageData.height, >-// imageData.x, imageData.y, imageData.width, >-// imageData.height); >-// } >-// >-// /* Draw the off-screen image to the shell. */ >-// animationImage = offScreenImage; >-// display.syncExec(new Runnable() { >-// public void run() { >-// if (!isDisposed()) >-// redraw(); >-// } >-// }); >-// /* >-// * Sleep for the specified delay time >-// */ >-// try { >-// Thread.sleep(MILLISECONDS_OF_DELAY); >-// } catch (InterruptedException e) { >-// e.printStackTrace(); >-// } >-// >-// >-// } >-// } catch (Exception e) { >-// } finally { >-// display.syncExec(new Runnable() { >-// public void run() { >-// if (offScreenImage != null >-// && !offScreenImage.isDisposed()) >-// offScreenImage.dispose(); >-// if (offScreenImageGC != null >-// && !offScreenImageGC.isDisposed()) >-// offScreenImageGC.dispose(); >-// } >-// }); >-// clearImages(); >-// } >-// if (busyThread == null) >-// display.syncExec(new Runnable() { >-// public void run() { >-// animationImage = null; >-// if (!isDisposed()) >-// redraw(); >-// } >-// }); >-// } >-// >-// public void setStop(boolean stop) { >-// this.stop = stop; >-// } >-// } >- > private static final int MARGIN = 0; > // RAP [rh] instead of manually animating 8 png images, RAP uses one animated gif > // private static final int IMAGE_COUNT = 8; > private static final int IMAGE_COUNT = 1; > // private static final int MILLISECONDS_OF_DELAY = 180; > private Image[] imageCache; >- protected Image image; >- >- protected Image animationImage; >+ private Image image; > >-// protected BusyThread busyThread; >- protected Thread busyThread; >+// private Display dpy; >+// private Runnable timer; >+ private boolean busy; >+// private int imageIndex; > > /** > * BusyWidget constructor comment. >@@ -182,16 +58,36 @@ > * int > */ > public BusyIndicator(Composite parent, int style) { >- super(parent, style); >+ super(parent, style | SWT.DOUBLE_BUFFERED); >+ >+// dpy = getDisplay(); >+// timer = new Runnable() { >+// public void run () { >+// if (isDisposed()) return; >+// redraw(); >+// if (!BusyIndicator.this.busy) return; >+// update(); >+// if (isDisposed()) return; >+// imageIndex = (imageIndex + 1) % IMAGE_COUNT; >+// dpy.timerExec(MILLISECONDS_OF_DELAY, this); >+// } >+// }; > > // addPaintListener(new PaintListener() { > // public void paintControl(PaintEvent event) { > // onPaint(event); > // } > // }); >+ >+ addDisposeListener(new DisposeListener() { >+ public void widgetDisposed(DisposeEvent e) { >+ clearImages(); >+ } >+ }); > } > > public Point computeSize(int wHint, int hHint, boolean changed) { >+// checkWidget(); > Point size = new Point(0, 0); > if (image != null) { > Rectangle ibounds = image.getBounds(); >@@ -216,34 +112,6 @@ > } > > /** >- * Creates a thread to animate the image. >- */ >- protected synchronized void createBusyThread() { >- if (busyThread != null) >- return; >- >-// RAP [rh] fake a busyThread that not actually used anywhere, so that the >-// various test on busyThread != null or == null succeed >-// Rectangle bounds = getImage(0).getBounds(); >-// Display display = getDisplay(); >-// Image offScreenImage = new Image(display, bounds.width, bounds.height); >-// GC offScreenImageGC = new GC(offScreenImage); >-// busyThread = new BusyThread(bounds, display, offScreenImageGC, offScreenImage); >-// busyThread.setPriority(Thread.NORM_PRIORITY + 2); >-// busyThread.setDaemon(true); >-// busyThread.start(); >- busyThread = Thread.currentThread(); >- } >- >- public void dispose() { >- if (busyThread != null) { >-// busyThread.setStop(true); >- busyThread = null; >- } >- super.dispose(); >- } >- >- /** > * Return the image or <code>null</code>. > */ > public Image getImage() { >@@ -258,7 +126,7 @@ > * @return boolean > */ > public boolean isBusy() { >- return (busyThread != null); >+ return busy; > } > > // /* >@@ -288,18 +156,10 @@ > * boolean > */ > public synchronized void setBusy(boolean busy) { >- if (busy) { >- if (busyThread == null) >- createBusyThread(); >- } else { >- if (busyThread != null) { >-// RAP [rh] no actual BusyThread implementation >-// busyThread.setStop(true); >- busyThread = null; >-// RAP [rh] call clearImages explicitly as it would have been don by setStop() >- clearImages(); >- } >- } >+ if (this.busy == busy) return; >+ this.busy = busy; >+// imageIndex = 0; >+// dpy.asyncExec(timer); > } > > /** >@@ -330,7 +190,7 @@ > return ImageDescriptor.createFromURL(url); > } > >- private synchronized Image getImage(int index) { >+ private Image getImage(int index) { > if (imageCache == null) { > imageCache = new Image[IMAGE_COUNT]; > } >@@ -343,10 +203,7 @@ > return imageCache[index]; > } > >- private synchronized void clearImages() { >-// RAP [rh] missing Image#dispose() and #isDisposed() >- if (busyThread != null) >- return; >+ private void clearImages() { > if (imageCache != null) { > for (int index = 0; index < IMAGE_COUNT; index++) { > if (imageCache[index] != null /* && !imageCache[index].isDisposed()*/) { >Index: src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java >diff -N src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java >--- src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java 25 Feb 2010 13:53:11 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,37 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation 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: >- * IBM Corporation - initial API and implementation >- *******************************************************************************/ >-package org.eclipse.ui.internal.forms.widgets; >- >-import org.eclipse.swt.graphics.FontMetrics; >-import org.eclipse.swt.graphics.GC; >-import org.eclipse.swt.widgets.Control; >- >-public class PixelConverter { >- /** >- * Number of horizontal dialog units per character, value <code>4</code>. >- */ >- private static final int HORIZONTAL_DIALOG_UNIT_PER_CHAR = 4; >- >- private FontMetrics fFontMetrics; >- >- public PixelConverter(Control control) { >- GC gc = new GC(control); >- gc.setFont(control.getFont()); >- fFontMetrics = gc.getFontMetrics(); >- gc.dispose(); >- } >- >- public int convertHorizontalDLUsToPixels(int dlus) { >- // round to the nearest pixel >- return (fFontMetrics.getAverageCharWidth() * dlus + HORIZONTAL_DIALOG_UNIT_PER_CHAR / 2) >- / HORIZONTAL_DIALOG_UNIT_PER_CHAR; >- } >-} >Index: src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java,v >retrieving revision 1.3 >diff -u -r1.3 BreakSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java 25 Feb 2010 13:53:11 -0000 1.3 >+++ src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation 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 >@@ -32,7 +32,8 @@ > locator.rowHeight = fm.getHeight(); > } > if (computeHeightOnly) locator.collectHeights(); >- locator.x = locator.indent; >+ locator.resetCaret(); >+ locator.width = locator.x; > locator.y += locator.rowHeight; > locator.rowHeight = 0; > locator.leading = 0; >Index: src/org/eclipse/ui/internal/forms/widgets/TextSegment.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/TextSegment.java,v >retrieving revision 1.4 >diff -u -r1.4 TextSegment.java >--- src/org/eclipse/ui/internal/forms/widgets/TextSegment.java 25 Feb 2010 13:53:11 -0000 1.4 >+++ src/org/eclipse/ui/internal/forms/widgets/TextSegment.java 26 Feb 2010 16:36:24 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -15,6 +15,8 @@ > import java.util.Vector; > > import org.eclipse.rwt.Adaptable; >+import org.eclipse.ui.forms.internal.widgets.ITextSegmentAdapter; >+ > import org.eclipse.swt.SWT; > // RAP [if] unnecessary > //import org.eclipse.swt.graphics.Color; >@@ -23,7 +25,6 @@ > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >-import org.eclipse.ui.forms.internal.widgets.ITextSegmentAdapter; > > import com.ibm.icu.text.BreakIterator; > >@@ -252,9 +253,9 @@ > if (isSelectable()) > totalExtent+=1; > >- if (wHint != SWT.DEFAULT && totalExtent > wHint) { >+ if (wHint != SWT.DEFAULT && totalExtent + locator.marginWidth > wHint) { > // new line >- locator.x = locator.indent; >+ locator.resetCaret(); > locator.y += locator.rowHeight; > if (computeHeightOnly) > locator.collectHeights(); >@@ -266,7 +267,7 @@ > if (isSelectable()) > width += 1; > locator.x += width; >- locator.width = locator.indent + width; >+ locator.width = locator.x; > locator.rowHeight = Math.max(locator.rowHeight, extent.y); > // RAP [if] fm.getLeading() is missing > // locator.leading = Math.max(locator.leading, fm.getLeading()); >@@ -286,7 +287,9 @@ > if (isSelectable()) > currentExtent += 1; > >- if (currentExtent + textFragment.length > wHint) { >+ // i != 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0) means: >+ // only wrap on the first fragment if we are not at the start of a line >+ if ((i != 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) && currentExtent + textFragment.length > wHint) { > // overflow > int lineWidth = currentExtent; > locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y); >@@ -306,6 +309,7 @@ > } > lineExtent.x += textFragment.length; > lineExtent.y = Math.max(lineHeight, lineExtent.y); >+ width = Math.max (width, locator.x + lineExtent.x); > } > int lineWidth = lineExtent.x; > if (isSelectable()) >@@ -680,7 +684,9 @@ > int breakLoc = fragment.index; > if (breakLoc == 0) > continue; >- if (locator.x + lineExtent.x + fragment.length > rightEdge) { >+ // (i != 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) means: >+ // only wrap on the first fragment if we are not at the start of a line >+ if ((i != 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) && locator.x + lineExtent.x + fragment.length > rightEdge) { > // overflow > int lineWidth = locator.x + lineExtent.x; > if (isSelectable()) >Index: src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java,v >retrieving revision 1.3 >diff -u -r1.3 BulletParagraph.java >--- src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java 25 Feb 2010 13:53:11 -0000 1.3 >+++ src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java 26 Feb 2010 16:36:23 -0000 >@@ -13,13 +13,14 @@ > import java.util.Hashtable; > > import org.eclipse.rwt.Adaptable; >+import org.eclipse.ui.forms.internal.widgets.IBulletParagraphAdapter; >+ > // RAP [if] unnecessary > //import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >-import org.eclipse.ui.forms.internal.widgets.IBulletParagraphAdapter; > > public class BulletParagraph extends Paragraph implements Adaptable { > public static final int CIRCLE = 1; >Index: src/org/eclipse/ui/internal/forms/widgets/FormFonts.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormFonts.java,v >retrieving revision 1.2 >diff -u -r1.2 FormFonts.java >--- src/org/eclipse/ui/internal/forms/widgets/FormFonts.java 2 Jun 2008 08:48:47 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/widgets/FormFonts.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation 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 >@@ -12,138 +12,120 @@ > > import java.util.HashMap; > >-import org.eclipse.rwt.SessionSingletonBase; > import org.eclipse.rwt.graphics.Graphics; >+ >+import org.eclipse.jface.resource.DeviceResourceException; >+import org.eclipse.jface.resource.FontDescriptor; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.jface.resource.LocalResourceManager; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Device; > import org.eclipse.swt.graphics.Font; > import org.eclipse.swt.graphics.FontData; > import org.eclipse.swt.widgets.Display; > > public class FormFonts { >-// RAP [fappel]: use session singleton approach since FontIdentifier holds >-// reference to display >-// private static FormFonts instance; >+ private static FormFonts instance; > > public static FormFonts getInstance() { >-// RAP [fappel]: use session singleton approach since FontIdentifier holds >-// reference to display >-// if (instance == null) >-// instance = new FormFonts(); >-// return instance; >- return ( FormFonts )SessionSingletonBase.getInstance( FormFonts.class ); >+ if (instance == null) >+ instance = new FormFonts(); >+ return instance; > } > >- private HashMap fonts; >- private HashMap ids; >+ private LocalResourceManager resources; >+ private HashMap descriptors; > > private FormFonts() { > } > >- private class FontIdentifier { >- private Display fDisplay; >- private Font fFont; >+ private class BoldFontDescriptor extends FontDescriptor { >+ private FontData[] fFontData; > >- FontIdentifier (Display display, Font font) { >- fDisplay = display; >- fFont = font; >+ BoldFontDescriptor (Font font) { >+// RAP [if] Changes due to different way of creating fonts >+// fFontData = font.getFontData(); >+// for (int i = 0; i < fFontData.length; i++) { >+// fFontData[i].setStyle(fFontData[i].getStyle() | SWT.BOLD); >+// } >+ FontData fontData = font.getFontData()[ 0 ]; >+ Font boldFont = Graphics.getFont( fontData.getName(), >+ fontData.getHeight(), >+ fontData.getStyle() | SWT.BOLD ); >+ fFontData = boldFont.getFontData(); > } > > public boolean equals(Object obj) { >- if (obj instanceof FontIdentifier) { >- FontIdentifier id = (FontIdentifier)obj; >- return id.fDisplay.equals(fDisplay) && id.fFont.equals(fFont); >+ if (obj instanceof BoldFontDescriptor) { >+ BoldFontDescriptor desc = (BoldFontDescriptor)obj; >+ if (desc.fFontData.length != fFontData.length) >+ return false; >+ for (int i = 0; i < fFontData.length; i++) >+ if (!fFontData[i].equals(desc.fFontData[i])) >+ return false; >+ return true; > } > return false; > } > > public int hashCode() { >- return fDisplay.hashCode() * 7 + fFont.hashCode(); >- } >- } >- >- private class FontReference { >- private Font fFont; >- private int fCount; >- >- public FontReference(Font font) { >- fFont = font; >- fCount = 1; >+ int hash = 0; >+ for (int i = 0; i < fFontData.length; i++) >+ hash = hash * 7 + fFontData[i].hashCode(); >+ return hash; > } > >- public Font getFont() { >- return fFont; >+ public Font createFont(Device device) throws DeviceResourceException { >+// RAP [if] Changes due to different way of creating fonts >+// return new Font(device, fFontData); >+ return Graphics.getFont( fFontData[ 0 ] ); > } >- // returns a boolean indicating if all clients of this font are finished >- // a true result indicates the underlying image should be disposed >- public boolean decCount() { >- return --fCount == 0; >- } >- public void incCount() { >- fCount++; >+ >+ public void destroyFont(Font previouslyCreatedFont) { >+// RAP [if] unnecessary >+// previouslyCreatedFont.dispose(); > } > } > > public Font getBoldFont(Display display, Font font) { > checkHashMaps(); >- FontIdentifier fid = new FontIdentifier(display, font); >- FontReference result = (FontReference) fonts.get(fid); >- // RAP [rh] Unnecessary, as there is no Font#dispose() >- if (result != null /* && !result.getFont().isDisposed() */) { >- result.incCount(); >- return result.getFont(); >- } >- Font boldFont = createBoldFont(display, font); >- fonts.put(fid, new FontReference(boldFont)); >- ids.put(boldFont, fid); >- return boldFont; >+ BoldFontDescriptor desc = new BoldFontDescriptor(font); >+ Font result = getResourceManager().createFont(desc); >+ descriptors.put(result, desc); >+ return result; > } > > public boolean markFinished(Font boldFont) { > checkHashMaps(); >- FontIdentifier id = (FontIdentifier)ids.get(boldFont); >- if (id != null) { >- FontReference ref = (FontReference) fonts.get(id); >- if (ref != null) { >- if (ref.decCount()) { >- fonts.remove(id); >- ids.remove(ref.getFont()); >-// RAP [rh] Unnecessary, as there is no Font#dispose() >-// ref.getFont().dispose(); >- validateHashMaps(); >- } >- return true; >+ BoldFontDescriptor desc = (BoldFontDescriptor)descriptors.get(boldFont); >+ if (desc != null) { >+ getResourceManager().destroyFont(desc); >+ if (getResourceManager().find(desc) == null) { >+ descriptors.remove(boldFont); >+ validateHashMaps(); > } >+ return true; >+ > } > // if the image was not found, dispose of it for the caller >-// RAP [rh] Unnecessary, as there is no Font#dispose() >+// RAP [if] unnecessary > // boldFont.dispose(); > return false; > } >- >- private Font createBoldFont(Display display, Font regularFont) { >-// RAP [rh] Changes due to different way of creating fonts >-// FontData[] fontDatas = regularFont.getFontData(); >-// for (int i = 0; i < fontDatas.length; i++) { >-// fontDatas[i].setStyle(fontDatas[i].getStyle() | SWT.BOLD); >-// } >-// return new Font(display, fontDatas); >- FontData fontData = regularFont.getFontData()[ 0 ]; >- return Graphics.getFont( fontData.getName(), >- fontData.getHeight(), >- fontData.getStyle() | SWT.BOLD ); >+ >+ private LocalResourceManager getResourceManager() { >+ if (resources == null) >+ resources = new LocalResourceManager(JFaceResources.getResources()); >+ return resources; > } > > private void checkHashMaps() { >- if (fonts == null) >- fonts = new HashMap(); >- if (ids == null) >- ids = new HashMap(); >+ if (descriptors == null) >+ descriptors = new HashMap(); > } > > private void validateHashMaps() { >- if (fonts.size() == 0) >- fonts = null; >- if (ids.size() == 0) >- ids = null; >+ if (descriptors.size() == 0) >+ descriptors = null; > } > } >Index: src/org/eclipse/ui/internal/forms/widgets/FormHeading.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormHeading.java,v >retrieving revision 1.10 >diff -u -r1.10 FormHeading.java >--- src/org/eclipse/ui/internal/forms/widgets/FormHeading.java 25 Feb 2010 13:53:11 -0000 1.10 >+++ src/org/eclipse/ui/internal/forms/widgets/FormHeading.java 26 Feb 2010 16:36:23 -0000 >@@ -1,11 +1,11 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation 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 >+ * Copyright (c) 2000, 2009 IBM Corporation 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: >+ * Contributors: > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.internal.forms.widgets; >@@ -455,13 +455,6 @@ > return messages; > } > >- public String getDetailedMessage() { >- Control c = getMessageControl(); >- if (c != null) >- return c.getToolTipText(); >- return null; >- } >- > public Control getMessageControl() { > if (needHyperlink() && messageHyperlink != null) > return messageHyperlink; >Index: src/org/eclipse/ui/internal/forms/widgets/FormUtil.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/widgets/FormUtil.java,v >retrieving revision 1.3 >diff -u -r1.3 FormUtil.java >--- src/org/eclipse/ui/internal/forms/widgets/FormUtil.java 25 Feb 2010 13:53:11 -0000 1.3 >+++ src/org/eclipse/ui/internal/forms/widgets/FormUtil.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation 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 >@@ -22,7 +22,7 @@ > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.layout.GridData; >-//import org.eclipse.swt.widgets.Combo; >+import org.eclipse.swt.widgets.Combo; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; > import org.eclipse.swt.widgets.Label; >@@ -376,36 +376,38 @@ > // } > } > >-// RAP [rh] FormUtil#processKey unnecessary >-// public static void processKey(int keyCode, Control c) { >-// ScrolledComposite scomp = FormUtil.getScrolledComposite(c); >-// if (scomp != null) { >-// if (c instanceof Combo) >-// return; >-// switch (keyCode) { >-// case SWT.ARROW_DOWN: >-// if (scomp.getData("novarrows") == null) //$NON-NLS-1$ >-// FormUtil.scrollVertical(scomp, false); >-// break; >-// case SWT.ARROW_UP: >-// if (scomp.getData("novarrows") == null) //$NON-NLS-1$ >-// FormUtil.scrollVertical(scomp, true); >-// break; >-// case SWT.ARROW_LEFT: >-// FormUtil.scrollHorizontal(scomp, true); >-// break; >-// case SWT.ARROW_RIGHT: >-// FormUtil.scrollHorizontal(scomp, false); >-// break; >-// case SWT.PAGE_UP: >-// FormUtil.scrollPage(scomp, true); >-// break; >-// case SWT.PAGE_DOWN: >-// FormUtil.scrollPage(scomp, false); >-// break; >-// } >-// } >-// } >+ public static void processKey(int keyCode, Control c) { >+ if (c.isDisposed()) { >+ return; >+ } >+ ScrolledComposite scomp = FormUtil.getScrolledComposite(c); >+ if (scomp != null) { >+ if (c instanceof Combo) >+ return; >+ switch (keyCode) { >+ case SWT.ARROW_DOWN: >+ if (scomp.getData("novarrows") == null) //$NON-NLS-1$ >+ FormUtil.scrollVertical(scomp, false); >+ break; >+ case SWT.ARROW_UP: >+ if (scomp.getData("novarrows") == null) //$NON-NLS-1$ >+ FormUtil.scrollVertical(scomp, true); >+ break; >+ case SWT.ARROW_LEFT: >+ FormUtil.scrollHorizontal(scomp, true); >+ break; >+ case SWT.ARROW_RIGHT: >+ FormUtil.scrollHorizontal(scomp, false); >+ break; >+ case SWT.PAGE_UP: >+ FormUtil.scrollPage(scomp, true); >+ break; >+ case SWT.PAGE_DOWN: >+ FormUtil.scrollPage(scomp, false); >+ break; >+ } >+ } >+ } > > public static boolean isWrapControl(Control c) { > if ((c.getStyle() & SWT.WRAP) != 0) >Index: src/org/eclipse/ui/forms/editor/FormEditor.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/editor/FormEditor.java,v >retrieving revision 1.1 >diff -u -r1.1 FormEditor.java >--- src/org/eclipse/ui/forms/editor/FormEditor.java 16 Apr 2008 09:44:37 -0000 1.1 >+++ src/org/eclipse/ui/forms/editor/FormEditor.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2010 IBM Corporation 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 >@@ -12,11 +12,6 @@ > > import java.util.Vector; > >-import org.eclipse.core.runtime.ListenerList; >-import org.eclipse.jface.dialogs.IPageChangeProvider; >-import org.eclipse.jface.dialogs.IPageChangedListener; >-import org.eclipse.jface.dialogs.PageChangedEvent; >-import org.eclipse.jface.util.SafeRunnable; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.ISelectionProvider; > import org.eclipse.jface.viewers.SelectionChangedEvent; >@@ -58,8 +53,7 @@ > * > * @since 1.0 > */ >-public abstract class FormEditor extends MultiPageEditorPart implements >- IPageChangeProvider { >+public abstract class FormEditor extends MultiPageEditorPart { > > /** > * An array of pages currently in the editor. Page objects are not limited >@@ -74,8 +68,6 @@ > > private int currentPage = -1; > >- private ListenerList pageListeners = new ListenerList(); >- > private static class FormEditorSelectionProvider extends > MultiPageSelectionProvider { > private ISelection globalSelection; >@@ -179,24 +171,6 @@ > /* > * (non-Javadoc) > * >- * @see org.eclipse.jface.dialogs.IPageChangeProvider#addPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) >- */ >- public void addPageChangedListener(IPageChangedListener listener) { >- pageListeners.add(listener); >- } >- >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jface.dialogs.IPageChangeProvider#removePageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) >- */ >- public void removePageChangedListener(IPageChangedListener listener) { >- pageListeners.remove(listener); >- } >- >- /* >- * (non-Javadoc) >- * > * @see org.eclipse.jface.dialogs.IPageChangeProvider#getSelectedPage() > */ > public Object getSelectedPage() { >@@ -230,6 +204,7 @@ > public void addPage(int index, IFormPage page) throws PartInitException { > super.addPage(index, page.getPartControl()); > configurePage(index, page); >+ updatePageIndices(index+1); > } > > /** >@@ -266,6 +241,7 @@ > } catch (PartInitException e) { > // cannot happen for controls > } >+ updatePageIndices(index+1); > } > > /** >@@ -285,6 +261,12 @@ > IFormPage fpage = (IFormPage) page; > if (fpage.isDirty()) > return true; >+ >+ } else if (page instanceof IEditorPart) { >+ IEditorPart editor = (IEditorPart) page; >+ if (editor.isDirty()) { >+ return true; >+ } > } > } > } >@@ -340,6 +322,7 @@ > configurePage(index, (IFormPage) editor); > else > registerPage(index, editor); >+ updatePageIndices(index+1); > } > > /** >@@ -374,15 +357,15 @@ > IFormPage fpage = (IFormPage) page; > if (!fpage.isEditor()) > fpage.dispose(); >- updatePageIndices(); > } >+ updatePageIndices(pageIndex); > } > super.removePage(pageIndex); > } > >- // fix the page indices after the removal >- private void updatePageIndices() { >- for (int i = 0; i < pages.size(); i++) { >+ // fix the page indices after the removal/insertion >+ private void updatePageIndices(int start) { >+ for (int i = start; i < pages.size(); i++) { > Object page = pages.get(i); > if (page instanceof IFormPage) { > IFormPage fpage = (IFormPage) page; >@@ -503,9 +486,6 @@ > // Call super - this will cause pages to switch > super.pageChange(newPageIndex); > this.currentPage = newPageIndex; >- IFormPage newPage = getActivePageInstance(); >- if (newPage != null) >- firePageChanged(new PageChangedEvent(this, newPage)); > } > > /** >@@ -672,16 +652,4 @@ > fpage.init(getEditorSite(), getEditorInput()); > } > } >- >- private void firePageChanged(final PageChangedEvent event) { >- Object[] listeners = pageListeners.getListeners(); >- for (int i = 0; i < listeners.length; ++i) { >- final IPageChangedListener l = (IPageChangedListener) listeners[i]; >- SafeRunnable.run(new SafeRunnable() { >- public void run() { >- l.pageChanged(event); >- } >- }); >- } >- } > } >Index: src/org/eclipse/ui/forms/editor/FormPage.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/editor/FormPage.java,v >retrieving revision 1.1 >diff -u -r1.1 FormPage.java >--- src/org/eclipse/ui/forms/editor/FormPage.java 16 Apr 2008 09:44:37 -0000 1.1 >+++ src/org/eclipse/ui/forms/editor/FormPage.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -121,7 +121,8 @@ > if (active) { > // We are switching to this page - refresh it > // if needed. >- mform.refresh(); >+ if (mform != null) >+ mform.refresh(); > } > } > /** >Index: src/org/eclipse/ui/forms/editor/SharedHeaderFormEditor.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/editor/SharedHeaderFormEditor.java,v >retrieving revision 1.1 >diff -u -r1.1 SharedHeaderFormEditor.java >--- src/org/eclipse/ui/forms/editor/SharedHeaderFormEditor.java 16 Apr 2008 09:44:37 -0000 1.1 >+++ src/org/eclipse/ui/forms/editor/SharedHeaderFormEditor.java 26 Feb 2010 16:36:21 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation 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 >@@ -65,7 +65,8 @@ > > /** > * Overrides <code>super</code> to create a form in which to host the tab >- * folder. This form will be responsible for managing >+ * folder. This form will be responsible for creating a common form header. >+ * Child pages should not have a header of their own. > * > * @param parent > * the page container parent >@@ -130,12 +131,12 @@ > > int activePage = getActivePage(); > if (SharedHeaderFormEditor.this.wasHeaderActive != wasHeaderActive && activePage != -1 && pages.get(activePage) instanceof IEditorPart) { >-// TODO [rh] enabled as soon as 3.4 Workbench code is in place >-// if (wasHeaderActive) { >-// deactivateSite(true, true); >-// } else { >-// activateSite(); >-// } >+ >+ if (wasHeaderActive) { >+ deactivateSite(true, true); >+ } else { >+ activateSite(); >+ } > } > > SharedHeaderFormEditor.this.wasHeaderActive = wasHeaderActive; >Index: src/org/eclipse/ui/forms/events/IHyperlinkListener.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/events/IHyperlinkListener.java,v >retrieving revision 1.1 >diff -u -r1.1 IHyperlinkListener.java >--- src/org/eclipse/ui/forms/events/IHyperlinkListener.java 16 Apr 2008 09:44:37 -0000 1.1 >+++ src/org/eclipse/ui/forms/events/IHyperlinkListener.java 26 Feb 2010 16:36:21 -0000 >@@ -15,7 +15,7 @@ > * > * @see org.eclipse.ui.forms.widgets.Hyperlink > * @see org.eclipse.ui.forms.widgets.ImageHyperlink >- * <!-- @see org.eclipse.ui.forms.widgets.FormText --> >+ * @see org.eclipse.ui.forms.widgets.FormText > * @since 1.0 > */ > public interface IHyperlinkListener { >Index: readme.txt >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/readme.txt,v >retrieving revision 1.1 >diff -u -r1.1 readme.txt >--- readme.txt 16 Apr 2008 09:44:32 -0000 1.1 >+++ readme.txt 26 Feb 2010 16:36:21 -0000 >@@ -1 +1 @@ >-Based on code from dev.eclipse.org:/cvsroot/eclipse, Tag v20080407 >\ No newline at end of file >+Based on code from dev.eclipse.org:/cvsroot/eclipse, v20100226 >\ No newline at end of file >Index: src/org/eclipse/ui/internal/forms/MessageManager.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/internal/forms/MessageManager.java,v >retrieving revision 1.2 >diff -u -r1.2 MessageManager.java >--- src/org/eclipse/ui/internal/forms/MessageManager.java 25 Feb 2010 09:59:54 -0000 1.2 >+++ src/org/eclipse/ui/internal/forms/MessageManager.java 26 Feb 2010 16:36:23 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation 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 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Benjamin Cabe (benjamin.cabe@anyware-tech.com) - patch (see Bugzilla #255466) > ******************************************************************************/ > > package org.eclipse.ui.internal.forms; >@@ -17,6 +18,7 @@ > import java.util.Enumeration; > import java.util.Hashtable; > import java.util.Iterator; >+import java.util.Map.Entry; > > import org.eclipse.jface.dialogs.IMessageProvider; > import org.eclipse.jface.fieldassist.ControlDecoration; >@@ -30,6 +32,7 @@ > import org.eclipse.ui.forms.IMessage; > import org.eclipse.ui.forms.IMessageManager; > import org.eclipse.ui.forms.IMessagePrefixProvider; >+import org.eclipse.ui.forms.widgets.Form; > import org.eclipse.ui.forms.widgets.Hyperlink; > import org.eclipse.ui.forms.widgets.ScrolledForm; > >@@ -40,9 +43,11 @@ > public class MessageManager implements IMessageManager { > private static final DefaultPrefixProvider DEFAULT_PREFIX_PROVIDER = new DefaultPrefixProvider(); > private ArrayList messages = new ArrayList(); >+ private ArrayList oldMessages; > private Hashtable decorators = new Hashtable(); >+ private Hashtable oldDecorators; > private boolean autoUpdate = true; >- private ScrolledForm scrolledForm; >+ private Form form; > private IMessagePrefixProvider prefixProvider = DEFAULT_PREFIX_PROVIDER; > private int decorationPosition = SWT.LEFT | SWT.BOTTOM; > private static FieldDecoration standardError = FieldDecorationRegistry >@@ -78,6 +83,15 @@ > this.type = type; > this.data = data; > } >+ >+ private Message(Message message) { >+ this.key = message.key; >+ this.message = message.message; >+ this.type = message.type; >+ this.data = message.data; >+ this.prefix = message.prefix; >+ this.control = message.control; >+ } > > /* > * (non-Javadoc) >@@ -132,6 +146,17 @@ > public String getPrefix() { > return prefix; > } >+ >+ public boolean equals(Object obj) { >+ if (!(obj instanceof Message)) >+ return false; >+ Message msg = (Message) obj; >+ return (msg.getPrefix() == null ? getPrefix() == null : msg.getPrefix().equals(getPrefix())) && >+ (msg.getControl() == null ? getControl() == null : msg.getControl().equals(getControl())) && >+ (msg.getMessageType() == getMessageType()) && >+ (msg.getMessage() == null ? getMessage() == null : msg.getMessage().equals(getMessage())) && >+ msg.getKey().equals(getKey()); >+ } > } > > static class DefaultPrefixProvider implements IMessagePrefixProvider { >@@ -172,7 +197,14 @@ > private String prefix; > > ControlDecorator(Control control) { >- this.decoration = new ControlDecoration(control, decorationPosition, scrolledForm.getBody()); >+ this.decoration = new ControlDecoration(control, decorationPosition, form.getBody()); >+ } >+ >+ private ControlDecorator (ControlDecorator cd) { >+ this.decoration = cd.decoration; >+ this.prefix = cd.prefix; >+ for (Iterator i = cd.controlMessages.iterator(); i.hasNext();) >+ this.controlMessages.add(new Message((Message)i.next())); > } > > public boolean isDisposed() { >@@ -186,7 +218,7 @@ > void updatePosition() { > Control control = decoration.getControl(); > decoration.dispose(); >- this.decoration = new ControlDecoration(control, decorationPosition, scrolledForm.getBody()); >+ this.decoration = new ControlDecoration(control, decorationPosition, form.getBody()); > update(); > } > >@@ -256,6 +288,23 @@ > decoration.show(); > } > } >+ >+ public boolean equals(Object obj) { >+ if (!(obj instanceof ControlDecorator)) >+ return false; >+ ControlDecorator cd = (ControlDecorator) obj; >+ if (!cd.decoration.equals(decoration)) >+ return false; >+ return cd.getPrefix().equals(getPrefix()); >+ } >+ >+ boolean hasSameMessages(ControlDecorator cd) { >+ if (cd.controlMessages.size() != controlMessages.size()) >+ return false; >+ if (!cd.controlMessages.containsAll(controlMessages)) >+ return false; >+ return true; >+ } > } > > /** >@@ -266,7 +315,18 @@ > * the form to control > */ > public MessageManager(ScrolledForm scrolledForm) { >- this.scrolledForm = scrolledForm; >+ this.form = scrolledForm.getForm(); >+ } >+ >+ /** >+ * Creates a new instance of the message manager that will work with the >+ * provided form. >+ * >+ * @param form >+ * the form to control >+ */ >+ public MessageManager(Form form) { >+ this.form = form; > } > > /* >@@ -440,8 +500,8 @@ > > private void update(ArrayList mergedList) { > pruneControlDecorators(); >- if (mergedList.isEmpty() || mergedList == null) { >- scrolledForm.setMessage(null, IMessageProvider.NONE); >+ if (form.getHead().getBounds().height == 0 || mergedList.isEmpty() || mergedList == null) { >+ form.setMessage(null, IMessageProvider.NONE); > return; > } > ArrayList peers = createPeers(mergedList); >@@ -453,7 +513,7 @@ > // a single message > IMessage message = (IMessage) peers.get(0); > messageText = message.getMessage(); >- scrolledForm.setMessage(messageText, maxType, array); >+ form.setMessage(messageText, maxType, array); > } else { > // show a summary message for the message > // and list of errors for the details >@@ -463,7 +523,7 @@ > new String[] { peers.size() + "" }); //$NON-NLS-1$ > else > messageText = SINGLE_MESSAGE_SUMMARY_KEYS[maxType]; >- scrolledForm.setMessage(messageText, maxType, array); >+ form.setMessage(messageText, maxType, array); > } > } > >@@ -593,9 +653,53 @@ > * @see org.eclipse.ui.forms.IMessageManager#setAutoUpdate(boolean) > */ > public void setAutoUpdate(boolean autoUpdate) { >+ boolean needsCaching = this.autoUpdate && !autoUpdate; > boolean needsUpdate = !this.autoUpdate && autoUpdate; > this.autoUpdate = autoUpdate; >- if (needsUpdate) >+ if (needsUpdate && isCacheChanged()) > update(); >+ if (needsCaching) { >+ oldMessages = new ArrayList(); >+ for (Iterator i = messages.iterator(); i.hasNext();) >+ oldMessages.add(new Message((Message)i.next())); >+ oldDecorators = new Hashtable(); >+ for (Enumeration e = decorators.keys(); e.hasMoreElements();) { >+ Object key = e.nextElement(); >+ oldDecorators.put(key, new ControlDecorator((ControlDecorator)decorators.get(key))); >+ } >+ } >+ } >+ >+ private boolean isCacheChanged() { >+ boolean result = false; >+ result = checkMessageCache() || checkDecoratorCache(); >+ oldMessages.clear(); >+ oldMessages = null; >+ oldDecorators.clear(); >+ oldDecorators = null; >+ return result; >+ } >+ >+ private boolean checkMessageCache() { >+ if (oldMessages == null) >+ return false; >+ if (messages.size() != oldMessages.size()) >+ return true; >+ if (!oldMessages.containsAll(messages)) >+ return true; >+ return false; >+ } >+ >+ private boolean checkDecoratorCache() { >+ if (oldDecorators == null) >+ return false; >+ for (Iterator i = decorators.entrySet().iterator(); i.hasNext();) { >+ Entry next = (Entry)i.next(); >+ ControlDecorator cd = (ControlDecorator)next.getValue(); >+ ControlDecorator oldCd = (ControlDecorator) oldDecorators.get(cd.decoration.getControl()); >+ if ((oldCd == null && cd.controlMessages.size() > 0) || (oldCd != null && !cd.hasSameMessages(oldCd))) >+ return true; >+ } >+ return false; > } > } >\ No newline at end of file >Index: src/org/eclipse/ui/internal/forms/FormsPlugin.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/forms/FormsPlugin.java >diff -N src/org/eclipse/ui/internal/forms/FormsPlugin.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/forms/FormsPlugin.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.ui.internal.forms; >+ >+import org.eclipse.ui.internal.forms.widgets.FormsResources; >+import org.eclipse.ui.plugin.AbstractUIPlugin; >+import org.osgi.framework.BundleContext; >+ >+public class FormsPlugin extends AbstractUIPlugin { >+ >+ public FormsPlugin() { >+ } >+ >+ public void stop(BundleContext context) throws Exception { >+ try { >+ FormsResources.shutdown(); >+ } finally { >+ super.stop(context); >+ } >+ } >+ >+}
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 303731
: 160332