Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » CDT Newbie: How do I get the MakeView Resource?
CDT Newbie: How do I get the MakeView Resource? [message #64336] Tue, 11 March 2003 22:53
Eclipse UserFriend
Originally posted by: derek.p.gilbert.intel.com

I am using the simple helloworld plugin to make a call to the
addPersistentTarget method of MakeUtil. I am not sure how to get the
IResource for the MakeView view though to pass into the method. I am just
trying to make a straight call to add a target so I can eventually
incorporate this behind the scenes in a wizard. Could someone assist me in
how to get the resource I need to pass in. Below is my code. I actaully
just want to make the following call without the prompt but I need the
resource. I left the dialog in for now.

"MakeUtil.addPersistentTarget(resource, "TargetNameString");"

Thanks

package AddTarget.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.cdt.core.resources.MakeUtil;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.swt.widgets.Shell;


/**
* Our sample action implements workbench action delegate.
* The action proxy will be created by the workbench and
* shown in the UI. When the user tries to use the action,
* this delegate will be created and execution will be
* delegated to it.
* @see IWorkbenchWindowActionDelegate
*/
public class SampleAction implements IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
IResource resource;
Shell shell;

/**
* The constructor.
*/
public SampleAction() {
}

/**
* The action has been activated. The argument of the
* method represents the 'real' action sitting
* in the workbench UI.
* @see IWorkbenchWindowActionDelegate#run

*/
public void run(IAction action) {
InputDialog dialog = new InputDialog(shell, "Target Dialog: ", "Enter
Target(s): ", null, null);
dialog.open();
String value = dialog.getValue();
if (value != null && value.length() > 0) {
if (resource != null)
MakeUtil.addPersistentTarget(resource, value);
}

MessageDialog.openInformation(
window.getShell(),
"AddTarget Plug-in",
"Target Added");
}

/**
* Selection in the workbench has been changed. We
* can change the state of the 'real' action here
* if we want, but this can only happen after
* the delegate has been created.
* @see IWorkbenchWindowActionDelegate#selectionChanged
*/
public void selectionChanged(IAction action, ISelection selection) {
}

/**
* We can use this method to dispose of any system
* resources we previously allocated.
* @see IWorkbenchWindowActionDelegate#dispose
*/
public void dispose() {
}

/**
* We will cache window object in order to
* be able to provide parent shell for the message dialog.
* @see IWorkbenchWindowActionDelegate#init
*/
public void init(IWorkbenchWindow window) {
this.window = window;
}
}
Previous Topic:Extending the "MakeTargets" View
Next Topic:Problems using CDT just for code browsing
Goto Forum:
  


Current Time: Sat Jul 27 12:51:55 GMT 2024

Powered by FUDForum. Page generated in 0.02843 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top