Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0ed7b3a66c82adefa43b8ab4a5df7ae4a19c2ea3 (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
/*******************************************************************************
 * Copyright (c) 2006 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.common.ui.internal.dialogfield;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;

/**
 * This class represents a group of dialog fields, following the normal dialog
 * field's lifecycle.
 * 
 * The design of this class is to make a section could be reused in both dialog
 * environment and form based editor environment.
 * 
 * @author mengbo
 */
public abstract class DialogFieldGroup {
	private IDialogFieldChangeListener _defaultChangeListener;

	private IDialogFieldApplyListener _defaultApplyListener;

	/**
	 * set default handler, should be called before <code>initialize()</code>
	 * @param changelistener 
	 * 
	 */
	public void setDefaultChangeListener(
			IDialogFieldChangeListener changelistener) {
		_defaultChangeListener = changelistener;
	}

	/**
	 * Normally, the client should call this method in <code>initialize()</code>
	 * for those field that wants to use the default event handler.
	 * 
	 * @return could be null
	 */
	public IDialogFieldChangeListener getDefaultChangeListener() {
		return _defaultChangeListener;
	}

	/**
	 * set default handler, should be called before <code>initialize()</code>
	 * 
	 * @param applylistener
	 */
	public void setDefaultApplyListener(IDialogFieldApplyListener applylistener) {
		_defaultApplyListener = applylistener;
	}

	/**
	 * Normally, the client should call this method in <code>initialize()</code>
	 * for those field that wants to use the default event handler.
	 * 
	 * @return could be null
	 */
	public IDialogFieldApplyListener getDefaultApplyListener() {
		return _defaultApplyListener;
	}

	/**
	 * it is supposed to create all dialog fields and setup event listeners in
	 * this method.
	 * 
	 * Normally client will create DialogFieldSection first, then
	 * setDefaultChangeListener()/setDefaultApplyListener(), then call
	 * initialize().
	 */
	public abstract void initialize();

	/**
	 * reload data from underlying model and set them into the dialog fields.
	 * 
	 */
	public abstract void refreshData();

	/**
	 * layout the dialog fields.
	 * 
	 * @param toolkit
	 *            could be null
	 * @param parent
	 * 
	 */
	public abstract void layoutDialogFields(FormToolkit toolkit,
			Composite parent);

	/**
	 * validate whether the values in the dialog fields are valid. This method
	 * should also enable/disable dialog fields based on their current value and
	 * relationship
	 * 
	 * @return could return null. or an array containing null elements.
	 */
	public abstract IStatus[] validateDialogFields();
	
	/**
	 * Intended to allow subclasses to recreate controls.  Default implementation does nothing.
	 */
	public void reset(){
		//do nothing by default	
	}
}

Back to the top