Search in sources :

Example 56 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project linuxtools by eclipse.

the class ClearMarkersHandler method execute.

@Override
public Object execute(ExecutionEvent event) {
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    try {
        root.deleteMarkers(ValgrindLaunchPlugin.MARKER_TYPE, true, IResource.DEPTH_INFINITE);
    } catch (CoreException e) {
    // do nothing for now
    }
    // Clear Valgrind view
    Display.getDefault().syncExec(() -> ValgrindUIPlugin.getDefault().resetView());
    return null;
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException)

Example 57 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project linuxtools by eclipse.

the class CovView method displayCovDetailedResult.

public static void displayCovDetailedResult(String binaryPath, String gcda) {
    try {
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        IFile binary = root.getFileForLocation(new Path(binaryPath));
        IProject project = null;
        if (binary != null) {
            project = binary.getProject();
        }
        // parse and process coverage data
        CovManager cvrgeMnger = new CovManager(binaryPath, project);
        List<String> gcdaPaths = new LinkedList<>();
        gcdaPaths.add(gcda);
        cvrgeMnger.processCovFiles(gcdaPaths, gcda);
        // generate model for view
        cvrgeMnger.fillGcovView();
        for (SourceFile sf : cvrgeMnger.getSourceMap().values()) {
            OpenSourceFileAction.openAnnotatedSourceFile(project, binary, sf, 0);
        }
    } catch (CoreException | IOException e) {
        reportError(e);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) CovManager(org.eclipse.linuxtools.internal.gcov.parser.CovManager) IFile(org.eclipse.core.resources.IFile) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) SourceFile(org.eclipse.linuxtools.internal.gcov.parser.SourceFile) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) LinkedList(java.util.LinkedList)

Example 58 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project linuxtools by eclipse.

the class CovView method displayCovResults.

public static void displayCovResults(String binaryPath, String gcda) {
    try {
        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
        IFile binary = root.getFileForLocation(new Path(binaryPath));
        IProject project = null;
        if (binary != null) {
            project = binary.getProject();
        }
        // parse and process coverage data
        CovManager cvrgeMnger = new CovManager(binaryPath, project);
        List<String> gcdaPaths = cvrgeMnger.getGCDALocations();
        cvrgeMnger.processCovFiles(gcdaPaths, gcda);
        // generate model for view
        cvrgeMnger.fillGcovView();
        // load an Eclipse view
        Date date = new Date(0);
        Date dateCandidate;
        for (String file : gcdaPaths) {
            dateCandidate = new Date(new File(file).lastModified());
            if (dateCandidate.after(date)) {
                date = dateCandidate;
            }
        }
        String timestamp = DateFormat.getInstance().format(date);
        PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
            try {
                displayCovResults(cvrgeMnger, timestamp);
            } catch (PartInitException e) {
                reportError(e);
            }
        });
    } catch (InterruptedException | IOException | CoreException e) {
        reportError(e);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IOException(java.io.IOException) IProject(org.eclipse.core.resources.IProject) Date(java.util.Date) CovManager(org.eclipse.linuxtools.internal.gcov.parser.CovManager) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) SourceFile(org.eclipse.linuxtools.internal.gcov.parser.SourceFile)

Example 59 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot 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 60 with IWorkspaceRoot

use of org.eclipse.core.resources.IWorkspaceRoot in project linuxtools by eclipse.

the class SystemTapOptionsTab method initializeFrom.

