1 11 12 package org.eclipse.debug.internal.ui.views.memory.renderings; 13 14 import java.util.Vector ; 15 16 import org.eclipse.debug.internal.ui.DebugUIMessages; 17 import org.eclipse.debug.ui.IDebugUIConstants; 18 import org.eclipse.jface.dialogs.IDialogConstants; 19 import org.eclipse.jface.dialogs.TrayDialog; 20 import org.eclipse.swt.SWT; 21 import org.eclipse.swt.events.ModifyEvent; 22 import org.eclipse.swt.events.ModifyListener; 23 import org.eclipse.swt.layout.GridData; 24 import org.eclipse.swt.layout.GridLayout; 25 import org.eclipse.swt.widgets.Combo; 26 import org.eclipse.swt.widgets.Composite; 27 import org.eclipse.swt.widgets.Control; 28 import org.eclipse.swt.widgets.Label; 29 import org.eclipse.swt.widgets.Shell; 30 import org.eclipse.ui.PlatformUI; 31 32 35 36 public class GoToAddressDialog extends TrayDialog implements ModifyListener{ 37 38 private static Vector history = new Vector (); 39 private Combo expressionInput; 40 private String expression; 41 42 45 public GoToAddressDialog(Shell parentShell) { 46 super(parentShell); 47 setShellStyle(getShellStyle() | SWT.RESIZE); 48 } 49 50 53 protected Control createDialogArea(Composite parent) { 54 55 PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugUIConstants.PLUGIN_ID + ".GoToAddressDialog_context"); parent.setLayout(new GridLayout()); 57 GridData spec2= new GridData(); 58 spec2.grabExcessVerticalSpace= true; 59 spec2.grabExcessHorizontalSpace= true; 60 spec2.horizontalAlignment= GridData.FILL; 61 spec2.verticalAlignment= GridData.CENTER; 62 parent.setLayoutData(spec2); 63 64 Label textLabel = new Label(parent, SWT.NONE); 65 textLabel.setText(DebugUIMessages.GoToAddressDialog_Address); 66 GridData textLayout = new GridData(); 67 textLayout.widthHint = 280; 68 textLabel.setLayoutData(textLayout); 69 70 expressionInput = new Combo(parent, SWT.BORDER); 71 GridData spec= new GridData(); 72 spec.grabExcessVerticalSpace= false; 73 spec.grabExcessHorizontalSpace= true; 74 spec.horizontalAlignment= GridData.FILL; 75 spec.verticalAlignment= GridData.BEGINNING; 76 spec.heightHint = 50; 77 expressionInput.setLayoutData(spec); 78 79 String [] historyExpression = (String [])history.toArray(new String [history.size()]); 81 for (int i=0; i<historyExpression.length; i++) 82 { 83 expressionInput.add(historyExpression[i]); 84 } 85 86 expressionInput.addModifyListener(this); 87 88 return parent; 89 } 90 93 protected void configureShell(Shell newShell) { 94 super.configureShell(newShell); 95 96 newShell.setText(DebugUIMessages.GoToAddressDialog_GoToAddress); 97 } 98 99 public String getExpression() 100 { 101 return expression; 102 } 103 104 107 protected void okPressed() { 108 109 expression = expressionInput.getText(); 110 111 if (!history.contains(expression)) 113 history.insertElementAt(expression, 0); 114 115 super.okPressed(); 116 } 117 118 121 public void modifyText(ModifyEvent e) { 122 123 String input = expressionInput.getText(); 124 125 if (input == null || input.equals("")) { 127 getButton(IDialogConstants.OK_ID).setEnabled(false); 128 } 129 else 130 { 131 getButton(IDialogConstants.OK_ID).setEnabled(true); 132 } 133 134 } 135 136 139 protected Control createButtonBar(Composite parent) { 140 141 Control ret = super.createButtonBar(parent); 142 getButton(IDialogConstants.OK_ID).setEnabled(false); 143 144 return ret; 145 } 146 147 } 148 | Popular Tags |