Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 77b883cfa7a5a376ee5dce23cb703b25eda4029c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*****************************************************************************
 * Copyright (c) 2009 CEA LIST.
 *    
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
 *
 *****************************************************************************/

package org.eclipse.papyrus.uml.properties.tabbedproperties.comments.propertysection;

//------------------------------------------------------------------------------
//Copyright (c) 2005, 2006 IBM Corporation and others.
//All rights reserved. This program and the accompanying materials
//are made available under the terms of the Eclipse Public License v1.0
//which accompanies this distribution, and is available at
//http://www.eclipse.org/legal/epl-v10.html
//
//Contributors:
//IBM Corporation - initial implementation
//------------------------------------------------------------------------------

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.uml2.uml.Comment;

/**
 * A helper toolkit for creating a rich text control and editor that can be added to an Eclipse
 * form.
 * 
 * @author Kelvin Low
 * @since 1.0
 */
public class CommentRichTextFormToolkit {

	//	/**
	//	 * Creates a rich text control and adapts it to be used in a form.
	//	 * 
	//	 * @param toolkit
	//	 *            the form toolkit
	//	 * @param parent
	//	 *            the parent control
	//	 * @param text
	//	 *            the initial text for the viewer
	//	 * @param style
	//	 *            the initial style for the viewer
	//	 * @param basePath
	//	 *            the base path used for resolving hrefs
	//	 * @return a new <code>IRichText</code> instance
	//	 */
	//	public static CommentRichText createRichText(FormToolkit toolkit, Composite parent, String text, int style) {
	//		CommentRichText richText = new CommentRichText(parent, toolkit.getBorderStyle() | style
	//				| toolkit.getOrientation(), null);
	//		richText.getControl().setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
	//		if (text != null) {
	//			richText.setText(text);
	//		}
	//		return richText;
	//	}

	/**
	 * Creates a rich text editor and adapts it to be used in a form.
	 * 
	 * @param toolkit
	 *        the form toolkit
	 * @param parent
	 *        the parent control
	 * @param text
	 *        the initial text for the viewer
	 * @param style
	 *        the initial style for the viewer
	 * @param basePath
	 *        the base path used for resolving hrefs
	 * @return a new <code>IRichText</code> instance
	 */
	public static CommentRichTextEditor createRichTextEditor(FormToolkit toolkit, Composite parent, String text, Comment comment, int style, IEditorSite editorSite) {
		CommentRichTextEditor richTextEditor = new CommentRichTextEditor(parent, toolkit.getBorderStyle() | style | toolkit.getOrientation(), null, comment, null, editorSite);
		// richTextEditor.getControl().setData(FormToolkit.KEY_DRAW_BORDER,
		// FormToolkit.TREE_BORDER);
		if(text != null) {
			richTextEditor.setInitialText(text);
		}
		return richTextEditor;
	}

	/**
	 * Creates a rich text editor and adapts it to be used in a form.
	 * 
	 * @param toolkit
	 *        the form toolkit
	 * @param parent
	 *        the parent control
	 * @param text
	 *        the initial text for the viewer
	 * @param style
	 *        the initial style for the viewer
	 * @param basePath
	 *        the base path used for resolving hrefs
	 * @return a new <code>IRichText</code> instance
	 */
	public static CommentRichTextEditor createFocusAwareRichTextEditor(FormToolkit toolkit, Composite parent, String text, Comment comment, int style, IEditorSite editorSite) {
		CommentRichTextEditor richTextEditor = new FocusAwareCommentRichTextEditor(parent, toolkit.getBorderStyle() | style | toolkit.getOrientation(), null, comment, null, editorSite);
		// richTextEditor.getControl().setData(FormToolkit.KEY_DRAW_BORDER,
		// FormToolkit.TREE_BORDER);
		if(text != null) {
			richTextEditor.setInitialText(text);
		}
		return richTextEditor;
	}
}

Back to the top