1 package net.sourceforge.phpdt.internal.debug.ui.properties;
3 import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint;
5 import org.eclipse.core.runtime.CoreException;
6 import org.eclipse.debug.internal.ui.actions.StatusInfo;
7 import org.eclipse.jface.dialogs.StatusDialog;
8 import org.eclipse.jface.resource.JFaceResources;
9 import org.eclipse.jface.text.Document;
10 import org.eclipse.jface.text.DocumentEvent;
11 import org.eclipse.jface.text.IDocument;
12 import org.eclipse.jface.text.IDocumentListener;
13 import org.eclipse.jface.text.source.SourceViewer;
14 import org.eclipse.jface.text.source.SourceViewerConfiguration;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.graphics.Font;
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.Label;
23 import org.eclipse.swt.widgets.Shell;
24 import org.eclipse.swt.widgets.Spinner;
26 public class PHPBreakpointPropertiesDialog extends StatusDialog {
28 private PHPLineBreakpoint fBreakpoint;
30 private SourceViewer fSnippetViewer;
32 private Button fCheckBox;
34 private Spinner fSpinner;
36 public PHPBreakpointPropertiesDialog(Shell parentShell, PHPLineBreakpoint bp) {
42 protected Control createDialogArea(Composite parent) {
50 String condition = "";
51 boolean enabled = false;
55 condition = fBreakpoint.getCondition();
56 enabled = fBreakpoint.isConditionEnabled();
57 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
65 layout = new GridLayout(); // Create a grid for control layouting
67 container.setLayout(layout); // Set the grid to the container
68 gd = new GridData(SWT.FILL, SWT.FILL, true, true);
69 container.setLayoutData(gd);
71 label = new Label(container, SWT.NONE); // spinner label
72 label.setText("Skip count"); // $NON-NLS-1$
74 gd = new GridData(SWT.BEGINNING); // Left align of label text
75 label.setLayoutData(gd); //
76 label.setFont(font); // Set the label's font
78 fSpinner = new Spinner(container, SWT.BORDER);
79 fSpinner.setMinimum(0);
80 fSpinner.setMaximum(100000);
81 fSpinner.setIncrement(1);
82 fSpinner.setPageIncrement(100);
83 fSpinner.setSelection(hitCount);
84 gd = new GridData(SWT.BEGINNING);
85 label.setLayoutData(gd); //
86 label.setFont(font); // Set the label's font
88 label = new Label(container, SWT.NONE); // snippet label
89 label.setText("Break Condition"); // $NON-NLS-1$
91 gd = new GridData(SWT.BEGINNING); // Left align of label text
92 label.setLayoutData(gd); //
93 label.setFont(font); // Set the label's font
95 fSnippetViewer = new SourceViewer(container, null, SWT.BORDER
96 | SWT.V_SCROLL | SWT.H_SCROLL);
97 fSnippetViewer.setInput(this);
99 document = new Document();
101 // IDocumentPartitioner partitioner= new RuleBasedPartitioner(...);
102 // document.setDocumentPartitioner(partitioner);
103 // partitioner.connect(document);
105 fSnippetViewer.configure(new SourceViewerConfiguration());
106 fSnippetViewer.setEditable(true);
107 fSnippetViewer.setDocument(document);
109 document.addDocumentListener(new IDocumentListener() {
110 public void documentAboutToBeChanged(DocumentEvent event) {
113 public void documentChanged(DocumentEvent event) {
118 fSnippetViewer.getTextWidget().setFont(JFaceResources.getTextFont());
120 control = fSnippetViewer.getControl();
121 gd = new GridData(GridData.FILL_BOTH);
122 gd.heightHint = convertHeightInCharsToPixels(10);
123 gd.widthHint = convertWidthInCharsToPixels(80);
125 control.setLayoutData(gd);
126 fSnippetViewer.getDocument().set(condition);
129 fCheckBox = new Button(container, SWT.CHECK | SWT.LEFT);
130 fCheckBox.setText("Enable Condition"); //$NON-NLS-1$
131 fCheckBox.setSelection(enabled);
132 fCheckBox.setFont(font);
134 applyDialogFont(container);
135 fSnippetViewer.getControl().setFocus();
142 protected void okPressed() {
144 fBreakpoint.setCondition(fSnippetViewer.getDocument().get());
145 fBreakpoint.setConditionEnabled(fCheckBox.getSelection());
146 fBreakpoint.setHitCount(fSpinner.getSelection());
148 int id = fBreakpoint.getChangeID();
150 fBreakpoint.setChangeID(id);
151 } catch (CoreException e) {
158 * Check the field values and display a message in the status if needed.
160 private void checkValues() {
163 status = new StatusInfo();
165 * StatusInfo status = new StatusInfo(); if
166 * (fSnippetViewer.getDocument().get().trim().length() == 0) {
167 * status.setError(ActionMessages.WatchExpressionDialog_4);
170 updateStatus(status);