Search in sources :

Example 71 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project jbosstools-hibernate by jbosstools.

the class GenerateInitWizardPage method createConsoleConfiguration.

private String createConsoleConfiguration() {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    String dialect = determineDialect();
    String ccName = launchManager.generateLaunchConfigurationName(HibernateConsoleMessages.AddConfigurationAction_hibernate);
    ConsoleConfigurationPreferences prefs = new EclipseConsoleConfigurationPreferences(ccName, ConfigurationMode.JPA, getHibernateVersion(), jpaProject.getName(), true, null, null, null, new IPath[0], new IPath[0], null, null, getConnectionProfileName(), dialect);
    ConsoleConfiguration cc = new ConsoleConfiguration(prefs);
    KnownConfigurations.getInstance().addConfiguration(cc, false);
    return ccName;
}
Also used : EclipseConsoleConfigurationPreferences(org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) ConsoleConfigurationPreferences(org.hibernate.console.preferences.ConsoleConfigurationPreferences) EclipseConsoleConfigurationPreferences(org.hibernate.eclipse.console.EclipseConsoleConfigurationPreferences) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Example 72 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project jbosstools-hibernate by jbosstools.

the class HibernateJpaPlatformUi method createDefaultLaunchConfig.

public static ILaunchConfigurationWorkingCopy createDefaultLaunchConfig(String projectName) {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(LaunchConfigurationType_ID);
    ILaunchConfigurationWorkingCopy wc = null;
    try {
        // $NON-NLS-1$
        wc = launchConfigurationType.newInstance(null, projectName + "-hibernate-generate");
        // Create exporters
        List<String> exporters = new ArrayList<String>();
        exporters.add(exporter_id);
        wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, exporters);
        wc.setAttribute(full_exporter_id, true);
    } catch (CoreException e) {
        HibernateJptUIPlugin.logException(e);
    }
    return wc;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ArrayList(java.util.ArrayList) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 73 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project erlide_eclipse by erlang.

the class ErlangNodeLaunchShortcut method getLaunchConfiguration.

private ILaunchConfiguration getLaunchConfiguration(final Collection<IErlProject> projects, final String mode) throws CoreException {
    final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    final List<String> projectNames = getProjectNames(projects);
    String name = ListsUtils.packList(projectNames, "_");
    if (name.length() > 15) {
        name = ListsUtils.packList(StringUtils.removeCommonPrefixes(projectNames), "_");
    }
    // try and find one
    final ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations();
    for (final ILaunchConfiguration launchConfiguration : launchConfigurations) {
        if (launchConfiguration.getName().equals(name)) {
            if (mode.equals(ILaunchManager.DEBUG_MODE)) {
                return addInterpretedModules(projects, launchConfiguration);
            }
            return launchConfiguration;
        }
    }
    // try and make one
    final ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(IErlangLaunchDelegateConstants.CONFIGURATION_TYPE);
    ILaunchConfigurationWorkingCopy wc;
    wc = launchConfigurationType.newInstance(null, name);
    wc.setAttribute(ErlRuntimeAttributes.PROJECTS, ListsUtils.packList(projectNames, ErlangNodeLaunchShortcut.PROJECT_NAME_SEPARATOR));
    wc.setAttribute(ErlRuntimeAttributes.RUNTIME_NAME, projects.iterator().next().getRuntimeInfo().getName());
    wc.setAttribute(ErlRuntimeAttributes.NODE_NAME, name);
    wc.setAttribute(ErlRuntimeAttributes.USE_LONG_NAME, // prefer short names
    !HostnameChecker.getInstance().canUseShortNames());
    wc.setAttribute(ErlRuntimeAttributes.CONSOLE, true);
    wc.setAttribute(ErlRuntimeAttributes.INTERNAL, false);
    wc.setAttribute(ErlRuntimeAttributes.LOAD_ALL_NODES, false);
    wc.setAttribute(ErlRuntimeAttributes.COOKIE, "erlide");
    wc.setAttribute(ErlRuntimeAttributes.WORKING_DIR, getWorkingDir(projectNames));
    final Map<String, String> map = Maps.newHashMap();
    wc.setAttribute("org.eclipse.debug.core.environmentVariables", map);
    if ("debug".equals(mode)) {
        final List<String> moduleNames = getProjectAndModuleNames(projects);
        wc.setAttribute(ErlRuntimeAttributes.DEBUG_INTERPRET_MODULES, moduleNames);
    }
    wc.setMappedResources(getProjectResources(projects));
    return wc.doSave();
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Example 74 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project erlide_eclipse by erlang.

the class ToolExecutor method run_0.

@Deprecated
public ToolResults run_0(final String cmd0, final String args, final String wdir, final ProgressCallback progressCallback, final BuildNotifier notifier) {
    final String cmd = new Path(cmd0).isAbsolute() ? cmd0 : ToolExecutor.getToolLocation(cmd0);
    if (cmd == null) {
        ErlLogger.warn("Tool '" + cmd0 + "' can't be found in $PATH");
        return new ToolResults();
    }
    final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    final ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_BUILDER_LAUNCH_CONFIGURATION_TYPE);
    if (type == null) {
        return null;
    }
    try {
        final ILaunchConfigurationWorkingCopy launchConfig = type.newInstance(null, launchManager.generateLaunchConfigurationName("erlTool"));
        launchConfig.setAttribute(IExternalToolConstants.ATTR_LOCATION, cmd);
        launchConfig.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, args);
        launchConfig.setAttribute(IExternalToolConstants.ATTR_WORKING_DIRECTORY, wdir);
        launchConfig.setAttribute(IExternalToolConstants.ATTR_LAUNCH_IN_BACKGROUND, true);
        launchConfig.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true);
        final ILaunch myLaunch = launchConfig.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor(), false, false);
        final ToolResults result = new ToolResults();
        if (myLaunch.getProcesses().length == 0) {
            ErlLogger.error("Tool process was not created?!");
            return null;
        }
        final IProcess process = myLaunch.getProcesses()[0];
        process.getStreamsProxy().getOutputStreamMonitor().addListener((text, mon) -> {
            final List<String> lines = Arrays.asList(text.split("\n"));
            if (progressCallback != null) {
                for (final String line : lines) {
                    progressCallback.stdout(line);
                }
            }
        });
        process.getStreamsProxy().getErrorStreamMonitor().addListener((text, mon) -> {
            final List<String> lines = Arrays.asList(text.split("\n"));
            if (progressCallback != null) {
                for (final String line : lines) {
                    progressCallback.stderr(line);
                }
            }
        });
        boolean done = false;
        try {
            Thread.sleep(60);
        } catch (final InterruptedException e1) {
        }
        final boolean canceled = notifier != null && notifier.isCanceled();
        while (!done && !canceled) {
            try {
                result.exit = process.getExitValue();
                done = true;
            } catch (final Exception e) {
                try {
                    Thread.sleep(60);
                } catch (final InterruptedException e1) {
                }
            }
        }
        if (canceled) {
            process.terminate();
        }
        return result;
    } catch (final CoreException e) {
        ErlLogger.error(e);
        return null;
    }
}
Also used : Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) CoreException(org.eclipse.core.runtime.CoreException) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunch(org.eclipse.debug.core.ILaunch) IProcess(org.eclipse.debug.core.model.IProcess)

