| 1 5 package org.terracotta.dso.editors; 6 7 import org.eclipse.jface.dialogs.IDialogConstants; 8 import org.eclipse.jface.dialogs.MessageDialog; 9 import org.eclipse.swt.SWT; 10 import org.eclipse.swt.layout.GridData; 11 import org.eclipse.swt.widgets.Composite; 12 import org.eclipse.swt.widgets.Control; 13 import org.eclipse.swt.widgets.Shell; 14 import org.eclipse.swt.widgets.Text; 15 16 public class RepoLocationDialog extends MessageDialog { 17 18 private Text m_repoLocation; 19 private ValueListener m_valueListener; 20 21 public RepoLocationDialog(Shell parentShell, String title, String message) { 22 super(parentShell, title, null, message, MessageDialog.NONE, new String [] { 23 IDialogConstants.OK_LABEL, 24 IDialogConstants.CANCEL_LABEL }, 0); 25 } 26 27 protected Control createCustomArea(Composite parent) { 28 m_repoLocation = new Text(parent, SWT.SINGLE | SWT.BORDER); 29 m_repoLocation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 30 return m_repoLocation; 31 } 32 33 protected void buttonPressed(int buttonId) { 34 if (buttonId == IDialogConstants.OK_ID) { 35 if (m_valueListener != null) m_valueListener.setValues(m_repoLocation.getText()); 36 } 37 super.buttonPressed(buttonId); 38 } 39 40 public void addValueListener(ValueListener listener) { 41 this.m_valueListener = listener; 42 } 43 44 46 public static interface ValueListener { 47 void setValues(String repoLocation); 48 } 49 } 50 | Popular Tags |