@Override
public void initializeFrom(ILaunchConfiguration configuration) {
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = workspace.getRoot();
    IPath location = root.getLocation();
    workspacePath = location.toString();
    try {
        button_k.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_KEEP_TEMPORARY, LaunchConfigurationConstants.DEFAULT_COMMAND_KEEP_TEMPORARY));
        button_u.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_NO_CODE_ELISION, LaunchConfigurationConstants.DEFAULT_COMMAND_NO_CODE_ELISION));
        button_w.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_DISABLE_WARNINGS, LaunchConfigurationConstants.DEFAULT_COMMAND_DISABLE_WARNINGS));
        button_b.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_BULK_MODE, LaunchConfigurationConstants.DEFAULT_COMMAND_BULK_MODE));
        button_g.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_GURU, LaunchConfigurationConstants.DEFAULT_COMMAND_GURU));
        button_P.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_PROLOGUE_SEARCH, LaunchConfigurationConstants.DEFAULT_COMMAND_PROLOGUE_SEARCH));
        button_t.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_TIMING_INFO, LaunchConfigurationConstants.DEFAULT_COMMAND_TIMING_INFO));
        buttonSkipBadvars.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_SKIP_BADVARS, LaunchConfigurationConstants.DEFAULT_COMMAND_SKIP_BADVARS));
        buttonIgnoreDwarf.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_IGNORE_DWARF, LaunchConfigurationConstants.DEFAULT_COMMAND_IGNORE_DWARF));
        button_q.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_TAPSET_COVERAGE, LaunchConfigurationConstants.DEFAULT_COMMAND_TAPSET_COVERAGE));
        button_F.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_LEAVE_RUNNING, LaunchConfigurationConstants.DEFAULT_COMMAND_LEAVE_RUNNING));
        button_s_Spinner.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_BUFFER_BYTES, LaunchConfigurationConstants.DEFAULT_COMMAND_BUFFER_BYTES));
        button_x_Spinner.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_TARGET_PID, LaunchConfigurationConstants.DEFAULT_COMMAND_TARGET_PID));
        button_v_Spinner.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_VERBOSE, LaunchConfigurationConstants.DEFAULT_COMMAND_VERBOSE));
        button_p_Spinner.setSelection(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_PASS, LaunchConfigurationConstants.DEFAULT_COMMAND_PASS));
        button_D_text.setText(configuration.getAttribute(LaunchConfigurationConstants.COMMAND_C_DIRECTIVES, LaunchConfigurationConstants.DEFAULT_COMMAND_C_DIRECTIVES));
        binaryFile.setText(configuration.getAttribute(LaunchConfigurationConstants.BINARY_PATH, LaunchConfigurationConstants.DEFAULT_BINARY_PATH));
        scriptFile.setText(configuration.getAttribute(LaunchConfigurationConstants.SCRIPT_PATH, LaunchConfigurationConstants.DEFAULT_SCRIPT_PATH));
        outputFile.setText(configuration.getAttribute(LaunchConfigurationConstants.OUTPUT_PATH, LaunchConfigurationConstants.DEFAULT_OUTPUT_PATH));
        arguments.setText(configuration.getAttribute(LaunchConfigurationConstants.ARGUMENTS, LaunchConfigurationConstants.DEFAULT_ARGUMENTS));
        binaryArguments.setText(configuration.getAttribute(LaunchConfigurationConstants.BINARY_ARGUMENTS, LaunchConfigurationConstants.DEFAULT_BINARY_ARGUMENTS));
        parser.setText(configuration.getAttribute(LaunchConfigurationConstants.PARSER_CLASS, LaunchConfigurationConstants.DEFAULT_PARSER_CLASS));
        viewer.setText(configuration.getAttribute(LaunchConfigurationConstants.VIEW_CLASS, LaunchConfigurationConstants.DEFAULT_VIEW_CLASS));
        useColourButton.setSelection(configuration.getAttribute(LaunchConfigurationConstants.USE_COLOUR, LaunchConfigurationConstants.DEFAULT_USE_COLOUR));
    } catch (CoreException e) {
        e.printStackTrace();
    }
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace)

Aggregations

IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)172 IProject (org.eclipse.core.resources.IProject)69 IPath (org.eclipse.core.runtime.IPath)60 IResource (org.eclipse.core.resources.IResource)57 IFile (org.eclipse.core.resources.IFile)53 CoreException (org.eclipse.core.runtime.CoreException)50 IWorkspace (org.eclipse.core.resources.IWorkspace)34 File (java.io.File)30 Path (org.eclipse.core.runtime.Path)29 IContainer (org.eclipse.core.resources.IContainer)26 URI (java.net.URI)18 IFolder (org.eclipse.core.resources.IFolder)17 IOException (java.io.IOException)15 IProjectDescription (org.eclipse.core.resources.IProjectDescription)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)12 IStatus (org.eclipse.core.runtime.IStatus)11 IJavaProject (org.eclipse.jdt.core.IJavaProject)11 Location (ch.acanda.eclipse.pmd.domain.Location)10