Пример #1
0
  protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    Composite inner = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 1;
    inner.setLayout(layout);

    int widthHint = convertWidthInCharsToPixels(50);

    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.widthHint = widthHint;

    if (fExistingFolders.contains(fCurrProject)) {
      fContainerDialogField.doFillIntoGrid(inner, 2);
    } else {
      fUseProjectButton.doFillIntoGrid(inner, 1);
      fUseFolderButton.doFillIntoGrid(inner, 1);
      fContainerDialogField.getTextControl(inner);

      int horizontalIndent = convertWidthInCharsToPixels(3);
      data.horizontalIndent = horizontalIndent;
    }
    Text text = fContainerDialogField.getTextControl(null);
    text.setLayoutData(data);
    TextFieldNavigationHandler.install(text);

    fContainerDialogField.postSetFocusOnDialogField(parent.getDisplay());
    applyDialogFont(composite);
    return composite;
  }
Пример #2
0
  protected void checkIfPathValid() {
    fFolder = null;
    IContainer folder = null;
    if (fUseFolderButton.isSelected()) {
      String pathStr = fContainerDialogField.getText();
      if (pathStr.length() == 0) {
        fContainerFieldStatus.setError(NewWizardMessages.NewSourceFolderDialog_error_enterpath);
        return;
      }
      IPath path = fCurrProject.getFullPath().append(pathStr);
      IWorkspace workspace = fCurrProject.getWorkspace();

      IStatus pathValidation = workspace.validatePath(path.toString(), IResource.FOLDER);
      if (!pathValidation.isOK()) {
        fContainerFieldStatus.setError(
            Messages.format(
                NewWizardMessages.NewSourceFolderDialog_error_invalidpath,
                pathValidation.getMessage()));
        return;
      }
      folder = fCurrProject.getFolder(pathStr);
    } else {
      folder = fCurrProject;
    }
    if (isExisting(folder)) {
      fContainerFieldStatus.setError(NewWizardMessages.NewSourceFolderDialog_error_pathexists);
      return;
    }
    fContainerFieldStatus.setOK();
    fFolder = folder;
  }
Пример #3
0
  public NewSourceFolderDialog(
      Shell parent,
      String title,
      IProject project,
      List existingFolders,
      BPListElement entryToEdit) {
    super(parent);
    setTitle(title);

    fContainerFieldStatus = new StatusInfo();

    SourceContainerAdapter adapter = new SourceContainerAdapter();

    fUseProjectButton = new SelectionButtonDialogField(SWT.RADIO);
    fUseProjectButton.setLabelText(NewWizardMessages.NewSourceFolderDialog_useproject_button);
    fUseProjectButton.setDialogFieldListener(adapter);

    fUseFolderButton = new SelectionButtonDialogField(SWT.RADIO);
    fUseFolderButton.setLabelText(NewWizardMessages.NewSourceFolderDialog_usefolder_button);
    fUseFolderButton.setDialogFieldListener(adapter);

    fContainerDialogField = new StringDialogField();
    fContainerDialogField.setDialogFieldListener(adapter);
    fContainerDialogField.setLabelText(NewWizardMessages.NewSourceFolderDialog_sourcefolder_label);

    fUseFolderButton.attachDialogField(fContainerDialogField);

    fFolder = null;
    fExistingFolders = existingFolders;
    fCurrProject = project;

    boolean useFolders = true;
    if (entryToEdit == null) {
      fContainerDialogField.setText(""); // $NON-NLS-1$
    } else {
      IPath editPath = entryToEdit.getPath().removeFirstSegments(1);
      fContainerDialogField.setText(editPath.toString());
      useFolders = !editPath.isEmpty();
    }
    fUseFolderButton.setSelection(useFolders);
    fUseProjectButton.setSelection(!useFolders);
  }