inital plugin from webtools project
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.monitor.ui / src / net / sourceforge / phpdt / monitor / ui / internal / MonitorPrefrencesDialog.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.phpdt.monitor.ui.internal;
12
13 import net.sourceforge.phpdt.monitor.core.IMonitorWorkingCopy;
14
15 import org.eclipse.jface.dialogs.Dialog;
16 import org.eclipse.jface.dialogs.IDialogConstants;
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.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 MonitorPrefrencesDialog extends Dialog {
28         protected IMonitorWorkingCopy monitor;
29         protected boolean isEdit;
30
31         /**
32          * @param parentShell
33          */
34         public MonitorPrefrencesDialog(Shell parentShell, IMonitorWorkingCopy monitor) {
35                 super(parentShell);
36                 this.monitor = monitor;
37                 isEdit = true;
38         }
39         
40         public MonitorPrefrencesDialog(Shell composite) {
41                 super(composite);
42                 isEdit=false;
43         }
44         
45         protected void configureShell(Shell shell) {
46                 super.configureShell(shell);
47                 shell.setText(MonitorUIPlugin.getResource("%preferenceTitle"));
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 compositeParent = (Composite) super.createDialogArea(parent);
55                 
56                 Composite composite = new Composite(compositeParent, SWT.NONE);
57                 GridLayout layout = new GridLayout();
58                 layout.marginHeight = convertHorizontalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
59                 layout.marginWidth = convertVerticalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
60                 layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
61                 composite.setLayout(layout);
62                 GridData data = new GridData(GridData.FILL_BOTH);
63                 composite.setLayoutData(data);
64                 WorkbenchHelp.setHelp(composite, ContextIds.PREF);
65                 
66                 MonitorComposite monitorComp = new MonitorComposite(composite, SWT.NONE);
67                 data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
68                 monitorComp.setLayoutData(data);
69                 
70                 Dialog.applyDialogFont(composite);
71                 
72                 return composite;
73         }
74
75         /* (non-Javadoc)
76          * @see org.eclipse.jface.dialogs.Dialog#okPressed()
77          */
78         protected void okPressed() {
79                 MonitorUIPlugin.getInstance().savePluginPreferences();  
80                 super.okPressed();
81         }
82 }