Esempio n. 1
0
 @Override
 public void launch(
     final ILaunchConfiguration configuration,
     String mode,
     ILaunch launch,
     IProgressMonitor monitor)
     throws CoreException {
   final RunletEvaluator main =
       new RunletEvaluator(
           configuration.getAttribute(RunletMainTab.PROJECT_ATTRIBUTE, RunletMainTab.NGPM_STDLIB));
   if (mode.equals("debug")) {
     RunletDebugTarget debugTarget =
         new RunletDebugTarget(main, launch, configuration.getName(), new RunletObjectFormatter());
     launch.addDebugTarget(debugTarget);
     launch.addProcess(debugTarget.getProcess());
     // TODO for testing, request to suspend immediately
     debugTarget.suspend();
     // debugSession.suspend(main.getInterpreter());
   }
   new Thread(mode + " Runlet " + configuration.getName()) {
     public void run() {
       try {
         RunletObject<AssociationEnd, TypeDefinition, ClassTypeDefinition>[] result =
             main.evaluate(
                 configuration.getAttribute(
                     RunletMainTab.EXPRESSION_ATTRIBUTE, "")); // $NON-NLS-1$
         main.getInterpreter().terminate();
         log.info(Messages.LaunchConfig_1 + Arrays.asList(result));
       } catch (Exception e) {
         log.throwing(getClass().getName(), "launch", e); // $NON-NLS-1$
       }
     }
   }.start();
 }
  /**
   * Get environment to append
   *
   * @param configuration
   * @return
   * @throws CoreException
   * @since 3.0
   */
  protected static String[] getEnvironment(ILaunchConfiguration configuration)
      throws CoreException {
    Map<?, ?> defaultEnv = null;
    Map<?, ?> configEnv =
        configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, defaultEnv);
    if (configEnv == null) {
      return null;
    }
    if (!configuration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true)) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              RMCorePlugin.getUniqueIdentifier(),
              Messages.AbstractToolRuntimeSystem_EnvNotSupported));
    }

    List<String> strings = new ArrayList<String>(configEnv.size());
    Iterator<?> iter = configEnv.entrySet().iterator();
    while (iter.hasNext()) {
      Entry<?, ?> entry = (Entry<?, ?>) iter.next();
      String key = (String) entry.getKey();
      String value = (String) entry.getValue();
      strings.add(key + "=" + value); // $NON-NLS-1$
    }
    return strings.toArray(new String[strings.size()]);
  }
Esempio n. 3
0
 public static IVMInstall getVMInstall(ILaunchConfiguration configuration) throws CoreException {
   String jre =
       configuration.getAttribute(
           IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, (String) null);
   IVMInstall vm = null;
   if (jre == null) {
     String name = configuration.getAttribute(IPDELauncherConstants.VMINSTALL, (String) null);
     if (name == null) {
       name = getDefaultVMInstallName(configuration);
     }
     vm = getVMInstall(name);
     if (vm == null) {
       throw new CoreException(
           LauncherUtils.createErrorStatus(
               NLS.bind(MDEMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name)));
     }
   } else {
     IPath jrePath = Path.fromPortableString(jre);
     vm = JavaRuntime.getVMInstall(jrePath);
     if (vm == null) {
       String id = JavaRuntime.getExecutionEnvironmentId(jrePath);
       if (id == null) {
         String name = JavaRuntime.getVMInstallName(jrePath);
         throw new CoreException(
             LauncherUtils.createErrorStatus(
                 NLS.bind(MDEMessages.WorkbenchLauncherConfigurationDelegate_noJRE, name)));
       }
       throw new CoreException(
           LauncherUtils.createErrorStatus(NLS.bind(MDEMessages.VMHelper_cannotFindExecEnv, id)));
     }
   }
   return vm;
 }
 /**
  * Updates the favorites selections from the local configuration
  *
  * @param config the local configuration
  */
 private void updateFavoritesFromConfig(ILaunchConfiguration config) {
   fFavoritesTable.setInput(config);
   fFavoritesTable.setCheckedElements(new Object[] {});
   try {
     List groups = config.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, new ArrayList());
     if (groups.isEmpty()) {
       // check old attributes for backwards compatible
       if (config.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false)) {
         groups.add(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP);
       }
       if (config.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false)) {
         groups.add(IDebugUIConstants.ID_RUN_LAUNCH_GROUP);
       }
     }
     if (!groups.isEmpty()) {
       List list = new ArrayList();
       Iterator iterator = groups.iterator();
       while (iterator.hasNext()) {
         String id = (String) iterator.next();
         LaunchGroupExtension extension = getLaunchConfigurationManager().getLaunchGroup(id);
         if (extension != null) {
           list.add(extension);
         }
       }
       fFavoritesTable.setCheckedElements(list.toArray());
     }
   } catch (CoreException e) {
     LaunchPlugin.log(e);
   }
 }
