KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > views > memory > renderings > SetPaddedStringDialog


1 /*******************************************************************************
2  * Copyright (c) 2004, 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
12 package org.eclipse.debug.internal.ui.views.memory.renderings;
13
14 import org.eclipse.debug.internal.ui.DebugUIMessages;
15 import org.eclipse.debug.internal.ui.DebugUIPlugin;
16 import org.eclipse.debug.internal.ui.views.memory.MemoryViewUtil;
17 import org.eclipse.debug.ui.IDebugUIConstants;
18 import org.eclipse.jface.dialogs.Dialog;
19 import org.eclipse.jface.preference.StringFieldEditor;
20 import org.eclipse.swt.SWT;
21 import org.eclipse.swt.layout.GridData;
22 import org.eclipse.swt.layout.GridLayout;
23 import org.eclipse.swt.widgets.Composite;
24 import org.eclipse.swt.widgets.Control;
25 import org.eclipse.swt.widgets.Label;
26 import org.eclipse.swt.widgets.Shell;
27 import org.eclipse.ui.PlatformUI;
28
29 /**
30  * Dialog for setting the padded string in renderings.
31  * @since 3.1
32  *
33  */

34 public class SetPaddedStringDialog extends Dialog {
35     
36     private StringFieldEditor fPaddedString;
37
38     
39     protected SetPaddedStringDialog(Shell parentShell) {
40         super(parentShell);
41         setShellStyle(getShellStyle() | SWT.RESIZE);
42     }
43
44     protected Control createDialogArea(Composite parent) {
45         PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".SetPaddedStrDialog_context"); //$NON-NLS-1$
46

47         getShell().setText(DebugUIMessages.SetPaddedStringDialog_0); //$NON-NLS-1$
48

49         Composite content = (Composite) super.createDialogArea(parent);
50         GridLayout layout = new GridLayout();
51         layout.numColumns = 1;
52         content.setLayout(layout);
53         
54         GridData contentData = new GridData(SWT.FILL);
55         content.setLayoutData(contentData);
56         
57         Label textLabel = new Label(content, SWT.NONE);
58         textLabel.setText(DebugUIMessages.SetPaddedStringDialog_1); //$NON-NLS-1$
59

60         GridData textLayout = new GridData();
61         textLabel.setLayoutData(textLayout);
62         
63         fPaddedString = new StringFieldEditor(IDebugUIConstants.PREF_PADDED_STR, "",content ); //$NON-NLS-1$
64
fPaddedString.fillIntoGrid(content, 2);
65         fPaddedString.setPreferenceStore(DebugUIPlugin.getDefault().getPreferenceStore());
66         fPaddedString.load();
67                 
68         return content;
69     }
70
71     protected void okPressed() {
72         String JavaDoc str = fPaddedString.getStringValue();
73         
74         if (str == null || str.length() == 0)
75         {
76             MemoryViewUtil.openError(DebugUIMessages.SetPaddedStringDialog_3, DebugUIMessages.SetPaddedStringDialog_4, null); //$NON-NLS-1$ //$NON-NLS-2$
77
return;
78         }
79             
80         fPaddedString.store();
81         
82         super.okPressed();
83         
84     }
85
86 }
87
Popular Tags