コード例 #1
0
 private void saveConnectionBean(String email) {
   ConnectionUserPerReader perReader = ConnectionUserPerReader.getInstance();
   List<ConnectionBean> cons = perReader.forceReadConnections();
   if (cons.isEmpty()) { // if have exited some connections, don't add default connection.
     cons = new ArrayList<ConnectionBean>();
     ConnectionBean bean = ConnectionBean.getDefaultConnectionBean();
     bean.setUser(email);
     cons.add(bean);
     perReader.saveConnections(cons);
   }
 }
コード例 #2
0
  private void showHideTexts() {
    if (passwordText != null && !passwordText.isDisposed()) {
      boolean enablePasswordField = false;
      if (connection != null) {
        IRepositoryFactory factory =
            RepositoryFactoryProvider.getRepositoriyById(connection.getRepositoryId());
        if (factory != null && factory.isAuthenticationNeeded()) {
          enablePasswordField = true;
        }
      } else if (getRepository() != null
          && RepositoryConstants.REPOSITORY_REMOTE_ID.equals(getRepository().getId())) {
        enablePasswordField = true;
      }

      if (enablePasswordField) {
        passwordText.setBackground(LoginDialogV2.WHITE_COLOR);
      } else {
        passwordText.setText(""); // $NON-NLS-1$
        passwordText.setBackground(LoginDialogV2.GREY_COLOR);
      }
      passwordText.setEnabled(enablePasswordField);
      passwordText.setEditable(enablePasswordField);

      hideControl(passwordText, !enablePasswordField, false);
      hideControl(passwordLabel, !enablePasswordField, false);

      passwordText.getParent().layout();
    }
  }
コード例 #3
0
  private void fillBean() {
    if (connection != null) {
      if (getRepository() != null) {
        connection.setRepositoryId(getRepository().getId());

        Map<String, String> connFields = new HashMap<String, String>();

        Map<String, LabelText> map = dynamicControls.get(getRepository());
        for (String fieldKey : map.keySet()) {
          connFields.put(fieldKey, map.get(fieldKey).getText());
        }

        Map<String, LabelledCombo> map2 = dynamicChoices.get(getRepository());
        for (String fieldKey : map2.keySet()) {
          for (DynamicChoiceBean dynamicChoiceBean : getRepository().getChoices()) {
            if (dynamicChoiceBean.getId().equals(fieldKey)) {
              int selectionIndex = map2.get(fieldKey).getCombo().getSelectionIndex();
              connFields.put(fieldKey, dynamicChoiceBean.getChoiceValue(selectionIndex));
            }
          }
        }

        connection.setDynamicFields(connFields);
      }
      connection.setName(nameText.getText());
      connection.setDescription(descriptionText.getText());
      connection.setUser(userText.getText());
      connection.setPassword(passwordText.getText());

      connectionsListComposite.refresh(connection);
    }
  }
コード例 #4
0
 private void showHideTexts() {
   if (connection != null) {
     IRepositoryFactory factory =
         RepositoryFactoryProvider.getRepositoriyById(connection.getRepositoryId());
     if (factory != null) {
       boolean authenticationNeeded = factory.isAuthenticationNeeded();
       if (authenticationNeeded) {
         passwordText.setEnabled(true);
         passwordText.setEditable(true);
         passwordText.setBackground(LoginComposite.WHITE_COLOR);
       } else {
         passwordText.setText(""); // $NON-NLS-1$
         passwordText.setEnabled(false);
         passwordText.setEditable(false);
         passwordText.setBackground(LoginComposite.GREY_COLOR);
       }
     }
   }
 }
