Thanks Frank
Last night I was able to get a simple menu entry to work , however I was struggling to get any submenus to show up.
The following works by for a single menu item.
newUserMenuItems = "\"Indent 5\" Indent5";
I have tried your code for the submenus and it looks close to what I was trying to do. When I run the code the UserActions are built and the KeyActions are built and looking in the com.ibm.lpex.prefs file there are entries in there. However no menus show up.
com.ibm.lpex.prefs file:
default.popup="beginSubmenu \\"CMOne\\" \\" Compile\\" CMOneCompile \\" Recompile_dependent_objects\\" CMOneRecompile endSubmenu separator popup.cut cut popup.copy copy popup.paste paste separator MARK-Compare beginSubmenu popup.selectMenu popup.blockMarkElement blockMarkElement popup.blockMarkCharacter blockMarkCharacter popup.blockMarkRectangle blockMarkRectangle endSubmenu beginSubmenu popup.selectedMenu popup.blockCopy blockCopy popup.blockOverlay blockOverlay popup.blockMove blockMove popup.blockDelete blockDelete popup.blockUpperCase blockUpperCase popup.blockLowerCase blockLowerCase popup.blockShiftLeft blockShiftLeft popup.blockShiftRight blockShiftRight separator popup.filterSelection filterSelection popup.excludeSelection excludeSelection popup.findSelection findSelection popup.blockFill blockFill endSubmenu popup.blockUnmark blockUnmark separator popup.showAll showAll separator MARK-Source beginSubmenu popup.sourceMenu separator popup.hexEditLine hexEditLine endSubmenu"
So this was what was added.
beginSubmenu \\"CMOne\\" \\" Compile\\" CMOneCompile \\" Recompile_dependent_objects\\" CMOneRecompile endSubmenu separator
I keep thinking the beginSubmenu should be after the initial menu. I tried that also and it did not seem to work.
\\"CMOne\\" beginSubmenu \\" Compile\\" CMOneCompile \\" Recompile_dependent_objects\\" CMOneRecompile endSubmenu separator
-----Original Message-----
From: wdsc-plugin-dev-bounces@xxxxxxxxxxxx [mailto:wdsc-plugin-dev-bounces@xxxxxxxxxxxx] On Behalf Of Frank Hildebrandt
Sent: Monday, November 25, 2013 3:01 AM
To: 'RDi / WDSC Plugin Developers'
Subject: Re: [RDi/WDSC-Plugin-Dev] Help with creating a popup menu item in an Lpex editor
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>
[mailto:wdsc-plugin-dev-bounces@xxxxxxxxxxxx] Im Auftrag von Ron Byrd
Gesendet: Sonntag, 24. November 2013 17:10
An: wdsc-plugin-dev@xxxxxxxxxxxx<mailto: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<mailto: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<mailto:WDSC-Plugin-Dev-request@xxxxxxxxxxxx>
Before posting, please take a moment to review the archives at
http://archive.midrange.com/wdsc-plugin-dev.
--
This is the RDi / WDSC Plugin Developers (WDSC-Plugin-Dev) mailing list To post a message email: WDSC-Plugin-Dev@xxxxxxxxxxxx<mailto: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<mailto: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.