Java Code Examples for docking.action.MenuData#getMenuPath()

The following examples show how to use docking.action.MenuData#getMenuPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MenuManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private MenuManager getSubMenu(MenuData menuData) {

		String[] fullPath = menuData.getMenuPath();
		String displayName = fullPath[level];
		char mnemonic = getMnemonicKey(displayName);
		String realName = stripMnemonicAmp(displayName);
		MenuManager subMenu = subMenus.get(realName);
		if (subMenu != null) {
			return subMenu;
		}

		int subMenuLevel = level + 1;
		String[] subMenuPath = new String[subMenuLevel];
		System.arraycopy(fullPath, 0, subMenuPath, 0, subMenuLevel);

		String subMenuGroup = getSubMenuGroup(menuData, realName, subMenuPath);
		subMenu = new MenuManager(realName, subMenuPath, mnemonic, subMenuLevel, subMenuGroup,
			usePopupPath, menuHandler, menuGroupMap);
		subMenus.put(realName, subMenu);
		managedMenuItems.add(subMenu);

		return subMenu;
	}
 
Example 2
Source File: MenuManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private String getPullRightMenuGroup(MenuData menuData) {

		// note: currently, the client can specify the group for the pull-right menu only for
		//       the immediate parent of the menu item.  We can change this later if we find
		//       we have a need for a multi-level cascaded menu that needs to specify groups for
		//       each pull-right in the menu path

		String[] actionMenuPath = menuData.getMenuPath();
		int leafLevel = actionMenuPath.length - 1;
		boolean isParentOfLeaf = level == (leafLevel - 1);
		if (!isParentOfLeaf) {
			return null;
		}

		return menuData.getParentMenuGroup();
	}
 
Example 3
Source File: MenuBarManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private MenuManager getMenuManager(DockingActionIf action) {
	MenuData menuBarData = action.getMenuBarData();
	if (menuBarData == null) {
		return null;
	}

	String[] menuPath = menuBarData.getMenuPath();
	if (menuPath == null || menuPath.length <= 1) {
		return null;
	}

	return getMenuManager(menuPath[0]);
}
 
Example 4
Source File: MenuManager.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private boolean isSubMenu(MenuData menuData) {
	String[] actionMenuPath = menuData.getMenuPath();
	return actionMenuPath.length > level + 1;
}
 
Example 5
Source File: PluginDetailsPanel.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void addLoadedActionsContent(StringBuilder buffer,
		PluginDescription pluginDescription) {
	if (!model.isLoaded(pluginDescription)) {
		return;
	}

	buffer.append("<TR>");
	buffer.append("<TD VALIGN=\"TOP\">");
	insertHTMLLine(buffer, "Loaded Actions:", titleAttrSet);
	buffer.append("</TD>");

	Set<DockingActionIf> actions = model.getActionsForPlugin(pluginDescription);
	if (actions.size() == 0) {
		buffer.append("<TD VALIGN=\"TOP\">");
		insertHTMLLine(buffer, "No actions for plugin", noValueAttrSet);
		buffer.append("</TD>");
		buffer.append("</TR>");
		return;
	}

	buffer.append("<TD VALIGN=\"TOP\">");

	buffer.append(
		"<TABLE BORDER=1><TR><TH>Action Name</TH><TH>Menu Path</TH><TH>Keybinding</TH></TR>");

	for (DockingActionIf dockableAction : actions) {
		buffer.append("<TR><TD WIDTH=\"200\">");
		insertHTMLString(buffer, dockableAction.getName(), locAttrSet);
		buffer.append("</TD>");

		buffer.append("<TD WIDTH=\"300\">");
		MenuData menuBarData = dockableAction.getMenuBarData();
		String[] menuPath = menuBarData == null ? null : menuBarData.getMenuPath();
		String menuPathString = createStringForMenuPath(menuPath);
		if (menuPathString != null) {
			insertHTMLString(buffer, menuPathString, locAttrSet);
		}
		else {
			MenuData popupMenuData = dockableAction.getPopupMenuData();
			String[] popupPath = popupMenuData == null ? null : popupMenuData.getMenuPath();

			if (popupPath != null) {
				insertHTMLString(buffer, "(in a context popup menu)", noValueAttrSet);
			}
			else {
				insertHTMLString(buffer, "Not in a menu", noValueAttrSet);
			}
		}

		buffer.append("</TD>");

		buffer.append("<TD WIDTH=\"100\">");
		KeyStroke keyBinding = dockableAction.getKeyBinding();
		if (keyBinding != null) {
			String keyStrokeString = KeyBindingUtils.parseKeyStroke(keyBinding);
			insertHTMLString(buffer, keyStrokeString, locAttrSet);
		}
		else {
			insertHTMLString(buffer, "No keybinding", noValueAttrSet);
		}

		buffer.append("</TD></TR>");
	}

	buffer.append("</TABLE>");
	buffer.append("</TD>");
	buffer.append("</TR>");
}
 
