1 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 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 F_FILE_EXTENSION = "xml"; 44 public static final int F_SIMPLE_CHEAT_SHEET = 0; 45 46 public static final int F_COMPOSITE_CHEAT_SHEET = 1; 47 48 52 public CSFileWizardPage(String pageName, 53 IStructuredSelection selection) { 54 super(pageName, selection); 55 56 initialize(); 57 } 58 59 62 protected void initialize() { 63 setTitle(PDEUIMessages.CheatSheetFileWizardPage_1); 64 setDescription(PDEUIMessages.CheatSheetFileWizardPage_2); 65 setFileExtension(F_FILE_EXTENSION); 67 } 68 69 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 return -1; 80 } 81 82 85 protected void createAdvancedControls(Composite parent) { 86 87 GridData data = null; 88 89 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 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 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 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 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 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 |