Esempio n. 5
0
  protected String computeName() {
    String label = fLabel;

    ILaunchConfiguration config = fLaunch.getLaunchConfiguration();
    if (config != null && !DebugUITools.isPrivate(config)) {
      String type = null;
      try {
        type = config.getType().getName();
      } catch (CoreException e) {
      }
      StringBuilder buffer = new StringBuilder();
      buffer.append(config.getName());
      if (type != null) {
        buffer.append(" ["); // $NON-NLS-1$
        buffer.append(type);
        buffer.append("] "); // $NON-NLS-1$
      }
      buffer.append(label);
      label = buffer.toString();
    }

    if (fLaunch.isTerminated()) {
      return ConsoleMessages.ConsoleMessages_console_terminated + label;
    }

    return label;
  }
  private void launchConfiguration() {
    try {
      ILaunch launch = launchConfig.launch(mode, null);
      if (launch.canTerminate()) {
        while (!launch.isTerminated()) {
          Thread.sleep(100);
        }
      }
    } catch (CoreException e) {
      BPCLIPreferences.logError("Error encountered during launch of " + launchConfig.getName(), e);
    } catch (InterruptedException e) {
      BPCLIPreferences.logError("Could not sleep execution thread", e);
    } finally {
      System.out.println("Execution complete.  Exiting.");
      // Unless running in debug exit after the build
      if (!debug) {
        PlatformUI.getWorkbench()
            .getDisplay()
            .asyncExec(
                new Runnable() {

                  @Override
                  public void run() {
                    PlatformUI.getWorkbench().close();
                  }
                });
      }
    }
  }
  protected void handleToolChanged() {
    try {
      // create dynamicTab
      loadDynamicArea();

      if (launchConfigurationWorkingCopy == null) {
        if (launchConfiguration.isWorkingCopy()) {
          launchConfigurationWorkingCopy = (ILaunchConfigurationWorkingCopy) launchConfiguration;
        } else {
          launchConfigurationWorkingCopy = launchConfiguration.getWorkingCopy();
        }
      }

      // setDefaults called on this tab so call on dynamicTab OR
      // user changed tool, not just restoring state
      if (initDefaults) {
        dynamicTab.setDefaults(launchConfigurationWorkingCopy);
      }
      initDefaults = false;
      dynamicTab.initializeFrom(launchConfigurationWorkingCopy);

      // change name of tool TabItem
      toolTab.setText(dynamicTab.getName());
      optionsFolder.layout(true);

      // adjust minimum size for ScrolledComposite
      recomputeSize();
    } catch (CoreException e) {
      ex = e;
    }
  }
 @Override
 public void moduleLoaded(
     final IBackend backend, final IProject project, final String moduleName) {
   try {
     final ErlangDebugTarget erlangDebugTarget = debugTargetOfBackend(backend.getOtpRpc());
     if (erlangDebugTarget != null
         && erlangDebugTarget.getInterpretedModules().contains(moduleName)) {
       if (isModuleRunningInInterpreter(erlangDebugTarget, backend.getOtpRpc(), moduleName)) {
         abortContinueDialog(erlangDebugTarget);
       } else {
         final ILaunchConfiguration launchConfiguration =
             erlangDebugTarget.getLaunch().getLaunchConfiguration();
         final EnumSet<ErlDebugFlags> debugFlags =
             ErlDebugFlags.makeSet(
                 launchConfiguration.getAttribute(
                     ErlRuntimeAttributes.DEBUG_FLAGS,
                     ErlDebugFlags.getFlag(ErlDebugFlags.DEFAULT_DEBUG_FLAGS)));
         final boolean distributed = debugFlags.contains(ErlDebugFlags.DISTRIBUTED_DEBUG);
         erlangDebugTarget.interpret(project, moduleName, distributed, true);
       }
     }
   } catch (final CoreException e) {
     ErlLogger.error(e);
   }
 }
