KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > editors > RepoLocationDialog


1 /*
2  * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

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 JavaDoc title, String JavaDoc message) {
22     super(parentShell, title, null, message, MessageDialog.NONE, new String JavaDoc[] {
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   // --------------------------------------------------------------------------------
45

46   public static interface ValueListener {
47     void setValues(String JavaDoc repoLocation);
48   }
49 }
50
Popular Tags