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

(-)src/org/eclipse/ui/forms/IManagedForm.java (-6 / +8 lines)
Lines 1-11 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2007 IBM Corporation and others.
2
 *  Copyright (c) 2003, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.forms;
11
package org.eclipse.ui.forms;
Lines 28-33 Link Here
28
 * 
28
 * 
29
 * @see ManagedForm
29
 * @see ManagedForm
30
 * @since 1.0
30
 * @since 1.0
31
 * @noimplement This interface is not intended to be implemented by clients.
32
 * @noextend This interface is not intended to be extended by clients.
31
 */
33
 */
32
public interface IManagedForm {
34
public interface IManagedForm {
33
	/**
35
	/**
(-)src/org/eclipse/ui/forms/MasterDetailsBlock.java (-8 / +56 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Roland Tepp (roland@videobet.com) - patch (see Bugzilla #107197) 
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.forms;
12
package org.eclipse.ui.forms;
12
13
Lines 141-156 Link Here
141
	 */
142
	 */
142
	public void createContent(IManagedForm managedForm) {
143
	public void createContent(IManagedForm managedForm) {
143
		final ScrolledForm form = managedForm.getForm();
144
		final ScrolledForm form = managedForm.getForm();
145
		createContent(managedForm, form.getBody());
146
	}
147
	
148
	/**
149
	 * Creates the content of the master/details block inside the parent composite.
150
	 * This method should be called as late as possible inside the parent part.
151
	 * 
152
	 * @param managedForm
153
	 *            the managed form to create the block in
154
	 */
155
	public void createContent(IManagedForm managedForm, Composite parent) {
156
		final ScrolledForm form = managedForm.getForm();
144
		FormToolkit toolkit = managedForm.getToolkit();
157
		FormToolkit toolkit = managedForm.getToolkit();
145
		GridLayout layout = new GridLayout();
158
		applyLayout(parent);
146
		layout.marginWidth = 0;
159
		sashForm = new MDSashForm(parent, SWT.NULL);
147
		layout.marginHeight = 0;
148
		form.getBody().setLayout(layout);
149
		sashForm = new MDSashForm(form.getBody(), SWT.NULL);
150
		sashForm.setData("form", managedForm); //$NON-NLS-1$
160
		sashForm.setData("form", managedForm); //$NON-NLS-1$
151
		toolkit.adapt(sashForm, false, false);
161
		toolkit.adapt(sashForm, false, false);
152
		sashForm.setMenu(form.getBody().getMenu());
162
		sashForm.setMenu(parent.getMenu());
153
		sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
163
		applyLayoutData(sashForm);
154
		createMasterPart(managedForm, sashForm);
164
		createMasterPart(managedForm, sashForm);
155
		createDetailsPart(managedForm, sashForm);
165
		createDetailsPart(managedForm, sashForm);
156
		hookResizeListener();
166
		hookResizeListener();
Lines 158-163 Link Here
158
		form.updateToolBar();
168
		form.updateToolBar();
159
	}
169
	}
160
	
170
	
171
	/**
172
	 * Applies layout data to the sash form containing master and detail parts
173
	 * of the master/details block.
174
	 * 
175
	 * <p>The default implementation fills the whole parent composite area.
176
	 * Override this method if master/details block is to be placed on a form
177
	 * along with other components.</p>
178
	 * 
179
	 * <p>Implementations that override this method should also override 
180
	 * <code>applyLayout(Composite)</code> method implementation.</p>
181
	 * 
182
	 * @param sashForm The sash form to be laid out on the parent composite.
183
	 * @see #applyLayout(Composite)
184
	 */
185
	protected void applyLayoutData(SashForm sashForm) {
186
		sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
187
	}
188
189
	/**
190
	 * Applies layout to the parent composite of the master/details block.
191
	 * 
192
	 * <p>The default implementation fills the whole parent composite area.
193
	 * Override this method if master/details block is to be placed on a form
194
	 * along with other components.</p>
195
	 * 
196
	 * <p>Implementations that override this method should also override 
197
	 * <code>applyLayoutData(SashForm)</code> method implementation.</p>
198
	 * 
199
	 * @param parent parent composite for the master/details block
200
	 * @see #applyLayoutData(SashForm)
201
	 */
202
	protected void applyLayout(final Composite parent) {
203
		GridLayout layout = new GridLayout();
204
		layout.marginWidth = 0;
205
		layout.marginHeight = 0;
206
		parent.setLayout(layout);
207
	}
208
	
161
	private void hookResizeListener() {
209
	private void hookResizeListener() {
162
		Listener listener = ((MDSashForm)sashForm).listener;
210
		Listener listener = ((MDSashForm)sashForm).listener;
163
		Control [] children = sashForm.getChildren();
211
		Control [] children = sashForm.getChildren();
(-)src/org/eclipse/ui/forms/FormColors.java (-17 / +24 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-19 Link Here
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.rwt.graphics.Graphics;
16
import org.eclipse.rwt.graphics.Graphics;
17
18
import org.eclipse.jface.resource.JFaceResources;
19
import org.eclipse.jface.resource.LocalResourceManager;
17
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.graphics.Color;
21
import org.eclipse.swt.graphics.Color;
19
import org.eclipse.swt.graphics.RGB;
22
import org.eclipse.swt.graphics.RGB;
Lines 94-99 Link Here
94
97
95
	protected Map colorRegistry = new HashMap(10);
98
	protected Map colorRegistry = new HashMap(10);
96
99
100
	private LocalResourceManager resources;
101
97
	protected Color background;
102
	protected Color background;
98
103
99
	protected Color foreground;
104
	protected Color foreground;
Lines 206-212 Link Here
206
	 * @return the allocated color object
211
	 * @return the allocated color object
207
	 */
212
	 */
208
	public Color createColor(String key, RGB rgb) {
213
	public Color createColor(String key, RGB rgb) {
209
		return createColor(key, rgb.red, rgb.green, rgb.blue);
214
		// RAP [rh] changes due to missing Color constructor
215
//		Color c = getResourceManager().createColor(rgb);
216
//		Color prevC = (Color) colorRegistry.get(key);
217
//		if (prevC != null && !prevC.isDisposed())
218
//			getResourceManager().destroyColor(prevC.getRGB());
219
	  	Color c = Graphics.getColor(rgb);
220
		colorRegistry.put(key, c);	  
221
		return c;
210
	}
222
	}
211
223
212
	/**
224
	/**
Lines 249-265 Link Here
249
	 * @return the allocated color object
261
	 * @return the allocated color object
250
	 */
262
	 */
251
	public Color createColor(String key, int r, int g, int b) {
263
	public Color createColor(String key, int r, int g, int b) {
252
// RAP [rh] changes due to missing Color constructor
264
		return createColor(key, new RGB(r,g,b));
253
//	  Color c = new Color(display, r, g, b);
254
//		Color prevC = (Color) colorRegistry.get(key);
255
//		if (prevC != null)
256
//			prevC.dispose();
257
//		colorRegistry.put(key, c);
258
259
	  Color c = Graphics.getColor(r, g, b);
260
		colorRegistry.put(key, c);
261
	  
262
		return c;
263
	}
265
	}
264
266
265
	/**
267
	/**
Lines 365-374 Link Here
365
	 * Disposes all the colors in the registry.
367
	 * Disposes all the colors in the registry.
366
	 */
368
	 */
367
	public void dispose() {
369
	public void dispose() {
368
	// RAP [rh] changes due to missing Color#dispose()
370
		if (resources != null)
369
//	  Iterator e = colorRegistry.values().iterator();
371
			resources.dispose();
370
//		while (e.hasNext())
372
		resources = null;
371
//			((Color) e.next()).dispose();
372
		colorRegistry = null;
373
		colorRegistry = null;
373
	}
374
	}
374
375
Lines 730-733 Link Here
730
		createColor(IFormColors.H_HOVER_LIGHT, light);
731
		createColor(IFormColors.H_HOVER_LIGHT, light);
731
		createColor(IFormColors.H_HOVER_FULL, full);
732
		createColor(IFormColors.H_HOVER_FULL, full);
732
	}
733
	}
734
	
735
	private LocalResourceManager getResourceManager() {
736
		if (resources == null)
737
			resources = new LocalResourceManager(JFaceResources.getResources());
738
		return resources;
739
	}
733
}
740
}
(-)src/org/eclipse/ui/forms/HyperlinkGroup.java (-7 / +8 lines)
Lines 12-17 Link Here
12
12
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
14
15
import org.eclipse.ui.forms.internal.widgets.IHyperlinkAdapter;
16
15
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.graphics.Color;
18
import org.eclipse.swt.graphics.Color;
17
import org.eclipse.swt.widgets.Display;
19
import org.eclipse.swt.widgets.Display;
Lines 19-25 Link Here
19
import org.eclipse.swt.widgets.Listener;
21
import org.eclipse.swt.widgets.Listener;
20
import org.eclipse.ui.forms.events.HyperlinkEvent;
22
import org.eclipse.ui.forms.events.HyperlinkEvent;
21
import org.eclipse.ui.forms.events.IHyperlinkListener;
23
import org.eclipse.ui.forms.events.IHyperlinkListener;
22
import org.eclipse.ui.forms.internal.widgets.IHyperlinkAdapter;
23
import org.eclipse.ui.forms.widgets.Hyperlink;
24
import org.eclipse.ui.forms.widgets.Hyperlink;
24
25
25
/**
26
/**
Lines 143-150 Link Here
143
		if (getHyperlinkUnderlineMode() == UNDERLINE_ALWAYS)
144
		if (getHyperlinkUnderlineMode() == UNDERLINE_ALWAYS)
144
			link.setUnderlined(true);
145
			link.setUnderlined(true);
145
		hook(link);
146
		hook(link);
146
    // RAP [rh] Provides information to handle hover effect on the client-side
147
    	// RAP [rh] Provides information to handle hover effect on the client-side
147
    updateHyperlinkSettings();
148
    	updateHyperlinkSettings();
148
	}
149
	}
149
150
150
	/**
151
	/**
Lines 157-164 Link Here
157
		super.setActiveBackground(newActiveBackground);
158
		super.setActiveBackground(newActiveBackground);
158
// RAP [rh] Obsolete, as mouse events are missing
159
// RAP [rh] Obsolete, as mouse events are missing
159
//		isActiveBackgroundSet = true;
160
//		isActiveBackgroundSet = true;
160
    // RAP [rh] Provides information to handle hover effect on the client-side
161
    	// RAP [rh] Provides information to handle hover effect on the client-side
161
    updateHyperlinkSettings();
162
    	updateHyperlinkSettings();
162
	}
163
	}
163
164
164
	/**
165
	/**
Lines 171-178 Link Here
171
		super.setActiveForeground(newActiveForeground);
172
		super.setActiveForeground(newActiveForeground);
172
// RAP [rh] Obsolete, as mouse events are missing
173
// RAP [rh] Obsolete, as mouse events are missing
173
//		isActiveForegroundSet = true;
174
//		isActiveForegroundSet = true;
174
    // RAP [rh] Provides information to handle hover effect on the client-side
175
    	// RAP [rh] Provides information to handle hover effect on the client-side
175
    updateHyperlinkSettings();
176
    	updateHyperlinkSettings();
176
	}
177
	}
177
178
178
  // RAP [rh] Update information to handle hover effect on the client-side
179
  // RAP [rh] Update information to handle hover effect on the client-side
(-)src/org/eclipse/ui/forms/HyperlinkSettings.java (-7 / +8 lines)
Lines 1-11 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.forms;
11
package org.eclipse.ui.forms;
Lines 16-25 Link Here
16
import org.eclipse.ui.internal.forms.widgets.*;
16
import org.eclipse.ui.internal.forms.widgets.*;
17
/**
17
/**
18
 * Manages color and underline mode settings for a group of hyperlinks. The
18
 * Manages color and underline mode settings for a group of hyperlinks. The
19
 * class is extended by HyperlinkGroup but is otwerwise not intended to be
19
 * class is extended by HyperlinkGroup but is otherwise not intended to be
20
 * subclassed.
20
 * subclassed.
21
 *
21
 *
22
 * @since 1.0
22
 * @since 1.0
23
 * @noextend This class is not intended to be subclassed by clients.
23
 */
24
 */
24
public class HyperlinkSettings {
25
public class HyperlinkSettings {
25
	/**
26
	/**
(-)src/org/eclipse/ui/forms/DetailsPart.java (-4 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 65-73 Link Here
65
			page.dispose();
65
			page.dispose();
66
			page=null;
66
			page=null;
67
		}
67
		}
68
		public boolean isDisposed() {
69
			return page==null;
70
		}
71
		public boolean isFixed() {
68
		public boolean isFixed() {
72
			return fixed;
69
			return fixed;
73
		}
70
		}
(-)src/org/eclipse/ui/forms/IMessageManager.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-13 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 ******************************************************************************/
10
 *******************************************************************************/
11
11
12
package org.eclipse.ui.forms;
12
package org.eclipse.ui.forms;
13
13
Lines 48-53 Link Here
48
 * @since 1.0
48
 * @since 1.0
49
 * @see IMessageProvider
49
 * @see IMessageProvider
50
 * @see IManagedForm
50
 * @see IManagedForm
51
 * @noimplement This interface is not intended to be implemented by clients.
52
 * @noextend This interface is not intended to be extended by clients.
51
 */
53
 */
52
54
53
public interface IMessageManager {
55
public interface IMessageManager {
(-)src/org/eclipse/ui/forms/ManagedForm.java (-8 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-20 Link Here
13
import java.util.Vector;
13
import java.util.Vector;
14
import org.eclipse.jface.viewers.ISelection;
14
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.ui.forms.widgets.*;
16
import org.eclipse.ui.forms.widgets.FormToolkit;
17
import org.eclipse.ui.internal.forms.MessageManager;
17
import org.eclipse.ui.forms.widgets.ScrolledForm;
18
18
19
/**
19
/**
20
 * Managed form wraps a form widget and adds life cycle methods for form parts.
20
 * Managed form wraps a form widget and adds life cycle methods for form parts.
Lines 47-54 Link Here
47
47
48
	private boolean initialized;
48
	private boolean initialized;
49
49
50
	private MessageManager messageManager;
51
52
	private Vector parts = new Vector();
50
	private Vector parts = new Vector();
53
51
54
	/**
52
	/**
Lines 328-335 Link Here
328
	 * @see org.eclipse.ui.forms.IManagedForm#getMessageManager()
326
	 * @see org.eclipse.ui.forms.IManagedForm#getMessageManager()
329
	 */
327
	 */
330
	public IMessageManager getMessageManager() {
328
	public IMessageManager getMessageManager() {
331
		if (messageManager == null)
329
		return form.getMessageManager();
332
			messageManager = new MessageManager(form);
333
		return messageManager;
334
	}
330
	}
335
}
331
}
(-)src/org/eclipse/ui/forms/widgets/AbstractHyperlink.java (-4 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Izzet Safer (isafer@ca.ibm.com) - patch (see Bugzilla #250505)
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.forms.widgets;
12
package org.eclipse.ui.forms.widgets;
12
13
Lines 31-36 Link Here
31
 * processing mouse and keyboard events, and converting them into unified
32
 * processing mouse and keyboard events, and converting them into unified
32
 * hyperlink events. Subclasses are responsible for rendering the hyperlink in
33
 * hyperlink events. Subclasses are responsible for rendering the hyperlink in
33
 * the client area.
34
 * the client area.
35
 * <p>
36
 * <dl>
37
 * <dt><b>Styles:</b></dt>
38
 * <dd>None</dd>
39
 * </dl>
34
 *
40
 *
35
 * @since 1.0
41
 * @since 1.0
36
 */
42
 */
Lines 227-234 Link Here
227
		// disarm link, back to normal state
233
		// disarm link, back to normal state
228
// RAP [rh] Unused code: was used by MouseUp/MouseDown listener code
234
// RAP [rh] Unused code: was used by MouseUp/MouseDown listener code
229
//		armed = false;
235
//		armed = false;
230
// RAP [rh] missing accessibility support
231
//		getAccessible().setFocus(ACC.CHILDID_SELF);
232
		if (listeners == null)
236
		if (listeners == null)
233
			return;
237
			return;
234
		int size = listeners.size();
238
		int size = listeners.size();
Lines 244-251 Link Here
244
// RAP [if] Cursor is managed on the client side
248
// RAP [if] Cursor is managed on the client side
245
//		if (!isDisposed())
249
//		if (!isDisposed())
246
//			setCursor(FormsResources.getHandCursor());
250
//			setCursor(FormsResources.getHandCursor());
251
// RAP [if]	missing accessibility support
252
//			triggerAccessible();
247
	}
253
	}
248
254
255
// RAP [if]	missing accessibility support
256
//	void triggerAccessible() {
257
//		getAccessible().setFocus(ACC.CHILDID_SELF);
258
//	}
259
249
	/**
260
	/**
250
	 * Sets the object associated with this hyperlink. Concrete implementation
261
	 * Sets the object associated with this hyperlink. Concrete implementation
251
	 * of this class can use if to store text, URLs or model objects that need
262
	 * of this class can use if to store text, URLs or model objects that need
Lines 349-355 Link Here
349
	 */
360
	 */
350
361
351
	public void setEnabled (boolean enabled) {
362
	public void setEnabled (boolean enabled) {
363
		boolean needsRedraw = enabled != getEnabled();
352
		super.setEnabled(enabled);
364
		super.setEnabled(enabled);
353
		redraw();
365
		if (needsRedraw)
366
			redraw();
354
	}
367
	}
355
}
368
}
(-)src/org/eclipse/ui/forms/widgets/FormText.java (-21 / +28 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Martin Donnelly (m2a3@eircom.net) - patch (see Bugzilla #145997) 
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.forms.widgets;
12
package org.eclipse.ui.forms.widgets;
12
13
Lines 16-21 Link Here
16
import java.util.Hashtable;
17
import java.util.Hashtable;
17
18
18
import org.eclipse.core.runtime.ListenerList;
19
import org.eclipse.core.runtime.ListenerList;
20
19
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.SWTException;
22
import org.eclipse.swt.SWTException;
21
// RAP [if] accessibility not supported
23
// RAP [if] accessibility not supported
Lines 94-100 Link Here
94
 * on the fly.
96
 * on the fly.
95
 * <p>
97
 * <p>
96
 * When configured to use formatting XML, the control requires the root element
98
 * When configured to use formatting XML, the control requires the root element
97
 * <code>form</code> to be used. The following tags can be children of the
99
 * <code>form</code> to be used and requires any ampersand (&amp;) characters in the text to
100
 * be replaced by the entity <b>&amp;amp;</b>. The following tags can be children of the
98
 * <code>form</code> element:
101
 * <code>form</code> element:
99
 * </p>
102
 * </p>
100
 * <ul>
103
 * <ul>
Lines 197-204 Link Here
197
	// RAP [if] Need to instruct LCA to relayout the segments to the client
200
	// RAP [if] Need to instruct LCA to relayout the segments to the client
198
	private boolean hasLayoutChanged = false;
201
	private boolean hasLayoutChanged = false;
199
202
200
	// private fields
203
	// private fields	
201
	//TODO We should remove the dependency on Platform
202
	private static final boolean DEBUG_TEXT = false;//"true".equalsIgnoreCase(Platform.getDebugOption(FormUtil.DEBUG_TEXT));
204
	private static final boolean DEBUG_TEXT = false;//"true".equalsIgnoreCase(Platform.getDebugOption(FormUtil.DEBUG_TEXT));
203
	private static final boolean DEBUG_TEXTSIZE = false;//"true".equalsIgnoreCase(Platform.getDebugOption(FormUtil.DEBUG_TEXTSIZE));
205
	private static final boolean DEBUG_TEXTSIZE = false;//"true".equalsIgnoreCase(Platform.getDebugOption(FormUtil.DEBUG_TEXTSIZE));
204
206
Lines 293-304 Link Here
293
					int pwidth = 0;
295
					int pwidth = 0;
294
					for (int j = 0; j < segments.length; j++) {
296
					for (int j = 0; j < segments.length; j++) {
295
						ParagraphSegment segment = segments[j];
297
						ParagraphSegment segment = segments[j];
296
						segment.advanceLocator(gc, wHint, loc, resourceTable,						
298
						segment.advanceLocator(gc, wHint, loc, resourceTable, false);
297
								false);
298
						if (wHint != SWT.DEFAULT) {
299
						if (wHint != SWT.DEFAULT) {
299
							width = Math.max(width, loc.width);
300
							width = Math.max(width, loc.width);
300
						} else {
301
						} else {
301
							pwidth += loc.width;
302
							pwidth = Math.max(pwidth, loc.width);
302
						}
303
						}
303
						if (segment instanceof IFocusSelectable)
304
						if (segment instanceof IFocusSelectable)
304
							selectableInTheLastRow = true;
305
							selectableInTheLastRow = true;
Lines 342-348 Link Here
342
			Locator loc = new Locator();
343
			Locator loc = new Locator();
343
			loc.marginWidth = marginWidth;
344
			loc.marginWidth = marginWidth;
344
			loc.marginHeight = marginHeight;
345
			loc.marginHeight = marginHeight;
345
			loc.x = marginWidth;
346
			loc.y = marginHeight;
346
			loc.y = marginHeight;
347
			FontMetrics fm = gc.getFontMetrics();
347
			FontMetrics fm = gc.getFontMetrics();
348
			int lineHeight = fm.getHeight();
348
			int lineHeight = fm.getHeight();
Lines 370-375 Link Here
370
	/**
370
	/**
371
	 * Contructs a new form text widget in the provided parent and using the
371
	 * Contructs a new form text widget in the provided parent and using the
372
	 * styles.
372
	 * styles.
373
	 * <p>
374
	 * The only valid style bit for <code>FormText</code> is <code>SWT.NO_FOCUS</code>.
375
	 * This will cause the widget to always refuse focus.
373
	 *
376
	 *
374
	 * @param parent
377
	 * @param parent
375
	 *            form text parent control
378
	 *            form text parent control
Lines 1374-1380 Link Here
1374
		SelectionEvent selEvent = new SelectionEvent( event );
1377
		SelectionEvent selEvent = new SelectionEvent( event );
1375
		selEvent.processEvent();
1378
		selEvent.processEvent();
1376
// RAP [if] accessibility not supported
1379
// RAP [if] accessibility not supported
1377
//		getAccessible().selectionChanged();
1380
//		// A listener could have caused the widget to be disposed
1381
//		if (!isDisposed()) {
1382
//		    getAccessible().selectionChanged();
1383
//		}
1378
	}
1384
	}
1379
1385
1380
// RAP [if] MouseMoveListener not supported
1386
// RAP [if] MouseMoveListener not supported
Lines 1403-1411 Link Here
1403
					setFocus();
1409
					setFocus();
1404
				}
1410
				}
1405
				model.selectLink(segmentUnder);
1411
				model.selectLink(segmentUnder);
1406
// RAP [if] MouseEvent#stateMask not implemented
1412
				enterLink(segmentUnder, e.stateMask);
1407
//				enterLink(segmentUnder, e.stateMask);
1408
				enterLink(segmentUnder, SWT.NULL);
1409
// RAP [if]	paintFocusTransfer unnecessary
1413
// RAP [if]	paintFocusTransfer unnecessary
1410
//				paintFocusTransfer(oldLink, segmentUnder);
1414
//				paintFocusTransfer(oldLink, segmentUnder);
1411
			}
1415
			}
Lines 1418-1429 Link Here
1418
		} else {
1422
		} else {
1419
			if (e.button == 1) {
1423
			if (e.button == 1) {
1420
				endSelection(e);
1424
				endSelection(e);
1425
				if (isDisposed()) return;
1421
				IHyperlinkSegment segmentUnder = model
1426
				IHyperlinkSegment segmentUnder = model
1422
						.findHyperlinkAt(e.x, e.y);
1427
						.findHyperlinkAt(e.x, e.y);
1423
				if (segmentUnder != null && armed == segmentUnder && selData == null) {
1428
				if (segmentUnder != null && armed == segmentUnder && selData == null) {
1424
// RAP [if] MouseEvent#stateMask not implemented
1429
					activateLink(segmentUnder, e.stateMask);
1425
//					activateLink(segmentUnder, e.stateMask);
1426
				    activateLink(segmentUnder, SWT.NULL);
1427
					armed = null;
1430
					armed = null;
1428
				}
1431
				}
1429
			}
1432
			}
Lines 1554-1574 Link Here
1554
						break;
1557
						break;
1555
					valid = setControlFocus(advance, selectable);
1558
					valid = setControlFocus(advance, selectable);
1556
				}
1559
				}
1557
				if (selectable == null)
1560
				if (selectable != null)
1558
					setFocusToNextSibling(this, true);
1559
				else
1560
					ensureVisible(selectable);
1561
					ensureVisible(selectable);
1561
				if (selectable instanceof IHyperlinkSegment) {
1562
				if (selectable instanceof IHyperlinkSegment) {
1562
					enterLink((IHyperlinkSegment) selectable, SWT.NULL);
1563
					enterLink((IHyperlinkSegment) selectable, SWT.NULL);
1563
// RAP [if]
1564
// RAP [if] paint not supported
1564
//					paintFocusTransfer(null, (IHyperlinkSegment) selectable);
1565
//					paintFocusTransfer(null, (IHyperlinkSegment) selectable);
1565
				}
1566
				}
1566
			}
1567
			}
1567
		} else {
1568
		} else {
1568
// RAP [if]
1569
// RAP [if] paint not supported
1569
//			paintFocusTransfer(getSelectedLink(), null);
1570
//			paintFocusTransfer(getSelectedLink(), null);
1570
			model.selectLink(null);
1571
			model.selectLink(null);
1571
		}
1572
		}
1573
		if (!model.hasFocusSegments())
1574
			redraw();
1572
	}
1575
	}
1573
1576
1574
	private void enterLink(IHyperlinkSegment link, int stateMask) {
1577
	private void enterLink(IHyperlinkSegment link, int stateMask) {
Lines 1746-1752 Link Here
1746
		} else {
1749
		} else {
1747
			size = new Point(wHint, hHint);
1750
			size = new Point(wHint, hHint);
1748
		}
1751
		}
1749
		Rectangle trim = computeTrim(0, 0, size.x, size.y);
1752
		// RAP [if] Last line of text is cutoff - increase the height with 2px
1753
		// TODO: Find proper solution
1754
		Rectangle trim = computeTrim(0, 0, size.x, size.y + 2 );
1750
		if (DEBUG_TEXTSIZE)
1755
		if (DEBUG_TEXTSIZE)
1751
			System.out.println("FormText Computed size: "+trim); //$NON-NLS-1$
1756
			System.out.println("FormText Computed size: "+trim); //$NON-NLS-1$
1752
		return new Point(trim.width, trim.height);
1757
		return new Point(trim.width, trim.height);
Lines 1795-1802 Link Here
1795
	 * @see org.eclipse.swt.widgets.Control#setFocus()
1800
	 * @see org.eclipse.swt.widgets.Control#setFocus()
1796
	 */
1801
	 */
1797
	public boolean setFocus() {
1802
	public boolean setFocus() {
1803
		mouseFocus = true;
1798
		FormUtil.setFocusScrollingEnabled(this, false);
1804
		FormUtil.setFocusScrollingEnabled(this, false);
1799
		boolean result = super.setFocus();
1805
		boolean result = super.setFocus();
1806
		mouseFocus = false;
1800
		FormUtil.setFocusScrollingEnabled(this, true);
1807
		FormUtil.setFocusScrollingEnabled(this, true);
1801
		return result;
1808
		return result;
1802
	}
1809
	}
(-)src/org/eclipse/ui/forms/widgets/Form.java (-1 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 27-33 Link Here
27
import org.eclipse.swt.widgets.Menu;
27
import org.eclipse.swt.widgets.Menu;
28
import org.eclipse.ui.forms.IFormColors;
28
import org.eclipse.ui.forms.IFormColors;
29
import org.eclipse.ui.forms.IMessage;
29
import org.eclipse.ui.forms.IMessage;
30
import org.eclipse.ui.forms.IMessageManager;
30
import org.eclipse.ui.forms.events.IHyperlinkListener;
31
import org.eclipse.ui.forms.events.IHyperlinkListener;
32
import org.eclipse.ui.internal.forms.MessageManager;
31
import org.eclipse.ui.internal.forms.widgets.FormHeading;
33
import org.eclipse.ui.internal.forms.widgets.FormHeading;
32
import org.eclipse.ui.internal.forms.widgets.FormUtil;
34
import org.eclipse.ui.internal.forms.widgets.FormUtil;
33
35
Lines 86-91 Link Here
86
 * desired layout manager explicitly.
88
 * desired layout manager explicitly.
87
 * <p>
89
 * <p>
88
 * Although the class is not final, it should not be subclassed.
90
 * Although the class is not final, it should not be subclassed.
91
 * 
92
 * @since 1.0
93
 * @noextend This class is not intended to be subclassed by clients.
89
 */
94
 */
90
public class Form extends Composite {
95
public class Form extends Composite {
91
	private FormHeading head;
96
	private FormHeading head;
Lines 97-102 Link Here
97
	private SizeCache headCache = new SizeCache();
102
	private SizeCache headCache = new SizeCache();
98
103
99
	private FormText selectionText;
104
	private FormText selectionText;
105
	
106
	private MessageManager messageManager;
100
107
101
	private class FormLayout extends Layout implements ILayoutExtension {
108
	private class FormLayout extends Layout implements ILayoutExtension {
102
		public int computeMinimumWidth(Composite composite, boolean flushCache) {
109
		public int computeMinimumWidth(Composite composite, boolean flushCache) {
Lines 758-761 Link Here
758
		}
765
		}
759
		this.selectionText = text;
766
		this.selectionText = text;
760
	}
767
	}
768
			
769
	/**
770
	 * Returns the message manager that will keep track of messages in this
771
	 * form. 
772
	 * 
773
	 * @return the message manager instance
774
	 */
775
	public IMessageManager getMessageManager() {
776
		if (messageManager == null)
777
			messageManager = new MessageManager(this);
778
		return messageManager;
779
	}
761
}
780
}
(-)src/org/eclipse/ui/forms/widgets/ImageHyperlink.java (-2 / +34 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-18 Link Here
12
package org.eclipse.ui.forms.widgets;
12
package org.eclipse.ui.forms.widgets;
13
13
14
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.graphics.*;
15
import org.eclipse.swt.events.DisposeEvent;
16
import org.eclipse.swt.events.DisposeListener;
17
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Point;
20
import org.eclipse.swt.graphics.Rectangle;
16
import org.eclipse.swt.widgets.Composite;
21
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Event;
22
import org.eclipse.swt.widgets.Event;
18
23
Lines 42-47 Link Here
42
	private Image hoverImage;
47
	private Image hoverImage;
43
48
44
	private Image activeImage;
49
	private Image activeImage;
50
	
51
//  RAP [if] unused	
52
//	private Image disabledImage;
45
53
46
	private int state;
54
	private int state;
47
55
Lines 64-69 Link Here
64
	public ImageHyperlink(Composite parent, int style) {
72
	public ImageHyperlink(Composite parent, int style) {
65
		super(parent, removeAlignment(style));
73
		super(parent, removeAlignment(style));
66
		extractAlignment(style);
74
		extractAlignment(style);
75
// RAP [if] unused
76
//		addDisposeListener(new DisposeListener() {
77
//			public void widgetDisposed(DisposeEvent e) {
78
//				if (disabledImage != null)
79
//					disabledImage.dispose();
80
//			}
81
//		});
67
	}
82
	}
68
83
69
//RAP [rh] Disabled because of disabled AbstractHyperlink#paintHyperlink()
84
//RAP [rh] Disabled because of disabled AbstractHyperlink#paintHyperlink()
Lines 234-239 Link Here
234
	 */
249
	 */
235
	public void setImage(Image image) {
250
	public void setImage(Image image) {
236
		this.image = image;
251
		this.image = image;
252
// RAP [if] unused
253
//		if (disabledImage != null)
254
//			disabledImage.dispose();
255
//		if (!isEnabled() && image != null && !image.isDisposed())
256
//			disabledImage = new Image(image.getDevice(), image, SWT.IMAGE_DISABLE);
237
	}
257
	}
238
258
239
	private Point computeMaxImageSize() {
259
	private Point computeMaxImageSize() {
Lines 288-291 Link Here
288
			horizontalAlignment = SWT.RIGHT;
308
			horizontalAlignment = SWT.RIGHT;
289
		}
309
		}
290
	}
310
	}
311
	
312
	public void setEnabled(boolean enabled) {
313
// RAP [if] unused
314
//		if (!enabled && (disabledImage == null || disabledImage.isDisposed()) && image != null && !image.isDisposed()) {
315
//			disabledImage = new Image(image.getDevice(), image, SWT.IMAGE_DISABLE);
316
//		}
317
		super.setEnabled(enabled);
318
//		if (enabled && disabledImage != null) {
319
//			disabledImage.dispose();
320
//			disabledImage = null;
321
//		}
322
	}
291
}
323
}
(-)src/org/eclipse/ui/forms/widgets/ExpandableComposite.java (-52 / +63 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Kai Nacke - Fix for Bug 202382
10
 *     Kai Nacke - Fix for Bug 202382
11
 *     Bryan Hunt - Fix for Bug 245457
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.ui.forms.widgets;
13
package org.eclipse.ui.forms.widgets;
13
14
Lines 16-23 Link Here
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
17
//import org.eclipse.swt.events.FocusEvent;
18
//import org.eclipse.swt.events.FocusEvent;
18
//import org.eclipse.swt.events.FocusListener;
19
//import org.eclipse.swt.events.FocusListener;
19
//import org.eclipse.swt.events.KeyAdapter;
20
import org.eclipse.swt.events.KeyAdapter;
20
//import org.eclipse.swt.events.KeyEvent;
21
import org.eclipse.swt.events.KeyEvent;
21
//import org.eclipse.swt.events.PaintEvent;
22
//import org.eclipse.swt.events.PaintEvent;
22
//import org.eclipse.swt.events.PaintListener;
23
//import org.eclipse.swt.events.PaintListener;
23
//import org.eclipse.swt.events.TraverseEvent;
24
//import org.eclipse.swt.events.TraverseEvent;
Lines 53-64 Link Here
53
 * The widget can be instantiated as-is, or subclassed to modify some aspects of
54
 * The widget can be instantiated as-is, or subclassed to modify some aspects of
54
 * it. *
55
 * it. *
55
 * <p>
56
 * <p>
56
 * <!-- RAP [rh] no key events
57
 * Since 3.1, left/right arrow keys can be used to control the expansion state.
57
 * Since 3.1, left/right arrow keys can be used to control the expansion state.
58
 * If several expandable composites are created in the same parent, up/down
58
 * If several expandable composites are created in the same parent, up/down
59
 * arrow keys can be used to traverse between them. Expandable text accepts
59
 * arrow keys can be used to traverse between them. Expandable text accepts
60
 * mnemonics and mnemonic activation will toggle the expansion state.
60
 * mnemonics and mnemonic activation will toggle the expansion state.
61
 * -->
62
 *
61
 *
63
 * <p>
62
 * <p>
64
 * While expandable composite recognize that different styles can be used to
63
 * While expandable composite recognize that different styles can be used to
Lines 132-137 Link Here
132
	 * be positioned after the text control and vertically centered with it.
131
	 * be positioned after the text control and vertically centered with it.
133
	 */
132
	 */
134
	public static final int LEFT_TEXT_CLIENT_ALIGNMENT = 1 << 13;
133
	public static final int LEFT_TEXT_CLIENT_ALIGNMENT = 1 << 13;
134
	
135
	/**
136
	 * By default, a focus box is painted around the title when it receives focus.
137
	 * If this style is used, the focus box will not be painted.  This style does
138
	 * not apply when FOCUS_TITLE is used.
139
	 */
140
	public static final int NO_TITLE_FOCUS_BOX = 1 << 14;
135
141
136
	/**
142
	/**
137
	 * Width of the margin that will be added around the control (default is 0).
143
	 * Width of the margin that will be added around the control (default is 0).
Lines 266-274 Link Here
266
					size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
272
					size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
267
					if (twidth < size.x + IGAP + tcsize.x) {
273
					if (twidth < size.x + IGAP + tcsize.x) {
268
						twidth -= IGAP;
274
						twidth -= IGAP;
269
						if (textLabel instanceof Label)
275
						if (textLabel instanceof Label) {
270
							size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x))));  						
276
							GC gc = new GC(textLabel);
271
						else
277
							size = FormUtil.computeWrapSize(gc, ((Label)textLabel).getText(), Math.round(twidth*(size.x/(float)(size.x+tcsize.x))));
278
							gc.dispose();
279
						} else
272
							size = textLabelCache.computeSize(Math.round(twidth*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
280
							size = textLabelCache.computeSize(Math.round(twidth*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
273
						tcsize = textClientCache.computeSize(twidth-size.x, SWT.DEFAULT);
281
						tcsize = textClientCache.computeSize(twidth-size.x, SWT.DEFAULT);
274
					}
282
					}
Lines 406-414 Link Here
406
					size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
414
					size = textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
407
					if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) {
415
					if (innertHint != SWT.DEFAULT && innertHint < size.x + IGAP + tcsize.x) {
408
						innertHint -= IGAP;
416
						innertHint -= IGAP;
409
						if (textLabel instanceof Label)
417
						if (textLabel instanceof Label) {
410
							size = FormUtil.computeWrapSize(new GC(textLabel), ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))));  						
418
							GC gc = new GC(textLabel);
411
						else
419
							size = FormUtil.computeWrapSize(gc, ((Label)textLabel).getText(), Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))));
420
							gc.dispose();
421
						} else
412
							size = textLabelCache.computeSize(Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
422
							size = textLabelCache.computeSize(Math.round(innertHint*(size.x/(float)(size.x+tcsize.x))), SWT.DEFAULT);
413
						tcsize = textClientCache.computeSize(innertHint-size.x, SWT.DEFAULT);
423
						tcsize = textClientCache.computeSize(innertHint-size.x, SWT.DEFAULT);
414
					}
424
					}
Lines 555-561 Link Here
555
					toggleState();
565
					toggleState();
556
				}
566
				}
557
			});
567
			});
558
// RAP [rh] missing paint and key events
568
// RAP [rh] missing paint
559
//			toggle.addPaintListener(new PaintListener() {
569
//			toggle.addPaintListener(new PaintListener() {
560
//				public void paintControl(PaintEvent e) {
570
//				public void paintControl(PaintEvent e) {
561
//					if (textLabel instanceof Label && !isFixedStyle())
571
//					if (textLabel instanceof Label && !isFixedStyle())
Lines 564-580 Link Here
564
//								: getTitleBarForeground());
574
//								: getTitleBarForeground());
565
//				}
575
//				}
566
//			});
576
//			});
567
//			toggle.addKeyListener(new KeyAdapter() {
577
			toggle.addKeyListener(new KeyAdapter() {
568
//				public void keyPressed(KeyEvent e) {
578
				public void keyPressed(KeyEvent e) {
569
//					if (e.keyCode == SWT.ARROW_UP) {
579
					if (e.keyCode == SWT.ARROW_UP) {
570
//						verticalMove(false);
580
						verticalMove(false);
571
//						e.doit = false;
581
						e.doit = false;
572
//					} else if (e.keyCode == SWT.ARROW_DOWN) {
582
					} else if (e.keyCode == SWT.ARROW_DOWN) {
573
//						verticalMove(true);
583
						verticalMove(true);
574
//						e.doit = false;
584
						e.doit = false;
575
//					}
585
					}
576
//				}
586
				}
577
//			});
587
			});
578
// RAP [rh] Unnecessary to add focus listener, focus-border must be handled
588
// RAP [rh] Unnecessary to add focus listener, focus-border must be handled
579
//		 on the client-side
589
//		 on the client-side
580
//			if ((getExpansionStyle()&FOCUS_TITLE)==0) {
590
//			if ((getExpansionStyle()&FOCUS_TITLE)==0) {
Lines 1018-1025 Link Here
1018
	 *            the title bar foreground
1028
	 *            the title bar foreground
1019
	 */
1029
	 */
1020
	public void setTitleBarForeground(Color color) {
1030
	public void setTitleBarForeground(Color color) {
1021
		titleBarForeground = color;
1031
		if (hasTitleBar())
1022
		textLabel.setForeground(color);
1032
			titleBarForeground = color;
1033
		if (textLabel != null)
1034
			textLabel.setForeground(color);
1023
	}
1035
	}
1024
1036
1025
	/**
1037
	/**
Lines 1057-1089 Link Here
1057
		}
1069
		}
1058
	}
1070
	}
1059
1071
1060
// RAP [rh] Obsolete, as there are no mouse events
1072
	private void verticalMove(boolean down) {
1061
//	private void verticalMove(boolean down) {
1073
		Composite parent = getParent();
1062
//		Composite parent = getParent();
1074
		Control[] children = parent.getChildren();
1063
//		Control[] children = parent.getChildren();
1075
		for (int i = 0; i < children.length; i++) {
1064
//		for (int i = 0; i < children.length; i++) {
1076
			Control child = children[i];
1065
//			Control child = children[i];
1077
			if (child == this) {
1066
//			if (child == this) {
1078
				ExpandableComposite sibling = getSibling(children, i, down);
1067
//				ExpandableComposite sibling = getSibling(children, i, down);
1079
				if (sibling != null && sibling.toggle != null) {
1068
//				if (sibling != null && sibling.toggle != null) {
1080
					sibling.setFocus();
1069
//					sibling.setFocus();
1081
				}
1070
//				}
1082
				break;
1071
//				break;
1083
			}
1072
//			}
1084
		}
1073
//		}
1085
	}
1074
//	}
1086
1075
//
1087
	private ExpandableComposite getSibling(Control[] children, int index,
1076
//	private ExpandableComposite getSibling(Control[] children, int index,
1088
			boolean down) {
1077
//			boolean down) {
1089
		int loc = down ? index + 1 : index - 1;
1078
//		int loc = down ? index + 1 : index - 1;
1090
		while (loc >= 0 && loc < children.length) {
1079
//		while (loc >= 0 && loc < children.length) {
1091
			Control c = children[loc];
1080
//			Control c = children[loc];
1092
			if (c instanceof ExpandableComposite && c.isVisible())
1081
//			if (c instanceof ExpandableComposite && c.isVisible())
1093
				return (ExpandableComposite) c;
1082
//				return (ExpandableComposite) c;
1094
			loc = down ? loc + 1 : loc - 1;
1083
//			loc = down ? loc + 1 : loc - 1;
1095
		}
1084
//		}
1096
		return null;
1085
//		return null;
1097
	}
1086
//	}
1087
1098
1088
	private void programmaticToggleState() {
1099
	private void programmaticToggleState() {
1089
		if (toggle != null)
1100
		if (toggle != null)
(-)src/org/eclipse/ui/forms/widgets/ToggleHyperlink.java (-32 / +41 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 9-15 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.forms.widgets;
11
package org.eclipse.ui.forms.widgets;
12
//import org.eclipse.swt.SWT;
12
import org.eclipse.swt.SWT;
13
//import org.eclipse.swt.accessibility.*;
13
//import org.eclipse.swt.accessibility.*;
14
import org.eclipse.swt.graphics.*;
14
import org.eclipse.swt.graphics.*;
15
import org.eclipse.swt.widgets.*;
15
import org.eclipse.swt.widgets.*;
Lines 22-27 Link Here
22
 * This is an abstract class. Subclasses are responsible for rendering the
22
 * This is an abstract class. Subclasses are responsible for rendering the
23
 * control using decoration and hover decoration color. Control should be
23
 * control using decoration and hover decoration color. Control should be
24
 * rendered based on the current expansion state.
24
 * rendered based on the current expansion state.
25
 * <p>
26
 * <dl>
27
 * <dt><b>Styles:</b></dt>
28
 * <dd>None</dd>
29
 * </dl>
25
 * 
30
 * 
26
 * @since 1.0
31
 * @since 1.0
27
 */
32
 */
Lines 42-51 Link Here
42
	 */
47
	 */
43
	public ToggleHyperlink(Composite parent, int style) {
48
	public ToggleHyperlink(Composite parent, int style) {
44
		super(parent, style);
49
		super(parent, style);
45
// RAP [rh] Mouse and key events missing
50
// RAP [rh] Mouse events missing
46
//		Listener listener = new Listener() {
51
		Listener listener = new Listener() {
47
//			public void handleEvent(Event e) {
52
			public void handleEvent(Event e) {
48
//				switch (e.type) {
53
				switch (e.type) {
49
//					case SWT.MouseEnter:
54
//					case SWT.MouseEnter:
50
//						hover=true;
55
//						hover=true;
51
//						redraw();
56
//						redraw();
Lines 54-68 Link Here
54
//						hover = false;
59
//						hover = false;
55
//						redraw();
60
//						redraw();
56
//						break;
61
//						break;
57
//					case SWT.KeyDown:
62
					case SWT.KeyDown:
58
//						onKeyDown(e);
63
						onKeyDown(e);
59
//						break;
64
						break;
60
//				}
65
				}
61
//			}
66
			}
62
//		};
67
		};
63
//		addListener(SWT.MouseEnter, listener);
68
//		addListener(SWT.MouseEnter, listener);
64
//		addListener(SWT.MouseExit, listener);
69
//		addListener(SWT.MouseExit, listener);
65
//		addListener(SWT.KeyDown, listener);
70
		addListener(SWT.KeyDown, listener);
66
		addHyperlinkListener(new HyperlinkAdapter() {
71
		addHyperlinkListener(new HyperlinkAdapter() {
67
			public void linkActivated(HyperlinkEvent e) {
72
			public void linkActivated(HyperlinkEvent e) {
68
				setExpanded(!isExpanded());
73
				setExpanded(!isExpanded());
Lines 157-164 Link Here
157
	 */
162
	 */
158
	public void setExpanded(boolean expanded) {
163
	public void setExpanded(boolean expanded) {
159
		this.expanded = expanded;
164
		this.expanded = expanded;
160
// RAP [rh] accessibility not implemented
161
//		getAccessible().selectionChanged();
162
		redraw();
165
		redraw();
163
	}
166
	}
164
// RAP [rh] accessibility not implemented
167
// RAP [rh] accessibility not implemented
Lines 224-245 Link Here
224
//					}
227
//					}
225
//				});
228
//				});
226
//	}
229
//	}
227
230
//	// set bogus childIDs on link activation to ensure state is read on expand/collapse
228
// RAP [rh] Key events missing
231
//	void triggerAccessible() {
229
//	private void onKeyDown(Event e) {
232
//		getAccessible().setFocus(getAccessibleChildID());
230
//		if (e.keyCode==SWT.ARROW_RIGHT) {
231
//			// expand if collapsed
232
//			if (!isExpanded()) {
233
//				handleActivate(e);
234
//			}
235
//			e.doit=false;
236
//		}
237
//		else if (e.keyCode==SWT.ARROW_LEFT) {
238
//			// collapse if expanded
239
//			if (isExpanded()) {
240
//				handleActivate(e);
241
//			}
242
//			e.doit=false;
243
//		}
244
//	}
233
//	}
234
//	private int getAccessibleChildID() {
235
//		return ToggleHyperlink.this.isExpanded() ? 1 : 2;
236
//	}
237
238
	private void onKeyDown(Event e) {
239
		if (e.keyCode==SWT.ARROW_RIGHT) {
240
			// expand if collapsed
241
			if (!isExpanded()) {
242
				handleActivate(e);
243
			}
244
			e.doit=false;
245
		}
246
		else if (e.keyCode==SWT.ARROW_LEFT) {
247
			// collapse if expanded
248
			if (isExpanded()) {
249
				handleActivate(e);
250
			}
251
			e.doit=false;
252
		}
253
	}
245
}
254
}
(-)src/org/eclipse/ui/forms/widgets/TableWrapLayout.java (-9 / +6 lines)
Lines 1-11 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.forms.widgets;
11
package org.eclipse.ui.forms.widgets;
Lines 108-122 Link Here
108
108
109
		int row;
109
		int row;
110
110
111
		int column;
112
113
		int height;
111
		int height;
114
112
115
		int totalHeight;
113
		int totalHeight;
116
114
117
		public RowSpan(Control child, int column, int row) {
115
		public RowSpan(Control child, int column, int row) {
118
			this.child = child;
116
			this.child = child;
119
			this.column = column;
120
			this.row = row;
117
			this.row = row;
121
		}
118
		}
122
119
(-)src/org/eclipse/ui/forms/widgets/TreeNode.java (-6 / +11 lines)
Lines 1-11 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.forms.widgets;
11
package org.eclipse.ui.forms.widgets;
Lines 22-27 Link Here
22
 * The control is rendered as box with a '+' or '-' sign, depending on the
22
 * The control is rendered as box with a '+' or '-' sign, depending on the
23
 * expansion state. Focus indication is rendered around the box when the
23
 * expansion state. Focus indication is rendered around the box when the
24
 * control has keyboard focus.
24
 * control has keyboard focus.
25
 * <p>
26
 * <dl>
27
 * <dt><b>Styles:</b></dt>
28
 * <dd>None</dd>
29
 * </dl>
25
 * 
30
 * 
26
 * @see Twistie
31
 * @see Twistie
27
 * @since 1.0
32
 * @since 1.0
(-)src/org/eclipse/ui/forms/widgets/FormToolkit.java (-34 / +39 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-26 Link Here
18
import org.eclipse.swt.custom.ScrolledComposite;
18
import org.eclipse.swt.custom.ScrolledComposite;
19
import org.eclipse.swt.events.FocusAdapter;
19
import org.eclipse.swt.events.FocusAdapter;
20
import org.eclipse.swt.events.FocusEvent;
20
import org.eclipse.swt.events.FocusEvent;
21
// RAP [rh] Key events missing
21
import org.eclipse.swt.events.KeyAdapter;
22
//import org.eclipse.swt.events.KeyAdapter;
22
import org.eclipse.swt.events.KeyEvent;
23
//import org.eclipse.swt.events.KeyEvent;
24
import org.eclipse.swt.events.MouseAdapter;
23
import org.eclipse.swt.events.MouseAdapter;
25
import org.eclipse.swt.events.MouseEvent;
24
import org.eclipse.swt.events.MouseEvent;
26
// RAP [rh] Paint events missing
25
// RAP [rh] Paint events missing
Lines 98-110 Link Here
98
	private BoldFontHolder boldFontHolder;
97
	private BoldFontHolder boldFontHolder;
99
98
100
	private HyperlinkGroup hyperlinkGroup;
99
	private HyperlinkGroup hyperlinkGroup;
100
	
101
	private boolean isDisposed = false;
101
102
102
	/* default */
103
	/* default */
103
	VisibilityHandler visibilityHandler;
104
	VisibilityHandler visibilityHandler;
104
105
105
	/* default */
106
	/* default */
106
// RAP [rh] Key events missing
107
	KeyboardHandler keyboardHandler;
107
//	KeyboardHandler keyboardHandler;
108
108
109
	// RAP [rh] Paint events missing
109
	// RAP [rh] Paint events missing
110
//	private class BorderPainter implements PaintListener {
110
//	private class BorderPainter implements PaintListener {
Lines 177-192 Link Here
177
		}
177
		}
178
	}
178
	}
179
179
180
	// RAP [rh] key events missing
180
	private static class KeyboardHandler extends KeyAdapter {
181
//	private static class KeyboardHandler extends KeyAdapter {
181
		public void keyPressed(KeyEvent e) {
182
//		public void keyPressed(KeyEvent e) {
182
			Widget w = e.widget;
183
//			Widget w = e.widget;
183
			if (w instanceof Control) {
184
//			if (w instanceof Control) {
184
				if (e.doit)
185
//				if (e.doit)
185
					FormUtil.processKey(e.keyCode, (Control) w);
186
//					FormUtil.processKey(e.keyCode, (Control) w);
186
			}
187
//			}
187
		}
188
//		}
188
	}
189
//	}
190
189
191
	private class BoldFontHolder {
190
	private class BoldFontHolder {
192
		private Font normalFont;
191
		private Font normalFont;
Lines 222-227 Link Here
222
221
223
	/**
222
	/**
224
	 * Creates a toolkit that is self-sufficient (will manage its own colors).
223
	 * Creates a toolkit that is self-sufficient (will manage its own colors).
224
	 * <p>
225
	 * Clients that call this method must call {@link #dispose()} when they
226
	 * are finished using the toolkit.
225
	 *
227
	 *
226
	 */
228
	 */
227
	public FormToolkit(Display display) {
229
	public FormToolkit(Display display) {
Lines 232-237 Link Here
232
	 * Creates a toolkit that will use the provided (shared) colors. The toolkit
234
	 * Creates a toolkit that will use the provided (shared) colors. The toolkit
233
	 * will dispose the colors if and only if they are <b>not</b> marked as
235
	 * will dispose the colors if and only if they are <b>not</b> marked as
234
	 * shared via the <code>markShared()</code> method.
236
	 * shared via the <code>markShared()</code> method.
237
	 * <p>
238
	 * Clients that call this method must call {@link #dispose()} when they
239
	 * are finished using the toolkit.
235
	 *
240
	 *
236
	 * @param colors
241
	 * @param colors
237
	 *            the shared colors
242
	 *            the shared colors
Lines 366-373 Link Here
366
		if (text != null)
371
		if (text != null)
367
			hyperlink.setText(text);
372
			hyperlink.setText(text);
368
		hyperlink.addFocusListener(visibilityHandler);
373
		hyperlink.addFocusListener(visibilityHandler);
369
// RAP [rh] Key events missing
374
		hyperlink.addKeyListener(keyboardHandler);
370
//		hyperlink.addKeyListener(keyboardHandler);
371
		hyperlinkGroup.add(hyperlink);
375
		hyperlinkGroup.add(hyperlink);
372
		return hyperlink;
376
		return hyperlink;
373
	}
377
	}
Lines 386-393 Link Here
386
		ImageHyperlink hyperlink = new ImageHyperlink(parent, style
390
		ImageHyperlink hyperlink = new ImageHyperlink(parent, style
387
				| orientation);
391
				| orientation);
388
		hyperlink.addFocusListener(visibilityHandler);
392
		hyperlink.addFocusListener(visibilityHandler);
389
// RAP [rh] Key events missing
393
		hyperlink.addKeyListener(keyboardHandler);
390
//		hyperlink.addKeyListener(keyboardHandler);
391
		hyperlinkGroup.add(hyperlink);
394
		hyperlinkGroup.add(hyperlink);
392
		return hyperlink;
395
		return hyperlink;
393
	}
396
	}
Lines 443-466 Link Here
443
			if (ec.toggle != null) {
446
			if (ec.toggle != null) {
444
				if (trackFocus)
447
				if (trackFocus)
445
					ec.toggle.addFocusListener(visibilityHandler);
448
					ec.toggle.addFocusListener(visibilityHandler);
446
// RAP [rh] Key events missing
449
				if (trackKeyboard)
447
//				if (trackKeyboard)
450
					ec.toggle.addKeyListener(keyboardHandler);
448
//					ec.toggle.addKeyListener(keyboardHandler);
449
			}
451
			}
450
			if (ec.textLabel != null) {
452
			if (ec.textLabel != null) {
451
				if (trackFocus)
453
				if (trackFocus)
452
					ec.textLabel.addFocusListener(visibilityHandler);
454
					ec.textLabel.addFocusListener(visibilityHandler);
453
// RAP [rh] Key events missing
455
				if (trackKeyboard)
454
//				if (trackKeyboard)
456
					ec.textLabel.addKeyListener(keyboardHandler);
455
//					ec.textLabel.addKeyListener(keyboardHandler);
456
			}
457
			}
457
			return;
458
			return;
458
		}
459
		}
459
		if (trackFocus)
460
		if (trackFocus)
460
			control.addFocusListener(visibilityHandler);
461
			control.addFocusListener(visibilityHandler);
461
// RAP [rh] Key events missing
462
		if (trackKeyboard)
462
//		if (trackKeyboard)
463
			control.addKeyListener(keyboardHandler);
463
//			control.addKeyListener(keyboardHandler);
464
	}
464
	}
465
465
466
	/**
466
	/**
Lines 476-482 Link Here
476
				((Control) e.widget).setFocus();
476
				((Control) e.widget).setFocus();
477
			}
477
			}
478
		});
478
		});
479
		composite.setMenu(composite.getParent().getMenu());
479
		if (composite.getParent() != null)
480
			composite.setMenu(composite.getParent().getMenu());
480
	}
481
	}
481
482
482
	/**
483
	/**
Lines 518-526 Link Here
518
			section.setTitleBarBackground(colors.getColor(IFormColors.TB_BG));
519
			section.setTitleBarBackground(colors.getColor(IFormColors.TB_BG));
519
			section.setTitleBarBorderColor(colors
520
			section.setTitleBarBorderColor(colors
520
					.getColor(IFormColors.TB_BORDER));
521
					.getColor(IFormColors.TB_BORDER));
521
			section.setTitleBarForeground(colors
522
					.getColor(IFormColors.TB_TOGGLE));
523
		}
522
		}
523
		// call setTitleBarForeground regardless as it also sets the label color
524
		section.setTitleBarForeground(colors
525
				.getColor(IFormColors.TB_TOGGLE));
524
		return section;
526
		return section;
525
	}
527
	}
526
528
Lines 714-719 Link Here
714
	 * Disposes the toolkit.
716
	 * Disposes the toolkit.
715
	 */
717
	 */
716
	public void dispose() {
718
	public void dispose() {
719
		if (isDisposed) {
720
			return;
721
		}
722
		isDisposed = true;
717
		if (colors.isShared() == false) {
723
		if (colors.isShared() == false) {
718
			colors.dispose();
724
			colors.dispose();
719
			colors = null;
725
			colors = null;
Lines 866-873 Link Here
866
		hyperlinkGroup = new HyperlinkGroup(colors.getDisplay());
872
		hyperlinkGroup = new HyperlinkGroup(colors.getDisplay());
867
		hyperlinkGroup.setBackground(colors.getBackground());
873
		hyperlinkGroup.setBackground(colors.getBackground());
868
		visibilityHandler = new VisibilityHandler();
874
		visibilityHandler = new VisibilityHandler();
869
// RAP [rh] Key events missing
875
		keyboardHandler = new KeyboardHandler();
870
//		keyboardHandler = new KeyboardHandler();
871
		boldFontHolder = new BoldFontHolder();
876
		boldFontHolder = new BoldFontHolder();
872
	}
877
	}
873
878
(-)src/org/eclipse/ui/forms/widgets/Hyperlink.java (-11 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 IBM Corporation and others.
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-22 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.forms.widgets;
11
package org.eclipse.ui.forms.widgets;
12
12
13
import org.eclipse.rwt.graphics.Graphics;
14
import org.eclipse.swt.SWT;
13
import org.eclipse.swt.SWT;
15
//import org.eclipse.swt.accessibility.*;
14
//import org.eclipse.swt.accessibility.*;
16
import org.eclipse.swt.graphics.*;
15
import org.eclipse.swt.graphics.*;
17
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.Composite;
17
//import org.eclipse.ui.forms.FormColors;
18
import org.eclipse.ui.internal.forms.widgets.*;
18
import org.eclipse.ui.forms.internal.widgets.IHyperlinkAdapter;
19
import org.eclipse.ui.forms.internal.widgets.IHyperlinkAdapter;
19
//import org.eclipse.ui.internal.forms.widgets.*;
20
20
21
/**
21
/**
22
 * Hyperlink is a concrete implementation of the abstract base class that draws
22
 * Hyperlink is a concrete implementation of the abstract base class that draws
Lines 25-30 Link Here
25
 * for all the hyperlinks that belong to it.
25
 * for all the hyperlinks that belong to it.
26
 * <p>
26
 * <p>
27
 * Hyperlink can be extended.
27
 * Hyperlink can be extended.
28
 * <p>
29
 * <dl>
30
 * <dt><b>Styles:</b></dt>
31
 * <dd>SWT.WRAP</dd>
32
 * </dl>
28
 *
33
 *
29
 * @see org.eclipse.ui.forms.HyperlinkGroup
34
 * @see org.eclipse.ui.forms.HyperlinkGroup
30
 */
35
 */
Lines 306-325 Link Here
306
//	}
311
//	}
307
312
308
	protected Point computeTextSize(int wHint, int hHint) {
313
	protected Point computeTextSize(int wHint, int hHint) {
309
// RAP [rh] Changed text size calculation due to missing GC
310
		Point extent;
314
		Point extent;
311
//		GC gc = new GC(this);
315
		GC gc = new GC(this);
312
//		gc.setFont(getFont());
316
		gc.setFont(getFont());
313
		if ((getStyle() & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
317
		if ((getStyle() & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
314
//			extent = FormUtil.computeWrapSize(gc, getText(), wHint);
318
			extent = FormUtil.computeWrapSize(gc, getText(), wHint);
315
			extent = Graphics.textExtent( getFont(), getText(), wHint );
316
		} else {
319
		} else {
317
//			extent = gc.textExtent(getText());
320
			extent = gc.textExtent(getText());
318
			extent = Graphics.stringExtent( getFont(), getText() );
319
			if ((getStyle() & SWT.WRAP)==0 && wHint!=SWT.DEFAULT)
321
			if ((getStyle() & SWT.WRAP)==0 && wHint!=SWT.DEFAULT)
320
				extent.x = wHint;
322
				extent.x = wHint;
321
		}
323
		}
322
//		gc.dispose();
324
		gc.dispose();
323
		return extent;
325
		return extent;
324
	}
326
	}
325
}
327
}
(-)src/org/eclipse/ui/forms/widgets/Twistie.java (-6 / +11 lines)
Lines 1-11 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.forms.widgets;
11
package org.eclipse.ui.forms.widgets;
Lines 24-29 Link Here
24
 * <p>
24
 * <p>
25
 * The control is rendered as a triangle that points to the right in the
25
 * The control is rendered as a triangle that points to the right in the
26
 * collapsed and down in the expanded state. Triangle color can be changed.
26
 * collapsed and down in the expanded state. Triangle color can be changed.
27
 * <p>
28
 * <dl>
29
 * <dt><b>Styles:</b></dt>
30
 * <dd>None</dd>
31
 * </dl>
27
 * 
32
 * 
28
 * @see TreeNode
33
 * @see TreeNode
29
 * @since 1.0
34
 * @since 1.0
(-)src/org/eclipse/ui/forms/widgets/ColumnLayout.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 8-13 Link Here
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     dinko.ivanov@sap.com - patch #70790
10
 *     dinko.ivanov@sap.com - patch #70790
11
 *     RasmussenJamie@comcast.net - patch for Bug 184345
11
 *******************************************************************************/
12
 *******************************************************************************/
12
package org.eclipse.ui.forms.widgets;
13
package org.eclipse.ui.forms.widgets;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
Lines 185-191 Link Here
185
			cwidth = Math.max(cwidth, sizes[i].x);
186
			cwidth = Math.max(cwidth, sizes[i].x);
186
			cheight += sizes[i].y;
187
			cheight += sizes[i].y;
187
		}
188
		}
188
		int ncolumns = (carea.width - leftMargin - rightMargin - horizontalSpacing) / (cwidth + horizontalSpacing);
189
		int ncolumns = (carea.width - leftMargin - rightMargin + horizontalSpacing) / (cwidth + horizontalSpacing);
189
		ncolumns = Math.min(ncolumns, children.length);		
190
		ncolumns = Math.min(ncolumns, children.length);		
190
		ncolumns = Math.max(ncolumns, minNumColumns);
191
		ncolumns = Math.max(ncolumns, minNumColumns);
191
		ncolumns = Math.min(ncolumns, maxNumColumns);
192
		ncolumns = Math.min(ncolumns, maxNumColumns);
(-)src/org/eclipse/ui/forms/widgets/TableWrapData.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 14-20 Link Here
14
import org.eclipse.swt.graphics.Point;
14
import org.eclipse.swt.graphics.Point;
15
15
16
/**
16
/**
17
 * Layout data used in conjunction with <code>HTMLTableLayout</code>.
17
 * Layout data used in conjunction with <code>TableWrapLayout</code>.
18
 * Children in a composite that uses this layout should call <samp>setLayoutData
18
 * Children in a composite that uses this layout should call <samp>setLayoutData
19
 * </samp> and pass an instance of this class to control physical placement in
19
 * </samp> and pass an instance of this class to control physical placement in
20
 * the parent.
20
 * the parent.
(-)src/org/eclipse/ui/forms/widgets/ScrolledForm.java (-5 / +31 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-23 Link Here
12
12
13
import org.eclipse.jface.action.IToolBarManager;
13
import org.eclipse.jface.action.IToolBarManager;
14
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.events.DisposeEvent;
16
import org.eclipse.swt.events.DisposeListener;
15
import org.eclipse.swt.graphics.Color;
17
import org.eclipse.swt.graphics.Color;
16
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Control;
20
import org.eclipse.swt.widgets.Control;
19
import org.eclipse.swt.widgets.Menu;
21
import org.eclipse.swt.widgets.Menu;
20
import org.eclipse.ui.forms.IMessage;
22
import org.eclipse.ui.forms.IMessage;
23
import org.eclipse.ui.forms.IMessageManager;
21
24
22
/**
25
/**
23
 * ScrolledForm is a control that is capable of scrolling an instance of the
26
 * ScrolledForm is a control that is capable of scrolling an instance of the
Lines 43-51 Link Here
43
 * Although the class is not final, it is not expected to be be extended.
46
 * Although the class is not final, it is not expected to be be extended.
44
 * 
47
 * 
45
 * @since 1.0
48
 * @since 1.0
49
 * @noextend This class is not intended to be subclassed by clients.
46
 */
50
 */
47
public class ScrolledForm extends SharedScrolledComposite {
51
public class ScrolledForm extends SharedScrolledComposite {
48
	private Form content;
52
	private Form content;
53
	
54
	private boolean customMenu;
49
55
50
	public ScrolledForm(Composite parent) {
56
	public ScrolledForm(Composite parent) {
51
		this(parent, SWT.V_SCROLL | SWT.H_SCROLL);
57
		this(parent, SWT.V_SCROLL | SWT.H_SCROLL);
Lines 63-68 Link Here
63
		content = new Form(this, SWT.NULL);
69
		content = new Form(this, SWT.NULL);
64
		super.setContent(content);
70
		super.setContent(content);
65
		content.setMenu(getMenu());
71
		content.setMenu(getMenu());
72
		addDisposeListener(new DisposeListener() {
73
			public void widgetDisposed(DisposeEvent e) {
74
				if (!customMenu)
75
					setMenu(null);
76
			}
77
		});
66
	}
78
	}
67
79
68
	/**
80
	/**
Lines 71-76 Link Here
71
	 * @param menu
83
	 * @param menu
72
	 */
84
	 */
73
	public void setMenu(Menu menu) {
85
	public void setMenu(Menu menu) {
86
		customMenu = true;
74
		super.setMenu(menu);
87
		super.setMenu(menu);
75
		if (content != null)
88
		if (content != null)
76
			content.setMenu(menu);
89
			content.setMenu(menu);
Lines 253-263 Link Here
253
		reflow(true);
266
		reflow(true);
254
	}
267
	}
255
268
256
	/*
269
	/**
257
	 * (non-Javadoc)
270
	 * Sets the form message.
258
	 * 
271
	 * 
259
	 * @see org.eclipse.ui.forms.IMessageContainer#setMessage(java.lang.String,
272
	 * @param newMessage
260
	 *      int)
273
	 *            the message text or <code>null</code> to reset.
274
	 * @param newType
275
	 *            as defined in
276
	 *            {@link org.eclipse.jface.dialogs.IMessageProvider}.
261
	 */
277
	 */
262
	public void setMessage(String newMessage, int newType) {
278
	public void setMessage(String newMessage, int newType) {
263
		this.setMessage(newMessage, newType, null);
279
		this.setMessage(newMessage, newType, null);
Lines 280-283 Link Here
280
	public int getMessageType() {
296
	public int getMessageType() {
281
		return content.getMessageType();
297
		return content.getMessageType();
282
	}
298
	}
299
	
300
	/**
301
	 * Returns the message manager that will keep track of messages in this
302
	 * form. 
303
	 * 
304
	 * @return the message manager instance
305
	 */
306
	public IMessageManager getMessageManager() {
307
		return content.getMessageManager();
308
	}
283
}
309
}
(-)src/org/eclipse/ui/forms/widgets/SharedScrolledComposite.java (-37 / +40 lines)
Lines 1-12 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Wojciech Galanciak - fix for Bug 294868 - [Forms] Problem with text
11
 *     wrapping in SharedScrolledComposite:
10
 *******************************************************************************/
12
 *******************************************************************************/
11
package org.eclipse.ui.forms.widgets;
13
package org.eclipse.ui.forms.widgets;
12
14
Lines 48-54 Link Here
48
50
49
	private boolean reflowPending = false;
51
	private boolean reflowPending = false;
50
52
51
	private boolean delayedReflow = true;
53
	private boolean delayedReflow = false;
52
	
54
	
53
	/**
55
	/**
54
	 * Creates the new instance.
56
	 * Creates the new instance.
Lines 179-221 Link Here
179
		Rectangle clientArea = getClientArea();
181
		Rectangle clientArea = getClientArea();
180
		if (c == null)
182
		if (c == null)
181
			return;
183
			return;
184
// RAP [if] No scrollbars			
185
//		if (clientArea.width == getSize().x) {
186
//			ScrollBar bar = getVerticalBar();
187
//			if (bar != null) {
188
//			    clientArea.width -= bar.getSize().x;
189
//			}
190
//		}
182
191
183
		contentCache.setControl(c);
192
		contentCache.setControl(c);
184
		if (flushCache) {
193
		if (flushCache) {
185
			contentCache.flush();
194
			contentCache.flush();
186
		}
195
		}
187
		try {
196
		Point newSize = contentCache.computeSize(FormUtil.getWidthHint(
188
			setRedraw(false);
197
				clientArea.width, c), FormUtil.getHeightHint(clientArea.height,
189
			Point newSize = contentCache.computeSize(FormUtil.getWidthHint(
198
				c));
190
					clientArea.width, c), FormUtil.getHeightHint(clientArea.height,
191
					c));
192
	
199
	
193
			// Point currentSize = c.getSize();
200
		if (!(expandHorizontal && expandVertical)) {
194
			if (!(expandHorizontal && expandVertical)) {
201
			c.setSize(newSize);
195
				c.setSize(newSize);
202
		}
196
			}
197
	
203
	
198
			setMinSize(newSize);
204
		setMinSize(newSize);
199
			FormUtil.updatePageIncrement(this);
205
		FormUtil.updatePageIncrement(this);
200
			
206
			
201
			// reduce vertical scroll increment if necessary
207
		// reduce vertical scroll increment if necessary
202
// RAP [rh] Scrollbar#setIncrement() missing			
208
// RAP [rh] Scrollbar#setIncrement() missing			
203
//			ScrollBar vbar = getVerticalBar();
209
//		ScrollBar vbar = getVerticalBar();
204
//			if (vbar != null) {
210
//		if (vbar != null) {
205
//				if (getClientArea().height - 5 < V_SCROLL_INCREMENT)
211
//			if (getClientArea().height - 5 < V_SCROLL_INCREMENT)
206
//					getVerticalBar().setIncrement(getClientArea().height - 5);
212
//				getVerticalBar().setIncrement(getClientArea().height - 5);
207
//				else 
213
//			else 
208
//					getVerticalBar().setIncrement(V_SCROLL_INCREMENT);
214
//				getVerticalBar().setIncrement(V_SCROLL_INCREMENT);
209
//			}
215
//		}
210
	
216
	
211
			ignoreLayouts = false;
217
		ignoreLayouts = false;
212
			layout(flushCache);
218
		layout(flushCache);
213
			ignoreLayouts = true;
219
		ignoreLayouts = true;
214
	
220
	
215
			contentCache.layoutIfNecessary();
221
		contentCache.layoutIfNecessary();
216
		} finally {
217
			setRedraw(true);
218
		}
219
	}
222
	}
220
223
221
	private void updateSizeWhilePending() {
224
	private void updateSizeWhilePending() {
Lines 230-243 Link Here
230
				updateSizeWhilePending();
233
				updateSizeWhilePending();
231
				return;
234
				return;
232
			}
235
			}
236
			reflowPending = true;
233
			getDisplay().asyncExec(new Runnable() {
237
			getDisplay().asyncExec(new Runnable() {
234
				public void run() {
238
				public void run() {
239
					reflowPending = false;
235
					if (!isDisposed())
240
					if (!isDisposed())
236
						reflow(flushCache);
241
						reflow(flushCache);
237
					reflowPending = false;
238
				}
242
				}
239
			});
243
			});
240
			reflowPending = true;
241
		} else
244
		} else
242
			reflow(flushCache);
245
			reflow(flushCache);
243
	}
246
	}
Lines 268-275 Link Here
268
	 * Sets the delayed reflow feature. When used,
271
	 * Sets the delayed reflow feature. When used,
269
	 * it will schedule a reflow on resize requests
272
	 * it will schedule a reflow on resize requests
270
	 * and reject subsequent reflows until the
273
	 * and reject subsequent reflows until the
271
	 * scheduled one is performed. This improves
274
	 * scheduled one is performed.
272
	 * performance by 
275
	 *
273
	 * @param delayedReflow
276
	 * @param delayedReflow
274
	 *            The delayedReflow to set.
277
	 *            The delayedReflow to set.
275
	 */
278
	 */
(-)src/org/eclipse/ui/forms/widgets/Section.java (-8 / +9 lines)
Lines 1-11 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Michael Williamson (eclipse-bugs@magnaworks.com) - patch (see Bugzilla #92545)
10
 *     Michael Williamson (eclipse-bugs@magnaworks.com) - patch (see Bugzilla #92545)
11
 *
11
 *
Lines 27-32 Link Here
27
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Event;
28
import org.eclipse.swt.widgets.Event;
29
import org.eclipse.swt.widgets.Listener;
29
import org.eclipse.swt.widgets.Listener;
30
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.swt.widgets.Text;
31
import org.eclipse.swt.widgets.Text;
31
import org.eclipse.ui.internal.forms.widgets.FormImages;
32
import org.eclipse.ui.internal.forms.widgets.FormImages;
32
//import org.eclipse.ui.internal.forms.widgets.FormUtil;
33
//import org.eclipse.ui.internal.forms.widgets.FormUtil;
Lines 130-136 Link Here
130
		while (c != null) {
131
		while (c != null) {
131
			c.setRedraw(false);
132
			c.setRedraw(false);
132
			c = c.getParent();
133
			c = c.getParent();
133
			if (c instanceof SharedScrolledComposite) {
134
			if (c instanceof SharedScrolledComposite || c instanceof Shell) {
134
				break;
135
				break;
135
			}
136
			}
136
		}
137
		}
Lines 147-153 Link Here
147
		while (c != null) {
148
		while (c != null) {
148
			c.setRedraw(true);
149
			c.setRedraw(true);
149
			c = c.getParent();
150
			c = c.getParent();
150
			if (c instanceof SharedScrolledComposite) {
151
			if (c instanceof SharedScrolledComposite || c instanceof Shell) {
151
				break;
152
				break;
152
			}
153
			}
153
		}
154
		}
(-)src/org/eclipse/ui/forms/widgets/ColumnLayoutData.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 37-47 Link Here
37
	 */
37
	 */
38
	public static final int LEFT = 1;
38
	public static final int LEFT = 1;
39
	/**
39
	/**
40
	 * Horizontal alignment constant - control will be aligned to the right.
40
	 * Horizontal alignment constant - control will be centered.
41
	 */
41
	 */
42
	public static final int CENTER = 2;
42
	public static final int CENTER = 2;
43
	/**
43
	/**
44
	 * Horizontal alignment constant - control will be centered.
44
	 * Horizontal alignment constant - control will be aligned to the right.
45
	 */
45
	 */
46
	public static final int RIGHT = 3;
46
	public static final int RIGHT = 3;
47
	/**
47
	/**
(-)src/org/eclipse/ui/internal/forms/widgets/Paragraph.java (-6 / +17 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-17 Link Here
12
12
13
import java.io.*;
13
import java.io.*;
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Arrays;
15
import java.util.Hashtable;
16
import java.util.Hashtable;
16
import java.util.Vector;
17
import java.util.Vector;
17
18
Lines 23-29 Link Here
23
 * @author
24
 * @author
24
 */
25
 */
25
public class Paragraph {
26
public class Paragraph {
26
	public static final String HTTP = "http://"; //$NON-NLS-1$
27
	public static final String[] PROTOCOLS = {"http://", "https://", "ftp://"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
27
28
28
	private Vector segments;
29
	private Vector segments;
29
30
Lines 67-73 Link Here
67
		if (text.length() == 0)
68
		if (text.length() == 0)
68
			return;
69
			return;
69
		if (expandURLs) {
70
		if (expandURLs) {
70
			int loc = text.indexOf(HTTP);
71
			int loc = findUrl(text,0);
71
72
72
			if (loc == -1)
73
			if (loc == -1)
73
				addSegment(new TextSegment(text, fontId, colorId, wrapAllowed));
74
				addSegment(new TextSegment(text, fontId, colorId, wrapAllowed));
Lines 92-98 Link Here
92
								fontId);
93
								fontId);
93
						break;
94
						break;
94
					}
95
					}
95
					loc = text.indexOf(HTTP, textLoc);
96
					loc = findUrl(text,textLoc);
96
				}
97
				}
97
				if (textLoc < text.length()) {
98
				if (textLoc < text.length()) {
98
					addSegment(new TextSegment(text.substring(textLoc), fontId,
99
					addSegment(new TextSegment(text.substring(textLoc), fontId,
Lines 103-108 Link Here
103
			addSegment(new TextSegment(text, fontId, colorId, wrapAllowed));
104
			addSegment(new TextSegment(text, fontId, colorId, wrapAllowed));
104
		}
105
		}
105
	}
106
	}
107
	
108
	private int findUrl(String text, int startIndex) {
109
		int[] locs = new int[PROTOCOLS.length];
110
		for (int i = 0; i < PROTOCOLS.length; i++)
111
			locs[i] = text.indexOf(PROTOCOLS[i], startIndex);
112
		Arrays.sort(locs);
113
		for (int i = 0; i < PROTOCOLS.length; i++)
114
			if (locs[i] != -1)
115
				return locs[i];
116
		return -1;
117
	}
106
118
107
	private void addHyperlinkSegment(String text, HyperlinkSettings settings,
119
	private void addHyperlinkSegment(String text, HyperlinkSettings settings,
108
			String fontId) {
120
			String fontId) {
Lines 121-130 Link Here
121
		ArrayList heights = new ArrayList();
133
		ArrayList heights = new ArrayList();
122
		hloc.heights = heights;
134
		hloc.heights = heights;
123
		hloc.rowCounter = 0;
135
		hloc.rowCounter = 0;
124
		int innerWidth = width - loc.marginWidth*2;
125
		for (int j = 0; j < segments.length; j++) {
136
		for (int j = 0; j < segments.length; j++) {
126
			ParagraphSegment segment = segments[j];
137
			ParagraphSegment segment = segments[j];
127
			segment.advanceLocator(gc, innerWidth, hloc, resourceTable, true);
138
			segment.advanceLocator(gc, width, hloc, resourceTable, true);
128
		}
139
		}
129
		hloc.collectHeights();
140
		hloc.collectHeights();
130
		loc.heights = heights;
141
		loc.heights = heights;
(-)src/org/eclipse/ui/internal/forms/widgets/TextHyperlinkSegment.java (-1 / +1 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
(-)src/org/eclipse/ui/internal/forms/widgets/FormImages.java (-180 / +179 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-22 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Wang Yizhuo (wangyizhuo@gmail.com) - patch (see Bugzilla #239178) 
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.ui.internal.forms.widgets;
12
package org.eclipse.ui.internal.forms.widgets;
12
13
13
//import java.util.Arrays;
14
//import java.util.Arrays;
14
import java.util.HashMap;
15
import java.util.HashMap;
15
16
17
import org.eclipse.jface.resource.ImageDescriptor;
18
//import org.eclipse.jface.resource.JFaceResources;
19
//import org.eclipse.jface.resource.LocalResourceManager;
16
import org.eclipse.swt.graphics.Color;
20
import org.eclipse.swt.graphics.Color;
21
//import org.eclipse.swt.graphics.Device;
17
//import org.eclipse.swt.graphics.GC;
22
//import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.graphics.Image;
23
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.widgets.Display;
24
//import org.eclipse.swt.graphics.ImageData;
25
import org.eclipse.swt.graphics.RGB;
20
26
21
public class FormImages {
27
public class FormImages {
22
	private static FormImages instance;
28
	private static FormImages instance;
Lines 27-56 Link Here
27
		return instance;
33
		return instance;
28
	}
34
	}
29
35
30
	private HashMap images;
36
//	private LocalResourceManager resources;
31
	private HashMap ids;
37
	private HashMap descriptors;
32
	
38
	
33
	private FormImages() {
39
	private FormImages() {
34
	}
40
	}
35
	
41
	
36
	private abstract class ImageIdentifier {
42
	private abstract class AbstractImageDescriptor extends ImageDescriptor {
37
		Display fDisplay;
43
		RGB[] fRGBs;
38
		Color[] fColors;
39
		int fLength;
44
		int fLength;
40
		
45
		
41
		ImageIdentifier(Display display, Color[] colors, int length) {
46
		AbstractImageDescriptor(Color[] colors, int length) {
42
			fDisplay = display;
47
			fRGBs = new RGB[colors.length];
43
			fColors = colors;
48
			for (int i = 0; i < colors.length; i++) {
49
				Color color = colors[i];
50
				fRGBs[i] = color == null ? null : color.getRGB();
51
			}
44
			fLength = length;
52
			fLength = length;
45
		}
53
		}
46
		
54
		
47
		public boolean equals(Object obj) {
55
		public boolean equals(Object obj) {
48
			if (obj instanceof ImageIdentifier) {
56
			if (obj instanceof AbstractImageDescriptor) {
49
				ImageIdentifier id = (ImageIdentifier)obj;
57
				AbstractImageDescriptor id = (AbstractImageDescriptor)obj;
50
				if (id.fColors.length == fColors.length) {
58
				if (id.fRGBs.length == fRGBs.length) {
51
					boolean result = id.fDisplay.equals(fDisplay) && id.fLength == fLength;
59
					boolean result = id.fLength == fLength;
52
					for (int i = 0; i < fColors.length && result; i++) {
60
					for (int i = 0; i < fRGBs.length && result; i++) {
53
						result = result && id.fColors[i].equals(fColors[i]);
61
						result = result && id.fRGBs[i].equals(fRGBs[i]);
54
					}
62
					}
55
					return result;
63
					return result;
56
				}
64
				}
Lines 59-87 Link Here
59
		}
67
		}
60
		
68
		
61
		public int hashCode() {
69
		public int hashCode() {
62
			int hash = fDisplay.hashCode();
70
			int hash = 0;
63
			for (int i = 0; i < fColors.length; i++)
71
			for (int i = 0; i < fRGBs.length; i++)
64
				hash = hash * 7 + fColors[i].hashCode();
72
				hash = hash * 7 + fRGBs[i].hashCode();
65
			hash = hash * 7 + fLength;
73
			hash = hash * 7 + fLength;
66
			return hash;
74
			return hash;
67
		}
75
		}
68
	}
76
	}
69
	
77
70
// RAP [rh] Unused code: was used by getGradient	
78
// RAP [if] Unused code: was used by getGradient    
71
//	private class SimpleImageIdentifier extends ImageIdentifier{
79
//	private class SimpleImageDescriptor extends AbstractImageDescriptor{
72
//		private int fTheight;
80
//		private int fTheight;
73
//		private int fMarginHeight;
81
//		private int fMarginHeight;
74
//		
82
//		
75
//		SimpleImageIdentifier (Display display, Color color1, Color color2,
83
//		SimpleImageDescriptor (Color color1, Color color2,
76
//				int realtheight, int theight, int marginHeight) {
84
//				int realtheight, int theight, int marginHeight) {
77
//			super(display, new Color[] {color1, color2}, realtheight);
85
//			super(new Color[] {color1, color2}, realtheight);
78
//			fTheight = theight;
86
//			fTheight = theight;
79
//			fMarginHeight = marginHeight;
87
//			fMarginHeight = marginHeight;
80
//		}
88
//		}
81
//		
89
//		
82
//		public boolean equals(Object obj) {
90
//		public boolean equals(Object obj) {
83
//			if (obj instanceof SimpleImageIdentifier) {
91
//			if (obj instanceof SimpleImageDescriptor) {
84
//				SimpleImageIdentifier id = (SimpleImageIdentifier) obj;
92
//				SimpleImageDescriptor id = (SimpleImageDescriptor) obj;
85
//				if (super.equals(obj)  &&
93
//				if (super.equals(obj)  &&
86
//						id.fTheight == fTheight && id.fMarginHeight == fMarginHeight)
94
//						id.fTheight == fTheight && id.fMarginHeight == fMarginHeight)
87
//					return true;
95
//					return true;
Lines 95-122 Link Here
95
//			hash = hash * 7 + new Integer(fMarginHeight).hashCode();
103
//			hash = hash * 7 + new Integer(fMarginHeight).hashCode();
96
//			return hash;
104
//			return hash;
97
//		}
105
//		}
106
//
107
//		public ImageData getImageData() {
108
//			return null;
109
//		}
110
//		
111
//		public Image createImage(boolean returnMissingImageOnError,	Device device) {
112
//			Image image = new Image(device, 1, fLength);
113
//			Color color1 = new Color(device, fRGBs[0]);
114
//			Color color2 = new Color(device, fRGBs[1]);
115
//			image.setBackground(color1);
116
//			GC gc = new GC(image);
117
//			gc.setBackground(color1);
118
//			gc.fillRectangle(0, 0, 1, fLength);
119
//			gc.setForeground(color2);
120
//			gc.setBackground(color1);
121
//			gc.fillGradientRectangle(0, fMarginHeight + 2, 1, fTheight - 2, true);
122
//			gc.dispose();
123
//			color1.dispose();
124
//			color2.dispose();
125
//			return image;
126
//		}
98
//	}
127
//	}
99
//	
128
	
100
//	private class ComplexImageIdentifier extends ImageIdentifier {
129
//	private class ComplexImageDescriptor extends AbstractImageDescriptor {
101
//		Color fBg;
130
//		RGB fBgRGB;
102
//		boolean fVertical;
131
//		boolean fVertical;
103
//		int[] fPercents;
132
//		int[] fPercents;
104
//		
133
//		
105
//		public ComplexImageIdentifier(Display display, Color[] colors, int length,
134
//		public ComplexImageDescriptor(Color[] colors, int length,
106
//				int[] percents, boolean vertical, Color bg) {
135
//				int[] percents, boolean vertical, Color bg) {
107
//			super(display, colors, length);
136
//			super(colors, length);
108
//			fBg = bg;
137
//			fBgRGB = bg == null ? null : bg.getRGB();
109
//			fVertical = vertical;
138
//			fVertical = vertical;
110
//			fPercents = percents;
139
//			fPercents = percents;
111
//		}
140
//		}
112
//		
141
//		
113
//		public boolean equals(Object obj) {
142
//		public boolean equals(Object obj) {
114
//			if (obj instanceof ComplexImageIdentifier) {
143
//			if (obj instanceof ComplexImageDescriptor) {
115
//				ComplexImageIdentifier id = (ComplexImageIdentifier) obj;
144
//				ComplexImageDescriptor id = (ComplexImageDescriptor) obj;
116
//				if (super.equals(obj)  &&
145
//				if (super.equals(obj)  &&
117
//						id.fVertical == fVertical && Arrays.equals(id.fPercents, fPercents)) {
146
//						id.fVertical == fVertical && Arrays.equals(id.fPercents, fPercents)) {
118
//					if ((id.fBg == null && fBg == null) ||
147
//					if ((id.fBgRGB == null && fBgRGB == null) ||
119
//							(id.fBg != null && id.fBg.equals(fBg)))
148
//							(id.fBgRGB != null && id.fBgRGB.equals(fBgRGB)))
120
//						return true;
149
//						return true;
121
//					// if the only thing that isn't the same is the background color
150
//					// if the only thing that isn't the same is the background color
122
//					// still return true if it does not matter (percents add up to 100)
151
//					// still return true if it does not matter (percents add up to 100)
Lines 137-304 Link Here
137
//				hash = hash * 7 + new Integer(fPercents[i]).hashCode();
166
//				hash = hash * 7 + new Integer(fPercents[i]).hashCode();
138
//			return hash;
167
//			return hash;
139
//		}
168
//		}
169
//
170
//		public ImageData getImageData() {
171
//			return null;
172
//		}
173
//		
174
//		public Image createImage(boolean returnMissingImageOnError,	Device device) {
175
//			int width = fVertical ? 1 : fLength;
176
//			int height = fVertical ? fLength : 1;
177
//			Image gradient = new Image(device, Math.max(width, 1), Math
178
//					.max(height, 1));
179
//			GC gc = new GC(gradient);
180
//			Color[] colors = new Color[fRGBs.length];
181
//			for (int i = 0; i < colors.length; i++)
182
//				colors[i] = new Color(device, fRGBs[i]);
183
//			Color bg = fBgRGB == null ? null : new Color(device, fBgRGB);
184
//			drawTextGradient(gc, width, height, colors, fPercents, fVertical, bg);
185
//			gc.dispose();
186
//			for (int i = 0; i < colors.length; i++)
187
//				colors[i].dispose();
188
//			if (bg != null)
189
//				bg.dispose();
190
//			return gradient;
191
//		}
192
//
193
//		private void drawTextGradient(GC gc, int width, int height, Color[] colors,
194
//				int[] percents, boolean vertical, Color bg) {
195
//			final Color oldBackground = gc.getBackground();
196
//			if (colors.length == 1) {
197
//				if (colors[0] != null)
198
//					gc.setBackground(colors[0]);
199
//				gc.fillRectangle(0, 0, width, height);
200
//			} else {
201
//				final Color oldForeground = gc.getForeground();
202
//				Color lastColor = colors[0];
203
//				if (lastColor == null)
204
//					lastColor = oldBackground;
205
//				int pos = 0;
206
//				for (int i = 0; i < percents.length; ++i) {
207
//					gc.setForeground(lastColor);
208
//					lastColor = colors[i + 1];
209
//					if (lastColor == null)
210
//						lastColor = oldBackground;
211
//					gc.setBackground(lastColor);
212
//					if (vertical) {
213
//						int gradientHeight = percents[i] * height / 100;
214
//						
215
//						gc.fillGradientRectangle(0, pos, width, gradientHeight,
216
//								true);
217
//						pos += gradientHeight;
218
//					} else {
219
//						int gradientWidth = percents[i] * width / 100;
220
//						
221
//						gc.fillGradientRectangle(pos, 0, gradientWidth, height,
222
//								false);
223
//						pos += gradientWidth;
224
//					}
225
//				}
226
//				if (vertical && pos < height) {
227
//					if (bg != null)
228
//						gc.setBackground(bg);
229
//					gc.fillRectangle(0, pos, width, height - pos);
230
//				}
231
//				if (!vertical && pos < width) {
232
//					if (bg != null)
233
//						gc.setBackground(bg);
234
//					gc.fillRectangle(pos, 0, width - pos, height);
235
//				}
236
//				gc.setForeground(oldForeground);
237
//			}
238
//		}
140
//	}
239
//	}
141
	
240
	
142
	private class ImageReference {
241
//	public Image getGradient(Color color1, Color color2,
143
		private Image fImage;
144
		private int fCount;
145
		
146
		public ImageReference(Image image) {
147
			fImage = image;
148
			fCount = 1;
149
		}
150
151
		public Image getImage() {
152
			return fImage;
153
		}
154
		// returns a boolean indicating if all clients of this image are finished
155
		// a true result indicates the underlying image should be disposed
156
		public boolean decCount() {
157
			return --fCount == 0;
158
		}
159
		public void incCount() {
160
			fCount++;
161
		}
162
	}
163
	
164
// RAP [rh] missing Image-GC
165
//	public Image getGradient(Display display, Color color1, Color color2,
166
//			int realtheight, int theight, int marginHeight) {
242
//			int realtheight, int theight, int marginHeight) {
167
//		checkHashMaps();
243
//		if (color1 == null || color1.isDisposed() || color2 == null || color2.isDisposed())
168
//		ImageIdentifier id = new SimpleImageIdentifier(display, color1, color2, realtheight, theight, marginHeight);
244
//			return null;
169
//		ImageReference result = (ImageReference) images.get(id);
245
//		AbstractImageDescriptor desc = new SimpleImageDescriptor(color1, color2, realtheight, theight, marginHeight);
170
//		if (result != null && !result.getImage().isDisposed()) {
246
//		return getGradient(desc);
171
//			result.incCount();
172
//			return result.getImage();
173
//		}
174
//		Image image = createGradient(display, color1, color2, realtheight, theight, marginHeight);
175
//		images.put(id, new ImageReference(image));
176
//		ids.put(image, id);
177
//		return image;
178
//	}
247
//	}
179
//	
248
	
180
//	public Image getGradient(Display display, Color[] colors, int[] percents,
249
//	public Image getGradient(Color[] colors, int[] percents,
181
//			int length, boolean vertical, Color bg) {
250
//			int length, boolean vertical, Color bg) {
251
//		if (colors.length == 0)
252
//			return null;
253
//		for (int i = 0; i < colors.length; i++)
254
//			if (colors[i] == null || colors[i].isDisposed())
255
//				return null;
256
//		if (bg != null && bg.isDisposed())
257
//			return null;
258
//		AbstractImageDescriptor desc = new ComplexImageDescriptor(colors, length, percents, vertical, bg);
259
//		return getGradient(desc);
260
//	}
261
	
262
//	private synchronized Image getGradient(AbstractImageDescriptor desc) {
182
//		checkHashMaps();
263
//		checkHashMaps();
183
//		ImageIdentifier id = new ComplexImageIdentifier(display, colors, length, percents, vertical, bg);
264
//		Image result = getResourceManager().createImage(desc);
184
//		ImageReference result = (ImageReference) images.get(id);
265
//		descriptors.put(result, desc);
185
//		if (result != null && !result.getImage().isDisposed()) {
266
//		return result;
186
//			result.incCount();
187
//			return result.getImage();
188
//		}
189
//		Image image = createGradient(display, colors, percents, length, vertical, bg);
190
//		images.put(id, new ImageReference(image));
191
//		ids.put(image, id);
192
//		return image;
193
//	}
267
//	}
194
	
268
	
195
	public boolean markFinished(Image image) {
269
	public synchronized boolean markFinished(Image image) {
196
		checkHashMaps();
270
		checkHashMaps();
197
		ImageIdentifier id = (ImageIdentifier)ids.get(image);
271
		AbstractImageDescriptor desc = (AbstractImageDescriptor)descriptors.get(image);
198
		if (id != null) {
272
		if (desc != null) {
199
			ImageReference ref = (ImageReference) images.get(id);
273
// RAP [if] unnecessary to destroy image
200
			if (ref != null) {
274
//			getResourceManager().destroyImage(desc);
201
				if (ref.decCount()) {
275
//			if (getResourceManager().find(desc) == null) {
202
					images.remove(id);
276
				descriptors.remove(image);
203
					ids.remove(ref.getImage());
277
				validateHashMaps();
204
// RAP [rh] no Image#dispose() API					
278
//			}
205
//					ref.getImage().dispose();
279
			return true;
206
					validateHashMaps();
207
				}
208
				return true;
209
			}
210
		}
280
		}
211
		// if the image was not found, dispose of it for the caller
281
		// if the image was not found, dispose of it for the caller
212
// RAP [rh] no Image#dispose() API		
282
// RAP [if] unnecessary
213
//		image.dispose();
283
//		image.dispose();
214
		return false;
284
		return false;
215
	}
285
	}
216
286
287
// RAP [if] unused	
288
//	private LocalResourceManager getResourceManager() {
289
//		if (resources == null)
290
//			resources = new LocalResourceManager(JFaceResources.getResources());
291
//		return resources;
292
//	}
293
217
	private void checkHashMaps() {
294
	private void checkHashMaps() {
218
		if (images == null)
295
		if (descriptors == null)
219
			images = new HashMap();
296
			descriptors = new HashMap();
220
		if (ids == null)
221
			ids = new HashMap();
222
	}
297
	}
223
	
298
	
224
	private void validateHashMaps() {
299
	private void validateHashMaps() {
225
		if (images.size() == 0)
300
		if (descriptors.size() == 0)
226
			images = null;
301
			descriptors = null;
227
		if (ids.size() == 0)
228
			ids = null;
229
	}
302
	}
230
	
231
// RAP [rh] Disabled unused code, called by getGradient
232
//	private Image createGradient(Display display, Color color1, Color color2,
233
//			int realtheight, int theight, int marginHeight) {
234
//		Image image = new Image(display, 1, realtheight);
235
//		image.setBackground(color1);
236
//		GC gc = new GC(image);
237
//		gc.setBackground(color1);
238
//		gc.fillRectangle(0, 0, 1, realtheight);
239
//		gc.setForeground(color2);
240
//		gc.setBackground(color1);
241
//		gc.fillGradientRectangle(0, marginHeight + 2, 1, theight - 2, true);
242
//		gc.dispose();
243
//		return image;
244
//	}
245
//	
246
//	private Image createGradient(Display display, Color[] colors, int[] percents,
247
//			int length, boolean vertical, Color bg) {
248
//		int width = vertical ? 1 : length;
249
//		int height = vertical ? length : 1;
250
//		Image gradient = new Image(display, Math.max(width, 1), Math
251
//				.max(height, 1));
252
//		GC gc = new GC(gradient);
253
//		drawTextGradient(gc, width, height, colors, percents, vertical, bg);
254
//		gc.dispose();
255
//		return gradient;
256
//	}
257
//
258
//	private void drawTextGradient(GC gc, int width, int height, Color[] colors,
259
//			int[] percents, boolean vertical, Color bg) {
260
//		final Color oldBackground = gc.getBackground();
261
//		if (colors.length == 1) {
262
//			if (colors[0] != null)
263
//				gc.setBackground(colors[0]);
264
//			gc.fillRectangle(0, 0, width, height);
265
//		} else {
266
//			final Color oldForeground = gc.getForeground();
267
//			Color lastColor = colors[0];
268
//			if (lastColor == null)
269
//				lastColor = oldBackground;
270
//			int pos = 0;
271
//			for (int i = 0; i < percents.length; ++i) {
272
//				gc.setForeground(lastColor);
273
//				lastColor = colors[i + 1];
274
//				if (lastColor == null)
275
//					lastColor = oldBackground;
276
//				gc.setBackground(lastColor);
277
//				if (vertical) {
278
//					int gradientHeight = percents[i] * height / 100;
279
//					
280
//					gc.fillGradientRectangle(0, pos, width, gradientHeight,
281
//							true);
282
//					pos += gradientHeight;
283
//				} else {
284
//					int gradientWidth = percents[i] * height / 100;
285
//					
286
//					gc.fillGradientRectangle(pos, 0, gradientWidth, height,
287
//							false);
288
//					pos += gradientWidth;
289
//				}
290
//			}
291
//			if (vertical && pos < height) {
292
//				if (bg != null)
293
//					gc.setBackground(bg);
294
//				gc.fillRectangle(0, pos, width, height - pos);
295
//			}
296
//			if (!vertical && pos < width) {
297
//				if (bg != null)
298
//					gc.setBackground(bg);
299
//				gc.fillRectangle(pos, 0, width - pos, height);
300
//			}
301
//			gc.setForeground(oldForeground);
302
//		}
303
//	}
304
}
303
}
(-)src/org/eclipse/ui/internal/forms/widgets/ObjectSegment.java (-5 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 57-70 Link Here
57
			iwidth = objectSize.x + (isSelectable()?2:0);
57
			iwidth = objectSize.x + (isSelectable()?2:0);
58
			iheight = objectSize.y + (isSelectable()?2:0);
58
			iheight = objectSize.y + (isSelectable()?2:0);
59
		}
59
		}
60
		if (wHint != SWT.DEFAULT && !nowrap && loc.x + iwidth > wHint) {
60
		if (wHint != SWT.DEFAULT && !nowrap && loc.x + iwidth + loc.marginWidth > wHint) {
61
			// new line
61
			// new line
62
			if (computeHeightOnly)
62
			if (computeHeightOnly)
63
				loc.collectHeights();
63
				loc.collectHeights();
64
			loc.x = loc.indent;
64
			loc.resetCaret();
65
			loc.x += iwidth;
65
			loc.x += iwidth;
66
			loc.y += loc.rowHeight;
66
			loc.y += loc.rowHeight;
67
			loc.width = loc.indent + iwidth;
67
			loc.width = loc.x;
68
			loc.rowHeight = iheight;
68
			loc.rowHeight = iheight;
69
			loc.leading = 0;
69
			loc.leading = 0;
70
			newLine = true;
70
			newLine = true;
Lines 126-132 Link Here
126
			return;
126
			return;
127
		loc.width = objWidth;
127
		loc.width = objWidth;
128
128
129
		if (!nowrap && loc.x + objWidth > width) {
129
		if (!nowrap && loc.x + objWidth + loc.marginWidth > width) {
130
			// new row
130
			// new row
131
			loc.newLine();
131
			loc.newLine();
132
			loc.rowCounter++;
132
			loc.rowCounter++;
(-)src/org/eclipse/ui/internal/forms/widgets/TitleRegion.java (-1 / +2 lines)
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.forms.widgets;
11
package org.eclipse.ui.internal.forms.widgets;
12
12
13
import org.eclipse.rwt.graphics.Graphics;
14
13
import org.eclipse.jface.action.IMenuManager;
15
import org.eclipse.jface.action.IMenuManager;
14
import org.eclipse.jface.action.MenuManager;
16
import org.eclipse.jface.action.MenuManager;
15
import org.eclipse.rwt.graphics.Graphics;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.dnd.DragSource;
18
import org.eclipse.swt.dnd.DragSource;
18
import org.eclipse.swt.dnd.DragSourceEffect;
19
import org.eclipse.swt.dnd.DragSourceEffect;
(-)src/org/eclipse/ui/internal/forms/widgets/AggregateHyperlinkSegment.java (-1 / +1 lines)
Lines 15-23 Link Here
15
15
16
// RAP [if] unnecessary
16
// RAP [if] unnecessary
17
//import org.eclipse.swt.graphics.Color;
17
//import org.eclipse.swt.graphics.Color;
18
import org.eclipse.rwt.Adaptable;
19
import org.eclipse.swt.graphics.GC;
18
import org.eclipse.swt.graphics.GC;
20
import org.eclipse.swt.graphics.Rectangle;
19
import org.eclipse.swt.graphics.Rectangle;
20
import org.eclipse.rwt.Adaptable;
21
import org.eclipse.ui.forms.internal.widgets.IAggregateHyperlinkSegmentAdapter;
21
import org.eclipse.ui.forms.internal.widgets.IAggregateHyperlinkSegmentAdapter;
22
22
23
/**
23
/**
(-)src/org/eclipse/ui/internal/forms/widgets/FormTextModel.java (-3 / +22 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 26-35 Link Here
26
import org.w3c.dom.NamedNodeMap;
26
import org.w3c.dom.NamedNodeMap;
27
import org.w3c.dom.Node;
27
import org.w3c.dom.Node;
28
import org.w3c.dom.NodeList;
28
import org.w3c.dom.NodeList;
29
import org.xml.sax.ErrorHandler;
29
import org.xml.sax.InputSource;
30
import org.xml.sax.InputSource;
30
import org.xml.sax.SAXException;
31
import org.xml.sax.SAXException;
32
import org.xml.sax.SAXParseException;
31
33
32
public class FormTextModel {
34
public class FormTextModel {
35
36
	/*
37
	 * This class prevents parse errors from being written to standard output
38
	 */
39
	public class ParseErrorHandler implements ErrorHandler {
40
41
		public void error(SAXParseException arg0) throws SAXException {
42
		}
43
44
		public void fatalError(SAXParseException arg0) throws SAXException {
45
		}
46
47
		public void warning(SAXParseException arg0) throws SAXException {
48
		}
49
	}
50
	
33
	private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
51
	private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
34
			.newInstance();
52
			.newInstance();
35
53
Lines 105-117 Link Here
105
		try {
123
		try {
106
			DocumentBuilder parser = documentBuilderFactory
124
			DocumentBuilder parser = documentBuilderFactory
107
					.newDocumentBuilder();
125
					.newDocumentBuilder();
126
			parser.setErrorHandler(new ParseErrorHandler());
108
			InputSource source = new InputSource(is);
127
			InputSource source = new InputSource(is);
109
			Document doc = parser.parse(source);
128
			Document doc = parser.parse(source);
110
			processDocument(doc, expandURLs);
129
			processDocument(doc, expandURLs);
111
		} catch (ParserConfigurationException e) {
130
		} catch (ParserConfigurationException e) {
112
			SWT.error(SWT.ERROR_INVALID_ARGUMENT, e);
131
			SWT.error(SWT.ERROR_INVALID_ARGUMENT, e, " " + e.getMessage()); //$NON-NLS-1$
113
		} catch (SAXException e) {
132
		} catch (SAXException e) {
114
			SWT.error(SWT.ERROR_INVALID_ARGUMENT, e);
133
			SWT.error(SWT.ERROR_INVALID_ARGUMENT, e, " " + e.getMessage()); //$NON-NLS-1$
115
		} catch (IOException e) {
134
		} catch (IOException e) {
116
			SWT.error(SWT.ERROR_IO, e);
135
			SWT.error(SWT.ERROR_IO, e);
117
		}
136
		}
(-)src/org/eclipse/ui/internal/forms/widgets/BusyIndicator.java (-183 / +40 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006, 2007 IBM Corporation and others.
2
 * Copyright (c) 2006, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-177 Link Here
18
import org.eclipse.core.runtime.Path;
18
import org.eclipse.core.runtime.Path;
19
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.jface.resource.ImageDescriptor;
20
import org.eclipse.jface.resource.ImageDescriptor;
21
//import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.DisposeEvent;
23
import org.eclipse.swt.events.DisposeListener;
22
//import org.eclipse.swt.events.PaintEvent;
24
//import org.eclipse.swt.events.PaintEvent;
23
//import org.eclipse.swt.events.PaintListener;
25
//import org.eclipse.swt.events.PaintListener;
24
//import org.eclipse.swt.graphics.GC;
26
//import org.eclipse.swt.graphics.GC;
25
import org.eclipse.swt.graphics.Image;
27
import org.eclipse.swt.graphics.Image;
26
//import org.eclipse.swt.graphics.ImageData;
27
import org.eclipse.swt.graphics.Point;
28
import org.eclipse.swt.graphics.Point;
28
import org.eclipse.swt.graphics.Rectangle;
29
import org.eclipse.swt.graphics.Rectangle;
29
import org.eclipse.swt.widgets.*;
30
import org.eclipse.swt.widgets.Label;
31
import org.eclipse.swt.widgets.Composite;
32
//import org.eclipse.swt.widgets.Display;
30
import org.osgi.framework.Bundle;
33
import org.osgi.framework.Bundle;
31
34
32
// RAP [rh] Changed class hierarchy: now extends Label instead of Canvas
35
// RAP [rh] Changed class hierarchy: now extends Label instead of Canvas
33
// public final class BusyIndicator extends Canvas {
36
// public final class BusyIndicator extends Canvas {
34
public final class BusyIndicator extends Label {
37
public final class BusyIndicator extends Label {
35
    
38
    
36
//	class BusyThread extends Thread {
37
//		Rectangle bounds;
38
//		Display display;
39
//		GC offScreenImageGC;
40
//		Image offScreenImage;
41
//		Image timage;
42
//		boolean stop;
43
//		
44
//		private BusyThread(Rectangle bounds, Display display, GC offScreenImageGC, Image offScreenImage) {
45
//			this.bounds = bounds;
46
//			this.display = display;
47
//			this.offScreenImageGC = offScreenImageGC;
48
//			this.offScreenImage = offScreenImage;
49
//		}
50
//		
51
//		public void run() {
52
//			try {
53
//				/*
54
//				 * Create an off-screen image to draw on, and fill it with
55
//				 * the shell background.
56
//				 */
57
//				FormUtil.setAntialias(offScreenImageGC, SWT.ON);
58
//				display.syncExec(new Runnable() {
59
//					public void run() {
60
//						if (!isDisposed())
61
//							drawBackground(offScreenImageGC, 0, 0,
62
//									bounds.width,
63
//									bounds.height);
64
//					}
65
//				});
66
//				if (isDisposed())
67
//					return;
68
//
69
//				/*
70
//				 * Create the first image and draw it on the off-screen
71
//				 * image.
72
//				 */
73
//				int imageDataIndex = 0;
74
//				ImageData imageData;
75
//				synchronized (BusyIndicator.this) {
76
//					timage = getImage(imageDataIndex);
77
//					imageData = timage.getImageData();
78
//					offScreenImageGC.drawImage(timage, 0, 0,
79
//							imageData.width, imageData.height, imageData.x,
80
//							imageData.y, imageData.width, imageData.height);
81
//				}
82
//
83
//				/*
84
//				 * Now loop through the images, creating and drawing
85
//				 * each one on the off-screen image before drawing it on
86
//				 * the shell.
87
//				 */
88
//				while (!stop && !isDisposed() && timage != null) {
89
//
90
//					/*
91
//					 * Fill with the background color before
92
//					 * drawing.
93
//					 */
94
//					final ImageData fimageData = imageData;
95
//					display.syncExec(new Runnable() {
96
//						public void run() {
97
//							if (!isDisposed()) {
98
//								drawBackground(offScreenImageGC, fimageData.x,
99
//										fimageData.y, fimageData.width,
100
//										fimageData.height);
101
//							}
102
//						}
103
//					});
104
//
105
//					synchronized (BusyIndicator.this) {
106
//						imageDataIndex = (imageDataIndex + 1) % IMAGE_COUNT;
107
//						timage = getImage(imageDataIndex);
108
//						imageData = timage.getImageData();
109
//						offScreenImageGC.drawImage(timage, 0, 0,
110
//								imageData.width, imageData.height,
111
//								imageData.x, imageData.y, imageData.width,
112
//								imageData.height);
113
//					}
114
//
115
//					/* Draw the off-screen image to the shell. */
116
//					animationImage = offScreenImage;
117
//					display.syncExec(new Runnable() {
118
//						public void run() {
119
//							if (!isDisposed())
120
//								redraw();
121
//						}
122
//					});
123
//					/*
124
//					 * Sleep for the specified delay time 
125
//					 */
126
//					try {
127
//						Thread.sleep(MILLISECONDS_OF_DELAY);
128
//					} catch (InterruptedException e) {
129
//						e.printStackTrace();
130
//					}
131
//
132
//
133
//				}
134
//			} catch (Exception e) {
135
//			} finally {
136
//				display.syncExec(new Runnable() {
137
//					public void run() {
138
//						if (offScreenImage != null
139
//								&& !offScreenImage.isDisposed())
140
//							offScreenImage.dispose();
141
//						if (offScreenImageGC != null
142
//								&& !offScreenImageGC.isDisposed())
143
//							offScreenImageGC.dispose();
144
//					}
145
//				});
146
//				clearImages();
147
//			}
148
//			if (busyThread == null)
149
//				display.syncExec(new Runnable() {
150
//					public void run() {
151
//						animationImage = null;
152
//						if (!isDisposed())
153
//							redraw();
154
//					}
155
//				});
156
//		}
157
//		
158
//		public void setStop(boolean stop) {
159
//			this.stop = stop;
160
//		}
161
//	}
162
163
	private static final int MARGIN = 0;
39
	private static final int MARGIN = 0;
164
// RAP [rh] instead  of manually animating 8 png images, RAP uses one animated gif	
40
// RAP [rh] instead  of manually animating 8 png images, RAP uses one animated gif	
165
//	private static final int IMAGE_COUNT = 8;
41
//	private static final int IMAGE_COUNT = 8;
166
	private static final int IMAGE_COUNT = 1;
42
	private static final int IMAGE_COUNT = 1;
167
//	private static final int MILLISECONDS_OF_DELAY = 180; 
43
//	private static final int MILLISECONDS_OF_DELAY = 180; 
168
	private Image[] imageCache;
44
	private Image[] imageCache;
169
	protected Image image;
45
	private Image image;
170
171
	protected Image animationImage;
172
46
173
//	protected BusyThread busyThread;
47
//	private Display dpy;
174
	protected Thread busyThread;
48
//	private Runnable timer;
49
	private boolean busy;
50
//	private int imageIndex;
175
	
51
	
176
	/**
52
	/**
177
	 * BusyWidget constructor comment.
53
	 * BusyWidget constructor comment.
Lines 182-197 Link Here
182
	 *            int
58
	 *            int
183
	 */
59
	 */
184
	public BusyIndicator(Composite parent, int style) {
60
	public BusyIndicator(Composite parent, int style) {
185
		super(parent, style);
61
		super(parent, style | SWT.DOUBLE_BUFFERED);
62
		
63
//		dpy = getDisplay();
64
//		timer = new Runnable() {
65
//			public void run () {
66
//				if (isDisposed()) return;
67
//				redraw();
68
//				if (!BusyIndicator.this.busy) return;
69
//				update();
70
//				if (isDisposed()) return;
71
//				imageIndex = (imageIndex + 1) % IMAGE_COUNT;
72
//				dpy.timerExec(MILLISECONDS_OF_DELAY, this);
73
//			}
74
//		};
186
75
187
//		addPaintListener(new PaintListener() {
76
//		addPaintListener(new PaintListener() {
188
//			public void paintControl(PaintEvent event) {
77
//			public void paintControl(PaintEvent event) {
189
//				onPaint(event);
78
//				onPaint(event);
190
//			}
79
//			}
191
//		});
80
//		});
81
82
		addDisposeListener(new DisposeListener() {
83
			public void widgetDisposed(DisposeEvent e) {
84
				clearImages();
85
			}
86
		});
192
	}
87
	}
193
88
194
	public Point computeSize(int wHint, int hHint, boolean changed) {
89
	public Point computeSize(int wHint, int hHint, boolean changed) {
90
//		checkWidget();
195
		Point size = new Point(0, 0);
91
		Point size = new Point(0, 0);
196
		if (image != null) {
92
		if (image != null) {
197
			Rectangle ibounds = image.getBounds();
93
			Rectangle ibounds = image.getBounds();
Lines 216-249 Link Here
216
	}
112
	}
217
113
218
	/**
114
	/**
219
	 * Creates a thread to animate the image.
220
	 */
221
	protected synchronized void createBusyThread() {
222
		if (busyThread != null)
223
			return;
224
225
// RAP [rh] fake a busyThread that not actually used anywhere, so that the  
226
//		 various test on busyThread != null or == null succeed
227
//		Rectangle bounds = getImage(0).getBounds();
228
//		Display display = getDisplay();
229
//		Image offScreenImage = new Image(display, bounds.width, bounds.height);
230
//		GC offScreenImageGC = new GC(offScreenImage);
231
//		busyThread = new BusyThread(bounds, display, offScreenImageGC, offScreenImage);
232
//		busyThread.setPriority(Thread.NORM_PRIORITY + 2);
233
//		busyThread.setDaemon(true);
234
//		busyThread.start();
235
	  busyThread = Thread.currentThread();
236
	}
237
238
	public void dispose() {
239
		if (busyThread != null) {
240
//			busyThread.setStop(true);
241
			busyThread = null;
242
		}
243
		super.dispose();
244
	}
245
246
	/**
247
	 * Return the image or <code>null</code>.
115
	 * Return the image or <code>null</code>.
248
	 */
116
	 */
249
	public Image getImage() {
117
	public Image getImage() {
Lines 258-264 Link Here
258
	 * @return boolean
126
	 * @return boolean
259
	 */
127
	 */
260
	public boolean isBusy() {
128
	public boolean isBusy() {
261
		return (busyThread != null);
129
		return busy;
262
	}
130
	}
263
131
264
//	/*
132
//	/*
Lines 288-305 Link Here
288
	 *            boolean
156
	 *            boolean
289
	 */
157
	 */
290
	public synchronized void setBusy(boolean busy) {
158
	public synchronized void setBusy(boolean busy) {
291
		if (busy) {
159
		if (this.busy == busy) return;
292
			if (busyThread == null)
160
		this.busy = busy;
293
				createBusyThread();
161
//		imageIndex = 0;
294
		} else {
162
//		dpy.asyncExec(timer);
295
			if (busyThread != null) {
296
// RAP [rh] no actual BusyThread implementation
297
//				busyThread.setStop(true);
298
				busyThread = null;
299
// RAP [rh] call clearImages explicitly as it would have been don by setStop()
300
				clearImages();
301
			}
302
		}
303
	}
163
	}
304
164
305
	/**
165
	/**
Lines 330-336 Link Here
330
	  return ImageDescriptor.createFromURL(url);
190
	  return ImageDescriptor.createFromURL(url);
331
	}
191
	}
332
192
333
	private synchronized Image getImage(int index) {
193
	private Image getImage(int index) {
334
		if (imageCache == null) {
194
		if (imageCache == null) {
335
			imageCache = new Image[IMAGE_COUNT];
195
			imageCache = new Image[IMAGE_COUNT];
336
		}
196
		}
Lines 343-352 Link Here
343
		return imageCache[index];
203
		return imageCache[index];
344
	}
204
	}
345
	
205
	
346
	private synchronized void clearImages() {
206
	private void clearImages() {
347
// RAP [rh] missing Image#dispose() and #isDisposed()	  
348
		if (busyThread != null)
349
			return;
350
		if (imageCache != null) {
207
		if (imageCache != null) {
351
			for (int index = 0; index < IMAGE_COUNT; index++) {
208
			for (int index = 0; index < IMAGE_COUNT; index++) {
352
				if (imageCache[index] != null /* && !imageCache[index].isDisposed()*/) {
209
				if (imageCache[index] != null /* && !imageCache[index].isDisposed()*/) {
(-)src/org/eclipse/ui/internal/forms/widgets/PixelConverter.java (-37 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.forms.widgets;
12
13
import org.eclipse.swt.graphics.FontMetrics;
14
import org.eclipse.swt.graphics.GC;
15
import org.eclipse.swt.widgets.Control;
16
17
public class PixelConverter {
18
	/**
19
	 * Number of horizontal dialog units per character, value <code>4</code>.
20
	 */
21
	private static final int HORIZONTAL_DIALOG_UNIT_PER_CHAR = 4;
22
23
	private FontMetrics fFontMetrics;
24
25
	public PixelConverter(Control control) {
26
		GC gc = new GC(control);
27
		gc.setFont(control.getFont());
28
		fFontMetrics = gc.getFontMetrics();
29
		gc.dispose();
30
	}
31
32
	public int convertHorizontalDLUsToPixels(int dlus) {
33
		// round to the nearest pixel
34
		return (fFontMetrics.getAverageCharWidth() * dlus + HORIZONTAL_DIALOG_UNIT_PER_CHAR / 2)
35
				/ HORIZONTAL_DIALOG_UNIT_PER_CHAR;
36
	}
37
}
(-)src/org/eclipse/ui/internal/forms/widgets/BreakSegment.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 32-38 Link Here
32
			locator.rowHeight = fm.getHeight();
32
			locator.rowHeight = fm.getHeight();
33
		}
33
		}
34
		if (computeHeightOnly) locator.collectHeights();
34
		if (computeHeightOnly) locator.collectHeights();
35
		locator.x = locator.indent;
35
		locator.resetCaret();
36
		locator.width = locator.x;
36
		locator.y += locator.rowHeight;
37
		locator.y += locator.rowHeight;
37
		locator.rowHeight = 0;
38
		locator.rowHeight = 0;
38
		locator.leading = 0;
39
		locator.leading = 0;
(-)src/org/eclipse/ui/internal/forms/widgets/TextSegment.java (-7 / +13 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-20 Link Here
15
import java.util.Vector;
15
import java.util.Vector;
16
16
17
import org.eclipse.rwt.Adaptable;
17
import org.eclipse.rwt.Adaptable;
18
import org.eclipse.ui.forms.internal.widgets.ITextSegmentAdapter;
19
18
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.SWT;
19
// RAP [if] unnecessary
21
// RAP [if] unnecessary
20
//import org.eclipse.swt.graphics.Color;
22
//import org.eclipse.swt.graphics.Color;
Lines 23-29 Link Here
23
import org.eclipse.swt.graphics.GC;
25
import org.eclipse.swt.graphics.GC;
24
import org.eclipse.swt.graphics.Point;
26
import org.eclipse.swt.graphics.Point;
25
import org.eclipse.swt.graphics.Rectangle;
27
import org.eclipse.swt.graphics.Rectangle;
26
import org.eclipse.ui.forms.internal.widgets.ITextSegmentAdapter;
27
28
28
import com.ibm.icu.text.BreakIterator;
29
import com.ibm.icu.text.BreakIterator;
29
30
Lines 252-260 Link Here
252
			if (isSelectable())
253
			if (isSelectable())
253
				totalExtent+=1;
254
				totalExtent+=1;
254
255
255
			if (wHint != SWT.DEFAULT && totalExtent > wHint) {
256
			if (wHint != SWT.DEFAULT && totalExtent + locator.marginWidth > wHint) {
256
				// new line
257
				// new line
257
				locator.x = locator.indent;
258
				locator.resetCaret();
258
				locator.y += locator.rowHeight;
259
				locator.y += locator.rowHeight;
259
				if (computeHeightOnly)
260
				if (computeHeightOnly)
260
					locator.collectHeights();
261
					locator.collectHeights();
Lines 266-272 Link Here
266
			if (isSelectable())
267
			if (isSelectable())
267
				width += 1;
268
				width += 1;
268
			locator.x += width;
269
			locator.x += width;
269
			locator.width = locator.indent + width;
270
			locator.width = locator.x;
270
			locator.rowHeight = Math.max(locator.rowHeight, extent.y);
271
			locator.rowHeight = Math.max(locator.rowHeight, extent.y);
271
			// RAP [if] fm.getLeading() is missing
272
			// RAP [if] fm.getLeading() is missing
272
//			locator.leading = Math.max(locator.leading, fm.getLeading());
273
//			locator.leading = Math.max(locator.leading, fm.getLeading());
Lines 286-292 Link Here
286
			if (isSelectable())
287
			if (isSelectable())
287
				currentExtent += 1;
288
				currentExtent += 1;
288
289
289
			if (currentExtent + textFragment.length > wHint) {
290
			// i != 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0) means:
291
			// only wrap on the first fragment if we are not at the start of a line
292
			if ((i != 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) && currentExtent + textFragment.length > wHint) {
290
				// overflow
293
				// overflow
291
				int lineWidth = currentExtent;
294
				int lineWidth = currentExtent;
292
				locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
295
				locator.rowHeight = Math.max(locator.rowHeight, lineExtent.y);
Lines 306-311 Link Here
306
			}
309
			}
307
			lineExtent.x += textFragment.length;
310
			lineExtent.x += textFragment.length;
308
			lineExtent.y = Math.max(lineHeight, lineExtent.y);
311
			lineExtent.y = Math.max(lineHeight, lineExtent.y);
312
			width = Math.max (width, locator.x + lineExtent.x);
309
		}
313
		}
310
		int lineWidth = lineExtent.x;
314
		int lineWidth = lineExtent.x;
311
		if (isSelectable())
315
		if (isSelectable())
Lines 680-686 Link Here
680
				int breakLoc = fragment.index;
684
				int breakLoc = fragment.index;
681
				if (breakLoc == 0)
685
				if (breakLoc == 0)
682
					continue;
686
					continue;
683
				if (locator.x + lineExtent.x + fragment.length > rightEdge) {
687
				// (i != 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) means:
688
				// only wrap on the first fragment if we are not at the start of a line
689
				if ((i != 0 || locator.x > locator.getStartX() + (isSelectable() ? 1 : 0)) && locator.x + lineExtent.x + fragment.length > rightEdge) {
684
					// overflow
690
					// overflow
685
					int lineWidth = locator.x + lineExtent.x;
691
					int lineWidth = locator.x + lineExtent.x;
686
					if (isSelectable())
692
					if (isSelectable())
(-)src/org/eclipse/ui/internal/forms/widgets/BulletParagraph.java (-1 / +2 lines)
Lines 13-25 Link Here
13
import java.util.Hashtable;
13
import java.util.Hashtable;
14
14
15
import org.eclipse.rwt.Adaptable;
15
import org.eclipse.rwt.Adaptable;
16
import org.eclipse.ui.forms.internal.widgets.IBulletParagraphAdapter;
17
16
// RAP [if] unnecessary
18
// RAP [if] unnecessary
17
//import org.eclipse.swt.graphics.Color;
19
//import org.eclipse.swt.graphics.Color;
18
import org.eclipse.swt.graphics.GC;
20
import org.eclipse.swt.graphics.GC;
19
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.graphics.Point;
22
import org.eclipse.swt.graphics.Point;
21
import org.eclipse.swt.graphics.Rectangle;
23
import org.eclipse.swt.graphics.Rectangle;
22
import org.eclipse.ui.forms.internal.widgets.IBulletParagraphAdapter;
23
24
24
public class BulletParagraph extends Paragraph implements Adaptable {
25
public class BulletParagraph extends Paragraph implements Adaptable {
25
	public static final int CIRCLE = 1;
26
	public static final int CIRCLE = 1;
(-)src/org/eclipse/ui/internal/forms/widgets/FormFonts.java (-86 / +68 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-149 Link Here
12
12
13
import java.util.HashMap;
13
import java.util.HashMap;
14
14
15
import org.eclipse.rwt.SessionSingletonBase;
16
import org.eclipse.rwt.graphics.Graphics;
15
import org.eclipse.rwt.graphics.Graphics;
16
17
import org.eclipse.jface.resource.DeviceResourceException;
18
import org.eclipse.jface.resource.FontDescriptor;
19
import org.eclipse.jface.resource.JFaceResources;
20
import org.eclipse.jface.resource.LocalResourceManager;
17
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.graphics.Device;
18
import org.eclipse.swt.graphics.Font;
23
import org.eclipse.swt.graphics.Font;
19
import org.eclipse.swt.graphics.FontData;
24
import org.eclipse.swt.graphics.FontData;
20
import org.eclipse.swt.widgets.Display;
25
import org.eclipse.swt.widgets.Display;
21
26
22
public class FormFonts {
27
public class FormFonts {
23
// RAP [fappel]: use session singleton approach since FontIdentifier holds
28
	private static FormFonts instance;
24
//               reference to display
25
//	private static FormFonts instance;
26
29
27
	public static FormFonts getInstance() {
30
	public static FormFonts getInstance() {
28
// RAP [fappel]: use session singleton approach since FontIdentifier holds
31
		if (instance == null)
29
//               reference to display
32
			instance = new FormFonts();
30
//		if (instance == null)
33
		return instance;
31
//			instance = new FormFonts();
32
//		return instance;
33
	    return ( FormFonts )SessionSingletonBase.getInstance( FormFonts.class );
34
	}
34
	}
35
	
35
	
36
	private HashMap fonts;
36
	private LocalResourceManager resources;
37
	private HashMap ids;
37
	private HashMap descriptors;
38
	
38
	
39
	private FormFonts() {
39
	private FormFonts() {
40
	}
40
	}
41
	
41
	
42
	private class FontIdentifier {
42
	private class BoldFontDescriptor extends FontDescriptor {
43
		private Display fDisplay;
43
		private FontData[] fFontData;
44
		private Font fFont;
45
		
44
		
46
		FontIdentifier (Display display, Font font) {
45
		BoldFontDescriptor (Font font) {
47
			fDisplay = display;
46
// RAP [if] Changes due to different way of creating fonts
48
			fFont = font;
47
//			fFontData = font.getFontData();
48
//			for (int i = 0; i < fFontData.length; i++) {
49
//				fFontData[i].setStyle(fFontData[i].getStyle() | SWT.BOLD);
50
//			}
51
		  FontData fontData = font.getFontData()[ 0 ];
52
		  Font boldFont = Graphics.getFont( fontData.getName(), 
53
		                                    fontData.getHeight(), 
54
		                                    fontData.getStyle() | SWT.BOLD );
55
		  fFontData = boldFont.getFontData();
49
		}
56
		}
50
		
57
		
51
		public boolean equals(Object obj) {
58
		public boolean equals(Object obj) {
52
			if (obj instanceof FontIdentifier) {
59
			if (obj instanceof BoldFontDescriptor) {
53
				FontIdentifier id = (FontIdentifier)obj;
60
				BoldFontDescriptor desc = (BoldFontDescriptor)obj;
54
				return id.fDisplay.equals(fDisplay) && id.fFont.equals(fFont);
61
				if (desc.fFontData.length != fFontData.length)
62
					return false;
63
				for (int i = 0; i < fFontData.length; i++)
64
					if (!fFontData[i].equals(desc.fFontData[i]))
65
						return false;
66
				return true;
55
			}
67
			}
56
			return false;
68
			return false;
57
		}
69
		}
58
		
70
		
59
		public int hashCode() {
71
		public int hashCode() {
60
			return fDisplay.hashCode() * 7 + fFont.hashCode();
72
			int hash = 0;
61
		}
73
			for (int i = 0; i < fFontData.length; i++)
62
	}
74
				hash = hash * 7 + fFontData[i].hashCode();
63
	
75
			return hash;
64
	private class FontReference {
65
		private Font fFont;
66
		private int fCount;
67
		
68
		public FontReference(Font font) {
69
			fFont = font;
70
			fCount = 1;
71
		}
76
		}
72
77
73
		public Font getFont() {
78
		public Font createFont(Device device) throws DeviceResourceException {
74
			return fFont;
79
// RAP [if] Changes due to different way of creating fonts
80
//			return new Font(device, fFontData);
81
		    return Graphics.getFont( fFontData[ 0 ] );
75
		}
82
		}
76
		// returns a boolean indicating if all clients of this font are finished
83
77
		// a true result indicates the underlying image should be disposed
84
		public void destroyFont(Font previouslyCreatedFont) {
78
		public boolean decCount() {
85
// RAP [if] unnecessary
79
			return --fCount == 0;
86
//			previouslyCreatedFont.dispose();
80
		}
81
		public void incCount() {
82
			fCount++;
83
		}
87
		}
84
	}
88
	}
85
	
89
	
86
	public Font getBoldFont(Display display, Font font) {
90
	public Font getBoldFont(Display display, Font font) {
87
		checkHashMaps();
91
		checkHashMaps();
88
		FontIdentifier fid = new FontIdentifier(display, font);
92
		BoldFontDescriptor desc = new BoldFontDescriptor(font);
89
		FontReference result = (FontReference) fonts.get(fid);
93
		Font result = getResourceManager().createFont(desc);
90
		// RAP [rh] Unnecessary, as there is no Font#dispose() 
94
		descriptors.put(result, desc);
91
		if (result != null /* && !result.getFont().isDisposed() */) {
95
		return result;
92
			result.incCount();
93
			return result.getFont();
94
		}
95
		Font boldFont = createBoldFont(display, font);
96
		fonts.put(fid, new FontReference(boldFont));
97
		ids.put(boldFont, fid);
98
		return boldFont;
99
	}
96
	}
100
	
97
	
101
	public boolean markFinished(Font boldFont) {
98
	public boolean markFinished(Font boldFont) {
102
		checkHashMaps();
99
		checkHashMaps();
103
		FontIdentifier id = (FontIdentifier)ids.get(boldFont);
100
		BoldFontDescriptor desc = (BoldFontDescriptor)descriptors.get(boldFont);
104
		if (id != null) {
101
		if (desc != null) {
105
			FontReference ref = (FontReference) fonts.get(id);
102
			getResourceManager().destroyFont(desc);
106
			if (ref != null) {
103
			if (getResourceManager().find(desc) == null) {
107
				if (ref.decCount()) {
104
				descriptors.remove(boldFont);
108
					fonts.remove(id);
105
				validateHashMaps();
109
					ids.remove(ref.getFont());
110
// RAP [rh] Unnecessary, as there is no Font#dispose() 
111
//					ref.getFont().dispose();
112
					validateHashMaps();
113
				}
114
				return true;
115
			}
106
			}
107
			return true;
108
			
116
		}
109
		}
117
		// if the image was not found, dispose of it for the caller
110
		// if the image was not found, dispose of it for the caller
118
// RAP [rh] Unnecessary, as there is no Font#dispose() 
111
// RAP [if] unnecessary
119
//		boldFont.dispose();
112
//		boldFont.dispose();
120
		return false;
113
		return false;
121
	}
114
	}
122
115
	
123
	private Font createBoldFont(Display display, Font regularFont) {
116
	private LocalResourceManager getResourceManager() {
124
// RAP [rh] Changes due to different way of creating fonts
117
		if (resources == null)
125
//	  FontData[] fontDatas = regularFont.getFontData();
118
			resources = new LocalResourceManager(JFaceResources.getResources());
126
//		for (int i = 0; i < fontDatas.length; i++) {
119
		return resources;
127
//			fontDatas[i].setStyle(fontDatas[i].getStyle() | SWT.BOLD);
128
//		}
129
//		return new Font(display, fontDatas);
130
	  FontData fontData = regularFont.getFontData()[ 0 ];
131
    return Graphics.getFont( fontData.getName(), 
132
		                         fontData.getHeight(), 
133
		                         fontData.getStyle() | SWT.BOLD );
134
	}
120
	}
135
121
136
	private void checkHashMaps() {
122
	private void checkHashMaps() {
137
		if (fonts == null)
123
		if (descriptors == null)
138
			fonts = new HashMap();
124
			descriptors = new HashMap();
139
		if (ids == null)
140
			ids = new HashMap();
141
	}
125
	}
142
	
126
	
143
	private void validateHashMaps() {
127
	private void validateHashMaps() {
144
		if (fonts.size() == 0)
128
		if (descriptors.size() == 0)
145
			fonts = null;
129
			descriptors = null;
146
		if (ids.size() == 0)
147
			ids = null;
148
	}
130
	}
149
}
131
}
(-)src/org/eclipse/ui/internal/forms/widgets/FormHeading.java (-13 / +6 lines)
Lines 1-11 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 *  Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 *  All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 *  are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 *  which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 *  http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.forms.widgets;
11
package org.eclipse.ui.internal.forms.widgets;
Lines 455-467 Link Here
455
			return messages;
455
			return messages;
456
		}
456
		}
457
457
458
		public String getDetailedMessage() {
459
			Control c = getMessageControl();
460
			if (c != null)
461
				return c.getToolTipText();
462
			return null;
463
		}
464
465
		public Control getMessageControl() {
458
		public Control getMessageControl() {
466
			if (needHyperlink() && messageHyperlink != null)
459
			if (needHyperlink() && messageHyperlink != null)
467
				return messageHyperlink;
460
				return messageHyperlink;
(-)src/org/eclipse/ui/internal/forms/widgets/FormUtil.java (-32 / +34 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 22-28 Link Here
22
import org.eclipse.swt.graphics.Point;
22
import org.eclipse.swt.graphics.Point;
23
import org.eclipse.swt.graphics.Rectangle;
23
import org.eclipse.swt.graphics.Rectangle;
24
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.layout.GridData;
25
//import org.eclipse.swt.widgets.Combo;
25
import org.eclipse.swt.widgets.Combo;
26
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Label;
28
import org.eclipse.swt.widgets.Label;
Lines 376-411 Link Here
376
//		}
376
//		}
377
	}
377
	}
378
378
379
// RAP [rh] FormUtil#processKey unnecessary
379
	public static void processKey(int keyCode, Control c) {
380
//	public static void processKey(int keyCode, Control c) {
380
		if (c.isDisposed()) {
381
//		ScrolledComposite scomp = FormUtil.getScrolledComposite(c);
381
			return;
382
//		if (scomp != null) {
382
		}
383
//			if (c instanceof Combo)
383
		ScrolledComposite scomp = FormUtil.getScrolledComposite(c);
384
//				return;
384
		if (scomp != null) {
385
//			switch (keyCode) {
385
			if (c instanceof Combo)
386
//			case SWT.ARROW_DOWN:
386
				return;
387
//				if (scomp.getData("novarrows") == null) //$NON-NLS-1$
387
			switch (keyCode) {
388
//					FormUtil.scrollVertical(scomp, false);
388
			case SWT.ARROW_DOWN:
389
//				break;
389
				if (scomp.getData("novarrows") == null) //$NON-NLS-1$
390
//			case SWT.ARROW_UP:
390
					FormUtil.scrollVertical(scomp, false);
391
//				if (scomp.getData("novarrows") == null) //$NON-NLS-1$
391
				break;
392
//					FormUtil.scrollVertical(scomp, true);
392
			case SWT.ARROW_UP:
393
//				break;
393
				if (scomp.getData("novarrows") == null) //$NON-NLS-1$
394
//			case SWT.ARROW_LEFT:
394
					FormUtil.scrollVertical(scomp, true);
395
//				FormUtil.scrollHorizontal(scomp, true);
395
				break;
396
//				break;
396
			case SWT.ARROW_LEFT:
397
//			case SWT.ARROW_RIGHT:
397
				FormUtil.scrollHorizontal(scomp, true);
398
//				FormUtil.scrollHorizontal(scomp, false);
398
				break;
399
//				break;
399
			case SWT.ARROW_RIGHT:
400
//			case SWT.PAGE_UP:
400
				FormUtil.scrollHorizontal(scomp, false);
401
//				FormUtil.scrollPage(scomp, true);
401
				break;
402
//				break;
402
			case SWT.PAGE_UP:
403
//			case SWT.PAGE_DOWN:
403
				FormUtil.scrollPage(scomp, true);
404
//				FormUtil.scrollPage(scomp, false);
404
				break;
405
//				break;
405
			case SWT.PAGE_DOWN:
406
//			}
406
				FormUtil.scrollPage(scomp, false);
407
//		}
407
				break;
408
//	}
408
			}
409
		}
410
	}
409
411
410
	public static boolean isWrapControl(Control c) {
412
	public static boolean isWrapControl(Control c) {
411
		if ((c.getStyle() & SWT.WRAP) != 0)
413
		if ((c.getStyle() & SWT.WRAP) != 0)
(-)src/org/eclipse/ui/forms/editor/FormEditor.java (-47 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 12-22 Link Here
12
12
13
import java.util.Vector;
13
import java.util.Vector;
14
14
15
import org.eclipse.core.runtime.ListenerList;
16
import org.eclipse.jface.dialogs.IPageChangeProvider;
17
import org.eclipse.jface.dialogs.IPageChangedListener;
18
import org.eclipse.jface.dialogs.PageChangedEvent;
19
import org.eclipse.jface.util.SafeRunnable;
20
import org.eclipse.jface.viewers.ISelection;
15
import org.eclipse.jface.viewers.ISelection;
21
import org.eclipse.jface.viewers.ISelectionProvider;
16
import org.eclipse.jface.viewers.ISelectionProvider;
22
import org.eclipse.jface.viewers.SelectionChangedEvent;
17
import org.eclipse.jface.viewers.SelectionChangedEvent;
Lines 58-65 Link Here
58
 * 
53
 * 
59
 * @since 1.0
54
 * @since 1.0
60
 */
55
 */
61
public abstract class FormEditor extends MultiPageEditorPart implements
56
public abstract class FormEditor extends MultiPageEditorPart  {
62
		IPageChangeProvider {
63
57
64
	/**
58
	/**
65
	 * An array of pages currently in the editor. Page objects are not limited
59
	 * An array of pages currently in the editor. Page objects are not limited
Lines 74-81 Link Here
74
68
75
	private int currentPage = -1;
69
	private int currentPage = -1;
76
70
77
	private ListenerList pageListeners = new ListenerList();
78
79
	private static class FormEditorSelectionProvider extends
71
	private static class FormEditorSelectionProvider extends
80
			MultiPageSelectionProvider {
72
			MultiPageSelectionProvider {
81
		private ISelection globalSelection;
73
		private ISelection globalSelection;
Lines 179-202 Link Here
179
	/*
171
	/*
180
	 * (non-Javadoc)
172
	 * (non-Javadoc)
181
	 * 
173
	 * 
182
	 * @see org.eclipse.jface.dialogs.IPageChangeProvider#addPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener)
183
	 */
184
	public void addPageChangedListener(IPageChangedListener listener) {
185
		pageListeners.add(listener);
186
	}
187
188
	/*
189
	 * (non-Javadoc)
190
	 * 
191
	 * @see org.eclipse.jface.dialogs.IPageChangeProvider#removePageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener)
192
	 */
193
	public void removePageChangedListener(IPageChangedListener listener) {
194
		pageListeners.remove(listener);
195
	}
196
197
	/*
198
	 * (non-Javadoc)
199
	 * 
200
	 * @see org.eclipse.jface.dialogs.IPageChangeProvider#getSelectedPage()
174
	 * @see org.eclipse.jface.dialogs.IPageChangeProvider#getSelectedPage()
201
	 */
175
	 */
202
	public Object getSelectedPage() {
176
	public Object getSelectedPage() {
Lines 230-235 Link Here
230
	public void addPage(int index, IFormPage page) throws PartInitException {
204
	public void addPage(int index, IFormPage page) throws PartInitException {
231
		super.addPage(index, page.getPartControl());
205
		super.addPage(index, page.getPartControl());
232
		configurePage(index, page);
206
		configurePage(index, page);
207
		updatePageIndices(index+1);
233
	}
208
	}
234
209
235
	/**
210
	/**
Lines 266-271 Link Here
266
		} catch (PartInitException e) {
241
		} catch (PartInitException e) {
267
			// cannot happen for controls
242
			// cannot happen for controls
268
		}
243
		}
244
		updatePageIndices(index+1);
269
	}
245
	}
270
246
271
	/**
247
	/**
Lines 285-290 Link Here
285
					IFormPage fpage = (IFormPage) page;
261
					IFormPage fpage = (IFormPage) page;
286
					if (fpage.isDirty())
262
					if (fpage.isDirty())
287
						return true;
263
						return true;
264
						
265
				} else if (page instanceof IEditorPart) {
266
					IEditorPart editor = (IEditorPart) page;
267
					if (editor.isDirty()) {
268
						return true;
269
					}	
288
				}
270
				}
289
			}
271
			}
290
		}
272
		}
Lines 340-345 Link Here
340
			configurePage(index, (IFormPage) editor);
322
			configurePage(index, (IFormPage) editor);
341
		else
323
		else
342
			registerPage(index, editor);
324
			registerPage(index, editor);
325
		updatePageIndices(index+1);	
343
	}
326
	}
344
327
345
	/**
328
	/**
Lines 374-388 Link Here
374
				IFormPage fpage = (IFormPage) page;
357
				IFormPage fpage = (IFormPage) page;
375
				if (!fpage.isEditor())
358
				if (!fpage.isEditor())
376
					fpage.dispose();
359
					fpage.dispose();
377
				updatePageIndices();
378
			}
360
			}
361
			updatePageIndices(pageIndex);
379
		}
362
		}
380
		super.removePage(pageIndex);
363
		super.removePage(pageIndex);
381
	}
364
	}
382
365
383
	// fix the page indices after the removal
366
	// fix the page indices after the removal/insertion
384
	private void updatePageIndices() {
367
	private void updatePageIndices(int start) {
385
		for (int i = 0; i < pages.size(); i++) {
368
		for (int i = start; i < pages.size(); i++) {
386
			Object page = pages.get(i);
369
			Object page = pages.get(i);
387
			if (page instanceof IFormPage) {
370
			if (page instanceof IFormPage) {
388
				IFormPage fpage = (IFormPage) page;
371
				IFormPage fpage = (IFormPage) page;
Lines 503-511 Link Here
503
		// Call super - this will cause pages to switch
486
		// Call super - this will cause pages to switch
504
		super.pageChange(newPageIndex);
487
		super.pageChange(newPageIndex);
505
		this.currentPage = newPageIndex;
488
		this.currentPage = newPageIndex;
506
		IFormPage newPage = getActivePageInstance();
507
		if (newPage != null)
508
			firePageChanged(new PageChangedEvent(this, newPage));
509
	}
489
	}
510
490
511
	/**
491
	/**
Lines 672-687 Link Here
672
				fpage.init(getEditorSite(), getEditorInput());
652
				fpage.init(getEditorSite(), getEditorInput());
673
		}
653
		}
674
	}
654
	}
675
676
	private void firePageChanged(final PageChangedEvent event) {
677
		Object[] listeners = pageListeners.getListeners();
678
		for (int i = 0; i < listeners.length; ++i) {
679
			final IPageChangedListener l = (IPageChangedListener) listeners[i];
680
			SafeRunnable.run(new SafeRunnable() {
681
				public void run() {
682
					l.pageChanged(event);
683
				}
684
			});
685
		}
686
	}
687
}
655
}
(-)src/org/eclipse/ui/forms/editor/FormPage.java (-2 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 121-127 Link Here
121
		if (active) {
121
		if (active) {
122
			// We are switching to this page - refresh it
122
			// We are switching to this page - refresh it
123
			// if needed.
123
			// if needed.
124
			mform.refresh();
124
			if (mform != null)
125
				mform.refresh();
125
		}
126
		}
126
	}
127
	}
127
	/**
128
	/**
(-)src/org/eclipse/ui/forms/editor/SharedHeaderFormEditor.java (-8 / +9 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2007 IBM Corporation and others.
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 65-71 Link Here
65
65
66
	/**
66
	/**
67
	 * Overrides <code>super</code> to create a form in which to host the tab
67
	 * Overrides <code>super</code> to create a form in which to host the tab
68
	 * folder. This form will be responsible for managing
68
	 * folder. This form will be responsible for creating a common form header. 
69
	 * Child pages should not have a header of their own.
69
	 * 
70
	 * 
70
	 * @param parent
71
	 * @param parent
71
	 *            the page container parent
72
	 *            the page container parent
Lines 130-141 Link Here
130
					
131
					
131
					int activePage = getActivePage();
132
					int activePage = getActivePage();
132
					if (SharedHeaderFormEditor.this.wasHeaderActive != wasHeaderActive && activePage != -1 && pages.get(activePage) instanceof IEditorPart) {
133
					if (SharedHeaderFormEditor.this.wasHeaderActive != wasHeaderActive && activePage != -1 && pages.get(activePage) instanceof IEditorPart) {
133
// TODO [rh] enabled as soon as 3.4 Workbench code is in place						
134
						
134
//						if (wasHeaderActive) {
135
						if (wasHeaderActive) {
135
//							deactivateSite(true, true);
136
							deactivateSite(true, true);
136
//						} else {
137
						} else {
137
//							activateSite();
138
							activateSite();
138
//						}
139
						}
139
					}
140
					}
140
					
141
					
141
					SharedHeaderFormEditor.this.wasHeaderActive = wasHeaderActive;
142
					SharedHeaderFormEditor.this.wasHeaderActive = wasHeaderActive;
(-)src/org/eclipse/ui/forms/events/IHyperlinkListener.java (-1 / +1 lines)
Lines 15-21 Link Here
15
 * 
15
 * 
16
 * @see org.eclipse.ui.forms.widgets.Hyperlink
16
 * @see org.eclipse.ui.forms.widgets.Hyperlink
17
 * @see org.eclipse.ui.forms.widgets.ImageHyperlink
17
 * @see org.eclipse.ui.forms.widgets.ImageHyperlink
18
 * <!-- @see org.eclipse.ui.forms.widgets.FormText -->
18
 * @see org.eclipse.ui.forms.widgets.FormText
19
 * @since 1.0
19
 * @since 1.0
20
 */
20
 */
21
public interface IHyperlinkListener {
21
public interface IHyperlinkListener {
(-)readme.txt (-1 / +1 lines)
Line 1 Link Here
1
Based on code from dev.eclipse.org:/cvsroot/eclipse, Tag v20080407 
1
Based on code from dev.eclipse.org:/cvsroot/eclipse, v20100226
(-)src/org/eclipse/ui/internal/forms/MessageManager.java (-10 / +114 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
2
 * Copyright (c) 2007, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Benjamin Cabe (benjamin.cabe@anyware-tech.com) - patch (see Bugzilla #255466) 
10
 ******************************************************************************/
11
 ******************************************************************************/
11
12
12
package org.eclipse.ui.internal.forms;
13
package org.eclipse.ui.internal.forms;
Lines 17-22 Link Here
17
import java.util.Enumeration;
18
import java.util.Enumeration;
18
import java.util.Hashtable;
19
import java.util.Hashtable;
19
import java.util.Iterator;
20
import java.util.Iterator;
21
import java.util.Map.Entry;
20
22
21
import org.eclipse.jface.dialogs.IMessageProvider;
23
import org.eclipse.jface.dialogs.IMessageProvider;
22
import org.eclipse.jface.fieldassist.ControlDecoration;
24
import org.eclipse.jface.fieldassist.ControlDecoration;
Lines 30-35 Link Here
30
import org.eclipse.ui.forms.IMessage;
32
import org.eclipse.ui.forms.IMessage;
31
import org.eclipse.ui.forms.IMessageManager;
33
import org.eclipse.ui.forms.IMessageManager;
32
import org.eclipse.ui.forms.IMessagePrefixProvider;
34
import org.eclipse.ui.forms.IMessagePrefixProvider;
35
import org.eclipse.ui.forms.widgets.Form;
33
import org.eclipse.ui.forms.widgets.Hyperlink;
36
import org.eclipse.ui.forms.widgets.Hyperlink;
34
import org.eclipse.ui.forms.widgets.ScrolledForm;
37
import org.eclipse.ui.forms.widgets.ScrolledForm;
35
38
Lines 40-48 Link Here
40
public class MessageManager implements IMessageManager {
43
public class MessageManager implements IMessageManager {
41
	private static final DefaultPrefixProvider DEFAULT_PREFIX_PROVIDER = new DefaultPrefixProvider();
44
	private static final DefaultPrefixProvider DEFAULT_PREFIX_PROVIDER = new DefaultPrefixProvider();
42
	private ArrayList messages = new ArrayList();
45
	private ArrayList messages = new ArrayList();
46
	private ArrayList oldMessages;
43
	private Hashtable decorators = new Hashtable();
47
	private Hashtable decorators = new Hashtable();
48
	private Hashtable oldDecorators;
44
	private boolean autoUpdate = true;
49
	private boolean autoUpdate = true;
45
	private ScrolledForm scrolledForm;
50
	private Form form;
46
	private IMessagePrefixProvider prefixProvider = DEFAULT_PREFIX_PROVIDER;
51
	private IMessagePrefixProvider prefixProvider = DEFAULT_PREFIX_PROVIDER;
47
	private int decorationPosition = SWT.LEFT | SWT.BOTTOM;
52
	private int decorationPosition = SWT.LEFT | SWT.BOTTOM;
48
	private static FieldDecoration standardError = FieldDecorationRegistry
53
	private static FieldDecoration standardError = FieldDecorationRegistry
Lines 78-83 Link Here
78
			this.type = type;
83
			this.type = type;
79
			this.data = data;
84
			this.data = data;
80
		}
85
		}
86
		
87
		private Message(Message message) {
88
			this.key = message.key;
89
			this.message = message.message;
90
			this.type = message.type;
91
			this.data = message.data;
92
			this.prefix = message.prefix;
93
			this.control = message.control;
94
		}
81
95
82
		/*
96
		/*
83
		 * (non-Javadoc)
97
		 * (non-Javadoc)
Lines 132-137 Link Here
132
		public String getPrefix() {
146
		public String getPrefix() {
133
			return prefix;
147
			return prefix;
134
		}
148
		}
149
		
150
		public boolean equals(Object obj) {
151
			if (!(obj instanceof Message))
152
				return false;
153
			Message msg = (Message) obj;
154
			return (msg.getPrefix() == null ? getPrefix() == null : msg.getPrefix().equals(getPrefix())) &&
155
					(msg.getControl() == null ? getControl() == null : msg.getControl().equals(getControl())) &&
156
					(msg.getMessageType() == getMessageType()) &&
157
					(msg.getMessage() == null ? getMessage() == null : msg.getMessage().equals(getMessage())) &&
158
					msg.getKey().equals(getKey());
159
		}
135
	}
160
	}
136
161
137
	static class DefaultPrefixProvider implements IMessagePrefixProvider {
162
	static class DefaultPrefixProvider implements IMessagePrefixProvider {
Lines 172-178 Link Here
172
		private String prefix;
197
		private String prefix;
173
198
174
		ControlDecorator(Control control) {
199
		ControlDecorator(Control control) {
175
			this.decoration = new ControlDecoration(control, decorationPosition, scrolledForm.getBody());
200
			this.decoration = new ControlDecoration(control, decorationPosition, form.getBody());
201
		}
202
		
203
		private ControlDecorator (ControlDecorator cd) {
204
			this.decoration = cd.decoration;
205
			this.prefix = cd.prefix;
206
			for (Iterator i = cd.controlMessages.iterator(); i.hasNext();)
207
				this.controlMessages.add(new Message((Message)i.next()));
176
		}
208
		}
177
209
178
		public boolean isDisposed() {
210
		public boolean isDisposed() {
Lines 186-192 Link Here
186
		void updatePosition() {		
218
		void updatePosition() {		
187
			Control control = decoration.getControl();
219
			Control control = decoration.getControl();
188
			decoration.dispose();
220
			decoration.dispose();
189
			this.decoration = new ControlDecoration(control, decorationPosition, scrolledForm.getBody());
221
			this.decoration = new ControlDecoration(control, decorationPosition, form.getBody());
190
			update();
222
			update();
191
		}
223
		}
192
224
Lines 256-261 Link Here
256
				decoration.show();
288
				decoration.show();
257
			}
289
			}
258
		}
290
		}
291
		
292
		public boolean equals(Object obj) {
293
			if (!(obj instanceof ControlDecorator))
294
				return false;
295
			ControlDecorator cd = (ControlDecorator) obj;
296
			if (!cd.decoration.equals(decoration))
297
				return false;
298
			return cd.getPrefix().equals(getPrefix());
299
		}
300
		
301
		boolean hasSameMessages(ControlDecorator cd) {
302
			if (cd.controlMessages.size() != controlMessages.size())
303
				return false;
304
			if (!cd.controlMessages.containsAll(controlMessages))
305
				return false;
306
			return true;
307
		}
259
	}
308
	}
260
309
261
	/**
310
	/**
Lines 266-272 Link Here
266
	 *            the form to control
315
	 *            the form to control
267
	 */
316
	 */
268
	public MessageManager(ScrolledForm scrolledForm) {
317
	public MessageManager(ScrolledForm scrolledForm) {
269
		this.scrolledForm = scrolledForm;
318
		this.form = scrolledForm.getForm();
319
	}
320
	
321
	/**
322
	 * Creates a new instance of the message manager that will work with the
323
	 * provided form.
324
	 * 
325
	 * @param form
326
	 *            the form to control
327
	 */
328
	public MessageManager(Form form) {
329
		this.form = form;
270
	}
330
	}
271
331
272
	/*
332
	/*
Lines 440-447 Link Here
440
500
441
	private void update(ArrayList mergedList) {
501
	private void update(ArrayList mergedList) {
442
		pruneControlDecorators();
502
		pruneControlDecorators();
443
		if (mergedList.isEmpty() || mergedList == null) {
503
		if (form.getHead().getBounds().height == 0 || mergedList.isEmpty() || mergedList == null) {
444
			scrolledForm.setMessage(null, IMessageProvider.NONE);
504
			form.setMessage(null, IMessageProvider.NONE);
445
			return;
505
			return;
446
		}
506
		}
447
		ArrayList peers = createPeers(mergedList);
507
		ArrayList peers = createPeers(mergedList);
Lines 453-459 Link Here
453
			// a single message
513
			// a single message
454
			IMessage message = (IMessage) peers.get(0);
514
			IMessage message = (IMessage) peers.get(0);
455
			messageText = message.getMessage();
515
			messageText = message.getMessage();
456
			scrolledForm.setMessage(messageText, maxType, array);
516
			form.setMessage(messageText, maxType, array);
457
		} else {
517
		} else {
458
			// show a summary message for the message
518
			// show a summary message for the message
459
			// and list of errors for the details
519
			// and list of errors for the details
Lines 463-469 Link Here
463
						new String[] { peers.size() + "" }); //$NON-NLS-1$
523
						new String[] { peers.size() + "" }); //$NON-NLS-1$
464
			else
524
			else
465
				messageText = SINGLE_MESSAGE_SUMMARY_KEYS[maxType];
525
				messageText = SINGLE_MESSAGE_SUMMARY_KEYS[maxType];
466
			scrolledForm.setMessage(messageText, maxType, array);
526
			form.setMessage(messageText, maxType, array);
467
		}
527
		}
468
	}
528
	}
469
529
Lines 593-601 Link Here
593
	 * @see org.eclipse.ui.forms.IMessageManager#setAutoUpdate(boolean)
653
	 * @see org.eclipse.ui.forms.IMessageManager#setAutoUpdate(boolean)
594
	 */
654
	 */
595
	public void setAutoUpdate(boolean autoUpdate) {
655
	public void setAutoUpdate(boolean autoUpdate) {
656
		boolean needsCaching = this.autoUpdate && !autoUpdate;
596
		boolean needsUpdate = !this.autoUpdate && autoUpdate;
657
		boolean needsUpdate = !this.autoUpdate && autoUpdate;
597
		this.autoUpdate = autoUpdate;
658
		this.autoUpdate = autoUpdate;
598
		if (needsUpdate)
659
		if (needsUpdate && isCacheChanged())
599
			update();
660
			update();
661
		if (needsCaching) {
662
			oldMessages = new ArrayList();
663
			for (Iterator i = messages.iterator(); i.hasNext();)
664
				oldMessages.add(new Message((Message)i.next()));
665
			oldDecorators = new Hashtable();
666
			for (Enumeration e = decorators.keys(); e.hasMoreElements();) {
667
				Object key = e.nextElement();
668
				oldDecorators.put(key, new ControlDecorator((ControlDecorator)decorators.get(key)));
669
			}
670
		}
671
	}
672
	
673
	private boolean isCacheChanged() {
674
		boolean result = false;
675
		result = checkMessageCache() || checkDecoratorCache();
676
		oldMessages.clear();
677
		oldMessages = null;
678
		oldDecorators.clear();
679
		oldDecorators = null;
680
		return result;
681
	}
682
	
683
	private boolean checkMessageCache() {
684
		if (oldMessages == null)
685
			return false;
686
		if (messages.size() != oldMessages.size())
687
			return true;
688
		if (!oldMessages.containsAll(messages))
689
			return true;
690
		return false;
691
	}
692
	
693
	private boolean checkDecoratorCache() {
694
		if (oldDecorators == null)
695
			return false;
696
		for (Iterator i = decorators.entrySet().iterator(); i.hasNext();) {
697
			Entry next = (Entry)i.next();
698
			ControlDecorator cd = (ControlDecorator)next.getValue();
699
			ControlDecorator oldCd = (ControlDecorator) oldDecorators.get(cd.decoration.getControl());
700
			if ((oldCd == null && cd.controlMessages.size() > 0) || (oldCd != null && !cd.hasSameMessages(oldCd)))
701
				return true;
702
		}
703
		return false;
600
	}
704
	}
601
}
705
}
(-)src/org/eclipse/ui/internal/forms/FormsPlugin.java (+30 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.forms;
12
13
import org.eclipse.ui.internal.forms.widgets.FormsResources;
14
import org.eclipse.ui.plugin.AbstractUIPlugin;
15
import org.osgi.framework.BundleContext;
16
17
public class FormsPlugin extends AbstractUIPlugin {
18
19
	public FormsPlugin() {
20
	}
21
	
22
	public void stop(BundleContext context) throws Exception {
23
		try {
24
			FormsResources.shutdown();
25
		} finally {
26
			super.stop(context);
27
		}
28
	}
29
30
}

Return to bug 303731