Package org.eclipse.php.internal.debug.core.preferences

Examples of org.eclipse.php.internal.debug.core.preferences.PHPexeItem


    return getPHPExecutable("");
  }
 
  public static String getPHPExecutable(String debugger) throws ExecutableNotFoundException {
    // find the default PHP executable
    PHPexeItem defaultPhpExe = getDefaultPHPExeItem(debugger);
   
    // check if the SAPI type is CLI
    if (PHPexeItem.SAPI_CLI.equals(defaultPhpExe.getSapiType())) {
      // if yes - return it
      return defaultPhpExe.getExecutable().toString();
    }
   
    // otherwise try to find a PHP CLI executable
    PHPexeItem[] cliItems = PHPexes.getInstance().getCLIItems();
    if (cliItems.length == 0) {
      // if no PHP CLI executable then return the default one
      return defaultPhpExe.getExecutable().toString();
    }
   
    // sort the PHP CLI executable by version
    SortedMap<String, PHPexeItem> map = new TreeMap<String, PHPexeItem>();
    for (PHPexeItem item : cliItems) {
      map.put(item.getVersion(), item);
    }
   
    // check if there is a PHP CLI executable with the same version as the default PHP executable
    PHPexeItem phpExe = map.get(defaultPhpExe.getVersion());
    if (phpExe != null) {
      return phpExe.getExecutable().toString();
    }
   
    // otherwise return the PHP CLI executable with the greatest version
    phpExe = map.get(map.lastKey());
    return phpExe.getExecutable().toString();
  }