Esempio n. 9
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
  */
 public boolean select(Viewer viewer, Object parent, Object element) {
   // always let through types, we only care about configs
   if (element instanceof ILaunchConfigurationType) {
     return true;
   }
   if (element instanceof ILaunchConfiguration) {
     try {
       ILaunchConfiguration config = (ILaunchConfiguration) element;
       IResource[] resources = config.getMappedResources();
       // if it has no mapping, it might not have migration delegate, so let it pass
       if (resources == null) {
         return true;
       }
       for (int i = 0; i < resources.length; i++) {
         IProject project = resources[i].getProject();
         // we don't want overlap with the deleted projects filter, so we need to allow projects
         // that don't exist through
         if (project != null && (project.isOpen() || !project.exists())) {
           return true;
         }
       }
     } catch (CoreException e) {
     }
   }
   return false;
 }
  public IDockerHostConfig getDockerHostConfig(ILaunchConfiguration config) throws CoreException {

    final DockerHostConfig.Builder hostConfigBuilder = new DockerHostConfig.Builder();
    if (config.getAttribute(IRunDockerImageLaunchConfigurationConstants.PUBLISH_ALL_PORTS, false)) {
      hostConfigBuilder.publishAllPorts(true);
    } else {
      final Map<String, List<IDockerPortBinding>> portBindings = new HashMap<>();
      Map<String, String> ports =
          config.getAttribute(
              IRunDockerImageLaunchConfigurationConstants.PUBLISHED_PORTS,
              new HashMap<String, String>());
      for (Map.Entry<String, String> entry : ports.entrySet()) {
        String key = entry.getKey();
        String entryValue = entry.getValue();

        String[] portPairs = entryValue.split("\\s*,\\s*"); // $NON-NLS-1$

        for (int i = 0; i < portPairs.length; i += 2) {
          DockerPortBinding portBinding = new DockerPortBinding(portPairs[i], portPairs[i + 1]);
          portBindings.put(key, Arrays.<IDockerPortBinding>asList(portBinding));
        }
      }
      hostConfigBuilder.portBindings(portBindings);
    }
    // container links
    final List<String> links =
        config.getAttribute(
            IRunDockerImageLaunchConfigurationConstants.LINKS, new ArrayList<String>());
    hostConfigBuilder.links(links);

    // data volumes

    List<String> volumesFromList =
        config.getAttribute(
            IRunDockerImageLaunchConfigurationConstants.VOLUMES_FROM, new ArrayList<String>());
    hostConfigBuilder.volumesFrom(volumesFromList);

    final List<String> binds = new ArrayList<>();

    List<String> bindsList =
        config.getAttribute(
            IRunDockerImageLaunchConfigurationConstants.BINDS, new ArrayList<String>());

    for (String bindsListEntry : bindsList) {
      String[] bindsEntryParms = bindsListEntry.split(":"); // $NON-NLS-1$
      String bind =
          LaunchConfigurationUtils.convertToUnixPath(bindsEntryParms[0])
              + ':'
              + bindsEntryParms[1]
              + ':'
              + 'Z';
      if (bindsEntryParms[2].equals("true")) {
        bind += ",ro"; // $NON-NLS-1$
      }
      binds.add(bind);
    }
    hostConfigBuilder.binds(binds);

    return hostConfigBuilder.build();
  }
  @SuppressWarnings("deprecation")
  private void launch(IContainer basecon, String mode) {
    if (basecon == null) {
      return;
    }

    IContainer basedir = findPomXmlBasedir(basecon);

    ILaunchConfiguration launchConfiguration = getLaunchConfiguration(basedir, mode);
    if (launchConfiguration == null) {
      return;
    }

    boolean openDialog = showDialog;
    if (!openDialog) {
      try {
        // if no goals specified
        String goals =
            launchConfiguration.getAttribute(MavenLaunchConstants.ATTR_GOALS, (String) null);
        openDialog = goals == null || goals.trim().length() == 0;
      } catch (CoreException ex) {
        log.error(ex.getMessage(), ex);
      }
    }

    if (openDialog) {
      DebugUITools.saveBeforeLaunch();
      // ILaunchGroup group = DebugUITools.getLaunchGroup(launchConfiguration, mode);
      DebugUITools.openLaunchConfigurationDialog(
          getShell(), launchConfiguration, MavenLaunchMainTab.ID_EXTERNAL_TOOLS_LAUNCH_GROUP, null);
    } else {
      DebugUITools.launch(launchConfiguration, mode);
    }
  }