コード例 #5
0
  private void fillFields() {
    if (connection != null) {
      removeListeners();
      String repositoryId = connection.getRepositoryId();
      if (repositoryId == null || "".equals(repositoryId)) {
        if (getRepository() != null) {
          connection.setRepositoryId(getRepository().getId());
        } else {
          connection.setRepositoryId(RepositoryConstants.REPOSITORY_LOCAL_ID);
        }
      }
      IRepositoryFactory repositoriyById =
          RepositoryFactoryProvider.getRepositoriyById(repositoryId);
      repositoryCombo.setSelection(new StructuredSelection(new Object[] {repositoriyById}));

      if (getRepository() != null) {
        Map<String, LabelText> map = dynamicControls.get(getRepository());

        for (String fieldKey : map.keySet()) {
          LabelText current = map.get(fieldKey);
          String string = connection.getDynamicFields().get(fieldKey);
          current.setText(string == null ? "" : string); // $NON-NLS-1$
        }

        Map<String, LabelledCombo> map2 = dynamicChoices.get(getRepository());
        for (String fieldKey : map2.keySet()) {
          Combo combo = map2.get(fieldKey).getCombo();
          String value = connection.getDynamicFields().get(fieldKey);
          combo.deselectAll();
          for (DynamicChoiceBean dynamicChoiceBean : getRepository().getChoices()) {
            if (dynamicChoiceBean.getId().equals(fieldKey)) {
              combo.select(dynamicChoiceBean.getChoiceIndex(value));
            }
          }
        }
      }
      nameText.setText((connection.getName() == null ? "" : connection.getName())); // $NON-NLS-1$
      descriptionText.setText(
          (connection.getDescription() == null ? "" : connection.getDescription())); // $NON-NLS-1$
      userText.setText((connection.getUser() == null ? "" : connection.getUser())); // $NON-NLS-1$
      passwordText.setText(
          (connection.getPassword() == null ? "" : connection.getPassword())); // $NON-NLS-1$
      workSpaceText.setText(
          ("".equals(connection.getWorkSpace()) || connection.getWorkSpace() == null)
              ? getRecentWorkSpace()
              : connection.getWorkSpace()); // $NON-NLS-1$
      addListeners();
    }
  }
コード例 #6
0
  private boolean validateFields() {
    String errorMsg = null;
    boolean valid = true;
    if (dialog.getOKButton() != null) {
      dialog.getOKButton().setEnabled(true);
    }
    IBrandingService brandingService =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean isOnlyRemoteConnection =
        brandingService.getBrandingConfiguration().isOnlyRemoteConnection();
    boolean usesMailCheck = brandingService.getBrandingConfiguration().isUseMailLoginCheck();
    LabelText emptyUrl = null;
    if (getRepository() != null) {
      for (LabelText currentUrlLabel : dynamicRequiredControls.get(getRepository()).values()) {
        if (valid && currentUrlLabel.getText().length() == 0) {
          emptyUrl = currentUrlLabel;
        }
      }
    }
    if (valid && getRepository() == null) {
      errorMsg = Messages.getString("connections.form.emptyField.repository"); // $NON-NLS-1$
    } else if (valid && getTextName().length() == 0) {
      errorMsg = Messages.getString("connections.form.emptyField.connname"); // $NON-NLS-1$
    } else if (valid && getUser().length() == 0) {
      errorMsg = Messages.getString("connections.form.emptyField.username"); // $NON-NLS-1$
    } else if (valid
        && usesMailCheck
        && !Pattern.matches(RepositoryConstants.MAIL_PATTERN, getUser())) {
      errorMsg = Messages.getString("connections.form.malformedField.username"); // $NON-NLS-1$
    } else if (valid && emptyUrl != null) {
      errorMsg =
          Messages.getString(
              "connections.form.dynamicFieldEmpty", emptyUrl.getLabel()); // $NON-NLS-1$
    } else if (valid && !this.isValidatedWorkspace(this.getWorkspace())) {
      errorMsg = Messages.getString("ConnectionFormComposite.workspaceInvalid"); // $NON-NLS-1$
    } else if (valid && isOnlyRemoteConnection) {
      // Uniserv feature 8,Add new Extension point to allow Uniserv to add some custom controls
      // during TAC
      // connection check
      List<ILoginConnectionService> loginConnections =
          LoginConnectionManager.getRemoteConnectionService();
      for (ILoginConnectionService loginConncetion : loginConnections) {
        errorMsg =
            loginConncetion.checkConnectionValidation(
                getTextName(),
                getDesc(),
                getUser(),
                getPassword(),
                getWorkspace(),
                connection.getDynamicFields().get(RepositoryConstants.REPOSITORY_URL));
      }
    } else if (valid && getTextName() != null) {
      List<ConnectionBean> connectionBeanList = dialog.getConnections();
      if (connectionBeanList != null && connectionBeanList.size() > 1) {
        for (ConnectionBean connectionBean : connectionBeanList) {
          String connectionBeanName = connectionBean.getName();
          if (connectionBeanName != null) {
            if (this.connection != connectionBean) {
              if (connectionBeanName.equals(getTextName())) {
                errorMsg =
                    Messages.getString(
                        "ConnectionFormComposite.connectionNameInvalid"); //$NON-NLS-1$
              }
            }
          }
        }
      }
    }
    if (errorMsg != null && !errorMsg.equals("")) { // $NON-NLS-1$
      valid = false;
    }
    if (!valid) {
      dialog.setErrorMessage(errorMsg);
      if (dialog.getOKButton() != null) {
        dialog.getOKButton().setEnabled(false);
      }
    } else {
      dialog.setErrorMessage(null);
    }

    if (connection != null) {
      connection.setComplete(valid);
      connectionsListComposite.refresh(connection);
    }
    return valid;
  }