Search in sources :

Example 51 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class LaunchConfigTabTest method initConfig.

private ILaunchConfigurationWorkingCopy initConfig() throws CoreException {
    ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
    tab.setDefaults(wc);
    tab.createControl(testShell);
    tab.initializeFrom(config);
    int ix = Arrays.asList(tab.getTools()).indexOf(MemcheckPlugin.TOOL_ID);
    tab.getToolsCombo().select(ix);
    ILaunchConfigurationTab dynamicTab = tab.getDynamicTab();
    this.dynamicTab = (MemcheckToolPage) dynamicTab;
    return wc;
}
Also used : ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) ILaunchConfigurationTab(org.eclipse.debug.ui.ILaunchConfigurationTab)

Example 52 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class LaunchConfigTabTest method testTrackOriginsValidity.

@Test
public void testTrackOriginsValidity() throws Exception {
    ILaunchConfigurationWorkingCopy wc = initConfig();
    IProject project = CDebugUtils.verifyCProject(config).getProject();
    Version ver = ValgrindLaunchPlugin.getDefault().getValgrindVersion(project);
    if (ver.compareTo(ValgrindLaunchPlugin.VER_3_4_0) >= 0) {
        dynamicTab.getTrackOriginsButton().setSelection(true);
        tab.performApply(wc);
        assertTrue(tab.isValid(wc));
        dynamicTab.getUndefValueButton().setSelection(false);
        tab.performApply(wc);
        assertFalse(tab.isValid(wc));
    }
}
Also used : Version(org.osgi.framework.Version) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 53 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class MultiProcessTest method testExec.

@Test
public void testExec() throws Exception {
    ILaunchConfigurationWorkingCopy config = createConfiguration(proj.getProject()).getWorkingCopy();
    config.setAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, true);
    config.doSave();
    // $NON-NLS-1$
    doLaunch(config, "testExec");
    IValgrindMessage[] messages = ValgrindUIPlugin.getDefault().getView().getMessages();
    assertEquals(4, messages.length);
    // $NON-NLS-1$
    checkTestMessages(messages, "testExec");
}
Also used : IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Test(org.junit.Test)

Example 54 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.

the class LaunchWizard method promptForInputs.

