Fix #1371992: Error with switch when last case block omits break or return
[phpeclipse.git] / net.sourceforge.phpeclipse.webbrowser / src / net / sourceforge / phpeclipse / webbrowser / internal / InternalBrowserDialog.java
1 /**********************************************************************
2  * Copyright (c) 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *    IBM - Initial API and implementation
10  **********************************************************************/
11 package net.sourceforge.phpeclipse.webbrowser.internal;
12
13 import net.sourceforge.phpeclipse.webbrowser.IInternalWebBrowserWorkingCopy;
14
15 import org.eclipse.jface.dialogs.Dialog;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.layout.GridData;
18 import org.eclipse.swt.layout.GridLayout;
19 import org.eclipse.swt.widgets.Button;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.swt.widgets.Control;
22 import org.eclipse.swt.widgets.Shell;
23 import org.eclipse.ui.help.WorkbenchHelp;
24 /**
25  * 
26  */
27 public class InternalBrowserDialog extends Dialog {
28         protected IInternalWebBrowserWorkingCopy browser;
29         protected boolean isEdit;
30         protected Button newPageCheckbox;
31         protected Button clearURLHistoryCheckbox;
32         
33         /**
34          * @param parentShell
35          */
36         public InternalBrowserDialog(Shell parentShell, IInternalWebBrowserWorkingCopy browser) {
37                 super(parentShell);
38                 this.browser = browser;
39                 isEdit = true;
40         }
41
42         protected void configureShell(Shell shell) {
43                 super.configureShell(shell);
44                 
45                 if (isEdit)
46                         shell.setText(WebBrowserUIPlugin.getResource("%editInternalBrowser"));
47         }
48
49         /* (non-Javadoc)
50          * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
51          */
52         protected Control createDialogArea(Composite parent) {
53                 Composite composite = (Composite) super.createDialogArea(parent);
54                 ((GridLayout)composite.getLayout()).numColumns = 1;
55                 
56                 Composite comp = new Composite(composite, SWT.NONE);
57                 GridLayout layout = new GridLayout(1, true);
58                 layout.marginHeight = 10;
59                 layout.marginWidth = 10;
60                 comp.setLayout(layout);
61                 comp.setLayoutData(new GridData(GridData.FILL_BOTH));
62                 WorkbenchHelp.setHelp(composite, ContextIds.PREF_BROWSER_INTERNAL);
63                 
64                 newPageCheckbox = SWTUtil.createCheckbox(comp, WebBrowserUIPlugin.getResource("%prefBrowserNewPage"), false);
65                 clearURLHistoryCheckbox = SWTUtil.createCheckbox(comp, WebBrowserUIPlugin.getResource("%clearURLHistory"), true);
66                 
67                 newPageCheckbox.setSelection(browser.getUseNewPage());
68                 clearURLHistoryCheckbox.setSelection(browser.getClearHistoryOnExit());
69                 
70                 return composite;
71         }
72
73         /* (non-Javadoc)
74          * @see org.eclipse.jface.dialogs.Dialog#okPressed()
75          */
76         protected void okPressed() {
77                 browser.setUseNewPage(newPageCheckbox.getSelection());
78                 browser.setClearHistoryOnExit(clearURLHistoryCheckbox.getSelection());
79                 browser.save();
80                 
81                 super.okPressed();
82         }
83 }