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