KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > cheatsheet > CSFileWizardPage


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.pde.internal.ui.wizards.cheatsheet;
13
14 import org.eclipse.jface.dialogs.Dialog;
15 import org.eclipse.jface.viewers.IStructuredSelection;
16 import org.eclipse.pde.internal.ui.IHelpContextIds;
17 import org.eclipse.pde.internal.ui.PDEUIMessages;
18 import org.eclipse.pde.internal.ui.wizards.PDEWizardNewFileCreationPage;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.events.SelectionAdapter;
21 import org.eclipse.swt.events.SelectionEvent;
22 import org.eclipse.swt.layout.GridData;
23 import org.eclipse.swt.layout.GridLayout;
24 import org.eclipse.swt.widgets.Button;
25 import org.eclipse.swt.widgets.Composite;
26 import org.eclipse.swt.widgets.Group;
27 import org.eclipse.swt.widgets.Label;
28 import org.eclipse.ui.PlatformUI;
29
30 /**
31  * CheatSheetFileWizardPage
32  *
33  */

34 public class CSFileWizardPage extends PDEWizardNewFileCreationPage {
35
36     private Button fSimpleCheatSheetButton;
37     
38     private Button fCompositeCheatSheetButton;
39     
40     private Group fGroup;
41     
42     protected static final String JavaDoc F_FILE_EXTENSION = "xml"; //$NON-NLS-1$
43

44     public static final int F_SIMPLE_CHEAT_SHEET = 0;
45     
46     public static final int F_COMPOSITE_CHEAT_SHEET = 1;
47     
48     /**
49      * @param pageName
50      * @param selection
51      */

52     public CSFileWizardPage(String JavaDoc pageName,
53             IStructuredSelection selection) {
54         super(pageName, selection);
55         
56         initialize();
57     }
58
59     /**
60      *
61      */

62     protected void initialize() {
63         setTitle(PDEUIMessages.CheatSheetFileWizardPage_1);
64         setDescription(PDEUIMessages.CheatSheetFileWizardPage_2);
65         // Force the file extension to be 'xml'
66
setFileExtension(F_FILE_EXTENSION);
67     }
68     
69     /**
70      * @return
71      */

72     public int getCheatSheetType() {
73         if (fSimpleCheatSheetButton.getSelection()) {
74             return F_SIMPLE_CHEAT_SHEET;
75         } else if (fCompositeCheatSheetButton.getSelection()) {
76             return F_COMPOSITE_CHEAT_SHEET;
77         }
78         // Neither selected. Unknown type
79
return -1;
80     }
81     
82     /* (non-Javadoc)
83      * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createAdvancedControls(org.eclipse.swt.widgets.Composite)
84      */

85     protected void createAdvancedControls(Composite parent) {
86
87         GridData data = null;
88         
89         // Cheat Sheet Group
90
fGroup = new Group(parent, SWT.NONE);
91         fGroup.setText(PDEUIMessages.CheatSheetFileWizardPage_4);
92         fGroup.setLayout(new GridLayout(1, false));
93         fGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
94         
95         // Simple Cheat Sheet Button
96
fSimpleCheatSheetButton = new Button(fGroup, SWT.RADIO);
97         fSimpleCheatSheetButton.setText(PDEUIMessages.CheatSheetFileWizardPage_5);
98         fSimpleCheatSheetButton.setSelection(true);
99         fSimpleCheatSheetButton.addSelectionListener(new SelectionAdapter() {
100             public void widgetSelected(SelectionEvent e) {
101                 getWizard().getContainer().updateButtons();
102             }
103         });
104         
105         // Simple Cheat Sheet Description Label
106
final Label simpleCSLabel = new Label(fGroup, SWT.WRAP);
107         simpleCSLabel.setText(PDEUIMessages.CheatSheetFileWizardPage_6);
108         data = new GridData(GridData.FILL_HORIZONTAL);
109         data.widthHint = 300;
110         data.horizontalIndent = 20;
111         simpleCSLabel.setLayoutData(data);
112         
113         // Composite Cheat Sheet Button
114
fCompositeCheatSheetButton = new Button(fGroup, SWT.RADIO);
115         fCompositeCheatSheetButton.setSelection(false);
116         fCompositeCheatSheetButton
117                 .setText(PDEUIMessages.CheatSheetFileWizardPage_7);
118         data = new GridData(GridData.FILL_HORIZONTAL);
119         data.verticalIndent = 10;
120         fCompositeCheatSheetButton.setLayoutData(data);
121         fCompositeCheatSheetButton.addSelectionListener(new SelectionAdapter() {
122             public void widgetSelected(SelectionEvent e) {
123                 getWizard().getContainer().updateButtons();
124             }
125         });
126         
127         // Composite Cheat Sheet Description Label
128
final Label compositeCSLabel = new Label(fGroup, SWT.WRAP);
129         compositeCSLabel.setText(PDEUIMessages.CheatSheetFileWizardPage_8);
130         data = new GridData(GridData.FILL_HORIZONTAL);
131         data.widthHint = 300;
132         data.horizontalIndent = 20;
133         compositeCSLabel.setLayoutData(data);
134         
135     }
136     
137     /* (non-Javadoc)
138      * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createControl(org.eclipse.swt.widgets.Composite)
139      */

140     public void createControl(Composite parent) {
141         super.createControl(parent);
142         Dialog.applyDialogFont(fGroup);
143
144         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IHelpContextIds.CHEAT_SHEET_PAGE );
145     }
146
147 }
148
Popular Tags