org.eclipse.swt.widgets.MenuItem#getParent ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.MenuItem#getParent ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: translationstudio8   文件: MenuItemProviders.java
/**
 * Walk up the MenuItems (in case they are nested) and find the parent {@link Menu}
 *
 * @param selectionEvent
 *            on the {@link MenuItem}
 * @return data associated with the parent {@link Menu}
 */
public static NatEventData getNatEventData(SelectionEvent selectionEvent) {
	Widget widget = selectionEvent.widget;
	if (widget == null || !(widget instanceof MenuItem)) {
		return null;
	}

	MenuItem menuItem = (MenuItem) widget;
	Menu parentMenu = menuItem.getParent();
	Object data = null;
	while (parentMenu != null) {
		if (parentMenu.getData() == null) {
			parentMenu = parentMenu.getParentMenu();
		} else {
			data = parentMenu.getData();
			break;
		}
	}

	return data != null ? (NatEventData) data : null;
}
 
源代码2 项目: tmxeditor8   文件: MenuItemProviders.java
/**
 * Walk up the MenuItems (in case they are nested) and find the parent {@link Menu}
 *
 * @param selectionEvent
 *            on the {@link MenuItem}
 * @return data associated with the parent {@link Menu}
 */
public static NatEventData getNatEventData(SelectionEvent selectionEvent) {
	Widget widget = selectionEvent.widget;
	if (widget == null || !(widget instanceof MenuItem)) {
		return null;
	}

	MenuItem menuItem = (MenuItem) widget;
	Menu parentMenu = menuItem.getParent();
	Object data = null;
	while (parentMenu != null) {
		if (parentMenu.getData() == null) {
			parentMenu = parentMenu.getParentMenu();
		} else {
			data = parentMenu.getData();
			break;
		}
	}

	return data != null ? (NatEventData) data : null;
}