KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > variables > MaxDetailsLengthDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.views.variables;
12
13 import org.eclipse.debug.internal.ui.DebugUIPlugin;
14 import org.eclipse.debug.ui.IDebugUIConstants;
15 import org.eclipse.jface.dialogs.IInputValidator;
16 import org.eclipse.jface.dialogs.InputDialog;
17 import org.eclipse.swt.widgets.Shell;
18
19 public class MaxDetailsLengthDialog extends InputDialog {
20
21     /**
22      * Cosntructs a new dialog on the given shell.
23      *
24      * @param parent shell
25      */

26     public MaxDetailsLengthDialog(Shell parent) {
27         super(parent, VariablesViewMessages.MaxDetailsLengthDialog_0, VariablesViewMessages.MaxDetailsLengthDialog_1,
28                 Integer.toString(DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH)),
29                 new IInputValidator() {
30                     public String JavaDoc isValid(String JavaDoc newText) {
31                         try {
32                             int num = Integer.parseInt(newText);
33                             if (num < 0) {
34                                 return VariablesViewMessages.MaxDetailsLengthDialog_2;
35                             }
36                         } catch (NumberFormatException JavaDoc e) {
37                             return VariablesViewMessages.MaxDetailsLengthDialog_3;
38                         }
39                         return null;
40                     }
41                 
42                 });
43     }
44
45     /* (non-Javadoc)
46      * @see org.eclipse.jface.dialogs.Dialog#okPressed()
47      */

48     protected void okPressed() {
49         String JavaDoc text = getValue();
50         try {
51             int max = Integer.parseInt(text);
52             DebugUIPlugin.getDefault().getPreferenceStore().setValue(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH, max);
53         } catch (NumberFormatException JavaDoc e) {
54         }
55         super.okPressed();
56     }
57     
58     
59
60 }
61
Popular Tags