Esempio n. 12
0
 private void setValuesFrom(Object object) throws CoreException {
   if (object instanceof IPreferenceStore) {
     IPreferenceStore preferences = (IPreferenceStore) object;
     suspendOnFirstLine.setSelection(
         preferences.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_FIRST_LINE));
     suspendOnExceptions.setSelection(
         preferences.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_EXCEPTIONS));
     suspendOnErrors.setSelection(
         preferences.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_ERRORS));
     suspendOnDebuggerKeyword.setSelection(
         preferences.getBoolean(IJSDebugPreferenceNames.SUSPEND_ON_DEBUGGER_KEYWORD));
   } else if (object instanceof ILaunchConfiguration) {
     ILaunchConfiguration configuration = (ILaunchConfiguration) object;
     suspendOnFirstLine.setSelection(
         configuration.getAttribute(
             ILaunchConfigurationConstants.CONFIGURATION_SUSPEND_ON_FIRST_LINE, false));
     suspendOnExceptions.setSelection(
         configuration.getAttribute(
             ILaunchConfigurationConstants.CONFIGURATION_SUSPEND_ON_EXCEPTIONS, false));
     suspendOnErrors.setSelection(
         configuration.getAttribute(
             ILaunchConfigurationConstants.CONFIGURATION_SUSPEND_ON_ERRORS, false));
     suspendOnDebuggerKeyword.setSelection(
         configuration.getAttribute(
             ILaunchConfigurationConstants.CONFIGURATION_SUSPEND_ON_DEBUGGER_KEYWORDS, false));
   }
 }
