1 package com.quantum.wizards;
 
   3 import org.eclipse.swt.SWT;
 
   4 import org.eclipse.swt.events.ModifyEvent;
 
   5 import org.eclipse.swt.events.ModifyListener;
 
   6 import org.eclipse.swt.events.SelectionAdapter;
 
   7 import org.eclipse.swt.events.SelectionEvent;
 
   8 import org.eclipse.swt.layout.GridData;
 
   9 import org.eclipse.swt.layout.GridLayout;
 
  10 import org.eclipse.swt.widgets.Button;
 
  11 import org.eclipse.swt.widgets.Composite;
 
  12 import org.eclipse.swt.widgets.Label;
 
  13 import org.eclipse.swt.widgets.Text;
 
  15 import com.quantum.Messages;
 
  16 import com.quantum.model.JDBCDriver;
 
  19 class BookmarkConnectionWizardPage extends PropertyChangeWizardPage {
 
  21         /* use this to paint a more helpful UI for the JDBC URL */
 
  22         private JDBCDriver driver;
 
  23         private String userid;
 
  24         private String password;
 
  25         private String connectionURL;
 
  26     private boolean prompt;
 
  29          * Constructor for BookmarkPage.
 
  32         public BookmarkConnectionWizardPage(String pageName) {
 
  34                 setTitle(Messages.getString(getClass(), "title"));
 
  35                 setDescription(Messages.getString(getClass(), "description"));
 
  37         public void createControl(Composite parent) {
 
  38                 setPageComplete(false);
 
  40                 Composite container = new Composite(parent, SWT.NULL);
 
  41                 GridLayout layout = new GridLayout();
 
  42                 container.setLayout(layout);
 
  43                 layout.numColumns = 3;
 
  44                 layout.verticalSpacing = 9;
 
  46                 Label label = new Label(container, SWT.NULL);
 
  47                 label.setText(Messages.getString(getClass(), "userid")); //$NON-NLS-1$
 
  48                 Text username = new Text(container, SWT.BORDER | SWT.SINGLE);
 
  51                 GridData fullHorizontal = new GridData(GridData.FILL_HORIZONTAL);
 
  52                 fullHorizontal.horizontalSpan = 2;
 
  53                 username.setLayoutData(fullHorizontal);
 
  54                 username.addModifyListener(new ModifyListener() {
 
  55                         public void modifyText(ModifyEvent event) {
 
  56                                 String userid = ((Text) event.getSource()).getText();
 
  62                 label = new Label(container, SWT.NULL);
 
  63                 label.setText(Messages.getString(getClass(), "password")); //$NON-NLS-1$
 
  64                 final Text password = new Text(container, SWT.BORDER | SWT.SINGLE);
 
  65                 password.setEchoChar('*');
 
  66                 fullHorizontal = new GridData(GridData.FILL_HORIZONTAL);
 
  67                 fullHorizontal.horizontalSpan = 2;
 
  68                 password.setLayoutData(fullHorizontal);
 
  69                 password.addModifyListener(new ModifyListener() {
 
  70                         public void modifyText(ModifyEvent event) {
 
  71                                 String password = ((Text) event.getSource()).getText();
 
  72                                 setPassword(password);
 
  77         Button prompt = new Button(container, SWT.CHECK);
 
  78                 prompt.setText(Messages.getString(getClass(), "prompt")); //$NON-NLS-1$
 
  79                 fullHorizontal = new GridData(GridData.FILL_HORIZONTAL);
 
  80                 fullHorizontal.horizontalSpan = 3;
 
  81         prompt.setLayoutData(fullHorizontal);
 
  83                 label = new Label(container, SWT.NULL);
 
  84                 label.setText(Messages.getString(getClass(), "url")); //$NON-NLS-1$
 
  86                 Text connect = new Text(container, SWT.BORDER | SWT.SINGLE);
 
  87                 fullHorizontal = new GridData(GridData.FILL_HORIZONTAL);
 
  88                 fullHorizontal.horizontalSpan = 2;
 
  89                 connect.setLayoutData(fullHorizontal);
 
  90                 connect.addModifyListener(new ModifyListener() {
 
  91                         public void modifyText(ModifyEvent event) {
 
  92                                 String connectionURL = ((Text) event.getSource()).getText();
 
  93                                 setConnectionURL(connectionURL);
 
  97         prompt.addSelectionListener(new SelectionAdapter() {
 
  98             public void widgetSelected(SelectionEvent event) {
 
  99                 Button prompt = ((Button) event.getSource());
 
 100                 password.setEditable(!prompt.getSelection());
 
 101                 setPrompt(prompt.getSelection());
 
 106                 setControl(container);
 
 110          * @return Returns the driver.
 
 112         public JDBCDriver getDriver() {
 
 116          * @param driver The driver to set.
 
 118         public void setDriver(JDBCDriver driver) {
 
 119                 this.driver = driver;
 
 124         private void updateButtonState() {
 
 125                 boolean complete = true;
 
 126                 complete &= (this.connectionURL != null 
 
 127                                 && this.connectionURL.trim().length() > 0);
 
 128                 complete &= (this.userid != null 
 
 129                                 && this.userid.trim().length() > 0);
 
 130                 setPageComplete(complete);
 
 133          * @return Returns the userid.
 
 135         public String getUserid() {
 
 139          * @param userid The userid to set.
 
 141         public void setUserid(String userid) {
 
 142                 if (userid != null && !userid.equals(this.userid)) {
 
 143                         String original = this.userid;
 
 144                         this.userid = userid;
 
 145                         firePropertyChange("userid", original, userid);
 
 149          * @return Returns the prompt.
 
 151         public boolean isPrompt() {
 
 155          * @param prompt The prompt to set.
 
 157         public void setPrompt(boolean prompt) {
 
 158                 if (this.prompt != prompt) {
 
 159                         boolean original = this.prompt;
 
 160                         this.prompt = prompt;
 
 161                         firePropertyChange("prompt", original, prompt);
 
 165          * @return Returns the connectionURL.
 
 167         public String getConnectionURL() {
 
 168                 return this.connectionURL;
 
 171          * @param connectionURL The connectionURL to set.
 
 173         public void setConnectionURL(String connectionURL) {
 
 174                 if (connectionURL != null && !connectionURL.equals(this.connectionURL)) {
 
 175                         String original = this.connectionURL;
 
 176                         this.connectionURL = connectionURL;
 
 177                         firePropertyChange("connectionURL", original, connectionURL);
 
 181          * @return Returns the password.
 
 183         public String getPassword() {
 
 184                 return this.password;
 
 187          * @param password The password to set.
 
 189         public void setPassword(String password) {
 
 190                 if (password != null && !password.equals(this.password)) {
 
 191                         String original = this.password;
 
 192                         this.password = password;
 
 193                         firePropertyChange("password", original, password);