Example 6
Source File: EquatePlugin1Test.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Test
public void testConvertMenuItemText1() {

	putCursorOnOperand(0x010064ae, 1);

	Set<DockingActionIf> actions = getActionsByOwner(tool, "EquatePlugin");
	int found = 0;
	for (DockingActionIf action : actions) {
		String name = action.getName();
		if (!name.startsWith("Convert") || !action.isAddToPopup(getListingContext())) {
			continue;
		}
		MenuData popupMenuData = action.getPopupMenuData();
		String[] popupPath = popupMenuData.getMenuPath();
		assertEquals(2, popupPath.length);

		if (name.indexOf("Unsigned Decimal") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Decimal"));
			assertTrue(popupPath[1].endsWith(" 4"));
		}
		else if (name.indexOf("Unsigned Octal") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Octal"));
			assertTrue(popupPath[1].endsWith(" 4o"));
		}
		else if (name.indexOf("Unsigned Binary") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Binary"));
			assertTrue(popupPath[1].endsWith(" 00000000000000000000000000000100b"));
		}
		else if (name.indexOf("Unsigned Hex") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Hex"));
			assertTrue(popupPath[1].endsWith(" 0x4"));
		}
		else if (name.indexOf("Char") >= 0) {
			assertTrue(popupPath[1].startsWith("Char"));
		}
		else if (name.indexOf("Double") >= 0) {
			assertTrue(popupPath[1].startsWith("Double"));
			assertTrue(popupPath[1].endsWith(" 1.112536929253602E-308"));
		}
		else if (name.indexOf("Float") >= 0) {
			assertTrue(popupPath[1].startsWith("Float"));
			assertTrue(popupPath[1].endsWith(" 5.877475E-39"));
		}
		else {
			fail("Unhandled Convert item: " + name);
		}
		++found;
	}
	assertEquals("Did not find convert actions expected", 7, found);
}
 
Example 7
Source File: EquatePlugin1Test.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Test
public void testConvertMenuItemText2() {
	putCursorOnOperand(0x010064a3, 0);

	int found = 0;
	Set<DockingActionIf> actions = getActionsByOwner(tool, "EquatePlugin");
	for (DockingActionIf action : actions) {
		String name = action.getName();
		if (!name.startsWith("Convert") || !action.isAddToPopup(getListingContext())) {
			continue;
		}
		MenuData popupMenuData = action.getPopupMenuData();
		String[] popupPath = popupMenuData.getMenuPath();
		assertEquals(2, popupPath.length);

		if (name.indexOf("Unsigned Decimal") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Decimal"));
			assertTrue(popupPath[1].endsWith(" 16803344"));
		}
		else if (name.indexOf("Signed Decimal") > 0) {
			assertTrue(popupPath[1].startsWith("Signed Decimal"));
			assertTrue(popupPath[1].endsWith(" 16803344"));
		}
		else if (name.indexOf("Unsigned Octal") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Octal"));
			assertTrue(popupPath[1].endsWith(" 100063020o"));
		}
		else if (name.indexOf("Unsigned Hex") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Hex"));
			assertTrue(popupPath[1].endsWith(" 0x1006610"));
		}
		else if (name.indexOf("Char") >= 0) {
			assertTrue(popupPath[1].startsWith("Char"));
		}
		else if (name.indexOf("Unsigned Binary") >= 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Binary"));
		}
		else if (name.indexOf("Float") >= 0) {
			assertTrue(popupPath[1].startsWith("Float"));
		}
		else if (name.indexOf("Double") >= 0) {
			assertTrue(popupPath[1].startsWith("Double"));
		}
		else {
			fail("Unhandled Convert item: " + name);
		}
		++found;
	}
	assertEquals("Did not find convert actions expected", 7, found);
}
 
Example 8
Source File: EquatePlugin1Test.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Test
public void testConvertMenuItemText3() {

	putCursorOnOperand(0x01003a94, 0);

	int found = 0;
	Set<DockingActionIf> actions = getActionsByOwner(tool, "EquatePlugin");
	for (DockingActionIf action : actions) {
		String name = action.getName();
		if (!name.startsWith("Convert") || !action.isAddToPopup(getListingContext())) {
			continue;
		}
		MenuData popupMenuData = action.getPopupMenuData();
		String[] popupPath = popupMenuData.getMenuPath();
		assertEquals(2, popupPath.length);

		if (name.indexOf("Unsigned Decimal") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Decimal"));
			assertTrue(popupPath[1].endsWith(" 4294967293"));
		}
		else if (name.indexOf("Signed Decimal") > 0) {
			assertTrue(popupPath[1].startsWith("Signed Decimal"));
			assertTrue(popupPath[1].endsWith(" -3"));
		}
		else if (name.indexOf("Unsigned Binary") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Binary"));
			assertTrue(popupPath[1].endsWith(" 11111111111111111111111111111101b"));
		}
		else if (name.indexOf("Unsigned Octal") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Octal"));
			assertTrue(popupPath[1].endsWith(" 37777777775o"));
		}
		else if (name.indexOf("Signed Hex") > 0) {
			assertTrue(popupPath[1].startsWith("Signed Hex"));
			assertTrue(popupPath[1].endsWith(" -0x3"));
		}
		else if (name.indexOf("Unsigned Hex") > 0) {
			assertTrue(popupPath[1].startsWith("Unsigned Hex"));
			assertTrue(popupPath[1].endsWith(" 0xFFFFFFFD"));
		}
		else if (name.indexOf("Char") >= 0) {
			assertTrue(popupPath[1].startsWith("Char"));
		}
		else {
			fail("Unhandled Convert item: " + name);
		}
		++found;
	}
	assertEquals("Did not find convert actions expected", 7, found);
}