Esempio n. 13
0
  public void initializeFrom(ILaunchConfiguration configuration) {
    try {
      // Port
      int port =
          configuration.getAttribute(ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_PORT, -1);

      setPort(port != -1 ? port : DEFAULT_PORT);

      // Session id
      String sessionId =
          configuration.getAttribute(
              ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_SESSION_ID, (String) null);

      setSessionId(sessionId != null ? sessionId : DEFAULT_SESSION_ID);

      // Timeout
      int timeout =
          configuration.getAttribute(
              ScriptLaunchConfigurationConstants.ATTR_DLTK_DBGP_WAITING_TIMEOUT,
              DLTKDebugPlugin.getConnectionTimeout());
      setTimeout(timeout);
    } catch (CoreException e) {
      // TODO: Log this
    }
  }
 protected void initializeServerControl(ILaunchConfiguration configuration) {
   try {
     String serverName = configuration.getAttribute(Server.NAME, ""); // $NON-NLS-1$
     if (serverName != null && !serverName.equals("")) { // $NON-NLS-1$
       server = ServersManager.getServer(serverName);
       if (server == null) { // server no longer exists
         setErrorMessage(
             PHPServerUIMessages.getString("ServerTab.invalidServerError")); // $NON-NLS-1$
         selectDefaultServer(configuration);
       } else {
         serverCombo.setText(server.getName());
       }
     } else {
       selectDefaultServer(configuration);
     }
     // flag should only be set if launch has been attempted on the
     // config
     if (configuration.getAttribute(READ_ONLY, false)) {
       serverCombo.setEnabled(false);
     }
     boolean enabled = configuration.getAttribute(SERVER_ENABLED, true);
     serverCombo.setEnabled(enabled);
     createNewServer.setEnabled(enabled);
   } catch (Exception e) {
   }
 }
  /** @see org.eclipse.debug.ui.ISourcePresentation#getEditorInput(java.lang.Object) */
  public IEditorInput getEditorInput(Object element) {
    IStorageEditorInput i;
    AtlStackFrame frame;
    //		String projectName;
    String fileName;

    if (element instanceof AtlStackFrame) {
      frame = (AtlStackFrame) element;
      if (((AtlDebugTarget) frame.getDebugTarget()).isDisassemblyMode())
        return getDisassemblyEditorInput(frame);
      ILaunchConfiguration configuration =
          frame.getDebugTarget().getLaunch().getLaunchConfiguration();
      try {
        // TODO Recuperer le nom du fichier sur la stackframe
        fileName =
            configuration.getAttribute(
                AtlLauncherTools.ATLFILENAME, AtlLauncherTools.NULLPARAMETER);

        IWorkspace wks = ResourcesPlugin.getWorkspace();
        IWorkspaceRoot wksroot = wks.getRoot();

        i = new FileEditorInput(wksroot.getFile(new Path(fileName)));
        return i;
      } catch (CoreException e) {
        e.printStackTrace();
      }
    } else if (element instanceof AtlBreakpoint) {
      IMarker marker = ((AtlBreakpoint) element).getMarker();
      IFile ifile = (IFile) marker.getResource();
      return new FileEditorInput(ifile);
    }
    return null;
  }
  @Override
  protected void createContributionItems(final List<IContributionItem> items) {
    final IWorkbenchWindow window = this.util.getWindow();
    final IFile file = this.util.getFile(window);
    final DocProcessingManager manager =
        this.util.getManager(this.util.getContentType(window, file));
    if (manager == null) {
      return;
    }

    final ImList<ILaunchConfiguration> configs = manager.getAvailableConfigs();
    final Data data = new Data(manager, file);

    int i = 0;
    for (int num = 1; i < configs.size(); i++, num++) {
      final ILaunchConfiguration configuration = configs.get(i);

      final ImageDescriptor icon = manager.getImageDescriptor(configuration);
      String mnemonic = null;
      final StringBuilder label = getStringBuilder();
      if (num > 0 && num <= 10) {
        mnemonic = Integer.toString((num % 10));
        label.append(mnemonic);
        label.append(' ');
      }
      label.append(MessageUtil.escapeForMenu(configuration.getName()));

      final ConfigContribution item =
          createConfigContribution(icon, label, mnemonic, configuration);
      item.data = data;

      items.add(item);
    }
  }
Esempio n. 17
0
 /** @since 2.0 */
 protected void updateCoreFromConfig(ILaunchConfiguration config) {
   if (fCoreText != null) {
     String coreName = EMPTY_STRING;
     String coreType = IGDBLaunchConfigurationConstants.DEBUGGER_POST_MORTEM_TYPE_DEFAULT;
     try {
       coreName =
           config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_COREFILE_PATH, EMPTY_STRING);
       coreType =
           config.getAttribute(
               IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_POST_MORTEM_TYPE,
               IGDBLaunchConfigurationConstants.DEBUGGER_POST_MORTEM_TYPE_DEFAULT);
     } catch (CoreException ce) {
       GdbUIPlugin.log(ce);
     }
     fCoreText.setText(coreName);
     if (coreType.equals(IGDBLaunchConfigurationConstants.DEBUGGER_POST_MORTEM_CORE_FILE)) {
       fCoreTypeCombo.setText(CORE_FILE);
     } else if (coreType.equals(
         IGDBLaunchConfigurationConstants.DEBUGGER_POST_MORTEM_TRACE_FILE)) {
       fCoreTypeCombo.setText(TRACE_FILE);
     } else {
       assert false : "Unknown core file type"; // $NON-NLS-1$
       fCoreTypeCombo.setText(CORE_FILE);
     }
     updateCoreFileLabel();
   }
 }
  @Override
  public boolean isValid(ILaunchConfiguration configuration) {
    try {
      if (!configuration.hasAttribute(COLaunchConfigurationDelegate.INPUT_FILE)) {
        setErrorMessage("No input configuration file defined");
        return false;
      }
      // Check input file exists
      File inputFile =
          new File(
              URI.create(
                  configuration.getAttribute(
                      COLaunchConfigurationDelegate.INPUT_FILE, StringUtils.EMPTY)));
      if (!inputFile.isFile()) {
        // Should not happen...
        setErrorMessage("Input file does not exist");
        return false;
      }
    } catch (Exception e) {
      // TODO: handle exception
    }

    setErrorMessage(null);
    return true;
  }