View Full Code Here


    phpExe = map.get(map.lastKey());
    return phpExe.getExecutable().toString();
  }
 
  private static PHPexeItem getDefaultPHPExeItem(String debugger) throws ExecutableNotFoundException {
    PHPexeItem phpExe = PHPexes.getInstance().getDefaultItem(debugger);
   
    if (phpExe != null) {
      return phpExe;
    }
   
View Full Code Here

      @Override
      public void widgetSelected(SelectionEvent e) {
        try {
          String current = exes.getText();
          PHPexeItem phPexeItem = null;

          for (PHPexeItem i : phpExes.getAllItems()) {
            if (current.equals(i.getName())) {
              phPexeItem = i;
              break;
View Full Code Here

          return false;
        }
      }
      // Check if script arguments can be passed (CLI SAPI required)
      if (!fPrgmArgumentsText.getText().isEmpty()) {
        PHPexeItem phpExeItem = phpsComboBlock.getPHPexe();
        if (phpExeItem != null
            && !(PHPexeItem.SAPI_CLI.equals(phpExeItem
                .getSapiType())))
          setWarningMessage(PHPDebugUIMessages.PHPExecutableLaunchTab_argumentsWillNotBePassed);
      }
    } catch (final CoreException e) {
    }
View Full Code Here

    try {
      String executableLocation = configuration.getAttribute(
          IPHPDebugConstants.ATTR_EXECUTABLE_LOCATION, ""); //$NON-NLS-1$
      if (executableLocation.equals("")) { //$NON-NLS-1$
        PHPexes phpExes = PHPexes.getInstance();
        final PHPexeItem phpExeItem = phpExes
            .getDefaultItem(PHPDebugPlugin.getCurrentDebuggerId());
        if (phpExeItem == null)
          return;
        executableLocation = phpExeItem.getExecutable().toString();
        configuration.setAttribute(
            IPHPDebugConstants.ATTR_EXECUTABLE_LOCATION,
            executableLocation);

        String iniPath = phpExeItem.getINILocation() != null ? phpExeItem
            .getINILocation().toString() : null;
        configuration.setAttribute(
            IPHPDebugConstants.ATTR_INI_LOCATION, iniPath);

        configuration.setAttribute(
View Full Code Here

          PHPDebugPlugin.getCurrentDebuggerId());
    } catch (final CoreException ce) {
      Logger.log(Logger.ERROR, "Error reading configuration", ce); //$NON-NLS-1$
    }
    final PHPexes exes = PHPexes.getInstance();
    PHPexeItem phpexe;
    if (location != null && location.length() > 0) {
      phpexe = exes.getItemForFile(location, iniPath);
    } else {
      phpexe = exes.getDefaultItem(PHPDebugPlugin.getCurrentDebuggerId());
    }
View Full Code Here

      }
    });
  }

  protected void init() {
    PHPexeItem phpExeItem = getPHPExeItem();
    if (phpExeItem == null || phpExeItem.getName() == null) {
      fPHPexeName.setTextWithoutUpdate(""); //$NON-NLS-1$
      fPHPExePath.setTextWithoutUpdate(""); //$NON-NLS-1$
      fPHPIni.setTextWithoutUpdate(""); //$NON-NLS-1$
      String defaultDebuggerId = PHPDebuggersRegistry
          .getDefaultDebuggerId();
      if (defaultDebuggerId != null) {
        int index = fDebuggers.indexOf(PHPDebuggersRegistry
            .getDebuggerName(defaultDebuggerId));
        fDebuggers.select(index);
      } else {
        if (fDebuggers.getItemCount() > 0) {
          fDebuggers.select(0);
        } else {
          hideDebuggersCombo();
        }
      }
      setTitle(PHPDebugUIMessages.PHPExeCompositeFragment_10);
    } else {
      initialName = phpExeItem.getName();
      fPHPexeName.setTextWithoutUpdate(phpExeItem.getName());
      fPHPexeName.setEnabled(phpExeItem.isEditable());
      fPHPExePath.setTextWithoutUpdate(phpExeItem.getExecutable()
          .getAbsolutePath());
      fPHPExePath.setEnabled(phpExeItem.isEditable());
      if (phpExeItem.getINILocation() != null) {
        fPHPIni.setTextWithoutUpdate(phpExeItem.getINILocation()
            .toString());
      }
      fPHPIni.setEnabled(phpExeItem.isEditable());
      fLoadDefaultPHPIni.setEnabled(phpExeItem.isEditable());
      fLoadDefaultPHPIni.setSelection(phpExeItem.isLoadDefaultINI());
      String debuggerID = phpExeItem.getDebuggerID();
      fDebuggers.setEnabled(phpExeItem.isEditable());
      fDebuggersLabel.setEnabled(phpExeItem.isEditable());
      int index = fDebuggers.indexOf(PHPDebuggersRegistry
          .getDebuggerName(debuggerID));
      if (index > -1) {
        fDebuggers.select(index);
      } else {
        if (fDebuggers.getItemCount() > 0) {
          fDebuggers.select(0);
        } else {
          hideDebuggersCombo();
        }
      }
      String sapiType = phpExeItem.getSapiType();
      if (sapiType != null) {
        fSapiTypes.setText(sapiType);
      }
      fSapiTypes.setEnabled(phpExeItem.isEditable());
      fSapiTypesLabel.setEnabled(phpExeItem.isEditable());

      setTitle(PHPDebugUIMessages.PHPExeCompositeFragment_11);
    }

    controlHandler.setTitle(getTitle());
View Full Code Here

    fDebuggers.setVisible(false);
    fDebuggersLabel.setVisible(false);
  }

  public void validate() {
    PHPexeItem phpExeItem = getPHPExeItem();
    // Let's reset previous state
    setComplete(true);
    setMessage(PHPDebugUIMessages.PHPExeCompositeFragment_0,
        IMessageProvider.INFORMATION);
    /* MESSAGES */
    // Check if PHP executable location is empty
    if (phpExeItem.getExecutable() == null
        || phpExeItem.getExecutable().getPath().length() == 0) {
      setComplete(false);
      setMessage(PHPDebugUIMessages.addPHPexeDialog_enterLocation,
          IMessageProvider.INFORMATION);
      return;
    }
    // Check if name is empty
    if (phpExeItem.getName().isEmpty()) {
      setComplete(false);
      setMessage(PHPDebugUIMessages.addPHPexeDialog_enterName,
          IMessageProvider.INFORMATION);
      return;
    }
    /* ERRORS */
    // Check PHP executable
    if (phpExeItem.getExecutable() == null) {
      setMessage(PHPDebugUIMessages.PHPExeCompositeFragment_13,
          IMessageProvider.ERROR);
      return;
    }
    if (!phpExeItem.getExecutable().exists()) {
      setMessage(PHPDebugUIMessages.addPHPexeDialog_locationNotExists,
          IMessageProvider.ERROR);
      return;
    }
    PHPExeInfo phpExecInfo = getPHPInfo(phpExeItem.getExecutable());
    if (phpExecInfo == null) {
      setMessage(PHPDebugUIMessages.PHPExeCompositeFragment_13,
          IMessageProvider.ERROR);
      return;
    }
    // Check whether the name already exists:
    if (existingItems != null) {
      for (PHPexeItem item : existingItems) {
        if (!item.getName().equals(initialName)
            && item.getName().equals(phpExeItem.getName())) {
          setMessage(
              PHPDebugUIMessages.addPHPexeDialog_duplicateName,
              IMessageProvider.ERROR);
          return;
        }
      }
    }
    // Check if SAPI type is provided
    if (phpExeItem.getSapiType().isEmpty()) {
      setMessage(PHPDebugUIMessages.PHPExeCompositeFragment_15,
          IMessageProvider.ERROR);
      return;
    }
    if (phpExecInfo.getSapiType() != null
        && !phpExeItem.getSapiType().equals(phpExecInfo.getSapiType())) {
      setMessage(MessageFormat.format(
          PHPDebugUIMessages.addPHPexeDialog_wrongSAPItype,
          phpExecInfo.getSapiType()), IMessageProvider.ERROR);
      return;
    }
    // Check INI file location
    if (phpExeItem.getINILocation() != null) {
      String iniLocationName = phpExeItem.getINILocation().getPath();
      File iniFile = null;
      if (iniLocationName.trim().length() > 0) {
        iniFile = new File(iniLocationName);
        if (!iniFile.exists()) {
          setMessage(
View Full Code Here

      return null;
    }
  }

  private void updateItem() {
    PHPexeItem phpExeItem = getPHPExeItem();
    if (phpExeItem == null)
      return;
    // Check whether we can edit this item
    if (phpExeItem != null && !phpExeItem.isEditable()) {
      setComplete(false);
      setMessage(PHPDebugUIMessages.addPHPexeDialog_readOnlyPHPExe,
          IMessageProvider.INFORMATION);
      // If it is not editable it doesn't mean that it is correct
      validate();
      return;
    }
    // Set up PHP exe item.
    phpExeItem.setLoadDefaultINI(fLoadDefaultPHPIni.getSelection());
    phpExeItem.setExecutable(new File(fPHPExePath.getText()));
    phpExeItem.setName(fPHPexeName.getText());
    phpExeItem.setDebuggerID(debuggersIds.get(fDebuggers
        .getSelectionIndex()));
    phpExeItem.setINILocation(new File(fPHPIni.getText()));
    phpExeItem.setSapiType(fSapiTypes.getText());
    PHPExeInfo phpExeInfo = getPHPInfo(phpExeItem.getExecutable());
    if (phpExeInfo != null)
      phpExeItem.setVersion(phpExeInfo.getVersion());
    // Validate all
    validate();
  }
View Full Code Here

    if (compositeFragment != null) {
      try {
        phpExeItem = (PHPexeItem) getWizardModel().getObject(
            PHPExeWizard.MODEL);
        if (phpExeItem == null) {
          phpExeItem = new PHPexeItem();
        }
        compositeFragment.setData(phpExeItem);
        compositeFragment.setExistingItems(existingItems);
      } catch (Exception e) {
        Logger.logException(e);
View Full Code Here

TOP

Related Classes of org.eclipse.php.internal.debug.core.preferences.PHPexeItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.