Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5f1d9c446ce8685ebf24aef6be16db0e80a35737 (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
/*******************************************************************************
 * 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.pageflow.properties.section;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.DialogField;
import org.eclipse.jst.jsf.common.ui.internal.dialogfield.IDialogFieldApplyListener;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.editpart.PageflowEditPart;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.Pageflow;
import org.eclipse.jst.jsf.facesconfig.ui.pageflow.model.impl.PageflowPackageImpl;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage;
import org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory;

/**
 * Edit section for Pagflow (EditPart)
 * 
 * @author jchoi, Xiao-guang Zhang
 */
public class EditorSection extends AbstractEditPartSection {
	/** edit group */
	private EditorGroup group;

	/** the emf model for Pageflow */
	private Pageflow pageflow;

	/**
	 * 
	 */
	public EditorSection() {
		super();
		group = new EditorGroup();
		group.setDefaultChangeListener(changeListener);
		group.initialize();

		group.getDisplayNameField().setDialogFieldApplyListener(
				new IDialogFieldApplyListener() {
					public void dialogFieldApplied(DialogField field) {
						EditorSection.this.setValue(
								PageflowPackageImpl.eINSTANCE
										.getPageflowElement_Name().getName(),
								group.getDisplayNameField().getText());
					}
				});

		group.getDescField().setDialogFieldApplyListener(
				new IDialogFieldApplyListener() {
					public void dialogFieldApplied(DialogField field) {
						EditorSection.this
								.setValue(
										PageflowPackageImpl.eINSTANCE
												.getPageflowElement_Comment()
												.getName(), group
												.getDescField().getText());
					}
				});
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#createControls(org.eclipse.swt.widgets.Composite,
	 *      org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetPage)
	 */
	public void createControls(Composite parent,
			TabbedPropertySheetPage aTabbedPropertySheetPage) {
		super.createControls(parent, aTabbedPropertySheetPage);
		TabbedPropertySheetWidgetFactory factory = aTabbedPropertySheetPage
				.getWidgetFactory();
		Composite top = factory.createFlatFormComposite(parent);

		group.layoutDialogFields(factory, top);

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#setInput(org.eclipse.ui.IWorkbenchPart,
	 *      org.eclipse.jface.viewers.ISelection)
	 */
	public void setInput(IWorkbenchPart part, ISelection selection) {
		super.setInput(part, selection);

		if (getInput() != null && getInput() instanceof PageflowEditPart) {
			Object model = ((PageflowEditPart) getInput()).getModel();
			if (model instanceof Pageflow) {
				pageflow = (Pageflow) model;
				refreshData();
			}
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sybase.stf.jmt.editors.pageflow.properties.sections.AbstractEditPartSection#refreshData()
	 */
	public void refreshData() {
		super.refreshData();
		group.setPropertyProvider(pageflow);
	}

    public void validate() {
        // do nothing.
    }
}

Back to the top