Skip to main content
summaryrefslogtreecommitdiffstats
blob: f9f7907d5bb8b81b004e0b860fd27b64b2748346 (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
116
117
118
119
120
121
122
123
/**
 * 
 */
package org.eclipse.papyrus.sasheditor.ui.views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;


/**
 * An View (from MVC) used to render data from the SashWindows.
 * This view is implemented with SWT.
 * 
 * @author cedric dumoulin
 */
public class SashWindowsView {

	private FormToolkit toolkit;

	private ScrolledForm form;

	private Text selectedElement;

	private Text selectedPage;

	private Text selectedPageName;

	private Text selectedFolder;

	private Text selectedIEditor;

	private Text selectedIEditorName;

	private final String TITLE = "SashWindows";

	/**
	 * Create associated part control.
	 * 
	 * @param parent
	 */
	public void createPartControl(Composite parent) {
		toolkit = new FormToolkit(parent.getDisplay());
		form = toolkit.createScrolledForm(parent);
		form.setText(TITLE);

		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		form.getBody().setLayout(layout);

		//
		selectedElement = createInputText("Selected Element:", "");
		selectedPage = createInputText("selected Page:", "");
		selectedPageName = createInputText("  page name:", "");
		selectedFolder = createInputText("selected Folder:", "");
		selectedIEditor = createInputText("selected IEditor:", "");
		selectedIEditorName = createInputText("  editor name:", "");

	}

	/**
	 * Create a Text with a label and an initial value.
	 * 
	 * @param labelValue
	 * @param textValue
	 * @return
	 */
	private Text createInputText(String labelValue, String textValue) {
		Text text;
		GridData gd = new GridData();
		Label label = toolkit.createLabel(form.getBody(), labelValue);
		label.setLayoutData(gd);
		text = toolkit.createText(form.getBody(), textValue, SWT.BORDER);
		text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

		return text;
	}

	public void setselectedElement(String newText) {
		selectedElement.setText(newText);
	}

	public void setSelectedPage(String newText) {
		selectedPage.setText(newText);
	}

	public void setSelectedPageName(String newText) {
		selectedPageName.setText(newText);
	}

	public void setSelectedFolder(String newText) {
		selectedFolder.setText(newText);
	}

	public void setSelectedIEditor(String newText) {
		selectedIEditor.setText(newText);
	}

	public void setSelectedIEditorName(String newText) {
		selectedIEditorName.setText(newText);
	}


	/**
	 * Dispose all resources
	 */
	public void dispose() {
		toolkit.dispose();
	}

	/**
	 * Set focus to this element.
	 */
	public void setFocus() {
		form.setFocus();
	}

}

Back to the top