Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] get artifact name and getProjet return null

You may find it useful to use the PTP performance tools framework for launching your tools.
http://wiki.eclipse.org/PTP/designs/perf_tools_framework
We are in the process of documenting this better.


...Beth

Beth Tibbitts (859) 243-4981 (TL 545-4981)
High Productivity Tools / Parallel Tools http://eclipse.org/ptp
IBM T.J.Watson Research Center
Mailing Address: IBM Corp., 745 West New Circle Road, Lexington, KY 40511
Inactive hide details for "Mikael Engbom" <mike.cdt.mail.list@xxxxxxxxx>"Mikael Engbom" <mike.cdt.mail.list@xxxxxxxxx>


          "Mikael Engbom" <mike.cdt.mail.list@xxxxxxxxx>
          Sent by: cdt-dev-bounces@xxxxxxxxxxx

          06/03/08 07:51 AM

          Please respond to
          "CDT General developers list." <cdt-dev@xxxxxxxxxxx>

To

"CDT General developers list." <cdt-dev@xxxxxxxxxxx>

cc


Subject

Re: [cdt-dev] get artifact name and getProjet return null

Thanks for the answer,

Will try and use something along the lines you wrote to find the active (focused) project.

The main problem is however question 1, I will describe the plug-in some more and maybe someone can give me some hints.

This part of the plug-in will run the program several times with different environments variables and report back execution time and output data from the program. Today I am using a hard coded shell script that is started from within eclipse and then parse the result and report it nicely.

The problem is that this is far from a general solution since I need a new shell script for each project, I would like to either create a dynamic shell script depending on the artifact name and the program arguments or start the program directly from within eclipse. The nice thing with a shell script is that I can very easily add the timing command and set different environment variables, this solution will be specific for the operating system (Kubuntu, 7.04), but that is not a problem for now.

I can however not find any functions in the API that will return artifact name and/or program arguments, any hints where I can find this information?

/Mikael

On Mon, Jun 2, 2008 at 6:14 PM, Wieant Nielander <wieant@xxxxxxxxx> wrote:

    > Using the following function to get the active project will always return
    > null, is this a bug or do I use it incorrect?
    >
    > IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject();
    >
    > For now I use this method, but it is far from perfect since I need to close
    > all the other projects.
    >
    > IProject[] myproject =
    > ResourcesPlugin.getWorkspace().getRoot().getProjects();
    > IProject project = null;
    > for(int i = 0; i < myproject.length; i++) {
    > if( myproject[i].isOpen()) {
    > project = myproject[i];
    > continue;
    > }
    > }

    You are using getProject incorrectly, 'getProject()' is a method
    defined on all IResource elements, including the root workspace, and
    returns the project to which the given resource belongs, but as the
    workspace root does not belong to any project it will by definition
    return null.

    It is important to state in what context you need this info, in
    general an action or view keeps track of the current selection,
    and from that you can distill the 'active' project, e.g. if you have
    an action, you could use something like the following in its delegate:

    /**
    * @see IActionDelegate#selectionChanged(IAction, ISelection)
    */
    public void selectionChanged(IAction action, ISelection selection)
    {
    if ( selection instanceof StructuredSelection )
    {
    Object obj = ((StructuredSelection)selection).getFirstElement();
    if ( obj instanceof IAdaptable )
    {
    obj = ((IAdaptable)obj).getAdapter(IResource.class);
    }
    if ( obj instanceof IResource )
    {
    m_project = ((IResource)obj).getProject();
    }
    }
    _______________________________________________
    cdt-dev mailing list

    cdt-dev@xxxxxxxxxxx
    https://dev.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev

GIF image

GIF image

GIF image


Back to the top