Skip to main content
summaryrefslogtreecommitdiffstats
blob: b0f7923ff898252a5a541ad3229b54f1d5ccc1c7 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*******************************************************************************
 * Copyright (c) 2004, 2005 Sybase, Inc. 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:
 *     Sybase, Inc. - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.jsf.facesconfig.ui.page;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jst.jsf.facesconfig.emf.FacesConfigType;
import org.eclipse.jst.jsf.facesconfig.ui.EditorPlugin;
import org.eclipse.jst.jsf.facesconfig.ui.FacesConfigEditor;
import org.eclipse.jst.jsf.facesconfig.ui.EditorMessages;
import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewComponentsSection;
import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewGeneralSection;
import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewManagedBeanSection;
import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewNavigationSection;
import org.eclipse.jst.jsf.facesconfig.ui.section.OverviewOthersSection;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;

/**
 * @author jchoi, Xiao-guang Zhang
 * @version
 */
public class OverviewPage extends FormPage implements ISelectionProvider,
		IFacesConfigPage {


    /**
     * The id of this page in the faces-config editor.
     */
	public static final String PAGE_ID = "org.eclipse.jst.jsf.facesconfig.ui.page.OverviewPage";
	
	private static final int LAYOUT_MARGIN_HEIGHT = 2;

	private static final int LAYOUT_MARGIN_WIDTH = 2;

	private Object input;

	private OverviewGeneralSection generalSection;

	private OverviewManagedBeanSection beanSection;

	private OverviewComponentsSection componentsSection;

	//
	private OverviewNavigationSection navigationSection;

	//
	private OverviewOthersSection otherSection;

	/**
	 * 
	 * @param editor
	 */
	public OverviewPage(FormEditor editor) {
		super(editor, "OverviewPage", EditorMessages.OverviewPage_page_name);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
	 */
	protected void createFormContent(IManagedForm managedForm) {

		ScrolledForm form = managedForm.getForm();
		form.setText(EditorMessages.OverviewPage_PageflowOverview_summary);
		form.setBackgroundImage(EditorPlugin.getDefault().getImage(
				"form_banner.gif")); //$NON-NLS-1$
		Composite body = form.getBody();
		GridLayout gridLayout = new GridLayout();
		gridLayout.marginWidth = LAYOUT_MARGIN_WIDTH;
		gridLayout.marginHeight = LAYOUT_MARGIN_HEIGHT;
		body.setLayout(gridLayout);
		gridLayout = new GridLayout(2, true);
		form.getBody().setLayout(gridLayout);
		FormEditor editor = getEditor();
		FormToolkit toolkit = editor.getToolkit();

		// add overview general information
		generalSection = new OverviewGeneralSection(managedForm.getForm()
				.getBody(), managedForm, this, toolkit);
		generalSection.initialize();
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 2;
		generalSection.getSection().setLayoutData(gd);

		// Navigation section
		navigationSection = new OverviewNavigationSection(managedForm.getForm()
				.getBody(), managedForm, this, toolkit);
		navigationSection.initialize();
		gd = new GridData(GridData.FILL_BOTH);
		navigationSection.getSection().setLayoutData(gd);
		navigationSection.getSection().setExpanded(true);

		// ManagedBeans section
		beanSection = new OverviewManagedBeanSection(managedForm.getForm()
				.getBody(), managedForm, this, toolkit);
		beanSection.initialize();
		gd = new GridData(GridData.FILL_BOTH);
		beanSection.getSection().setLayoutData(gd);
		beanSection.getSection().setExpanded(true);

		/* components section */
		componentsSection = new OverviewComponentsSection(managedForm.getForm()
				.getBody(), managedForm, this, toolkit);
		componentsSection.initialize();
		gd = new GridData(GridData.FILL_BOTH);
		componentsSection.getSection().setLayoutData(gd);
		componentsSection.getSection().setExpanded(true);

		/* other sections */
		otherSection = new OverviewOthersSection(managedForm.getForm()
				.getBody(), managedForm, this, toolkit);
		otherSection.initialize();
		gd = new GridData(GridData.FILL_BOTH);
		otherSection.getSection().setLayoutData(gd);
		otherSection.getSection().setExpanded(true);

		this.getSite().setSelectionProvider(this);

	}

	/**
	 * set input for this page when the it got activated at the first time; if
	 * it's not the first time, then refresh the page.
	 * 
	 * @see org.eclipse.ui.forms.editor.FormPage#setActive(boolean)
	 */
	public void setActive(boolean active) {
		super.setActive(active);
		if (active) {
			if (getInput() != ((FacesConfigEditor) getEditor())
					.getFacesConfig()) {
				setInput(((FacesConfigEditor) getEditor()).getFacesConfig());
			} else {
				this.refresh();
			}
		}
	}

	/**
	 * 
	 */
	public void setInput(Object input) {
		if (input instanceof FacesConfigType) {
			this.input = input;
			navigationSection.setInput(input);
			beanSection.setInput(input);
			componentsSection.setInput(input);
			otherSection.setInput(input);
		}
	}

	/**
	 * Call refreshAll on all sections on this page
	 */
	public void refreshAll() {
		generalSection.refreshAll();
		navigationSection.refreshAll();
		beanSection.refreshAll();
		componentsSection.refreshAll();
		otherSection.refreshAll();
	}

	public Object getInput() {
		return input;
	}

	public void refresh() {
		generalSection.refresh();
		navigationSection.refresh();
		beanSection.refresh();
		componentsSection.refresh();
		otherSection.refresh();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.forms.editor.IFormPage#isEditor()
	 */
	public boolean isEditor() {
		return true;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
	 */
	public void addSelectionChangedListener(ISelectionChangedListener listener) {
        // do not support change in selection
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
	 */
	public ISelection getSelection() {
		return StructuredSelection.EMPTY;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
	 */
	public void removeSelectionChangedListener(
			ISelectionChangedListener listener) {
        // do not support change in selection
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
	 */
	public void setSelection(ISelection selection) {
	    // do not support change in selection
	}
	
	public void dispose() {
		beanSection.dispose();
		componentsSection.dispose();
		generalSection.dispose();
		navigationSection.dispose();
		otherSection.dispose();
		super.dispose();
	}
}

Back to the top