org.eclipse.mylyn.tasks.ui_3.7.1.v20120425-0100

mbo.add(encoding);
                }
              }
            }
            catch (LinkageError e)
            {
              StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
                Messages.AbstractRepositorySettingsPage_Problems_encountered_determining_available_charsets, e));
              
              otherEncoding.setEnabled(false);
              otherEncodingCombo.setEnabled(false);
            }
            setDefaultEncoding();
            
            otherEncoding.addSelectionListener(new SelectionAdapter()
            {
              public void widgetSelected(SelectionEvent e)
              {
                if (otherEncoding.getSelection())
                {
                  defaultEncoding.setSelection(false);
                  otherEncodingCombo.setEnabled(true);
                }
                else
                {
                  defaultEncoding.setSelection(true);
                  otherEncodingCombo.setEnabled(false);
                }
              }
            });
            if (repository != null) {
              try
              {
                String repositoryEncoding = repository.getCharacterEncoding();
                if (repositoryEncoding != null) {
                  if ((otherEncodingCombo.getItemCount() > 0) && 
                    (otherEncodingCombo.indexOf(repositoryEncoding) > -1))
                  {
                    otherEncodingCombo.setEnabled(true);
                    otherEncoding.setSelection(true);
                    defaultEncoding.setSelection(false);
                    otherEncodingCombo.select(otherEncodingCombo.indexOf(repositoryEncoding));
                  }
                  else
                  {
                    setDefaultEncoding();
                  }
                }
              }
              catch (Throwable t)
              {
                StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", "Could not set field value", t));
              }
            }
          }
        }
        
        private void createCertAuthSection()
        {
          ExpandableComposite section = createSection(compositeContainer, 
            Messages.AbstractRepositorySettingsPage_certificate_settings);
          
          certAuthComp = toolkit.createComposite(section, 0);
          certAuthComp.setBackground(compositeContainer.getBackground());
          section.setClient(certAuthComp);
          
          certAuthButton = new Button(certAuthComp, 32);
          GridDataFactory.fillDefaults()
            .indent(0, 5)
            .align(16384, 128)
            .span(3, -1)
            .applyTo(certAuthButton);
          
          certAuthButton.setText(Messages.AbstractRepositorySettingsPage_Enable_certificate_authentification);
          
          certAuthButton.addSelectionListener(new SelectionListener()
          {
            public void widgetSelected(SelectionEvent e)
            {
              setCertAuth(certAuthButton.getSelection());
            }
            
            public void widgetDefaultSelected(SelectionEvent e) {}
          });
          certAuthFileNameEditor = new StringFieldEditor(
            "", Messages.AbstractRepositorySettingsPage_CertificateFile_, StringFieldEditor.UNLIMITED, certAuthComp)
            {
              protected boolean doCheckState()
              {
                return true;
              }
              
              protected void valueChanged()
              {
                super.valueChanged();
                if (getWizard() != null) {
                  getWizard().getContainer().updateButtons();
                }
              }
              
              public int getNumberOfControls()
              {
                return 2;
              }
            };
            certBrowseButton = new Button(certAuthComp, 8);
            certBrowseButton.setText(Messages.AbstractRepositorySettingsPage_ChooseCertificateFile_);
            certBrowseButton.addSelectionListener(new SelectionAdapter()
            {
              public void widgetSelected(SelectionEvent e)
              {
                FileDialog fileDialog = new FileDialog(getShell(), 4096);
                fileDialog.setFilterPath(System.getProperty("user.home", "."));
                String returnFile = fileDialog.open();
                if (returnFile != null) {
                  certAuthFileNameEditor.setStringValue(returnFile);
                }
              }
            });
            certAuthPasswordEditor = new RepositoryStringFieldEditor(
              "", Messages.AbstractRepositorySettingsPage_CertificatePassword_, StringFieldEditor.UNLIMITED, 
              certAuthComp)
              {
                public int getNumberOfControls()
                {
                  return 2;
                }
              };
              ((RepositoryStringFieldEditor)certAuthPasswordEditor).getTextControl().setEchoChar('*');
              
              saveCertPasswordButton = new Button(certAuthComp, 32);
              saveCertPasswordButton.setText(Messages.AbstractRepositorySettingsPage_Save_Password);
              
              certAuthFileNameEditor.setEnabled(certAuthButton.getSelection(), certAuthComp);
              certBrowseButton.setEnabled(certAuthButton.getSelection());
              certAuthPasswordEditor.setEnabled(certAuthButton.getSelection(), certAuthComp);
              saveCertPasswordButton.setEnabled(certAuthButton.getSelection());
              if (repository != null) {
                saveCertPasswordButton.setSelection(repository.getSavePassword(AuthenticationType.CERTIFICATE));
              } else {
                saveCertPasswordButton.setSelection(false);
              }
              setCertAuth((oldCertAuthPassword != null) || (oldCertAuthFileName != null));
              section.setExpanded(certAuthButton.getSelection());
              
              GridLayout gridLayout2 = new GridLayout();
              numColumns = 3;
              marginWidth = 0;
              certAuthComp.setLayout(gridLayout2);
            }
            
            private void createHttpAuthSection()
            {
              ExpandableComposite section = createSection(compositeContainer, 
                Messages.AbstractRepositorySettingsPage_Http_Authentication);
              
              httpAuthComp = toolkit.createComposite(section, 0);
              httpAuthComp.setBackground(compositeContainer.getBackground());
              section.setClient(httpAuthComp);
              
              httpAuthButton = new Button(httpAuthComp, 32);
              GridDataFactory.fillDefaults()
                .indent(0, 5)
                .align(16384, 128)
                .span(3, -1)
                .applyTo(httpAuthButton);
              
              httpAuthButton.setText(Messages.AbstractRepositorySettingsPage_Enable_http_authentication);
              
              httpAuthButton.addSelectionListener(new SelectionListener()
              {
                public void widgetSelected(SelectionEvent e)
                {
                  setHttpAuth(httpAuthButton.getSelection());
                }
                
                public void widgetDefaultSelected(SelectionEvent e) {}
              });
              httpAuthUserNameEditor = new StringFieldEditor(
                "", Messages.AbstractRepositorySettingsPage_User_ID_, StringFieldEditor.UNLIMITED, httpAuthComp)
                {
                  protected boolean doCheckState()
                  {
                    return true;
                  }
                  
                  protected void valueChanged()
                  {
                    super.valueChanged();
                    if (getWizard() != null) {
                      getWizard().getContainer().updateButtons();
                    }
                  }
                  
                  public int getNumberOfControls()
                  {
                    return 3;
                  }
                };
                httpAuthPasswordEditor = new RepositoryStringFieldEditor(
                  "", Messages.AbstractRepositorySettingsPage_Password_, StringFieldEditor.UNLIMITED, 
                  httpAuthComp)
                  {
                    public int getNumberOfControls()
                    {
                      return 2;
                    }
                  };
                  ((RepositoryStringFieldEditor)httpAuthPasswordEditor).getTextControl().setEchoChar('*');
                  
                  saveHttpPasswordButton = new Button(httpAuthComp, 32);
                  saveHttpPasswordButton.setText(Messages.AbstractRepositorySettingsPage_Save_Password);
                  
                  httpAuthUserNameEditor.setEnabled(httpAuthButton.getSelection(), httpAuthComp);
                  httpAuthPasswordEditor.setEnabled(httpAuthButton.getSelection(), httpAuthComp);
                  saveHttpPasswordButton.setEnabled(httpAuthButton.getSelection());
                  if (repository != null) {
                    saveHttpPasswordButton.setSelection(repository.getSavePassword(AuthenticationType.HTTP));
                  } else {
                    saveHttpPasswordButton.setSelection(false);
                  }
                  setHttpAuth((oldHttpAuthPassword != null) || (oldHttpAuthUserId != null));
                  section.setExpanded(httpAuthButton.getSelection());
                  
                  GridLayout gridLayout2 = new GridLayout();
                  numColumns = 3;
                  marginWidth = 0;
                  httpAuthComp.setLayout(gridLayout2);
                }
                
                private void initializeOldValues()
                {
                  if (repository != null)
                  {
                    originalUrl = repository.getRepositoryUrl();
                    AuthenticationCredentials oldCredentials = repository.getCredentials(AuthenticationType.REPOSITORY);
                    if (oldCredentials != null)
                    {
                      oldUsername = oldCredentials.getUserName();
                      oldPassword = oldCredentials.getPassword();
                    }
                    else
                    {
                      oldUsername = "";
                      oldPassword = "";
                    }
                    AuthenticationCredentials oldCertCredentials = repository.getCredentials(AuthenticationType.CERTIFICATE);
                    if (oldCertCredentials != null)
                    {
                      oldCertAuthFileName = oldCertCredentials.getUserName();
                      oldCertAuthPassword = oldCertCredentials.getPassword();
                    }
                    else
                    {
                      oldCertAuthPassword = null;
                      oldCertAuthFileName = null;
                    }
                    AuthenticationCredentials oldHttpCredentials = repository.getCredentials(AuthenticationType.HTTP);
                    if (oldHttpCredentials != null)
                    {
                      oldHttpAuthUserId = oldHttpCredentials.getUserName();
                      oldHttpAuthPassword = oldHttpCredentials.getPassword();
                    }
                    else
                    {
                      oldHttpAuthPassword = null;
                      oldHttpAuthUserId = null;
                    }
                    oldProxyHostname = repository.getProperty("org.eclipse.mylyn.tasklist.repositories.proxy.hostname");
                    oldProxyPort = repository.getProperty("org.eclipse.mylyn.tasklist.repositories.proxy.port");
                    if (oldProxyHostname == null) {
                      oldProxyHostname = "";
                    }
                    if (oldProxyPort == null) {
                      oldProxyPort = "";
                    }
                    AuthenticationCredentials oldProxyCredentials = repository.getCredentials(AuthenticationType.PROXY);
                    if (oldProxyCredentials != null)
                    {
                      oldProxyUsername = oldProxyCredentials.getUserName();
                      oldProxyPassword = oldProxyCredentials.getPassword();
                    }
                    else
                    {
                      oldProxyUsername = null;
                      oldProxyPassword = null;
                    }
                  }
                  else
                  {
                    oldUsername = "";
                    oldPassword = "";
                    oldHttpAuthPassword = null;
                    oldHttpAuthUserId = null;
                    oldCertAuthFileName = null;
                    oldCertAuthPassword = null;
                  }
                }
                
                private void createProxySection()
                {
                  ExpandableComposite section = createSection(compositeContainer, 
                    Messages.AbstractRepositorySettingsPage_Proxy_Server_Configuration);
                  
                  proxyAuthComp = toolkit.createComposite(section, 0);
                  GridLayout gridLayout2 = new GridLayout();
                  verticalSpacing = 0;
                  numColumns = 3;
                  proxyAuthComp.setLayout(gridLayout2);
                  proxyAuthComp.setBackground(compositeContainer.getBackground());
                  section.setClient(proxyAuthComp);
                  
                  Composite systemSettingsComposite = new Composite(proxyAuthComp, 0);
                  GridLayout gridLayout3 = new GridLayout();
                  verticalSpacing = 0;
                  numColumns = 2;
                  marginWidth = 0;
                  systemSettingsComposite.setLayout(gridLayout3);
                  
                  systemProxyButton = new Button(systemSettingsComposite, 32);
                  GridDataFactory.fillDefaults().align(16384, 128).span(3, -1).applyTo(systemSettingsComposite);
                  
                  systemProxyButton.setText(Messages.AbstractRepositorySettingsPage_Use_global_Network_Connections_preferences);
                  
                  systemProxyButton.addSelectionListener(new SelectionListener()
                  {
                    public void widgetSelected(SelectionEvent e)
                    {
                      setUseDefaultProxy(systemProxyButton.getSelection());
                    }
                    
                    public void widgetDefaultSelected(SelectionEvent e) {}
                  });
                  Hyperlink changeProxySettingsLink = toolkit.createHyperlink(systemSettingsComposite, 
                    Messages.AbstractRepositorySettingsPage_Change_Settings, 0);
                  changeProxySettingsLink.setBackground(compositeContainer.getBackground());
                  changeProxySettingsLink.addHyperlinkListener(new IHyperlinkListener()
                  {
                    public void linkActivated(HyperlinkEvent e)
                    {
                      PreferenceDialog dlg = PreferencesUtil.createPreferenceDialogOn(getShell(), "org.eclipse.ui.net.NetPreferences", 
                        new String[] { "org.eclipse.ui.net.NetPreferences" }, null);
                      dlg.open();
                    }
                    
                    public void linkEntered(HyperlinkEvent e) {}
                    
                    public void linkExited(HyperlinkEvent e) {}
                  });
                  proxyHostnameEditor = new StringFieldEditor(
                    "", Messages.AbstractRepositorySettingsPage_Proxy_host_address_, StringFieldEditor.UNLIMITED, 
                    proxyAuthComp)
                    {
                      protected boolean doCheckState()
                      {
                        return true;
                      }
                      
                      protected void valueChanged()
                      {
                        super.valueChanged();
                        if (getWizard() != null) {
                          getWizard().getContainer().updateButtons();
                        }
                      }
                      
                      public int getNumberOfControls()
                      {
                        return 3;
                      }
                    };
                    proxyHostnameEditor.setStringValue(oldProxyHostname);
                    
                    proxyPortEditor = new RepositoryStringFieldEditor(
                      "", Messages.AbstractRepositorySettingsPage_Proxy_host_port_, StringFieldEditor.UNLIMITED, 
                      proxyAuthComp)
                      {
                        public int getNumberOfControls()
                        {
                          return 3;
                        }
                      };
                      proxyPortEditor.setStringValue(oldProxyPort);
                      
                      proxyHostnameEditor.setEnabled(systemProxyButton.getSelection(), proxyAuthComp);
                      proxyPortEditor.setEnabled(systemProxyButton.getSelection(), proxyAuthComp);
                      
                      proxyAuthButton = new Button(proxyAuthComp, 32);
                      GridDataFactory.fillDefaults().span(3, -1).applyTo(proxyAuthButton);
                      proxyAuthButton.setText(Messages.AbstractRepositorySettingsPage_Enable_proxy_authentication);
                      proxyAuthButton.addSelectionListener(new SelectionListener()
                      {
                        public void widgetSelected(SelectionEvent e)
                        {
                          setProxyAuth(proxyAuthButton.getSelection());
                        }
                        
                        public void widgetDefaultSelected(SelectionEvent e) {}
                      });
                      proxyUserNameEditor = new StringFieldEditor(
                        "", Messages.AbstractRepositorySettingsPage_User_ID_, StringFieldEditor.UNLIMITED, proxyAuthComp)
                        {
                          protected boolean doCheckState()
                          {
                            return true;
                          }
                          
                          protected void valueChanged()
                          {
                            super.valueChanged();
                            if (getWizard() != null) {
                              getWizard().getContainer().updateButtons();
                            }
                          }
                          
                          public int getNumberOfControls()
                          {
                            return 3;
                          }
                        };
                        proxyPasswordEditor = new RepositoryStringFieldEditor(
                          "", Messages.AbstractRepositorySettingsPage_Password_, StringFieldEditor.UNLIMITED, 
                          proxyAuthComp)
                          {
                            public int getNumberOfControls()
                            {
                              return 2;
                            }
                          };
                          ((RepositoryStringFieldEditor)proxyPasswordEditor).getTextControl().setEchoChar('*');
                          
                          proxyAuthComp.getLayout()).numColumns += 1;
                          saveProxyPasswordButton = new Button(proxyAuthComp, 32);
                          saveProxyPasswordButton.setText(Messages.AbstractRepositorySettingsPage_Save_Password);
                          saveProxyPasswordButton.setEnabled(proxyAuthButton.getSelection());
                          if (repository != null) {
                            saveProxyPasswordButton.setSelection(repository.getSavePassword(AuthenticationType.PROXY));
                          } else {
                            saveProxyPasswordButton.setSelection(false);
                          }
                          setProxyAuth((oldProxyUsername != null) || (oldProxyPassword != null));
                          
                          setUseDefaultProxy(repository != null ? repository.isDefaultProxyEnabled() : true);
                          section.setExpanded(!systemProxyButton.getSelection());
                        }
                        
                        protected void setEncoding(String encoding)
                        {
                          if (encoding.equals("UTF-8"))
                          {
                            setDefaultEncoding();
                          }
                          else if (otherEncodingCombo.indexOf(encoding) != -1)
                          {
                            defaultEncoding.setSelection(false);
                            otherEncodingCombo.setEnabled(true);
                            otherEncoding.setSelection(true);
                            otherEncodingCombo.select(otherEncodingCombo.indexOf(encoding));
                          }
                          else
                          {
                            setDefaultEncoding();
                          }
                        }
                        
                        private void setDefaultEncoding()
                        {
                          defaultEncoding.setSelection(true);
                          otherEncoding.setSelection(false);
                          otherEncodingCombo.setEnabled(false);
                          if (otherEncodingCombo.getItemCount() > 0) {
                            otherEncodingCombo.select(0);
                          }
                        }
                        
                        public void setAnonymous(boolean selected)
                        {
                          if (!needsAnonymousLogin) {
                            return;
                          }
                          anonymousButton.setSelection(selected);
                          if (selected)
                          {
                            oldUsername = repositoryUserNameEditor.getStringValue();
                            oldPassword = repositoryPasswordEditor.getStringValue();
                            repositoryUserNameEditor.setStringValue("");
                            repositoryPasswordEditor.setStringValue("");
                          }
                          else
                          {
                            repositoryUserNameEditor.setStringValue(oldUsername);
                            repositoryPasswordEditor.setStringValue(oldPassword);
                          }
                          repositoryUserNameEditor.setEnabled(!selected, compositeContainer);
                          repositoryPasswordEditor.setEnabled(!selected, compositeContainer);
                          savePasswordButton.setEnabled(!selected);
                          if (getWizard() != null) {
                            getWizard().getContainer().updateButtons();
                          }
                        }
                        
                        public void setHttpAuth(boolean selected)
                        {
                          if (!needsHttpAuth) {
                            return;
                          }
                          httpAuthButton.setSelection(selected);
                          if (!selected)
                          {
                            oldHttpAuthUserId = httpAuthUserNameEditor.getStringValue();
                            oldHttpAuthPassword = httpAuthPasswordEditor.getStringValue();
                            httpAuthUserNameEditor.setStringValue(null);
                            httpAuthPasswordEditor.setStringValue(null);
                          }
                          else
                          {
                            httpAuthUserNameEditor.setStringValue(oldHttpAuthUserId);
                            httpAuthPasswordEditor.setStringValue(oldHttpAuthPassword);
                          }
                          httpAuthUserNameEditor.setEnabled(selected, httpAuthComp);
                          httpAuthPasswordEditor.setEnabled(selected, httpAuthComp);
                          saveHttpPasswordButton.setEnabled(selected);
                        }
                        
                        public void setCertAuth(boolean selected)
                        {
                          if (!needsCertAuth) {
                            return;
                          }
                          certAuthButton.setSelection(selected);
                          if (!selected)
                          {
                            oldCertAuthFileName = certAuthFileNameEditor.getStringValue();
                            oldCertAuthPassword = certAuthPasswordEditor.getStringValue();
                            certAuthFileNameEditor.setStringValue(null);
                            certAuthPasswordEditor.setStringValue(null);
                          }
                          else
                          {
                            certAuthFileNameEditor.setStringValue(oldCertAuthFileName);
                            certAuthPasswordEditor.setStringValue(oldCertAuthPassword);
                          }
                          certAuthFileNameEditor.setEnabled(selected, certAuthComp);
                          certBrowseButton.setEnabled(selected);
                          certAuthPasswordEditor.setEnabled(selected, certAuthComp);
                          saveCertPasswordButton.setEnabled(selected);
                        }
                        
                        public boolean getHttpAuth()
                        {
                          return httpAuthButton.getSelection();
                        }
                        
                        public boolean getCertAuth()
                        {
                          return certAuthButton.getSelection();
                        }
                        
                        public void setUseDefaultProxy(boolean selected)
                        {
                          if (!needsProxy) {
                            return;
                          }
                          systemProxyButton.setSelection(selected);
                          if (selected)
                          {
                            oldProxyHostname = proxyHostnameEditor.getStringValue();
                            oldProxyPort = proxyPortEditor.getStringValue();
                          }
                          else
                          {
                            proxyHostnameEditor.setStringValue(oldProxyHostname);
                            proxyPortEditor.setStringValue(oldProxyPort);
                          }
                          proxyHostnameEditor.setEnabled(!selected, proxyAuthComp);
                          proxyPortEditor.setEnabled(!selected, proxyAuthComp);
                          proxyAuthButton.setEnabled(!selected);
                          setProxyAuth(proxyAuthButton.getSelection());
                        }
                        
                        public void setProxyAuth(boolean selected)
                        {
                          proxyAuthButton.setSelection(selected);
                          proxyAuthButton.setEnabled(!systemProxyButton.getSelection());
                          if (!selected)
                          {
                            oldProxyUsername = proxyUserNameEditor.getStringValue();
                            oldProxyPassword = proxyPasswordEditor.getStringValue();
                            proxyUserNameEditor.setStringValue(null);
                            proxyPasswordEditor.setStringValue(null);
                          }
                          else
                          {
                            proxyUserNameEditor.setStringValue(oldProxyUsername);
                            proxyPasswordEditor.setStringValue(oldProxyPassword);
                          }
                          proxyUserNameEditor.setEnabled((selected) && (!systemProxyButton.getSelection()), proxyAuthComp);
                          proxyPasswordEditor.setEnabled((selected) && (!systemProxyButton.getSelection()), proxyAuthComp);
                          saveProxyPasswordButton.setEnabled((selected) && (!systemProxyButton.getSelection()));
                        }
                        
                        public boolean getProxyAuth()
                        {
                          return proxyAuthButton.getSelection();
                        }
                        
                        protected void addRepositoryTemplatesToServerUrlCombo()
                        {
                          final RepositoryTemplateManager templateManager = TasksUiPlugin.getRepositoryTemplateManager();
                          for (RepositoryTemplate template : templateManager.getTemplates(connector.getConnectorKind())) {
                            serverUrlCombo.add(label);
                          }
                          serverUrlCombo.addSelectionListener(new SelectionAdapter()
                          {
                            public void widgetSelected(SelectionEvent e)
                            {
                              String text = serverUrlCombo.getText();
                              RepositoryTemplate template = templateManager.getTemplate(connector.getConnectorKind(), text);
                              if (template != null)
                              {
                                repositoryTemplateSelected(template);
                                return;
                              }
                            }
                          });
                        }
                        
                        protected void repositoryTemplateSelected(RepositoryTemplate template) {}
                        
                        protected abstract void createAdditionalControls(Composite paramComposite);
                        
                        protected abstract boolean isValidUrl(String paramString);
                        
                        private void updateHyperlinks()
                        {
                          if ((getRepositoryUrl() != null) && (getRepositoryUrl().length() > 0))
                          {
                            TaskRepository repository = new TaskRepository(connector.getConnectorKind(), getRepositoryUrl());
                            
                            String accountCreationUrl = TasksUiPlugin.getConnectorUi(connector.getConnectorKind())
                              .getAccountCreationUrl(repository);
                            createAccountHyperlink.setEnabled(accountCreationUrl != null);
                            createAccountHyperlink.setVisible(accountCreationUrl != null);
                            
                            String accountManagementUrl = TasksUiPlugin.getConnectorUi(connector.getConnectorKind())
                              .getAccountManagementUrl(repository);
                            manageAccountHyperlink.setEnabled(accountManagementUrl != null);
                            manageAccountHyperlink.setVisible(accountManagementUrl != null);
                          }
                          else
                          {
                            createAccountHyperlink.setEnabled(false);
                            createAccountHyperlink.setVisible(false);
                            manageAccountHyperlink.setEnabled(false);
                            manageAccountHyperlink.setVisible(false);
                          }
                        }
                        
                        public String getRepositoryLabel()
                        {
                          return repositoryLabelEditor.getStringValue();
                        }
                        
                        public String getRepositoryUrl()
                        {
                          return TaskRepositoryManager.stripSlashes(serverUrlCombo.getText());
                        }
                        
                        public String getUserName()
                        {
                          return repositoryUserNameEditor.getStringValue();
                        }
                        
                        public String getPassword()
                        {
                          return repositoryPasswordEditor.getStringValue();
                        }
                        
                        public String getHttpAuthUserId()
                        {
                          if (needsHttpAuth()) {
                            return httpAuthUserNameEditor.getStringValue();
                          }
                          return "";
                        }
                        
                        public String getHttpAuthPassword()
                        {
                          if (needsHttpAuth()) {
                            return httpAuthPasswordEditor.getStringValue();
                          }
                          return "";
                        }
                        
                        public String getCertAuthFileName()
                        {
                          if (needsCertAuth()) {
                            return certAuthFileNameEditor.getStringValue();
                          }
                          return "";
                        }
                        
                        public String getCertAuthPassword()
                        {
                          if (needsCertAuth()) {
                            return certAuthPasswordEditor.getStringValue();
                          }
                          return "";
                        }
                        
                        public String getProxyHostname()
                        {
                          if (needsProxy()) {
                            return proxyHostnameEditor.getStringValue();
                          }
                          return "";
                        }
                        
                        public String getProxyPort()
                        {
                          if (needsProxy()) {
                            return proxyPortEditor.getStringValue();
                          }
                          return "";
                        }
                        
                        public Boolean getUseDefaultProxy()
                        {
                          if (needsProxy()) {
                            return Boolean.valueOf(systemProxyButton.getSelection());
                          }
                          return Boolean.valueOf(true);
                        }
                        
                        public String getProxyUserName()
                        {
                          if (needsProxy()) {
                            return proxyUserNameEditor.getStringValue();
                          }
                          return "";
                        }
                        
                        public String getProxyPassword()
                        {
                          if (needsProxy()) {
                            return proxyPasswordEditor.getStringValue();
                          }
                          return "";
                        }
                        
                        public void init(IWorkbench workbench) {}
                        
                        public boolean isAnonymousAccess()
                        {
                          if (anonymousButton != null) {
                            return anonymousButton.getSelection();
                          }
                          return false;
                        }
                        
                        private static class RepositoryStringFieldEditor
                          extends StringFieldEditor
                        {
                          public RepositoryStringFieldEditor(String name, String labelText, int style, Composite parent)
                          {
                            super(labelText, style, parent);
                          }
                          
                          public void refreshValidState()
                          {
                            try
                            {
                              super.refreshValidState();
                            }
                            catch (Exception e)
                            {
                              StatusHandler.log(new Status(4, "org.eclipse.mylyn.tasks.ui", 
                                "Problem refreshing password field", e));
                            }
                          }
                          
                          public Text getTextControl()
                          {
                            return super.getTextControl();
                          }
                        }
                        
                        public boolean isPageComplete()
                        {
                          String errorMessage = null;
                          String url = getRepositoryUrl();
                          
                          errorMessage = isUniqueUrl(url);
                          if (errorMessage == null) {
                            for (TaskRepository repository : TasksUi.getRepositoryManager().getAllRepositories()) {
                              if ((!repository.equals(getRepository())) && (getRepositoryLabel().equals(repository.getRepositoryLabel())))
                              {
                                errorMessage = Messages.AbstractRepositorySettingsPage_A_repository_with_this_name_already_exists;
                                break;
                              }
                            }
                          }
                          if (errorMessage == null)
                          {
                            if (!isValidUrl(url)) {
                              errorMessage = Messages.AbstractRepositorySettingsPage_Enter_a_valid_server_url;
                            }
                            if ((errorMessage == null) && ((!needsAnonymousLogin()) || (!anonymousButton.getSelection())) && 
                              (isMissingCredentials())) {
                              errorMessage = Messages.AbstractRepositorySettingsPage_Enter_a_user_id_Message0;
                            }
                            setMessage(errorMessage, this.repository == null ? 0 : 3);
                          }
                          else
                          {
                            setMessage(errorMessage, 3);
                          }
                          return (errorMessage == null) && (super.isPageComplete());
                        }
                        
                        protected boolean isMissingCredentials()
                        {
                          return (repositoryUserNameEditor.getStringValue().trim().equals("")) || ((getSavePassword().booleanValue()) && (repositoryPasswordEditor.getStringValue().trim().equals("")));
                        }
                        
                        protected String isUniqueUrl(String urlString)
                        {
                          if (!urlString.equals(originalUrl))
                          {
                            if (repositoryUrls == null)
                            {
                              List<TaskRepository> repositories = TasksUi.getRepositoryManager().getAllRepositories();
                       
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd