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


I worked around the issue I mentioned in my erlier email by using 

		IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
		if (windows.length==1) {
			IWorkbenchWindow window = windows[0];
			if (window != null) { 

because I noticed that the length of the IWorkbenchWindow[] was 1 on my desktop. Although I am not sure what I am doing ...

But there is another issue, further down in the code, when I try to get the selection from the ISelectionProvider:

						ISelection selection = selectionProvider.getSelection();

When I step over this line I get a CoreException ("Invalid thread access"). So it seems there is no straightforward way to access GUI components from the LauchConfigurationDelegate.

Any hints on this?


-----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