Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.68 KB | None | 0 0
  1. package gui;
  2.  
  3. import org.eclipse.jface.dialogs.Dialog;
  4. import org.eclipse.swt.SWT;
  5. import org.eclipse.swt.layout.GridData;
  6. import org.eclipse.swt.layout.GridLayout;
  7. import org.eclipse.swt.widgets.Composite;
  8. import org.eclipse.swt.widgets.Control;
  9. import org.eclipse.swt.widgets.Label;
  10. import org.eclipse.swt.widgets.Text;
  11.  
  12. public class ConnectionDialog extends Dialog {
  13.  
  14.     Text textRepository;
  15.     Text textUsername;
  16.     Text textPassword;
  17.     ConnectionInfo connectionInfo;
  18.  
  19.     public ConnectionDialog(GUI gui) {
  20.         super(gui.getShell());
  21.     }
  22.  
  23.     protected Control createDialogArea(Composite parent) {
  24.         getShell().setText("Connection Settings");
  25.  
  26.         Composite composite = (Composite) super.createDialogArea(parent);
  27.         composite.setLayout(new GridLayout(2, false));
  28.  
  29.         new Label(composite, SWT.NULL).setText("Repository");
  30.         textRepository = new Text(composite, SWT.BORDER);
  31.         textRepository.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  32.  
  33.         new Label(composite, SWT.NULL).setText("Username");
  34.         textUsername = new Text(composite, SWT.BORDER);
  35.         textUsername.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  36.  
  37.         new Label(composite, SWT.NULL).setText("Password");
  38.         textPassword = new Text(composite, SWT.PASSWORD | SWT.BORDER);
  39.         textPassword.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  40.  
  41.         return composite;
  42.     }
  43.  
  44.     public ConnectionInfo getConnectionInfo() {
  45.         return connectionInfo;
  46.     }
  47.  
  48.     protected void okPressed() {
  49.  
  50.         connectionInfo = new ConnectionInfo();
  51.         connectionInfo.setRepository(textRepository.getText());
  52.         connectionInfo.setUsername(textUsername.getText());
  53.         connectionInfo.setPassword(textPassword.getText());
  54.  
  55.         super.okPressed();
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement