001: /*******************************************************************************
002: * Copyright (c) 2006, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.ui.wizards.cheatsheet;
011:
012: import org.eclipse.jface.dialogs.Dialog;
013: import org.eclipse.jface.viewers.IStructuredSelection;
014: import org.eclipse.pde.internal.ui.IHelpContextIds;
015: import org.eclipse.pde.internal.ui.PDEUIMessages;
016: import org.eclipse.pde.internal.ui.wizards.PDEWizardNewFileCreationPage;
017: import org.eclipse.swt.SWT;
018: import org.eclipse.swt.events.SelectionAdapter;
019: import org.eclipse.swt.events.SelectionEvent;
020: import org.eclipse.swt.layout.GridData;
021: import org.eclipse.swt.layout.GridLayout;
022: import org.eclipse.swt.widgets.Button;
023: import org.eclipse.swt.widgets.Composite;
024: import org.eclipse.swt.widgets.Group;
025: import org.eclipse.swt.widgets.Label;
026: import org.eclipse.ui.PlatformUI;
027:
028: /**
029: * CheatSheetFileWizardPage
030: *
031: */
032: public class CSFileWizardPage extends PDEWizardNewFileCreationPage {
033:
034: private Button fSimpleCheatSheetButton;
035:
036: private Button fCompositeCheatSheetButton;
037:
038: private Group fGroup;
039:
040: protected static final String F_FILE_EXTENSION = "xml"; //$NON-NLS-1$
041:
042: public static final int F_SIMPLE_CHEAT_SHEET = 0;
043:
044: public static final int F_COMPOSITE_CHEAT_SHEET = 1;
045:
046: /**
047: * @param pageName
048: * @param selection
049: */
050: public CSFileWizardPage(String pageName,
051: IStructuredSelection selection) {
052: super (pageName, selection);
053:
054: initialize();
055: }
056:
057: /**
058: *
059: */
060: protected void initialize() {
061: setTitle(PDEUIMessages.CheatSheetFileWizardPage_1);
062: setDescription(PDEUIMessages.CheatSheetFileWizardPage_2);
063: // Force the file extension to be 'xml'
064: setFileExtension(F_FILE_EXTENSION);
065: }
066:
067: /**
068: * @return
069: */
070: public int getCheatSheetType() {
071: if (fSimpleCheatSheetButton.getSelection()) {
072: return F_SIMPLE_CHEAT_SHEET;
073: } else if (fCompositeCheatSheetButton.getSelection()) {
074: return F_COMPOSITE_CHEAT_SHEET;
075: }
076: // Neither selected. Unknown type
077: return -1;
078: }
079:
080: /* (non-Javadoc)
081: * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createAdvancedControls(org.eclipse.swt.widgets.Composite)
082: */
083: protected void createAdvancedControls(Composite parent) {
084:
085: GridData data = null;
086:
087: // Cheat Sheet Group
088: fGroup = new Group(parent, SWT.NONE);
089: fGroup.setText(PDEUIMessages.CheatSheetFileWizardPage_4);
090: fGroup.setLayout(new GridLayout(1, false));
091: fGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
092:
093: // Simple Cheat Sheet Button
094: fSimpleCheatSheetButton = new Button(fGroup, SWT.RADIO);
095: fSimpleCheatSheetButton
096: .setText(PDEUIMessages.CheatSheetFileWizardPage_5);
097: fSimpleCheatSheetButton.setSelection(true);
098: fSimpleCheatSheetButton
099: .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
122: .addSelectionListener(new SelectionAdapter() {
123: public void widgetSelected(SelectionEvent e) {
124: getWizard().getContainer().updateButtons();
125: }
126: });
127:
128: // Composite Cheat Sheet Description Label
129: final Label compositeCSLabel = new Label(fGroup, SWT.WRAP);
130: compositeCSLabel
131: .setText(PDEUIMessages.CheatSheetFileWizardPage_8);
132: data = new GridData(GridData.FILL_HORIZONTAL);
133: data.widthHint = 300;
134: data.horizontalIndent = 20;
135: compositeCSLabel.setLayoutData(data);
136:
137: }
138:
139: /* (non-Javadoc)
140: * @see org.eclipse.ui.dialogs.WizardNewFileCreationPage#createControl(org.eclipse.swt.widgets.Composite)
141: */
142: public void createControl(Composite parent) {
143: super.createControl(parent);
144: Dialog.applyDialogFont(fGroup);
145:
146: PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(),
147: IHelpContextIds.CHEAT_SHEET_PAGE);
148: }
149:
150: }
|