public EditRoutineAction() {
    super();

    setText(Messages.getString("EditRoutineAction.text.editRoutine")); // $NON-NLS-1$
    setToolTipText(Messages.getString("EditRoutineAction.toolTipText.editRoutine")); // $NON-NLS-1$
    setImageDescriptor(ImageProvider.getImageDesc(ECoreImage.ROUTINE_ICON));
  }
  /** Constructs a new OpenDocumentationAction. */
  public OpenDocumentationAction() {
    super();

    setText(Messages.getString("OpenDocumentationAction.openDocAction.openDoc")); // $NON-NLS-1$
    setToolTipText(
        Messages.getString("OpenDocumentationAction.openDocAcitonTipText.openDoc")); // $NON-NLS-1$
    setImageDescriptor(ImageProvider.getImageDesc(ECoreImage.DOCUMENTATION_ICON));
  }
  /** Constructs a new ExtractDocumentationAction. */
  public ExtractDocumentationAction() {
    super();

    setText(Messages.getString("ExtractDocumentationAction.text.saveAs")); // $NON-NLS-1$
    setToolTipText(
        Messages.getString(
            "ExtractDocumentationAction.toolTipText.extractDoctoFileSys")); //$NON-NLS-1$
    setImageDescriptor(ImageProvider.getImageDesc(ECoreImage.DOCUMENTATION_ICON));
  }
  public void createControl(Composite parent) {
    setControl(parent);
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    container.setLayout(new GridLayout(1, false));

    Group destinationGroup = new Group(container, SWT.NONE);
    destinationGroup.setLayoutData(
        new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
    destinationGroup.setText("Destination");
    destinationGroup.setLayout(new GridLayout(2, false));

    destinationText = new Text(destinationGroup, SWT.SINGLE | SWT.BORDER);
    destinationText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    destinationText.setText(getDestinationValue());
    destinationText.addModifyListener(
        new ModifyListener() {

          public void modifyText(ModifyEvent e) {
            destinationValue = destinationText.getText();
            checkDestination(destinationValue);
          }
        });
    Button browseButton = new Button(destinationGroup, SWT.PUSH);
    browseButton.setText("Browse");
    browseButton.addSelectionListener(
        new SelectionListener() {

          public void widgetSelected(SelectionEvent e) {
            handleDestinationBrowseButtonPressed();
            destinationText.setText(destinationValue);
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            ;
          }
        });
    Group optionsGroup = new Group(container, SWT.NONE);
    GridData layoutData = new GridData(GridData.FILL_BOTH);
    optionsGroup.setLayoutData(layoutData);
    GridLayout layout = new GridLayout();
    optionsGroup.setLayout(layout);

    // optionsGroup.setText(IDEWorkbenchMessages.WizardExportPage_options);
    optionsGroup.setText(
        org.talend.repository.i18n.Messages.getString(
            "IDEWorkbenchMessages.WizardExportPage_options")); //$NON-NLS-1$
    optionsGroup.setFont(parent.getFont());

    createBSGroup(optionsGroup);
  }
  public static void importArchiveProject(
      Shell shell, String technicalName, String sourcePath, IProgressMonitor monitor)
      throws InvocationTargetException, InterruptedException, TarException, IOException {

    IImportStructureProvider provider;
    Object source;

    if (ArchiveFileManipulations.isZipFile(sourcePath)) {
      ZipLeveledStructureProvider zipProvider =
          new ZipLeveledStructureProvider(new ZipFile(sourcePath));
      source = zipProvider.getRoot();
      boolean ok = true;
      for (Object o : zipProvider.getChildren(source)) {
        String label = zipProvider.getLabel(o);
        if (!label.equals(IProjectDescription.DESCRIPTION_FILE_NAME) && ok) {
          source = o;
        } else {
          ok = false;
        }
      }
      if (!ok) {
        source = zipProvider.getRoot();
      }

      provider = zipProvider;
    } else if (ArchiveFileManipulations.isTarFile(sourcePath)) {
      TarLeveledStructureProvider tarProvider =
          new TarLeveledStructureProvider(new TarFile(sourcePath));
      source = tarProvider.getRoot();
      boolean ok = true;
      for (Object o : tarProvider.getChildren(source)) {
        String label = tarProvider.getLabel(o);
        if (!label.equals(IProjectDescription.DESCRIPTION_FILE_NAME) && ok) {
          source = o;
        } else {
          ok = false;
        }
      }
      if (!ok) {
        source = tarProvider.getRoot();
      }

      provider = tarProvider;
    } else {
      throw new IllegalArgumentException(
          Messages.getString("ImportProjectsUtilities.fileFormatError", sourcePath)); // $NON-NLS-1$
    }

    importProject(shell, provider, source, new Path(technicalName), false, false, monitor);
  }
  private static void importProject(
      Shell shell,
      IImportStructureProvider provider,
      Object source,
      IPath path,
      boolean overwriteResources,
      boolean createContainerStructure,
      IProgressMonitor monitor)
      throws InvocationTargetException, InterruptedException {
    monitor.beginTask(
        Messages.getString("ImportProjectsUtilities.task.importingProject"), 1); // $NON-NLS-1$

    ArrayList fileSystemObjects = new ArrayList();
    ImportProjectsUtilities.getFilesForProject(fileSystemObjects, provider, source);

    ImportOperation operation =
        new ImportOperation(path, source, provider, new MyOverwriteQuery(), fileSystemObjects);
    operation.setContext(shell);
    operation.setOverwriteResources(overwriteResources);
    operation.setCreateContainerStructure(createContainerStructure);
    operation.run(new SubProgressMonitor(monitor, 1));
    monitor.done();
  }
 /**
  * Collect the list of .project files that are under directory into files. <br>
  * Method almost as taken in
  * org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage. Modifications are:
  *
  * <ol>
  *   <li>no recusrive search
  *   <li>add searchFileName as parameter
  *   <li>checks if monitor is null
  * </ol>
  *
  * @param files
  * @param directory
  * @param monitor The monitor to report to
  * @param searchFileName
  * @return boolean <code>true</code> if the operation was completed.
  */
 public static boolean collectProjectFilesFromDirectory(
     Collection files, File directory, IProgressMonitor monitor, String searchFileName) {
   if (monitor != null && monitor.isCanceled()) {
     return false;
   }
   if (monitor != null) {
     monitor.subTask(
         Messages.getString(
             "ImportProjectsUtilities.task.checkingFolder", directory.getPath())); // $NON-NLS-1$
   }
   File[] contents = directory.listFiles();
   // first look for project description files
   for (int i = 0; i < contents.length; i++) {
     File file = contents[i];
     if (file.isFile() && file.getName().equals(searchFileName)) {
       files.add(file);
       // don't search sub-directories since we can't have nested
       // projects
       return true;
     }
   }
   return true;
 }
  /**
   * Collect the list of .project files that are under directory into files. <br>
   * Method almost as taken in
   * org.eclipse.ui.internal.wizards.datatransfer.WizardProjectsImportPage. Modifications are:
   *
   * <ol>
   *   <li>no recusrive search
   *   <li>add searchFileName as parameter
   *   <li>checks if monitor is null
   * </ol>
   *
   * @param files
   * @param monitor The monitor to report to
   * @return boolean <code>true</code> if the operation was completed.
   */
  public static boolean collectProjectFilesFromProvider(
      Collection files,
      IImportStructureProvider provider,
      Object entry,
      int level,
      IProgressMonitor monitor,
      String searchFileName) {

    if (monitor != null && monitor.isCanceled()) {
      return false;
    }
    if (monitor != null) {
      monitor.subTask(
          Messages.getString(
              "ImportProjectsUtilities.task.checkingFolder",
              provider.getLabel(entry))); // $NON-NLS-1$
    }
    List children = provider.getChildren(entry);
    if (children == null) {
      children = new ArrayList(1);
    }
    Iterator childrenEnum = children.iterator();
    while (childrenEnum.hasNext()) {
      Object child = childrenEnum.next();
      if (level < 1) {
        if (provider.isFolder(child)) {
          collectProjectFilesFromProvider(
              files, provider, child, level + 1, monitor, searchFileName);
        }
      }
      String elementLabel = provider.getLabel(child);
      if (elementLabel.equals(searchFileName)) {
        files.add(elementLabel);
      }
    }
    return true;
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);

    GridLayout layout = new GridLayout(2, false);
    container.setLayout(layout);

    // Name
    Label nameLab = new Label(container, SWT.NONE);
    nameLab.setText(Messages.getString("NewProjectWizardPage.name")); // $NON-NLS-1$

    nameText = new Text(container, SWT.BORDER);
    nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // TechnicalName (for information only)
    Label technicalNameLab = new Label(container, SWT.NONE);
    technicalNameLab.setText(
        Messages.getString("NewProjectWizardPage.technicalName")); // $NON-NLS-1$

    technicalNameText = new Text(container, SWT.BORDER);
    technicalNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    technicalNameText.setEnabled(false);

    // Description
    Label descriptionLab = new Label(container, SWT.NONE);
    descriptionLab.setText(Messages.getString("NewProjectWizardPage.comment")); // $NON-NLS-1$
    descriptionLab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    descriptionText = new Text(container, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = 60;
    descriptionText.setLayoutData(data);

    // Language
    Label languageLab = new Label(container, SWT.NONE);
    languageLab.setText(Messages.getString("NewProjectWizardPage.language")); // $NON-NLS-1$
    languageLab.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));

    Composite radioContainer = new Composite(container, SWT.NONE);
    radioContainer.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL + GridData.VERTICAL_ALIGN_BEGINNING));
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = 0;
    radioContainer.setLayout(gridLayout);

    languageJavaRadio = new Button(radioContainer, SWT.RADIO);
    languageJavaRadio.setText(ECodeLanguage.JAVA.getName());
    languageJavaRadio.setSelection(true);

    languagePerlRadio = new Button(radioContainer, SWT.RADIO);
    languagePerlRadio.setText(ECodeLanguage.PERL.getName() + " (deprecated)");

    IBrandingService brandingService =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    String[] availableLanguages =
        brandingService.getBrandingConfiguration().getAvailableLanguages();
    if (availableLanguages.length != 2) {
      if (ArrayUtils.contains(availableLanguages, ECodeLanguage.JAVA.getName())) {
        languagePerlRadio.setVisible(false);
        languageJavaRadio.setVisible(false);
        languageJavaRadio.setSelection(true);
        languageLab.setVisible(false);
      }
      if (ArrayUtils.contains(availableLanguages, ECodeLanguage.PERL.getName())) {
        languagePerlRadio.setSelection(true);
        languageJavaRadio.setVisible(false);
        languageJavaRadio.setVisible(false);
        languageLab.setVisible(false);
      }
    }

    // languageCombo = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
    // languageCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // languageCombo.setItems(new String[] { ECodeLanguage.PERL.getName(),
    // ECodeLanguage.JAVA.getName() });
    // languageCombo.select(0);

    setControl(container);
    addListeners();
    setPageComplete(false);
  }
 protected String getHeadTitle() {
   return Messages.getString("AbstractScriptPreferencePage_scriptTitle"); // $NON-NLS-1$
 }
  /** DOC ocarbone Comment method "checkField". */
  protected void checkFieldsValue() {
    // Field Name
    if (nameText.getText().length() == 0) {
      nameStatus =
          new Status(
              IStatus.ERROR,
              RepositoryPlugin.PLUGIN_ID,
              IStatus.OK,
              Messages.getString("NewProjectWizardPage.nameEmpty"),
              null); //$NON-NLS-1$
    } else {
      // for bug 11214
      if (!nameText.getText().endsWith(" ")) { // $NON-NLS-1$
        technicalNameText.setText(Project.createTechnicalName(nameText.getText()));
      }
      if (ProjectUtils.isNotValidProjectName(nameText.getText())) { // $NON-NLS-1$
        nameStatus =
            new Status(
                IStatus.ERROR,
                RepositoryPlugin.PLUGIN_ID,
                IStatus.OK,
                Messages.getString("NewProjectWizardPage.illegalCharacter"),
                null); //$NON-NLS-1$
      } else {

        if (isProjectNameAlreadyUsed(nameText.getText())) {
          nameStatus =
              new Status(
                  IStatus.ERROR,
                  RepositoryPlugin.PLUGIN_ID,
                  IStatus.OK,
                  Messages.getString("NewProjectWizardPage.projectNameAlredyExists"),
                  null); //$NON-NLS-1$
        } else {
          nameStatus = createOkStatus();

          // Field description
          descriptionStatus = createOkStatus();

          // Combo language
          if (!languageJavaRadio.getSelection() && !languagePerlRadio.getSelection()) {
            languageStatus =
                new Status(
                    IStatus.ERROR,
                    RepositoryPlugin.PLUGIN_ID,
                    IStatus.OK,
                    Messages.getString("NewProjectWizardPage.languageEmpty"), // $NON-NLS-1$
                    null);
          } else if (!languageEnable(getLanguage())) {
            languageStatus =
                new Status(
                    IStatus.ERROR,
                    RepositoryPlugin.PLUGIN_ID,
                    IStatus.WARNING,
                    Messages.getString(
                        "NewProjectWizard.error.languageNotSupported",
                        getLanguage()), //$NON-NLS-1$
                    null);
          } else {
            languageStatus = createOkStatus();
          }
        }
      }
    }
    updatePageStatus();
  }
  /**
   * DOC Administrator NewImportProjectWizardPage constructor comment.
   *
   * @param pageName
   */
  protected NewImportProjectWizardPage() {
    super("WizardPage"); // $NON-NLS-1$

    setTitle(Messages.getString("NewProjectWizardPage.title2")); // $NON-NLS-1$
    setDescription(Messages.getString("NewProjectWizardPage.description"));
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.action.Action#run()
   */
  protected void doRun() {
    RepositoryNode node =
        (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();

    final Item item = node.getObject().getProperty().getItem();
    if (item == null) {
      return;
    }
    String initialFileName = null;
    String initialExtension = null;
    if (item instanceof DocumentationItem) {
      DocumentationItem documentationItem = (DocumentationItem) item;
      initialFileName = documentationItem.getName();
      if (documentationItem.getExtension() != null) {
        initialExtension = documentationItem.getExtension();
      }
    } else if (item instanceof LinkDocumentationItem) { // link documenation
      LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;

      if (!LinkUtils.validateLink(linkDocItem.getLink())) {
        MessageDialog.openError(
            Display.getCurrent().getActiveShell(),
            Messages.getString("ExtractDocumentationAction.fileErrorTitle"), // $NON-NLS-1$
            Messages.getString("ExtractDocumentationAction.fileErrorMessages")); // $NON-NLS-1$
        return;
      }

      initialFileName = linkDocItem.getName();
      if (linkDocItem.getExtension() != null) {
        initialExtension = linkDocItem.getExtension();
      }
    }
    if (initialFileName != null) {
      FileDialog fileDlg = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);

      if (initialExtension != null) {
        initialFileName = initialFileName + LinkUtils.DOT + initialExtension; // $NON-NLS-1$
        fileDlg.setFilterExtensions(
            new String[] {"*." + initialExtension, "*.*"}); // $NON-NLS-1$ //$NON-NLS-2$
      }
      fileDlg.setFileName(initialFileName);
      String filename = fileDlg.open();
      if (filename != null) {
        final File file = new File(filename);

        ProgressDialog progressDialog =
            new ProgressDialog(Display.getCurrent().getActiveShell()) {

              @Override
              public void run(IProgressMonitor monitor)
                  throws InvocationTargetException, InterruptedException {
                try {
                  if (item instanceof DocumentationItem) {
                    DocumentationItem documentationItem = (DocumentationItem) item;
                    documentationItem.getContent().setInnerContentToFile(file);
                  } else if (item instanceof LinkDocumentationItem) { // link documenation
                    LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
                    ByteArray byteArray = LinkDocumentationHelper.getLinkItemContent(linkDocItem);
                    if (byteArray != null) {
                      byteArray.setInnerContentToFile(file);
                    }
                  }

                } catch (IOException ioe) {
                  MessageBoxExceptionHandler.process(ioe);
                }
              }
            };
        try {
          progressDialog.executeProcess();
        } catch (InvocationTargetException e) {
          ExceptionHandler.process(e);
        } catch (InterruptedException e) {
          // Nothing to do
        }
      }
    }
  }
 private void showErrorMessage() {
   MessageDialog.openError(
       Display.getCurrent().getActiveShell(),
       Messages.getString("ExtractDocumentationAction.fileErrorTitle"), // $NON-NLS-1$
       Messages.getString("ExtractDocumentationAction.fileErrorMessages")); // $NON-NLS-1$
 }
  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;
  }
  /**
   * DOC smallet ConnectionsComposite constructor comment.
   *
   * @param parent
   * @param style
   */
  public ConnectionFormComposite(
      Composite parent,
      int style,
      ConnectionsListComposite connectionsListComposite,
      ConnectionsDialog dialog) {
    super(parent, style);
    this.dialog = dialog;
    this.connectionsListComposite = connectionsListComposite;

    toolkit = new FormToolkit(this.getDisplay());
    toolkit.setBackground(ColorConstants.white);
    Composite formBody = toolkit.createComposite(this);
    formBody.setBackground(ColorConstants.white);

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    setLayout(layout);
    formBody.setLayoutData(new GridData(GridData.FILL_BOTH));

    formBody.setLayout(new GridLayout(3, false));
    GridDataFactory formDefaultFactory = GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER);
    // Repository
    Label repositoryLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.repository")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(repositoryLabel);

    repositoryCombo = new ComboViewer(formBody, SWT.BORDER | SWT.READ_ONLY);
    repositoryCombo.setContentProvider(ArrayContentProvider.getInstance());
    repositoryCombo.setLabelProvider(new RepositoryFactoryLabelProvider());
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(repositoryCombo.getControl());

    // Name
    Label nameLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.name")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(nameLabel);

    nameText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(nameText);

    // Comment
    Label descriptionLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.description")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(descriptionLabel);

    descriptionText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(descriptionText);

    // User
    IBrandingService brandingService =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean usesMailCheck = brandingService.getBrandingConfiguration().isUseMailLoginCheck();
    Label userLabel;
    if (usesMailCheck) {
      userLabel =
          toolkit.createLabel(
              formBody, Messages.getString("connections.form.field.username")); // $NON-NLS-1$
    } else {
      userLabel =
          toolkit.createLabel(
              formBody, Messages.getString("connections.form.field.usernameNoMail")); // $NON-NLS-1$
    }

    formDefaultFactory.copy().applyTo(userLabel);

    userText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(userText);

    // Password
    passwordLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.password")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(passwordLabel);

    passwordText = toolkit.createText(formBody, "", SWT.PASSWORD | SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(passwordText);

    Label workSpaceLabel =
        toolkit.createLabel(
            formBody, Messages.getString("ConnectionFormComposite.WORKSPACE")); // $NON-NLS-1$
    formDefaultFactory.copy().applyTo(workSpaceLabel);

    Composite wsCompo = toolkit.createComposite(formBody);
    GridLayout wsCompoLayout = new GridLayout(2, false);
    wsCompoLayout.marginHeight = 0;
    wsCompoLayout.marginWidth = 0;

    wsCompo.setLayout(wsCompoLayout);
    formDefaultFactory.copy().grab(true, false).span(2, 1).applyTo(wsCompo);

    workSpaceText = toolkit.createText(wsCompo, "", SWT.BORDER); // $NON-NLS-1$
    formDefaultFactory.copy().grab(true, false).applyTo(workSpaceText);

    workSpaceButton = toolkit.createButton(wsCompo, null, SWT.PUSH);
    workSpaceButton.setToolTipText(
        Messages.getString("ConnectionFormComposite.SELECT_WORKSPACE")); // $NON-NLS-1$
    workSpaceButton.setImage(ImageProvider.getImage(EImage.THREE_DOTS_ICON));
    GridDataFactory.fillDefaults().applyTo(workSpaceButton);

    List<IRepositoryFactory> availableRepositories = getUsableRepositoryProvider();
    for (IRepositoryFactory current : availableRepositories) {
      Map<String, LabelText> list = new HashMap<String, LabelText>();
      Map<String, LabelText> listRequired = new HashMap<String, LabelText>();
      Map<String, Button> listButtons = new HashMap<String, Button>();
      Map<String, LabelledCombo> listChoices = new HashMap<String, LabelledCombo>();
      dynamicControls.put(current, list);
      dynamicRequiredControls.put(current, listRequired);
      dynamicButtons.put(current, listButtons);
      dynamicChoices.put(current, listChoices);

      for (final DynamicChoiceBean currentChoiceBean : current.getChoices()) {
        Label label = toolkit.createLabel(formBody, currentChoiceBean.getName());
        formDefaultFactory.copy().applyTo(label);

        Combo combo = new Combo(formBody, SWT.BORDER | SWT.READ_ONLY);
        for (String label1 : currentChoiceBean.getChoices().values()) {
          combo.add(label1);
        }

        formDefaultFactory.copy().grab(true, false).applyTo(combo);

        listChoices.put(currentChoiceBean.getId(), new LabelledCombo(label, combo));
      }

      for (DynamicFieldBean currentField : current.getFields()) {
        int textStyle = SWT.BORDER;
        if (currentField.isPassword()) {
          textStyle = textStyle | SWT.PASSWORD;
        }
        Label label = toolkit.createLabel(formBody, currentField.getName());
        formDefaultFactory.copy().align(SWT.FILL, SWT.CENTER).applyTo(label);

        Text text = toolkit.createText(formBody, "", textStyle); // $NON-NLS-1$

        formDefaultFactory.copy().grab(true, false).align(SWT.FILL, SWT.CENTER).applyTo(text);
        LabelText labelText = new LabelText(label, text);
        if (currentField.isRequired()) {
          listRequired.put(currentField.getId(), labelText);
        }
        list.put(currentField.getId(), labelText);
      }

      for (final DynamicButtonBean currentButtonBean : current.getButtons()) {
        Button button = new Button(formBody, SWT.PUSH);
        button.setText(currentButtonBean.getName());
        button.addSelectionListener(new DelegateSelectionListener(currentButtonBean));
        formDefaultFactory.copy().align(SWT.RIGHT, SWT.CENTER).applyTo(button);

        listButtons.put(currentButtonBean.getId(), button);
      }
    }

    Label seperator = new Label(formBody, SWT.NONE);
    seperator.setVisible(false);
    GridData seperatorGridData = new GridData();
    seperatorGridData.horizontalSpan = 3;
    seperatorGridData.heightHint = 0;
    seperator.setLayoutData(seperatorGridData);
    Label placeHolder = new Label(formBody, SWT.NONE);
    // add delete buttons
    deleteProjectsButton = new Button(formBody, SWT.NONE);
    deleteProjectsButton.setText(
        Messages.getString("ConnectionFormComposite.deleteExistingProject")); // $NON-NLS-1$
    GridData deleteButtonGridData = new GridData();
    deleteButtonGridData.widthHint = LoginDialogV2.getNewButtonSize(deleteProjectsButton).x;
    deleteButtonGridData.horizontalSpan = 2;
    deleteProjectsButton.setLayoutData(deleteButtonGridData);

    addListeners();
    addWorkSpaceListener();
    fillLists();
    showHideDynamicsControls();
    showHideTexts();
    // validateFields();
  }
  /**
   * DOC smallet ConnectionsComposite constructor comment.
   *
   * @param parent
   * @param style
   */
  public ConnectionFormComposite(
      Composite parent,
      int style,
      ConnectionsListComposite connectionsListComposite,
      ConnectionsDialog dialog) {
    super(parent, style);
    this.dialog = dialog;
    this.connectionsListComposite = connectionsListComposite;

    toolkit = new FormToolkit(this.getDisplay());
    ScrolledForm form = toolkit.createScrolledForm(this);
    Composite formBody = form.getBody();

    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    setLayout(layout);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));

    final int hSpan = 10;

    formBody.setLayout(new GridLayout(2, false));

    // Repository
    Label repositoryLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.repository")); // $NON-NLS-1$
    GridDataFactory.fillDefaults().applyTo(repositoryLabel);

    repositoryCombo = new ComboViewer(formBody, SWT.BORDER | SWT.READ_ONLY);
    repositoryCombo.setContentProvider(new ArrayContentProvider());
    repositoryCombo.setLabelProvider(new RepositoryFactoryLabelProvider());
    GridDataFactory.fillDefaults().grab(true, false).applyTo(repositoryCombo.getControl());

    // Name
    Label nameLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.name")); // $NON-NLS-1$
    GridDataFactory.fillDefaults().applyTo(nameLabel);

    nameText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText);

    // Comment
    Label descriptionLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.description")); // $NON-NLS-1$
    GridDataFactory.fillDefaults().applyTo(descriptionLabel);

    descriptionText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    GridDataFactory.fillDefaults().grab(true, false).applyTo(descriptionText);

    // User
    IBrandingService brandingService =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    boolean usesMailCheck = brandingService.getBrandingConfiguration().isUseMailLoginCheck();
    Label userLabel;
    if (usesMailCheck) {
      userLabel =
          toolkit.createLabel(
              formBody, Messages.getString("connections.form.field.username")); // $NON-NLS-1$
    } else {
      userLabel =
          toolkit.createLabel(
              formBody, Messages.getString("connections.form.field.usernameNoMail")); // $NON-NLS-1$
    }

    GridDataFactory.fillDefaults().applyTo(userLabel);

    userText = toolkit.createText(formBody, "", SWT.BORDER); // $NON-NLS-1$
    GridDataFactory.fillDefaults().grab(true, false).applyTo(userText);

    // Password
    Label passwordLabel =
        toolkit.createLabel(
            formBody, Messages.getString("connections.form.field.password")); // $NON-NLS-1$
    GridDataFactory.fillDefaults().applyTo(passwordLabel);

    passwordText = toolkit.createText(formBody, "", SWT.PASSWORD | SWT.BORDER); // $NON-NLS-1$
    GridDataFactory.fillDefaults().grab(true, false).applyTo(passwordText);

    GridData data;
    List<IRepositoryFactory> availableRepositories = getUsableRepositoryProvider();
    for (IRepositoryFactory current : availableRepositories) {
      Map<String, LabelText> list = new HashMap<String, LabelText>();
      Map<String, LabelText> listRequired = new HashMap<String, LabelText>();
      Map<String, Button> listButtons = new HashMap<String, Button>();
      Map<String, LabelledCombo> listChoices = new HashMap<String, LabelledCombo>();
      dynamicControls.put(current, list);
      dynamicRequiredControls.put(current, listRequired);
      dynamicButtons.put(current, listButtons);
      dynamicChoices.put(current, listChoices);
      Control baseControl = passwordLabel;

      for (final DynamicChoiceBean currentChoiceBean : current.getChoices()) {
        Label label = toolkit.createLabel(formBody, currentChoiceBean.getName());
        GridDataFactory.fillDefaults().applyTo(label);

        Combo combo = new Combo(formBody, SWT.BORDER | SWT.READ_ONLY);
        for (String label1 : currentChoiceBean.getChoices().values()) {
          combo.add(label1);
        }

        GridDataFactory.fillDefaults().grab(true, false).applyTo(combo);

        baseControl = combo;

        listChoices.put(currentChoiceBean.getId(), new LabelledCombo(label, combo));
      }

      for (DynamicFieldBean currentField : current.getFields()) {
        int textStyle = SWT.BORDER;
        if (currentField.isPassword()) {
          textStyle = textStyle | SWT.PASSWORD;
        }
        Label label = toolkit.createLabel(formBody, currentField.getName());
        GridDataFactory.fillDefaults().applyTo(label);

        Text text = toolkit.createText(formBody, "", textStyle); // $NON-NLS-1$

        GridDataFactory.fillDefaults().grab(true, false).applyTo(text);
        baseControl = text;

        LabelText labelText = new LabelText(label, text);
        if (currentField.isRequired()) {
          listRequired.put(currentField.getId(), labelText);
        }
        list.put(currentField.getId(), labelText);
      }

      for (final DynamicButtonBean currentButtonBean : current.getButtons()) {
        Label label = toolkit.createLabel(formBody, ""); // $NON-NLS-1$
        label.setVisible(false);
        GridDataFactory.fillDefaults().applyTo(label);
        Button button = new Button(formBody, SWT.PUSH);
        button.setText(currentButtonBean.getName());
        button.addSelectionListener(new DelegateSelectionListener(currentButtonBean));
        GridDataFactory.fillDefaults().grab(true, false).applyTo(button);

        baseControl = button;

        listButtons.put(currentButtonBean.getId(), button);
      }
    }

    addListeners();
    fillLists();
    showHideDynamicsControls();
    showHideTexts();
    // validateFields();
  }