1 11 12 package org.eclipse.ui.internal.layout; 13 14 import org.eclipse.jface.dialogs.Dialog; 15 import org.eclipse.swt.SWT; 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.Text; 24 import org.eclipse.ui.internal.TrimDragPreferences; 25 26 37 public class TrimDragPreferenceDialog extends Dialog { 38 39 private Text thresholdValue; 40 private Button raggedTrimButton; 41 42 45 public TrimDragPreferenceDialog(Shell parentShell) { 46 super(parentShell); 47 } 48 49 52 protected Control createDialogArea(Composite parent) { 53 Composite composite = new Composite(parent, SWT.NONE); 54 composite.setLayout(new GridLayout(2, false)); 55 56 Label disclaimer = new Label(composite, SWT.BORDER | SWT.WRAP); 57 disclaimer.setText("NOTE: This dialog is for testing purposes -only- and "+ " will be removed from the code before release."); disclaimer.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_RED)); 60 61 new Label(composite, SWT.NONE); 63 new Label(composite, SWT.NONE); 64 65 GridData dgd = new GridData(); 66 dgd.grabExcessHorizontalSpace = true; 67 dgd.horizontalSpan = 2; 68 dgd.minimumWidth = 50; 69 disclaimer.setLayoutData(dgd); 70 71 Label tLabel = new Label(composite, SWT.NONE); 73 tLabel.setText("Drag Threshold"); 75 thresholdValue = new Text(composite, SWT.SINGLE | SWT.BORDER); 76 thresholdValue.setText(Integer.toString(TrimDragPreferences.getThreshold())); 77 thresholdValue.setToolTipText("The minimum distance to snap to"); 79 GridData tgd = new GridData(); 80 tgd.grabExcessHorizontalSpace = true; 81 tgd.minimumWidth = 50; 82 thresholdValue.setLayoutData(tgd); 83 84 raggedTrimButton = new Button(composite, SWT.CHECK); 86 raggedTrimButton.setText("Ragged Trim"); raggedTrimButton.setSelection(TrimDragPreferences.showRaggedTrim()); 88 raggedTrimButton.setToolTipText("Allows trim in the same area to have different heights if checked"); 90 GridData rgd = new GridData(); 91 rgd.horizontalSpan = 2; 92 raggedTrimButton.setLayoutData(rgd); 93 94 return composite; 95 } 96 97 100 protected void okPressed() { 101 try { 103 TrimDragPreferences.setThreshold(Integer.parseInt(thresholdValue.getText())); 104 } catch (NumberFormatException e) { 105 } 107 108 boolean val = raggedTrimButton.getSelection(); 110 TrimDragPreferences.setRaggedTrim(val); 111 112 super.okPressed(); 113 } 114 115 } 116 | Popular Tags |