Esempio n. 19
0
  /**
   * Initialize a <code>ILaunchConfigurationWorkingCopy</code> either by using an existing one (if
   * found), or using a default configuration (for example, the one used for the most recent
   * launch), or by creating a new one based on the <code>project</code> name and the <code>confName
   * </code>.
   *
   * @throws CoreException if getting an working copy from an existing configuration fails
   */
  private static ILaunchConfigurationWorkingCopy createLaunchConfiguration(
      IProject project, String confName, RunInfo runInfo) {
    ILaunchManager launchManager = getLaunchManager();
    ILaunchConfiguration config =
        ConfigurationHelper.findConfiguration(launchManager, project, confName, runInfo);

    ILaunchConfigurationWorkingCopy configWC = null;
    if (null != config) {
      try {
        configWC = config.getWorkingCopy();
      } catch (CoreException cex) {
        TestNGPlugin.log(
            new Status(
                IStatus.ERROR,
                TestNGPlugin.PLUGIN_ID,
                TestNGPluginConstants.LAUNCH_ERROR,
                "Cannot create working copy of existing launcher " + config.getName(),
                cex));
      }
    }
    if (null == configWC) {
      if (confName == null && runInfo != null) {
        confName = runInfo.getClassName() + "." + runInfo.getMethodName();
      }
      configWC = ConfigurationHelper.createBasicConfiguration(launchManager, project, confName);
    }

    return configWC;
  }
Esempio n. 20
0
  private void byteScalingHelper(int ix, long times, long bytes, String testName) throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    wc.setAttribute(
        ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
        String.valueOf(bytes) + " " + String.valueOf(times)); // $NON-NLS-1$
    wc.setAttribute(MassifLaunchConstants.ATTR_MASSIF_TIMEUNIT, MassifLaunchConstants.TIME_B);
    config = wc.doSave();

    doLaunch(config, testName);

    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    IAction chartAction = getChartAction(view);
    assertNotNull(chartAction);
    chartAction.run();

    IEditorPart part =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (part.getEditorInput() instanceof ChartEditorInput) {
      ChartEditorInput input = (ChartEditorInput) part.getEditorInput();
      HeapChart chart = input.getChart();
      assertEquals(HeapChart.getByteUnits()[ix], chart.getXUnits());
    } else {
      fail();
    }
  }
Esempio n. 21
0
  /*
   * Expands and returns the location attribute of the given launch configuration. The location is verified to point
   * to an existing file, in the local file system.
   *
   * @param configuration launch configuration
   *
   * @return an absolute path to a file in the local file system
   *
   * @throws CoreException if unable to retrieve the associated launch configuration attribute, if unable to resolve
   * any variables, or if the resolved location does not point to an existing file in the local file system
   */
  public static IPath[] getLocation(ILaunchConfiguration configuration, IPythonNature nature)
      throws CoreException {
    String locationsStr =
        configuration.getAttribute(Constants.ATTR_ALTERNATE_LOCATION, (String) null);
    if (locationsStr == null) {
      locationsStr = configuration.getAttribute(Constants.ATTR_LOCATION, (String) null);
    }
    if (locationsStr == null) {
      throw new CoreException(
          PydevDebugPlugin.makeStatus(IStatus.ERROR, "Unable to get location for run", null));
    }

    List<String> locations = StringUtils.splitAndRemoveEmptyTrimmed(locationsStr, '|');
    Path[] ret = new Path[locations.size()];
    int i = 0;
    for (String location : locations) {
      String expandedLocation = getStringSubstitution(nature).performStringSubstitution(location);
      if (expandedLocation == null || expandedLocation.length() == 0) {
        throw new CoreException(
            PydevDebugPlugin.makeStatus(
                IStatus.ERROR, "Unable to get expanded location for run", null));
      } else {
        ret[i] = new Path(expandedLocation);
      }
      i++;
    }
    return ret;
  }
  /**
   * Looks for and returns all existing Launch Configuration object for a specified project.
   *
   * @param projectName The name of the project
   * @return all the ILaunchConfiguration object. If none are present, an empty array is returned.
   */
  private static ILaunchConfiguration[] findConfigs(String projectName) {
    // get the launch manager
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

    // now get the config type for our particular android type.
    ILaunchConfigurationType configType =
        manager.getLaunchConfigurationType(LaunchConfigDelegate.ANDROID_LAUNCH_TYPE_ID);

    // create a temp list to hold all the valid configs
    ArrayList<ILaunchConfiguration> list = new ArrayList<ILaunchConfiguration>();

    try {
      ILaunchConfiguration[] configs = manager.getLaunchConfigurations(configType);

      for (ILaunchConfiguration config : configs) {
        if (config
            .getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "")
            .equals(projectName)) { // $NON-NLS-1$
          list.add(config);
        }
      }
    } catch (CoreException e) {
    }

    return list.toArray(new ILaunchConfiguration[list.size()]);
  }
