Skip to main content
summaryrefslogtreecommitdiffstats
blob: f9706467493d3b7390557d2b03b46d9229432a98 (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
/*******************************************************************************
 * Copyright (c) 2007 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 API and implementation
 * yyyymmdd bug      Email and other contact information
 * -------- -------- -----------------------------------------------------------
 * 20071025 196997   ericdp@ca.ibm.com - Eric Peters
 * 20071107 196997   ericdp@ca.ibm.com - Eric Peters
 * 20071120   209858 ericdp@ca.ibm.com - Eric Peters, Enhancing service policy framework and UI
 *******************************************************************************/
package org.eclipse.wst.ws.internal.service.policy.ui.preferences;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.wst.ws.internal.service.policy.ui.ServicePoliciesComposite;
import org.eclipse.wst.ws.service.policy.ServicePolicyPlatform;

public class ServicePoliciesPreferencePage extends PreferencePage implements
		IWorkbenchPreferencePage, SelectionListener

{
	ServicePoliciesComposite preferencePage;
	Composite superParent;
	public static final String PAGE_ID = "org.eclipse.wst.ws.internal.ui.wsi.preferences.WSICompliancePreferencePage"; //$NON-NLS-1$

	/**
	 * Creates preference page controls on demand.
	 * 
	 * @param parentComposite
	 *            the parent for the preference page
	 */
	protected Control createContents(Composite superparent) {
		preferencePage = new ServicePoliciesComposite(superparent, null, this);
		org.eclipse.jface.dialogs.Dialog.applyDialogFont(superparent);
		this.superParent = superparent;
		return preferencePage;

	}

	/**
	 * Does anything necessary because the default button has been pressed.
	 */
	protected void performDefaults() {
		preferencePage.performDefaults();
		IStatus error = preferencePage.getError();
		if (error == null) {
			super.setValid(true);
			super.setErrorMessage(null);
		} else {
			super.setErrorMessage(error.getMessage());
			super.setValid(false);
		}
	}

	/**
	 * Do anything necessary because the OK button has been pressed.
	 * 
	 * @return whether it is okay to close the preference page
	 */
	public boolean performOk() {
		storeValues();
		return true;
	}

	/**
	 * Stores the values of the controls back to the preference store.
	 */
	private void storeValues() {
		ServicePolicyPlatform.getInstance().commitChanges();
	}

	/**
	 * Do anything necessary because the Cancel button has been pressed.
	 * 
	 * @return whether it is okay to close the preference page
	 */
	public boolean performCancel() {
		ServicePolicyPlatform.getInstance().discardChanges();
		return true;
	}

	/**
	 * Do anything necessary because the OK button has been pressed.
	 * 
	 */
	protected void performApply() {
		storeValues();
	}

	/**
	 * @see IWorkbenchPreferencePage
	 */
	public void init(IWorkbench workbench) {
	}

	/**
	 * @return whether it is okay to close the preference page
	 */
	public boolean okToLeave() {
		return preferencePage.getError() == null;

	}

	public void dispose() {
		super.dispose();
		preferencePage.dispose();
	}

	public void widgetDefaultSelected(SelectionEvent e) {

	}

	public void widgetSelected(SelectionEvent e) {
		IStatus error = preferencePage.getError();
		if (error == null) {
			super.setValid(true);
			super.setErrorMessage(null);
		} else {
			super.setErrorMessage(error.getMessage());
			super.setValid(false);
		}

	}

}

Back to the top