1 11 package org.eclipse.jdt.internal.ui.javadocexport; 12 13 import java.io.File ; 14 15 import org.eclipse.core.runtime.IPath; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Path; 18 19 import org.eclipse.swt.SWT; 20 import org.eclipse.swt.events.ModifyEvent; 21 import org.eclipse.swt.events.ModifyListener; 22 import org.eclipse.swt.events.SelectionAdapter; 23 import org.eclipse.swt.events.SelectionEvent; 24 import org.eclipse.swt.layout.GridData; 25 import org.eclipse.swt.layout.GridLayout; 26 import org.eclipse.swt.widgets.Button; 27 import org.eclipse.swt.widgets.Combo; 28 import org.eclipse.swt.widgets.Composite; 29 import org.eclipse.swt.widgets.Control; 30 import org.eclipse.swt.widgets.Text; 31 32 import org.eclipse.jface.dialogs.Dialog; 33 34 import org.eclipse.ui.PlatformUI; 35 36 import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; 37 import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; 38 import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; 39 import org.eclipse.jdt.internal.ui.util.SWTUtil; 40 41 public class JavadocSpecificsWizardPage extends JavadocWizardPage { 42 43 private Button fAntBrowseButton; 44 private Button fCheckbrowser; 45 private Text fAntText; 46 private Button fOverViewButton; 47 private Button fOverViewBrowseButton; 48 private Button fAntButton; 49 private Combo fSourceCombo; 50 51 private Composite fLowerComposite; 52 private Text fOverViewText; 53 private Text fExtraOptionsText; 54 private Text fVMOptionsText; 55 56 private StatusInfo fOverviewStatus; 57 private StatusInfo fAntStatus; 58 59 private JavadocTreeWizardPage fFirstPage; 60 61 private JavadocOptionsManager fStore; 62 63 private final int OVERVIEWSTATUS= 1; 64 private final int ANTSTATUS= 2; 65 66 protected JavadocSpecificsWizardPage(String pageName, JavadocTreeWizardPage firstPage, JavadocOptionsManager store) { 67 super(pageName); 68 setDescription(JavadocExportMessages.JavadocSpecificsWizardPage_description); 69 70 fStore= store; 71 72 fOverviewStatus= new StatusInfo(); 73 fAntStatus= new StatusInfo(); 74 fFirstPage= firstPage; 75 } 76 77 80 public void createControl(Composite parent) { 81 initializeDialogUnits(parent); 82 83 fLowerComposite= new Composite(parent, SWT.NONE); 84 fLowerComposite.setLayoutData(createGridData(GridData.FILL_BOTH, 1, 0)); 85 86 GridLayout layout= createGridLayout(3); 87 layout.marginHeight= 0; 88 fLowerComposite.setLayout(layout); 89 90 createExtraOptionsGroup(fLowerComposite); 91 createAntGroup(fLowerComposite); 92 93 setControl(fLowerComposite); 94 Dialog.applyDialogFont(fLowerComposite); 95 PlatformUI.getWorkbench().getHelpSystem().setHelp(fLowerComposite, IJavaHelpContextIds.JAVADOC_SPECIFICS_PAGE); 96 97 } 99 private void createExtraOptionsGroup(Composite composite) { 100 Composite c= new Composite(composite, SWT.NONE); 101 c.setLayout(createGridLayout(3)); 102 c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 3, 0)); 103 ((GridLayout) c.getLayout()).marginWidth= 0; 104 105 fOverViewButton= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbutton_label, createGridData(1)); 106 fOverViewText= createText(c, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 1, 0)); 107 ((GridData) fOverViewText.getLayoutData()).widthHint= 200; 109 fOverViewBrowseButton= createButton(c, SWT.PUSH, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbrowse_label, createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 0)); 110 SWTUtil.setButtonDimensionHint(fOverViewBrowseButton); 111 112 String str= fStore.getOverview(); 113 if (str.length() == 0) { 114 fOverViewText.setEnabled(false); 116 fOverViewBrowseButton.setEnabled(false); 117 } else { 118 fOverViewButton.setSelection(true); 119 fOverViewText.setText(str); 120 } 121 122 createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_vmoptionsfield_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 3, 0)); 123 fVMOptionsText= createText(composite, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.HORIZONTAL_ALIGN_FILL, 3, 0)); 124 fVMOptionsText.setText(fStore.getVMParams()); 125 126 127 createLabel(composite, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_extraoptionsfield_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 3, 0)); 128 fExtraOptionsText= createText(composite, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL, null, createGridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL, 3, 0)); 129 131 fExtraOptionsText.setText(fStore.getAdditionalParams()); 132 133 Composite inner= new Composite(composite, SWT.NONE); 134 inner.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, false, false, 3, 1)); 135 GridLayout layout= new GridLayout(2, false); 136 layout.marginHeight= 0; 137 layout.marginWidth= 0; 138 inner.setLayout(layout); 139 140 createLabel(inner, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_sourcecompatibility_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 0)); 141 142 fSourceCombo= createCombo(inner, SWT.NONE, fStore.getSource(), createGridData(1)); 143 String [] versions= { "-", "1.3", "1.4", "1.5", "1.6" }; fSourceCombo.setItems(versions); 145 fSourceCombo.setText(fStore.getSource()); 146 147 148 fOverViewButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fOverViewBrowseButton, fOverViewText }) { 150 public void validate() { 151 doValidation(OVERVIEWSTATUS); 152 } 153 }); 154 155 fOverViewText.addModifyListener(new ModifyListener() { 156 public void modifyText(ModifyEvent e) { 157 doValidation(OVERVIEWSTATUS); 158 } 159 }); 160 161 fOverViewBrowseButton.addSelectionListener(new SelectionAdapter() { 162 public void widgetSelected(SelectionEvent event) { 163 handleFileBrowseButtonPressed(fOverViewText, new String [] { "*.html" }, JavadocExportMessages.JavadocSpecificsWizardPage_overviewbrowsedialog_title); } 165 }); 166 167 } 168 169 private void createAntGroup(Composite composite) { 170 Composite c= new Composite(composite, SWT.NONE); 171 c.setLayout(createGridLayout(3)); 172 c.setLayoutData(createGridData(GridData.FILL_HORIZONTAL, 3, 0)); 173 ((GridLayout) c.getLayout()).marginWidth= 0; 174 175 fAntButton= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocSpecificsWizardPage_antscriptbutton_label, createGridData(3)); 176 createLabel(c, SWT.NONE, JavadocExportMessages.JavadocSpecificsWizardPage_antscripttext_label, createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 0)); 177 fAntText= createText(c, SWT.SINGLE | SWT.BORDER, null, createGridData(GridData.FILL_HORIZONTAL, 1, 0)); 178 ((GridData) fAntText.getLayoutData()).widthHint= 200; 180 181 fAntText.setText(fStore.getAntpath()); 182 183 fAntBrowseButton= createButton(c, SWT.PUSH, JavadocExportMessages.JavadocSpecificsWizardPage_antscriptbrowse_label, createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 0)); 184 SWTUtil.setButtonDimensionHint(fAntBrowseButton); 185 fAntText.setEnabled(false); 186 fAntBrowseButton.setEnabled(false); 187 188 fCheckbrowser= createButton(c, SWT.CHECK, JavadocExportMessages.JavadocSpecificsWizardPage_openbrowserbutton_label, createGridData(3)); 189 fCheckbrowser.setSelection(fStore.doOpenInBrowser()); 190 191 fAntButton.addSelectionListener(new ToggleSelectionAdapter(new Control[] { fAntText, fAntBrowseButton }) { 192 public void validate() { 193 doValidation(ANTSTATUS); 194 } 195 }); 196 197 fAntText.addModifyListener(new ModifyListener() { 198 public void modifyText(ModifyEvent e) { 199 doValidation(ANTSTATUS); 200 } 201 }); 202 203 fAntBrowseButton.addSelectionListener(new SelectionAdapter() { 204 public void widgetSelected(SelectionEvent event) { 205 String temp= fAntText.getText(); 206 IPath path= Path.fromOSString(temp); 207 String file= path.lastSegment(); 208 if (file == null) 209 file= "javadoc.xml"; path= path.removeLastSegments(1); 211 212 String selected= handleFolderBrowseButtonPressed(path.toOSString(), JavadocExportMessages.JavadocSpecificsWizardPage_antscriptbrowsedialog_title, JavadocExportMessages.JavadocSpecificsWizardPage_antscriptbrowsedialog_label); 213 214 path= Path.fromOSString(selected).append(file); 215 fAntText.setText(path.toOSString()); 216 217 } 218 }); 219 } 221 private void doValidation(int val) { 222 switch (val) { 223 224 case OVERVIEWSTATUS : 225 fOverviewStatus= new StatusInfo(); 226 if (fOverViewButton.getSelection()) { 227 String filename= fOverViewText.getText(); 228 if (filename.length() == 0) { 229 fOverviewStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error); 230 } else { 231 File file= new File (filename); 232 String ext= filename.substring(filename.lastIndexOf('.') + 1); 233 if (!file.isFile()) { 234 fOverviewStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewnotfound_error); 235 } else if (!ext.equalsIgnoreCase("html")) { fOverviewStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_overviewincorrect_error); 237 } 238 } 239 } 240 break; 241 case ANTSTATUS : 242 fAntStatus= new StatusInfo(); 243 if (fAntButton.getSelection()) { 244 String filename= fAntText.getText(); 245 if (filename.length() == 0) { 246 fOverviewStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_antfileincorrect_error); 247 } else { 248 File file= new File (filename); 249 String ext= filename.substring(filename.lastIndexOf('.') + 1); 250 if (file.isDirectory() || !(ext.equalsIgnoreCase("xml"))) fAntStatus.setError(JavadocExportMessages.JavadocSpecificsWizardPage_antfileincorrect_error); 252 else if (file.exists()) 253 fAntStatus.setWarning(JavadocExportMessages.JavadocSpecificsWizardPage_antfileoverwrite_warning); 254 } 255 } 256 break; 257 } 258 259 updateStatus(findMostSevereStatus()); 260 261 } 262 263 266 267 protected void updateStore() { 268 269 fStore.setVMParams(fVMOptionsText.getText()); 270 fStore.setAdditionalParams(fExtraOptionsText.getText()); 271 272 if (fOverViewText.getEnabled()) 273 fStore.setOverview(fOverViewText.getText()); 274 else 275 fStore.setOverview(""); 277 if (fAntText.getEnabled()) { 279 fStore.setGeneralAntpath(fAntText.getText()); 280 } 281 fStore.setOpenInBrowser(fCheckbrowser.getSelection()); 282 fStore.setSource(fSourceCombo.getText()); 283 284 } 285 286 public void setVisible(boolean visible) { 287 super.setVisible(visible); 288 if (visible) { 289 doValidation(OVERVIEWSTATUS); 290 doValidation(ANTSTATUS); 291 fCheckbrowser.setVisible(!fFirstPage.getCustom()); 292 } 293 } 294 295 public void init() { 296 updateStatus(new StatusInfo()); 297 } 298 299 private IStatus findMostSevereStatus() { 300 return StatusUtil.getMostSevere(new IStatus[] { fAntStatus, fOverviewStatus }); 301 } 302 303 public boolean generateAnt() { 304 return fAntButton.getSelection(); 305 } 306 307 } 308 | Popular Tags |