Search in sources :

Example 11 with ILaunchConfigurationTab

use of org.eclipse.debug.ui.ILaunchConfigurationTab in project linuxtools by eclipse.

the class ProviderLaunchConfigurationDelegate method launch.

@Override
public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    if (config != null) {
        // get provider id from configuration.
        String providerId = config.getAttribute(ProviderProfileConstants.PROVIDER_CONFIG_ATT, // $NON-NLS-1$
        "");
        String providerToolName = config.getAttribute(ProviderProfileConstants.PROVIDER_CONFIG_TOOLNAME_ATT, // $NON-NLS-1$
        "");
        if (providerId == null || providerId.isEmpty()) {
            // $NON-NLS-1$
            String cProjectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "");
            if (cProjectName != null && !cProjectName.isEmpty()) {
                // We have a previously created C/C++ run/debug configuration and now Linux Tools
                // profiling framework has been added.  Find a suitable default provider id to use
                // and perform initialization prior to profiling.
                String defaultType = null;
                String[] categories = ProviderFramework.getProviderCategories();
                if (categories.length == 0) {
                    infoDialog(Messages.ProviderNoProfilers_title_0, Messages.ProviderNoProfilers_msg_0);
                    return;
                }
                for (String category : categories) {
                    // Give precedence to timing category if present
                    if (category.equals("timing")) {
                        // $NON-NLS-1$
                        // $NON-NLS-1$
                        defaultType = "timing";
                    }
                }
                // if default category still not set, take first one found
                if (defaultType == null)
                    defaultType = categories[0];
                providerId = ProviderFramework.getProviderIdToRun(null, defaultType);
                ProfileLaunchConfigurationTabGroup tabGroupConfig = ProviderFramework.getTabGroupProviderFromId(providerId);
                if (tabGroupConfig == null) {
                    infoDialog(Messages.ProviderNoProfilers_title_0, Messages.ProviderNoProfilers_msg_0);
                    return;
                }
                AbstractLaunchConfigurationTab[] tabs = tabGroupConfig.getProfileTabs();
                // Set up defaults according to profiling tabs.  We must use a working copy
                // to do this which we save at the end to the original copy.
                ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
                for (ILaunchConfigurationTab tab : tabs) {
                    tab.setDefaults(wc);
                }
                config = wc.doSave();
            }
        }
        // get delegate associated with provider id.
        AbstractCLaunchDelegate delegate = ProviderFramework.getConfigurationDelegateFromId(providerId);
        // launch delegate
        if (delegate != null) {
            try {
                delegate.launch(config, mode, launch, monitor);
            } catch (CoreException e) {
                errorDialog(Messages.ProviderLaunchError_msg_0, e.getMessage());
            }
        } else {
            String message = providerToolName.isEmpty() ? NLS.bind(Messages.ProviderProfilerMissing_msg_0, providerId) : NLS.bind(Messages.ProviderProfilerMissing_msg_1, providerToolName);
            infoDialog(Messages.ProviderProfilerMissing_title_0, message);
        }
    }
}
Also used : AbstractLaunchConfigurationTab(org.eclipse.debug.ui.AbstractLaunchConfigurationTab) CoreException(org.eclipse.core.runtime.CoreException) ProfileLaunchConfigurationTabGroup(org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) AbstractCLaunchDelegate(org.eclipse.cdt.launch.AbstractCLaunchDelegate) ILaunchConfigurationTab(org.eclipse.debug.ui.ILaunchConfigurationTab)

Example 12 with ILaunchConfigurationTab

use of org.eclipse.debug.ui.ILaunchConfigurationTab in project linuxtools by eclipse.

the class ProviderLaunchShortcut method setDefaultProfileAttributes.

