initial version
[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 import net.sourceforge.phpeclipse.webbrowser.internal.SWTUtil;
15
16 import org.eclipse.jface.dialogs.Dialog;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.layout.GridData;
19 import org.eclipse.swt.layout.GridLayout;
20 import org.eclipse.swt.widgets.Button;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.swt.widgets.Control;
23 import org.eclipse.swt.widgets.Shell;
24 import org.eclipse.ui.help.WorkbenchHelp;
25 /**
26  * 
27  */
28 public class InternalBrowserDialog extends Dialog {
29         protected IInternalWebBrowserWorkingCopy browser;
30         protected boolean isEdit;
31         protected Button newPageCheckbox;
32         protected Button clearURLHistoryCheckbox;
33         
34         /**
35          * @param parentShell
36          */
37         public InternalBrowserDialog(Shell parentShell, IInternalWebBrowserWorkingCopy browser) {
38                 super(parentShell);
39                 this.browser = browser;
40                 isEdit = true;
41         }
42
43         protected void configureShell(Shell shell) {
44                 super.configureShell(shell);
45                 
46                 if (isEdit)
47                         shell.setText(WebBrowserUIPlugin.getResource("%editInternalBrowser"));
48         }
49
50         /* (non-Javadoc)
51          * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
52          */
53         protected Control createDialogArea(Composite parent) {
54                 Composite composite = (Composite) super.createDialogArea(parent);
55                 ((GridLayout)composite.getLayout()).numColumns = 1;
56                 
57                 Composite comp = new Composite(composite, SWT.NONE);
58                 GridLayout layout = new GridLayout(1, true);
59                 layout.marginHeight = 10;
60                 layout.marginWidth = 10;
61                 comp.setLayout(layout);
62                 comp.setLayoutData(new GridData(GridData.FILL_BOTH));
63                 WorkbenchHelp.setHelp(composite, ContextIds.PREF_BROWSER_INTERNAL);
64                 
65                 newPageCheckbox = SWTUtil.createCheckbox(comp, WebBrowserUIPlugin.getResource("%prefBrowserNewPage"), false);
66                 clearURLHistoryCheckbox = SWTUtil.createCheckbox(comp, WebBrowserUIPlugin.getResource("%clearURLHistory"), true);
67                 
68                 newPageCheckbox.setSelection(browser.getUseNewPage());
69                 clearURLHistoryCheckbox.setSelection(browser.getClearHistoryOnExit());
70                 
71                 return composite;
72         }
73
74         /* (non-Javadoc)
75          * @see org.eclipse.jface.dialogs.Dialog#okPressed()
76          */
77         protected void okPressed() {
78                 browser.setUseNewPage(newPageCheckbox.getSelection());
79                 browser.setClearHistoryOnExit(clearURLHistoryCheckbox.getSelection());
80                 browser.save();
81                 
82                 super.okPressed();
83         }
84 }