01: /*******************************************************************************
02: * Copyright (c) 2003 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jsp;
11:
12: import org.eclipse.jface.preference.PreferencePage;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.swt.events.SelectionAdapter;
15: import org.eclipse.swt.events.SelectionEvent;
16: import org.eclipse.swt.widgets.Button;
17: import org.eclipse.swt.widgets.Composite;
18: import org.eclipse.swt.widgets.Control;
19: import org.eclipse.ui.IWorkbench;
20: import org.eclipse.ui.IWorkbenchPreferencePage;
21:
22: public class JavaFamilyExamplePreferencePage extends PreferencePage
23: implements IWorkbenchPreferencePage {
24:
25: /* (non-Javadoc)
26: * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
27: */
28: protected Control createContents(Composite parent) {
29: Composite c = new Composite(parent, SWT.NULL);
30: //c.setLayout(new FillLayout());
31:
32: final Button b = new Button(c, SWT.NULL);
33: b.setText(getButtonLabel());
34: b.addSelectionListener(new SelectionAdapter() {
35: public void widgetSelected(SelectionEvent e) {
36: JspUIPlugin.getDefault().controlJSPIndexing(
37: !JspUIPlugin.getDefault().isJSPIndexingOn());
38: b.setText(getButtonLabel());
39: }
40: });
41: b.pack();
42:
43: return c;
44: }
45:
46: private String getButtonLabel() {
47: if (JspUIPlugin.getDefault().isJSPIndexingOn())
48: return "Stop JSP Indexing"; //$NON-NLS-1$
49: return "Start JSP Indexing"; //$NON-NLS-1$
50: }
51:
52: /* (non-Javadoc)
53: * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
54: */
55: public void init(IWorkbench workbench) {
56: // empty implementation
57: }
58: }
|