Esempio n. 23
0
  public static List<LaunchConfigData> getProjectLaunchConfigs(final IProject project) {
    List<LaunchConfigData> matches = new LinkedList<>();

    try {
      ILaunchConfiguration[] configs =
          DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();

      for (ILaunchConfiguration launchConfig : configs) {
        String launchConfigProjectName =
            launchConfig.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_PROJECT, "");

        if (launchConfigProjectName != null
            && !launchConfigProjectName.equals("")
            && launchConfigProjectName.equals(project.getName())) {
          String exp = launchConfig.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_EXPRESSION, "");
          matches.add(new LaunchConfigData(launchConfig.getName(), exp));
        }
      }
    } catch (CoreException e) {

      CodeGenConsole.GetInstance()
          .printErrorln(
              "Problem looking up launch configurations for project "
                  + project.getName()
                  + ": "
                  + e.getMessage());
      e.printStackTrace();
    }

    return matches;
  }
Esempio n. 24
0
 protected void initProject(ILaunchConfiguration configuration) throws CoreException {
   String name =
       configuration.getAttribute(RUNCONFIG_PROJECT_NAME_ATTRIBUTE, getDefaultProjectName());
   fillProjectDropDownMenue(name);
   name = configuration.getAttribute(RUNCONFIG_PRODUCT_NAME_ATTRIBUTE, (String) null);
   fillProductDropDownMenue(name);
   updateErrors();
 }
 /**
  * Tests the {@link BuilderCoreUtils#toBuildCommand(org.eclipse.core.resources.IProject,
  * org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.resources.ICommand)} method <br>
  * <br>
  * Tests the case of the working copy of an existing configuration
  *
  * @throws Exception
  */
 public void testToBuildCommand3() throws Exception {
   Map<String, String> args = new HashMap<>();
   ILaunchConfiguration copy =
       createExternalToolBuilder(getProject(), "testToBuildCommand3", args); // $NON-NLS-1$
   ICommand command =
       BuilderCoreUtils.toBuildCommand(
           getProject(), copy.getWorkingCopy(), getProject().getDescription().newCommand());
   assertNotNull("There should have been a new build command created", command); // $NON-NLS-1$
 }