Example 75 with ILaunchManager

use of org.eclipse.debug.core.ILaunchManager in project erlide_eclipse by erlang.

the class BackendData method asLaunchConfiguration.

public ILaunchConfiguration asLaunchConfiguration() {
    final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    final ILaunchConfigurationType type = manager.getLaunchConfigurationType(IErlangLaunchDelegateConstants.CONFIGURATION_TYPE_INTERNAL);
    ILaunchConfigurationWorkingCopy workingCopy;
    try {
        final RuntimeInfo info = getRuntimeInfo();
        final String name = getNodeName();
        workingCopy = type.newInstance(null, name);
        if (info.getVersion().isReleaseCompatible(new RuntimeVersion(17))) {
            workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, Charsets.UTF_8.name());
        } else {
            workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, Charsets.ISO_8859_1.name());
        }
        workingCopy.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, "org.erlide.backend.ertsProcessFactory");
        workingCopy.setAttribute(ErlRuntimeAttributes.NODE_NAME, getNodeName());
        workingCopy.setAttribute(ErlRuntimeAttributes.RUNTIME_NAME, info.getName());
        workingCopy.setAttribute(ErlRuntimeAttributes.COOKIE, getCookie());
        // workingCopy.setAttribute(ErlLaunchAttributes.CONSOLE,
        // !options.contains(BackendOptions.NO_CONSOLE));
        workingCopy.setAttribute(ErlRuntimeAttributes.USE_LONG_NAME, hasLongName());
        workingCopy.setAttribute(ErlRuntimeAttributes.INTERNAL, isInternal());
        workingCopy.setAttribute(ErlRuntimeAttributes.WORKING_DIR, getWorkingDir());
        return workingCopy;
    } catch (final CoreException e) {
        ErlLogger.error(e);
        return null;
    }
}
Also used : RuntimeInfo(org.erlide.runtime.runtimeinfo.RuntimeInfo) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) RuntimeVersion(org.erlide.runtime.runtimeinfo.RuntimeVersion) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Aggregations

ILaunchManager (org.eclipse.debug.core.ILaunchManager)78 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)53 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)41 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)37 CoreException (org.eclipse.core.runtime.CoreException)28 ArrayList (java.util.ArrayList)15 ILaunch (org.eclipse.debug.core.ILaunch)14 IPath (org.eclipse.core.runtime.IPath)9 File (java.io.File)7 HashMap (java.util.HashMap)6 Path (org.eclipse.core.runtime.Path)6 IProject (org.eclipse.core.resources.IProject)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 IOException (java.io.IOException)4 Map (java.util.Map)4 IStatus (org.eclipse.core.runtime.IStatus)4 LinkedList (java.util.LinkedList)3 Status (org.eclipse.core.runtime.Status)3 IProcess (org.eclipse.debug.core.model.IProcess)3 IProcess2 (org.talend.core.model.process.IProcess2)3