private void promptForInputs() {
    InputDialog id = new // $NON-NLS-1$
    InputDialog(// $NON-NLS-1$
    new Shell(), // $NON-NLS-1$
    Messages.getString("LaunchWizard.WelcomeWizard"), // $NON-NLS-1$
    Messages.getString("LaunchWizard.Text1") + // $NON-NLS-1$
    Messages.getString("LaunchWizard.Text2") + // $NON-NLS-1$
    Messages.getString("LaunchWizard.Text3"), getLaunchManager().generateLaunchConfigurationName(Messages.getString("LaunchWizard.NamePrefix")), // $NON-NLS-1$
    null);
    id.open();
    if (id.getReturnCode() == Window.CANCEL) {
        return;
    }
    name = id.getValue();
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IPath location = root.getLocation();
    workspacePath = location.toString();
    sh = new Shell();
    sh.setSize(WIDTH, HEIGHT);
    sh.setLayout(new GridLayout(1, false));
    sh.setText(name);
    // $NON-NLS-1$
    Image img = new Image(sh.getDisplay(), PluginConstants.getPluginLocation() + "systemtapbanner.png");
    Composite imageCmp = new Composite(sh, SWT.BORDER);
    imageCmp.setLayout(new FillLayout());
    GridData imageData = new GridData(650, 157);
    imageData.horizontalAlignment = SWT.CENTER;
    imageCmp.setLayoutData(imageData);
    imageCmp.setBackgroundImage(img);
    Composite fileComp = new Composite(sh, SWT.NONE);
    fileComp.setLayout(new GridLayout(2, false));
    fileComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    GridDataFactory labelData = GridDataFactory.fillDefaults().grab(true, false).span(2, 1);
    Label scriptLabel = new Label(fileComp, SWT.HORIZONTAL);
    // $NON-NLS-1$
    scriptLabel.setText(Messages.getString("LaunchWizard.Script"));
    labelData.applyTo(scriptLabel);
    GridDataFactory textData = GridDataFactory.fillDefaults().grab(true, false).hint(WIDTH, SWT.DEFAULT);
    scriptLocation = new Text(fileComp, SWT.SINGLE | SWT.BORDER);
    textData.applyTo(scriptLocation);
    Button scriptButton = new Button(fileComp, SWT.PUSH);
    // $NON-NLS-1$
    scriptButton.setText(Messages.getString("SystemTapOptionsTab.BrowseFiles"));
    scriptButton.setLayoutData(new GridData());
    scriptButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        String filePath = scriptLocation.getText();
        FileDialog dialog = new FileDialog(sh, SWT.SAVE);
        filePath = dialog.open();
        if (filePath != null) {
            scriptLocation.setText(filePath);
        }
    }));
    GridData gd2 = new GridData();
    gd2.horizontalSpan = 3;
    Label binaryLabel = new Label(fileComp, SWT.HORIZONTAL);
    // $NON-NLS-1$
    binaryLabel.setText(Messages.getString("LaunchWizard.BinFile"));
    labelData.applyTo(binaryLabel);
    binaryLocation = new Text(fileComp, SWT.SINGLE | SWT.BORDER);
    textData.applyTo(binaryLocation);
    Button binaryButton = new Button(fileComp, SWT.PUSH);
    // $NON-NLS-1$
    binaryButton.setText(Messages.getString("SystemTapOptionsTab.WorkspaceButton2"));
    binaryButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(sh, new WorkbenchLabelProvider(), new WorkbenchContentProvider());
        // $NON-NLS-1$
        dialog.setTitle(Messages.getString("SystemTapOptionsTab.SelectResource"));
        // $NON-NLS-1$
        dialog.setMessage(Messages.getString("SystemTapOptionsTab.SelectSuppressions"));
        dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
        dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
        if (dialog.open() == IDialogConstants.OK_ID) {
            IResource resource = (IResource) dialog.getFirstResult();
            String arg = resource.getFullPath().toString();
            binaryLocation.setText(workspacePath + arg);
        }
    }));
    Composite argumentsComp = new Composite(sh, SWT.BORDER_DASH);
    argumentsComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    argumentsComp.setLayout(new GridLayout(2, false));
    Label argumentsLabel = new Label(argumentsComp, SWT.HORIZONTAL);
    // $NON-NLS-1$
    argumentsLabel.setText(Messages.getString("LaunchWizard.Args"));
    labelData.applyTo(argumentsLabel);
    argumentsLocation = new Text(argumentsComp, SWT.MULTI | SWT.WRAP | SWT.BORDER);
    GridData gd3 = new GridData(GridData.FILL_HORIZONTAL);
    gd3.heightHint = 200;
    argumentsLocation.setLayoutData(gd3);
    Button argumentsButton = new Button(argumentsComp, SWT.PUSH);
    // $NON-NLS-1$
    argumentsButton.setText(Messages.getString("LaunchWizard.Func"));
    argumentsButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> argumentsLocation.setText(// $NON-NLS-1$
    argumentsLocation.getText() + " process(\"" + binaryLocation.getText() + // $NON-NLS-1$
    "\").function(\"\")")));
    // TODO: Don't use blank labels to move button to the right column :P
    Label blankLabel2 = new Label(argumentsComp, SWT.HORIZONTAL);
    // $NON-NLS-1$
    blankLabel2.setText("");
    Button launch = new Button(sh, SWT.PUSH);
    launch.setLayoutData(new GridData(GridData.CENTER, GridData.BEGINNING, false, false));
    // $NON-NLS-1$
    launch.setText(Messages.getString("LaunchWizard.Launch"));
    launch.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
        scriptPath = scriptLocation.getText();
        binaryPath = binaryLocation.getText();
        arguments = argumentsLocation.getText();
        ILaunchConfigurationWorkingCopy wc = createConfiguration(null, name);
        try {
            // $NON-NLS-1$
            finishLaunch(scriptPath + ": " + binName, mode, wc);
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        sh.dispose();
    }));
    // TODO: Verify that this works
    Display.getCurrent().asyncExec(() -> sh.open());
}
Also used : InputDialog(org.eclipse.jface.dialogs.InputDialog) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Image(org.eclipse.swt.graphics.Image) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IWorkspace(org.eclipse.core.resources.IWorkspace) IPath(org.eclipse.core.runtime.IPath) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) FillLayout(org.eclipse.swt.layout.FillLayout) IEditorPart(org.eclipse.ui.IEditorPart) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) FileDialog(org.eclipse.swt.widgets.FileDialog) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) Display(org.eclipse.swt.widgets.Display) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Window(org.eclipse.jface.window.Window) IResource(org.eclipse.core.resources.IResource) SWT(org.eclipse.swt.SWT) ISelection(org.eclipse.jface.viewers.ISelection) Label(org.eclipse.swt.widgets.Label) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) PluginConstants(org.eclipse.linuxtools.internal.callgraph.core.PluginConstants) SelectionListener(org.eclipse.swt.events.SelectionListener) GridLayout(org.eclipse.swt.layout.GridLayout) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) InputDialog(org.eclipse.jface.dialogs.InputDialog) IPath(org.eclipse.core.runtime.IPath) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) FillLayout(org.eclipse.swt.layout.FillLayout) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Image(org.eclipse.swt.graphics.Image) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) GridDataFactory(org.eclipse.jface.layout.GridDataFactory) Shell(org.eclipse.swt.widgets.Shell) GridLayout(org.eclipse.swt.layout.GridLayout) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) Button(org.eclipse.swt.widgets.Button) IWorkspace(org.eclipse.core.resources.IWorkspace) GridData(org.eclipse.swt.layout.GridData) FileDialog(org.eclipse.swt.widgets.FileDialog) IResource(org.eclipse.core.resources.IResource)

