Ron,
here is a snippet for you. Place it to the plugin`s activator class. Invoke
initializeLpexEditor() at the end of the start method of the activator
class. Add the plugin "com.ibm.lpex" to the plugins dependencies. The
snippet creates a submenu "CMOne" in the LPEX Editor context menu. Within
the submenu "CMOne" there will be created the menu items "Compile" and
"Recompile dependent objects". If you take a look at the code I think you
should be able to customize it.
Frank
protected void initializeLpexEditor() {
LpexView.doGlobalCommand("set
default.updateProfile.userActions " +
getLPEXEditorUserActions(LpexView.globalQuery("current.updateProfile.userAct
ions")));
LpexView.doGlobalCommand("set
default.updateProfile.userKeyActions " +
getLPEXEditorUserKeyActions(LpexView.globalQuery("current.updateProfile.user
KeyActions")));
LpexView.doGlobalCommand("set default.popup " +
getLPEXEditorPopupMenu(LpexView.globalQuery("current.popup")));
}
public static String getLPEXEditorUserActions(String actions) {
StringBuffer newActions = new StringBuffer();
if (actions == null) {
newActions.append("");
}
else {
newActions.append(actions);
}
String cmoneAction;
cmoneAction = "CMOneCompile
de.taskforce.cmoneng.rse.lpexactions.CompileLPEXAction";
if (newActions.indexOf(cmoneAction) == -1) {
if (newActions.length() != 0) {
newActions.append(" ");
}
newActions.append(cmoneAction);
}
cmoneAction = "CMOneRecompile
de.taskforce.cmoneng.rse.lpexactions.RecompileLPEXAction";
if (newActions.indexOf(cmoneAction) == -1) {
if (newActions.length() != 0) {
newActions.append(" ");
}
newActions.append(cmoneAction);
}
return newActions.toString();
}
public static String getLPEXEditorUserKeyActions(String keyActions)
{
StringBuffer newKeyActions = new StringBuffer();
if (keyActions == null) {
newKeyActions.append("");
}
else {
newKeyActions.append(keyActions);
}
String cmoneKeyAction;
cmoneKeyAction = "c-1 CMOneCompile";
if (newKeyActions.indexOf(cmoneKeyAction) == -1) {
if (newKeyActions.length() != 0) {
newKeyActions.append(" ");
}
newKeyActions.append(cmoneKeyAction);
}
cmoneKeyAction = "c-2 CMOneRecompile";
if (newKeyActions.indexOf(cmoneKeyAction) == -1) {
if (newKeyActions.length() != 0) {
newKeyActions.append(" ");
}
newKeyActions.append(cmoneKeyAction);
}
return newKeyActions.toString();
}
public static String getLPEXEditorPopupMenu(String popupMenu) {
String startMenu = "beginSubmenu \"CMOne\"";
String endMenu = "endSubmenu separator";
StringBuffer oldMenu = null;
if (popupMenu != null) {
do {
oldMenu = new StringBuffer("");
int startIndex =
popupMenu.indexOf(startMenu, 0);
if (startIndex == -1) {
oldMenu.append(popupMenu);
break;
}
else {
int endIndex =
popupMenu.indexOf(endMenu, startIndex);
if (startIndex > 0) {
oldMenu.append(popupMenu.substring(0, startIndex));
}
if (popupMenu.length() > endIndex +
endMenu.length() + 1) {
oldMenu.append(popupMenu.substring(endIndex + endMenu.length() + 1));
}
popupMenu = oldMenu.toString();
}
}
while (true);
}
StringBuffer newMenu = new StringBuffer("");
newMenu.append(startMenu);
newMenu.append(" ");
newMenu.append("\"" + Messages.getString("Compile") + "\"
CMOneCompile");
newMenu.append(" ");
newMenu.append("\"" +
Messages.getString("Recompile_dependent_objects") + "\" CMOneRecompile");
newMenu.append(" ");
newMenu.append(endMenu);
newMenu.append(" ");
if (oldMenu != null) {
newMenu.append(oldMenu.toString());
}
return newMenu.toString();
}
-----Ursprüngliche Nachricht-----
Von: wdsc-plugin-dev-bounces@xxxxxxxxxxxx
[mailto:wdsc-plugin-dev-bounces@xxxxxxxxxxxx] Im Auftrag von Ron Byrd
Gesendet: Sonntag, 24. November 2013 17:10
An: wdsc-plugin-dev@xxxxxxxxxxxx
Betreff: [RDi/WDSC-Plugin-Dev] Help with creating a popup menu item in an
Lpex editor
I am sending this to two lists. WDSCI-L and JAVA400-L.
I am trying to add a menu item to the LPEX Popup menu.
I can add a new item to the popup menu in other editors using the
SimplePopupMenu example on the web.
However I cannot get the new menu item to show up on a member opened in the
LPEX editor.
Below is the plugin.xml file
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.ui.IEditorInput"
id="simplePopupMenu.contribution1">
<menu
label="ShowIFile"
path="additions"
id="simplePopupMenu.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="SimpleMessageAction"
class="simplepopupmenu.popup.actions.SimpleMessageAction"
menubarPath="simplePopupMenu.menu1/group1"
enablesFor="1"
id="simplePopupMenu.newAction">
</action>
</objectContribution>
</extension>
<extension
point="com.ibm.lpex.preload">
<preload
class="simplePopupMenu.preload3">
</preload>
</extension>
</plugin>
If anyone has any ideas what I need to do to make this show up in the Lpex
Editor I would appreciate it.
Thanks
Ron
--
This is the RDi / WDSC Plugin Developers (WDSC-Plugin-Dev) mailing list To
post a message email: WDSC-Plugin-Dev@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/wdsc-plugin-dev
or email: WDSC-Plugin-Dev-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/wdsc-plugin-dev.
As an Amazon Associate we earn from qualifying purchases.