Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
AW: [cdt-dev] Programatically getting settings from the current project


thanks a lot for your support. Your response, together with that of Chris helped me a lot. 

There is one catch: I need to figure out to currently selected project when running inside the launch configuration delegate's launch() method, and in this place I can't do 

	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

because getActiveWorkbenchWindow() returns null.

Can you help me out?


-----Ursprüngliche Nachricht-----
Von: cdt-dev-admin@xxxxxxxxxxx [mailto:cdt-dev-admin@xxxxxxxxxxx] Im Auftrag von Alain Magloire
Gesendet: Mittwoch, 2. März 2005 15:52
An: cdt-dev@xxxxxxxxxxx
Betreff: Re: [cdt-dev] Programatically getting settings from the current project

> Hello folks,
> =20
> I want to write an external tool which will transfer the output of a =
> selected managed make project to the target machine. So I need to find =
> out
> =20
> - which project is currently selected in the C/C++ projects navigator

If it is specific to the C/C++ project navigator you can get the Viewer
which is an ISelectionProvider, see the docs on ISelectionProvider and Viewer classes.

But you may want to be a little more general:

	IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (window != null) {
		IWorkbenchPage page = window.getActivePage();
		if (page != null) {
			IWorkbenchPart activePart = page.getActivePart();
			if (activePart instanceof IEditorPart) {
				IEditorInput input = ((IEditorPart)activePart).getEditorInput();
				// TODO:extract project from the input IFile.
			} else if (activePart != null) {
				IWorkbenchPartSite site = activePart.getSite();
				if (site != null) {
					ISelectionProvider selectionProvider = site.getSelectionProvider();
					if (selectionProvider != null) {
						ISelection selection = selectionProvider.getSelection();
						if (selection instanceof IStructuredSelection) {
							List list = ((IStructuredSelection)selection).toList();
							// TODO: Go through the object an extract the Project.

Browse the Eclipse API and documentation, this is not really a specific CDT task.

> - which configuration of this project is currently activated and

Browse the org.eclipse.cdt.managedbuilder.core plugin, you will probably find what you are
looking for.  However as a policy, do not use classes in *internal* package name.
See Eclipse coding conventions.

> - what the name of output artifact is.=20
> =20
> Can you give me any hints on how to gather this information?
> =20
> Regards,
> =20

cdt-dev mailing list

Back to the top