Esempio n. 26
0
 private boolean configEquals(final ILaunchConfiguration a) throws CoreException {
   return opsFile.equals(
           a.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "X"))
       && MigDbLauncher.class
           .getName()
           .equals(a.getAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, "X"))
       && project.equals(
           a.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "X"))
       && a.getType().getIdentifier().equals("migdb.dsl.ide.launch.OpsLaunchConfigurationType");
 }
 /**
  * Tests the {@link
  * BuilderCoreUtils#migrateBuilderConfiguration(org.eclipse.core.resources.IProject,
  * org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)} method
  *
  * @throws Exception
  */
 public void testMigrateBuilderConfiguration2() throws Exception {
   ILaunchConfigurationWorkingCopy copy =
       createExternalToolBuilderWorkingCopy(
           getProject(), "testMigra/teBuilderConfi/guration2", null); // $NON-NLS-1$
   ILaunchConfiguration config = BuilderCoreUtils.migrateBuilderConfiguration(getProject(), copy);
   assertNotNull("The un-saved working copy should have been migrated", config); // $NON-NLS-1$
   assertTrue(
       "The name of the migrated configuration should be testMigra.teBuilderConfi.guration2",
       config.getName().equals("testMigra.teBuilderConfi.guration2")); // $NON-NLS-1$ //$NON-NLS-2$
 }
  @Override
  public Object getAdapter(
      final Object adaptableObject, @SuppressWarnings("rawtypes") final Class adapterType) {

    // TODO: This entire method is ugly and needs to be cleaned up

    final Object adapted;
    if (KarafPlatformModel.class.equals(adapterType)
        && adaptableObject instanceof ILaunchConfiguration) {
      final ILaunchConfiguration configuration = (ILaunchConfiguration) adaptableObject;
      try {
        if (configuration
            .getAttributes()
            .containsKey(KarafLaunchConfigurationConstants.KARAF_LAUNCH_SOURCE_RUNTIME)) {
          final String platformPath =
              (String)
                  configuration
                      .getAttributes()
                      .get(KarafLaunchConfigurationConstants.KARAF_LAUNCH_SOURCE_RUNTIME);
          adapted = KarafPlatformModelRegistry.findPlatformModel(new Path(platformPath));
        } else {
          adapted = null;
        }
      } catch (final CoreException e) {
        KarafUIPluginActivator.getLogger().error("Unable to find Karaf Platform model", e);
        return null;
      }
    } else if (IKarafProject.class.equals(adapterType)
        && adaptableObject instanceof KarafPlatformModel) {
      IKarafProject karafProject = null;
      final KarafPlatformModel karafPlatformModel = (KarafPlatformModel) adaptableObject;
      for (final IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
        if (KarafProject.isKarafProject(project)) {
          karafProject = new KarafProject(project);
          if (karafPlatformModel
              .getRootDirectory()
              .equals(karafProject.getPlatformRootDirectory())) {
            break;
          }
        }
      }

      adapted = karafProject;
    } else if (IKarafProject.class.equals(adapterType) && adaptableObject instanceof IProject) {
      if (KarafProject.isKarafProject((IProject) adaptableObject)) {
        adapted = new KarafProject((IProject) adaptableObject);
      } else {
        return null;
      }
    } else {
      adapted = null;
    }

    return adapted;
  }
Esempio n. 29
0
  /**
   * Gets the CDT environment from the CDT project's configuration referenced by the launch
   *
   * @since 3.0
   */
  public static String[] getLaunchEnvironment(ILaunchConfiguration config) throws CoreException {
    // Get the project
    String projectName =
        config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
    if (projectName == null) {
      return null;
    }
    projectName = projectName.trim();
    if (projectName.length() == 0) {
      return null;
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    if (project == null || !project.isAccessible()) return null;

    ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project, false);

    // Not a CDT project?
    if (projDesc == null) return null;

    String buildConfigID =
        config.getAttribute(
            ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); // $NON-NLS-1$
    ICConfigurationDescription cfg = null;
    if (buildConfigID.length() != 0) cfg = projDesc.getConfigurationById(buildConfigID);

    // if configuration is null fall-back to active
    if (cfg == null) cfg = projDesc.getActiveConfiguration();

    // Environment variables and inherited vars
    HashMap<String, String> envMap = new HashMap<String, String>();
    IEnvironmentVariable[] vars =
        CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cfg, true);
    for (IEnvironmentVariable var : vars) envMap.put(var.getName(), var.getValue());

    // Add variables from build info
    ICdtVariable[] build_vars = CCorePlugin.getDefault().getCdtVariableManager().getVariables(cfg);
    for (ICdtVariable var : build_vars) {
      try {
        envMap.put(var.getName(), var.getStringValue());
      } catch (CdtVariableException e) {
        // Some Eclipse dynamic variables can't be resolved dynamically... we don't care.
      }
    }

    // Turn it into an envp format
    List<String> strings = new ArrayList<String>(envMap.size());
    for (Entry<String, String> entry : envMap.entrySet()) {
      StringBuffer buffer = new StringBuffer(entry.getKey());
      buffer.append('=').append(entry.getValue());
      strings.add(buffer.toString());
    }

    return strings.toArray(new String[strings.size()]);
  }
Esempio n. 30
0
  public void testDoubleClickLine() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    wc.setAttribute(MassifLaunchConstants.ATTR_MASSIF_DETAILEDFREQ, 2);
    wc.doSave();
    doLaunch(config, "testDoubleClickLine"); // $NON-NLS-1$

    doDoubleClick();

    checkLine(node);
  }