01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package org.terracotta.dso.editors;
06:
07: import org.eclipse.jface.dialogs.IDialogConstants;
08: import org.eclipse.jface.dialogs.MessageDialog;
09: 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,
22: String message) {
23: super (parentShell, title, null, message, MessageDialog.NONE,
24: new String[] { IDialogConstants.OK_LABEL,
25: IDialogConstants.CANCEL_LABEL }, 0);
26: }
27:
28: protected Control createCustomArea(Composite parent) {
29: m_repoLocation = new Text(parent, SWT.SINGLE | SWT.BORDER);
30: m_repoLocation.setLayoutData(new GridData(
31: GridData.FILL_HORIZONTAL));
32: return m_repoLocation;
33: }
34:
35: protected void buttonPressed(int buttonId) {
36: if (buttonId == IDialogConstants.OK_ID) {
37: if (m_valueListener != null)
38: m_valueListener.setValues(m_repoLocation.getText());
39: }
40: super .buttonPressed(buttonId);
41: }
42:
43: public void addValueListener(ValueListener listener) {
44: this .m_valueListener = listener;
45: }
46:
47: // --------------------------------------------------------------------------------
48:
49: public static interface ValueListener {
50: void setValues(String repoLocation);
51: }
52: }
|