Example 55 with ILaunchConfigurationWorkingCopy

use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project bndtools by bndtools.

the class JUnitShortcut method launchJavaElements.

@Override
protected void launchJavaElements(List<IJavaElement> elements, String mode) throws CoreException {
    assert elements != null && elements.size() > 0;
    IProject targetProject = elements.get(0).getJavaProject().getProject();
    IPath projectPath = targetProject.getFullPath().makeRelative();
    ILaunchConfiguration config = findLaunchConfig(projectPath);
    ILaunchConfigurationWorkingCopy wc = null;
    if (config == null) {
        wc = createConfiguration(projectPath, targetProject);
    } else {
        wc = config.getWorkingCopy();
    }
    if (wc != null) {
        customise(elements, wc);
        config = wc.doSave();
        DebugUITools.launch(config, mode);
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) IPath(org.eclipse.core.runtime.IPath) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IProject(org.eclipse.core.resources.IProject)

Aggregations

ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)119 Test (org.junit.Test)75 ILaunch (org.eclipse.debug.core.ILaunch)52 IProcess (org.eclipse.debug.core.model.IProcess)49 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)29 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)18 CoreException (org.eclipse.core.runtime.CoreException)16 IPath (org.eclipse.core.runtime.IPath)12 ILaunchManager (org.eclipse.debug.core.ILaunchManager)10 AbstractTest (org.eclipse.linuxtools.profiling.tests.AbstractTest)8 IProject (org.eclipse.core.resources.IProject)7 Shell (org.eclipse.swt.widgets.Shell)7 ArrayList (java.util.ArrayList)6 Path (org.eclipse.core.runtime.Path)6 ILaunchConfigurationTab (org.eclipse.debug.ui.ILaunchConfigurationTab)5 Version (org.osgi.framework.Version)5 IResource (org.eclipse.core.resources.IResource)4 Launch (org.eclipse.debug.core.Launch)3 MassifViewPart (org.eclipse.linuxtools.internal.valgrind.massif.MassifViewPart)3 Button (org.eclipse.swt.widgets.Button)3