/** Loads combo choices fromt he platform and from PDE core preferences */
  private void initializeChoices() {
    IEclipsePreferences node = new InstanceScope().getNode(PDECore.PLUGIN_ID);

    fOSChoices = new TreeSet<String>();
    String[] os = Platform.knownOSValues();
    for (int i = 0; i < os.length; i++) {
      fOSChoices.add(os[i]);
    }
    String pref = node.get(ICoreConstants.OS_EXTRA, EMPTY_STRING);
    if (!EMPTY_STRING.equals(pref)) {
      addExtraChoices(fOSChoices, pref);
    }

    fWSChoices = new TreeSet<String>();
    String[] ws = Platform.knownWSValues();
    for (int i = 0; i < ws.length; i++) {
      fWSChoices.add(ws[i]);
    }
    pref = node.get(ICoreConstants.WS_EXTRA, EMPTY_STRING);
    if (!EMPTY_STRING.equals(pref)) {
      addExtraChoices(fWSChoices, pref);
    }

    fArchChoices = new TreeSet<String>();
    String[] arch = Platform.knownOSArchValues();
    for (int i = 0; i < arch.length; i++) {
      fArchChoices.add(arch[i]);
    }
    pref = node.get(ICoreConstants.ARCH_EXTRA, EMPTY_STRING);
    if (!EMPTY_STRING.equals(pref)) {
      addExtraChoices(fArchChoices, pref);
    }

    fNLChoices = new TreeSet<String>();
    String[] nl = LocaleUtil.getLocales();
    for (int i = 0; i < nl.length; i++) {
      fNLChoices.add(nl[i]);
    }
    pref = node.get(ICoreConstants.NL_EXTRA, EMPTY_STRING);
    if (!EMPTY_STRING.equals(pref)) {
      addExtraChoices(fNLChoices, pref);
    }
  }
Пример #2
0
  public void createControl(Composite parent) {
    initializeDialogUnits(parent);
    final Composite composite = new Composite(parent, SWT.NULL);
    composite.setFont(parent.getFont());
    composite.setLayout(initGridLayout(new GridLayout(1, false), false));
    composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    // create UI elements
    fNameGroup = new NameGroup(composite, fInitialName, getShell());
    fPHPLocationGroup = new LocationGroup(composite, fNameGroup, getShell());

    CompositeData data = new CompositeData();
    data.setParetnt(composite);
    data.setSettings(getDialogSettings());
    data.setObserver(fPHPLocationGroup);
    fragment =
        (WizardFragment)
            Platform.getAdapterManager()
                .loadAdapter(data, PHPProjectWizardFirstPage.class.getName());

    fVersionGroup = new VersionGroup(composite);
    fLayoutGroup = new LayoutGroup(composite);
    fJavaScriptSupportGroup = new JavaScriptSupportGroup(composite, this);

    fDetectGroup = new DetectGroup(composite, fPHPLocationGroup, fNameGroup);

    // establish connections
    fNameGroup.addObserver(fPHPLocationGroup);
    fDetectGroup.addObserver(fLayoutGroup);

    fPHPLocationGroup.addObserver(fDetectGroup);
    // initialize all elements
    fNameGroup.notifyObservers();
    // create and connect validator
    fPdtValidator = new Validator();

    fNameGroup.addObserver(fPdtValidator);
    fPHPLocationGroup.addObserver(fPdtValidator);

    setControl(composite);
    Dialog.applyDialogFont(composite);

    // set the focus to the project name
    fNameGroup.postSetFocus();

    setHelpContext(composite);
  }
Пример #3
0
    public void update(Observable o, Object arg) {
      final IWorkspace workspace = DLTKUIPlugin.getWorkspace();
      final String name = fNameGroup.getName();
      // check whether the project name field is empty
      if (name.length() == 0) {
        setErrorMessage(null);
        setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterProjectName);
        setPageComplete(false);
        return;
      }
      // check whether the project name is valid
      final IStatus nameStatus = workspace.validateName(name, IResource.PROJECT);
      if (!nameStatus.isOK()) {
        setErrorMessage(nameStatus.getMessage());
        setPageComplete(false);
        return;
      }
      // check whether project already exists
      final IProject handle = getProjectHandle();

      if (!isInLocalServer()) {
        if (handle.exists()) {
          setErrorMessage(
              NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists);
          setPageComplete(false);
          return;
        }
      }

      IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
      String newProjectNameLowerCase = name.toLowerCase();
      for (IProject currentProject : projects) {
        String existingProjectName = currentProject.getName();
        if (existingProjectName.toLowerCase().equals(newProjectNameLowerCase)) {
          setErrorMessage(
              NewWizardMessages.ScriptProjectWizardFirstPage_Message_projectAlreadyExists);
          setPageComplete(false);
          return;
        }
      }

      final String location = fPHPLocationGroup.getLocation().toOSString();
      // check whether location is empty
      if (location.length() == 0) {
        setErrorMessage(null);
        setMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_enterLocation);
        setPageComplete(false);
        return;
      }
      // check whether the location is a syntactically correct path
      if (!Path.EMPTY.isValidPath(location)) {
        setErrorMessage(NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory);
        setPageComplete(false);
        return;
      }
      // check whether the location has the workspace as prefix
      IPath projectPath = Path.fromOSString(location);
      if (!fPHPLocationGroup.isInWorkspace() && Platform.getLocation().isPrefixOf(projectPath)) {
        setErrorMessage(
            NewWizardMessages.ScriptProjectWizardFirstPage_Message_cannotCreateInWorkspace);
        setPageComplete(false);
        return;
      }
      // If we do not place the contents in the workspace validate the
      // location.
      if (!fPHPLocationGroup.isInWorkspace()) {
        IEnvironment environment = getEnvironment();
        if (EnvironmentManager.isLocal(environment)) {
          final IStatus locationStatus = workspace.validateProjectLocation(handle, projectPath);
          File file = projectPath.toFile();
          if (!locationStatus.isOK()) {
            setErrorMessage(locationStatus.getMessage());
            setPageComplete(false);
            return;
          }

          if (!canCreate(projectPath.toFile())) {
            setErrorMessage(
                NewWizardMessages.ScriptProjectWizardFirstPage_Message_invalidDirectory);
            setPageComplete(false);
            return;
          }
        }
      }

      if (fragment != null) {
        fragment.getWizardModel().putObject("ProjectName", fNameGroup.getName());
        if (!fragment.isComplete()) {
          setErrorMessage((String) fragment.getWizardModel().getObject(ERROR_MESSAGE));
          setPageComplete(false);
          return;
        }
      }

      setPageComplete(true);
      setErrorMessage(null);
      setMessage(null);
    }