2 package net.sourceforge.phpdt.internal.debug.ui.properties;
4 import org.eclipse.core.runtime.CoreException;
5 import org.eclipse.debug.internal.ui.actions.*;
6 import org.eclipse.jface.dialogs.StatusDialog;
7 import org.eclipse.jface.resource.JFaceResources;
8 import org.eclipse.jface.text.Document;
9 import org.eclipse.jface.text.DocumentEvent;
10 import org.eclipse.jface.text.IDocument;
11 import org.eclipse.jface.text.IDocumentListener;
12 import org.eclipse.jface.text.source.SourceViewer;
13 import org.eclipse.jface.text.source.SourceViewerConfiguration;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.graphics.Font;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.Button;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.swt.widgets.Label;
22 import org.eclipse.swt.widgets.Shell;
23 import org.eclipse.swt.widgets.Spinner;
25 import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint;
27 public class PHPBreakpointPropertiesDialog extends StatusDialog {
29 private PHPLineBreakpoint fBreakpoint;
30 private SourceViewer fSnippetViewer;
31 private Button fCheckBox;
32 private Spinner fSpinner;
34 public PHPBreakpointPropertiesDialog(Shell parentShell, PHPLineBreakpoint bp) {
41 protected Control createDialogArea (Composite parent) {
49 String condition = "";
50 boolean enabled = false;
54 condition = fBreakpoint.getCondition ();
55 enabled = fBreakpoint.isConditionEnabled ();
56 hitCount = fBreakpoint.getHitCount();
58 catch (CoreException e) {
61 Font font = parent.getFont(); // Get the dialog's font
62 container = new Composite(parent, SWT.NONE); // Create a new container for our controls
63 layout = new GridLayout(); // Create a grid for control layouting
65 container.setLayout (layout); // Set the grid to the container
66 gd = new GridData (SWT.FILL, SWT.FILL, true, true);
67 container.setLayoutData (gd);
69 label = new Label (container, SWT.NONE); // spinner label
70 label.setText ("Skip count"); // $NON-NLS-1$
72 gd = new GridData (SWT.BEGINNING); // Left align of label text
73 label.setLayoutData (gd); //
74 label.setFont (font); // Set the label's font
76 fSpinner = new Spinner (container, SWT.BORDER);
77 fSpinner.setMinimum (0);
78 fSpinner.setMaximum (100000);
79 fSpinner.setIncrement (1);
80 fSpinner.setPageIncrement (100);
81 fSpinner.setSelection (hitCount);
82 gd = new GridData (SWT.BEGINNING);
83 label.setLayoutData (gd); //
84 label.setFont (font); // Set the label's font
86 label = new Label (container, SWT.NONE); // snippet label
87 label.setText ("Break Condition"); // $NON-NLS-1$
89 gd = new GridData (SWT.BEGINNING); // Left align of label text
90 label.setLayoutData (gd); //
91 label.setFont (font); // Set the label's font
93 fSnippetViewer = new SourceViewer (container, null, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
94 fSnippetViewer.setInput (this);
96 document = new Document();
98 //IDocumentPartitioner partitioner= new RuleBasedPartitioner(...);
99 //document.setDocumentPartitioner(partitioner);
100 //partitioner.connect(document);
102 fSnippetViewer.configure (new SourceViewerConfiguration());
103 fSnippetViewer.setEditable (true);
104 fSnippetViewer.setDocument (document);
106 document.addDocumentListener (new IDocumentListener() {
107 public void documentAboutToBeChanged(DocumentEvent event) {
109 public void documentChanged(DocumentEvent event) {
114 fSnippetViewer.getTextWidget ().setFont (JFaceResources.getTextFont());
116 control = fSnippetViewer.getControl ();
117 gd = new GridData (GridData.FILL_BOTH);
118 gd.heightHint = convertHeightInCharsToPixels (10);
119 gd.widthHint = convertWidthInCharsToPixels (80);
121 control.setLayoutData (gd);
122 fSnippetViewer.getDocument ().set (condition);
125 fCheckBox = new Button (container, SWT.CHECK | SWT.LEFT);
126 fCheckBox.setText ("Enable Condition"); //$NON-NLS-1$
127 fCheckBox.setSelection (enabled);
128 fCheckBox.setFont (font);
130 applyDialogFont(container);
131 fSnippetViewer.getControl().setFocus();
138 protected void okPressed () {
140 fBreakpoint.setCondition (fSnippetViewer.getDocument().get());
141 fBreakpoint.setConditionEnabled (fCheckBox.getSelection());
142 fBreakpoint.setHitCount(fSpinner.getSelection());
144 int id = fBreakpoint.getChangeID();
146 fBreakpoint.setChangeID(id);
148 catch (CoreException e) {
155 * Check the field values and display a message in the status if needed.
157 private void checkValues() {
160 status = new StatusInfo ();
162 StatusInfo status = new StatusInfo();
163 if (fSnippetViewer.getDocument().get().trim().length() == 0) {
164 status.setError(ActionMessages.WatchExpressionDialog_4); //$NON-NLS-1$
167 updateStatus(status);