@Override
protected void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) {
    // acquire a provider id to run.
    final String providerId = ProviderFramework.getProviderIdToRun(wc, getProfilingType());
    // get tool name from id.
    final String providerToolName = ProviderFramework.getProviderToolNameFromId(providerId);
    // get tab group associated with provider id.
    final ProfileLaunchConfigurationTabGroup tabgroup = ProviderFramework.getTabGroupProviderFromId(providerId);
    /**
     * Certain tabs' setDefaults(ILaunchConfigurationWorkingCopy) may
     * require a launch configuration dialog. Eg. CMainTab generates
     * a name for the configuration based on generateName in setDefaults()
     * so we can create a temporary launch configuration dialog here. With
     * the exception of generateName(String), the other methods do not
     * get called.
     */
    ILaunchConfigurationDialog dialog = new ILaunchConfigurationDialog() {

        @Override
        public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void updateMessage() {
            throw new UnsupportedOperationException();
        }

        @Override
        public void updateButtons() {
            throw new UnsupportedOperationException();
        }

        @Override
        public void setName(String name) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void setActiveTab(int index) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void setActiveTab(ILaunchConfigurationTab tab) {
            throw new UnsupportedOperationException();
        }

        @Override
        public ILaunchConfigurationTab[] getTabs() {
            return null;
        }

        @Override
        public String getMode() {
            return null;
        }

        @Override
        public ILaunchConfigurationTab getActiveTab() {
            return null;
        }

        @Override
        public String generateName(String name) {
            if (name == null) {
                // $NON-NLS-1$
                name = "";
            }
            String providerConfigutationName = generateProviderConfigurationName(name, providerToolName);
            return getLaunchManager().generateLaunchConfigurationName(providerConfigutationName);
        }
    };
    // $NON-NLS-1$
    tabgroup.createTabs(dialog, "profile");
    // set configuration to match default attributes for all tabs.
    for (ILaunchConfigurationTab tab : tabgroup.getTabs()) {
        tab.setLaunchConfigurationDialog(dialog);
        tab.setDefaults(wc);
    }
    // get configuration shortcut associated with provider id.
    ProfileLaunchShortcut shortcut = ProviderFramework.getLaunchShortcutProviderFromId(providerId);
    // set attributes related to the specific profiling shortcut configuration.
    shortcut.setDefaultProfileLaunchShortcutAttributes(wc);
    wc.setAttribute(ProviderProfileConstants.PROVIDER_CONFIG_ATT, providerId);
    // set tool name in configuration.
    wc.setAttribute(ProviderProfileConstants.PROVIDER_CONFIG_TOOLNAME_ATT, providerToolName);
    /**
     * To avoid renaming an already renamed launch configuration, we can
     * check the expected format of the name using regular expressions and
     * skip on matches.
     */
    String curConfigName = wc.getName();
    // $NON-NLS-1$
    Pattern configNamePattern = Pattern.compile(".+\\s\\[.+\\](\\s\\(\\d+\\))?$");
    Matcher match = configNamePattern.matcher(curConfigName);
    if (!match.find()) {
        wc.rename(dialog.generateName(curConfigName));
    }
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ILaunchConfigurationDialog(org.eclipse.debug.ui.ILaunchConfigurationDialog) ProfileLaunchConfigurationTabGroup(org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup) ProfileLaunchShortcut(org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) ILaunchConfigurationTab(org.eclipse.debug.ui.ILaunchConfigurationTab)

Example 13 with ILaunchConfigurationTab

use of org.eclipse.debug.ui.ILaunchConfigurationTab in project linuxtools by eclipse.

the class HelgrindLaunchShortcut method setDefaultProfileAttributes.

@Override
protected void setDefaultProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException {
    ValgrindOptionsTab tab = new ValgrindOptionsTab();
    tab.setDefaults(wc);
    ILaunchConfigurationTab defaultTab = ValgrindLaunchPlugin.getDefault().getToolPage(HelgrindPlugin.TOOL_ID);
    defaultTab.setDefaults(wc);
}
Also used : ValgrindOptionsTab(org.eclipse.linuxtools.internal.valgrind.launch.ValgrindOptionsTab) ILaunchConfigurationTab(org.eclipse.debug.ui.ILaunchConfigurationTab)

Example 14 with ILaunchConfigurationTab

use of org.eclipse.debug.ui.ILaunchConfigurationTab in project linuxtools by eclipse.

the class AbstractValgrindTest method setProfileAttributes.

@Override
protected void setProfileAttributes(ILaunchConfigurationWorkingCopy wc) throws CoreException {
    ILaunchConfigurationTab tab = new ValgrindOptionsTab();
    tab.setDefaults(wc);
    tab = ValgrindLaunchPlugin.getDefault().getToolPage(getToolID());
    tab.setDefaults(wc);
    wc.setAttribute(LaunchConfigurationConstants.ATTR_TOOL, getToolID());
    wc.setAttribute(LaunchConfigurationConstants.ATTR_FULLPATH_AFTER, false);
}
Also used : ValgrindOptionsTab(org.eclipse.linuxtools.internal.valgrind.launch.ValgrindOptionsTab) ILaunchConfigurationTab(org.eclipse.debug.ui.ILaunchConfigurationTab)

Aggregations

ILaunchConfigurationTab (org.eclipse.debug.ui.ILaunchConfigurationTab)14 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)5 ValgrindOptionsTab (org.eclipse.linuxtools.internal.valgrind.launch.ValgrindOptionsTab)4 ProfileLaunchConfigurationTabGroup (org.eclipse.linuxtools.profiling.launch.ProfileLaunchConfigurationTabGroup)3 CoreException (org.eclipse.core.runtime.CoreException)2 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 AbstractCLaunchDelegate (org.eclipse.cdt.launch.AbstractCLaunchDelegate)1 AbstractLaunchConfigurationTab (org.eclipse.debug.ui.AbstractLaunchConfigurationTab)1 CommonTab (org.eclipse.debug.ui.CommonTab)1 EnvironmentTab (org.eclipse.debug.ui.EnvironmentTab)1 ILaunchConfigurationDialog (org.eclipse.debug.ui.ILaunchConfigurationDialog)1 SourceLookupTab (org.eclipse.debug.ui.sourcelookup.SourceLookupTab)1 JavaArgumentsTab (org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab)1 JavaClasspathTab (org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 SystemTapOptionsTab (org.eclipse.linuxtools.internal.callgraph.launch.SystemTapOptionsTab)1 ProfileLaunchShortcut (org.eclipse.linuxtools.profiling.launch.ProfileLaunchShortcut)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 ServerLaunchConfigurationTab (org.eclipse.wst.server.ui.ServerLaunchConfigurationTab)1