Board index » jbuilder » What is a source Object used in Actions?

What is a source Object used in Actions?


2003-10-23 02:53:24 AM
jbuilder0
Hi,
I am trying to create an opentool that will add a PopUp Menu Item
when right clicking on a JBuilder Project in the left hand side pane.
I am guessing I would use the "ActionPopupMenu" class to accomplish this.
However I cannot find any examples to demonstrate the use of this class.
The contructor of ActionPopupMenu takes an Object "source object" and a
ActionGroup. I am not sure what it is meant exactly by the source object.
Would appreciate if anybody can explain what a source object is and any
examples showing how to add a popup menu to Projects or somthing similar
would be great.
Thank you,
Gina
 
 

Re:What is a source Object used in Actions?

"Gina Assaf" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
Hi,
I am trying to create an opentool that will add a PopUp Menu Item
when right clicking on a JBuilder Project in the left hand side pane.
I am guessing I would use the "ActionPopupMenu" class to accomplish this.
However I cannot find any examples to demonstrate the use of this class.
The contructor of ActionPopupMenu takes an Object "source object" and a
ActionGroup. I am not sure what it is meant exactly by the source object.
Would appreciate if anybody can explain what a source object is and any
examples showing how to add a popup menu to Projects or somthing similar
would be great.
AFAI understand you, you are trying to add an own right click context menu
entry for the project viewer's project node, right?
You can setup this in one of your OT's classes, which has to implement the
corresponding JB OTAPI hooks. I'll give you a short imaginary example:
---------------------- start -------------------------
package yourothook;
import javax.swing.ImageIcon;
import com.borland.primetime.util.Images;
import com.borland.primetime.ide.*;
import com.borland.primetime.actions.*;
import com.borland.primetime.vfs.*;
import com.borland.jbuilder.node.*;
import com.borland.primetime.node.*;
import com.borland.jbuilder.JBuilderMenu;
import com.borland.jbuilder.JBuilderToolBar;
...
...
/**
* This is an OpenTool which allows to whatever...
* in a JBuilder Project.
*/
public class YourOTHook
{
//
// constructor
//
/**
* Construct a your OT hook object
*/
public YourOTHook() {
super();
}
//
// public operations
//
/**
* Start a your OT hook process for the given JBuilder browser
* @param browser the JBuilder browser
*/
public void start (Browser browser)
{
_browser = browser;
Project project = browser.getActiveProject();
// add any of your real problems processing code here...
// ...
}
/**
* static hook method to get the callback from the user interface of the
* JBuilder
*/
public static final BrowserAction ACTION_YourOTHook =
new BrowserAction("Your short description text", 'A', "Your longer
description text",
new ImageIcon(Images.getImage(YourOTHook.class,
"images/yourothook.gif")))
{
public void actionPerformed(Browser browser)
{
YourOTHook service = new YourOTHook();
service.start(browser);
}
};
/**
* Action group for the your OT hook stuff
*/
public static final ActionGroup GROUP_YourOTHook =
new ActionGroup("YourOTHookGroup", 'A', "Your OT Hook group...", new
ImageIcon(Images.getImage(YourOTHook.class, "images/yourothook.gif")));
/**
* Init the your ot hook opentool.
* This method is invoked by the JBuilder runtime system to setup
* this opentool.
* The YourOTHook tool includes the action into the menu, the toolbar and
* the context menu of the project.
*
* @param majorVersion the JB OTAPI major version number
* @param minorVersion the JB OTAPI minor version number
*/
public static void initOpenTool(byte majorVersion, byte minorVersion) {
// Add our actions to the Your OT Hook group
GROUP_YourOTHook.add(ACTION_YourOTHook);
// Add our YourOTHook group to the main Tools menu
//JBuilderMenu.GROUP_Tools.add(GROUP_YourOTHook);
// Add our YourOTHook group to the main toolbar
//Browser.addToolBarGroup(GROUP_YourOTHook);
JBuilderToolBar.GROUP_BuildBar.add(GROUP_YourOTHook);
// Register our actions with the Project View's context menu
ProjectView.registerContextActionProvider(new ContextActionProvider() {
public Action getContextAction(Browser browser, Node[] nodes) {
// Only return the your OT hook action if the selected nodes are all
// JBProject nodes, otherwise return null.
for (int i=0; i<nodes.length; i++) {
if (!(nodes[i] instanceof JBProject))
return null;
}
return GROUP_YourOTHook;
}
});
}
//
// private attributes
//
private Browser _browser;
}
--------------------------- end ---------------------------------
Don't forget also to add/setup some "classes.opentools" manifest file into
your project which then contains a line of:
OpenTools-UI: yourothook.YourOTHook
...or...
OpenTools-Core: yourothook.YourOTHook
...so you can use and tryout your OT via a setup JB runtime configuration
directly via a JBuilders "run" or "debug" runtime.
-Valentino