本文整理匯總了Java中org.eclipse.jface.action.IMenuCreator類的典型用法代碼示例。如果您正苦於以下問題:Java IMenuCreator類的具體用法?Java IMenuCreator怎麽用?Java IMenuCreator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IMenuCreator類屬於org.eclipse.jface.action包,在下文中一共展示了IMenuCreator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: runWithEvent
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Override
public void runWithEvent(Event event) {
final IMenuCreator mc = getMenuCreator();
if (mc == null) {
logger.error("No menu creator for action: {}", getId());
return;
}
if (event.widget instanceof ToolItem) {
final ToolItem ti = (ToolItem) event.widget;
final Menu menu = mc.getMenu(ti.getParent());
// calculate the position where to display the drop-down menu
Point point = new Point(event.x, event.y);
final Rectangle rect = ti.getBounds();
point.x += rect.x;
point.y += rect.y + rect.height;
point = ti.getParent().toDisplay(point);
// position the menu below the drop down item
menu.setLocation(point.x, point.y);
menu.setVisible(true);
} else {
logger.error("Cannot create pop-menu for action: {}", getId());
}
}
示例2: testGetMenuCreator
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Test
public void testGetMenuCreator() {
LaunchModeAction action = createLaunchModeAction();
IMenuCreator menuCreator = action.getMenuCreator();
assertThat( menuCreator ).isNull();
}
示例3: testMenuCreator
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Test
public void testMenuCreator() {
LaunchModeDropDownAction action = new LaunchModeDropDownAction( launchModeSetting );
IMenuCreator menuCreator = action.getMenuCreator();
assertThat( menuCreator ).isSameAs( action );
}
示例4: addActionToMenu
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
private void addActionToMenu(Menu parent, IAction action) {
//If the action is a menu creator the create it as submenu
if (action instanceof IMenuCreator){
IMenuCreator creator = (IMenuCreator) action;
creator.getMenu(parent);
} else {
ActionContributionItem item = new ActionContributionItem(action);
item.fill(parent, -1);
}
}
示例5: createOutlineContextMenu
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
/**
* Uses a <code>MenuManager</code> to create the context menu for the
* outline. The <code>IActions</code> used to create the context menu are
* those created in {@link #createOutlineActions()}.
*
* @return The newly created Menu
*/
protected Menu createOutlineContextMenu() {
// MenuManager for the tree's context menu
final MenuManager outlineMenu = new MenuManager();
List actions = getOutlineActions();
// Add all the actions to the context menu
for (Iterator iter = actions.iterator(); iter.hasNext();) {
IAction action = (IAction) iter.next();
if (action instanceof IMenuCreator)
outlineMenu.add(new ActionContributionItem(action) {
public boolean isDynamic() {
return true;
}
});
else
outlineMenu.add(action);
// Add separators after new and delete
if (action instanceof NewAction || action instanceof DeleteAction) {
outlineMenu.add(new Separator());
}
}
outlineMenu.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
outlineMenu.update(true);
}
});
outlineMenu.createContextMenu(tree);
return outlineMenu.getMenu();
}
示例6: fill
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
/**
* The <code>ToolbarDropdownContributionItem</code> implementation of this
* <code>IContributionItem</code> method creates a SWT MenuItem for the
* action. If the action's checked property has been set, a toggle button is
* created and primed to the value of the checked property. If the action's
* menu creator property has been set, a cascading submenu is created.
*/
public void fill(Menu parent, int index) {
if (widget == null && parent != null) {
int flags = SWT.PUSH;
Menu subMenu = null;
if (action != null) {
int style = action.getStyle();
if (style == IAction.AS_CHECK_BOX)
flags = SWT.CHECK;
else if (style == IAction.AS_DROP_DOWN_MENU) {
IMenuCreator mc = action.getMenuCreator();
subMenu = mc.getMenu(parent);
flags = SWT.CASCADE;
}
}
MenuItem mi = null;
if (index >= 0)
mi = new MenuItem(parent, flags, index);
else
mi = new MenuItem(parent, flags);
widget = mi;
mi.setData(this);
mi.addListener(SWT.Arm, listener);
mi.addListener(SWT.Dispose, listener);
mi.addListener(SWT.Selection, listener);
if (action.getHelpListener() != null)
mi.addHelpListener(action.getHelpListener());
if (subMenu != null)
mi.setMenu(subMenu);
update(null);
action.addPropertyChangeListener(listener);
}
}
示例7: handleWidgetDispose
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
/**
* Handles a widget dispose event for the widget corresponding to this item.
*/
private void handleWidgetDispose(Event e) {
// Check if our widget is the one being disposed.
if (e.widget == widget) {
// Dispose of the menu creator.
if ((action.getStyle() == IAction.AS_DROP_DOWN_MENU) && menuCreatorCalled) {
final IMenuCreator mc = action.getMenuCreator();
if (mc != null) {
mc.dispose();
}
}
// Unhook all of the listeners.
action.removePropertyChangeListener(propertyListener);
if (action != null) {
final String commandId = action.getActionDefinitionId();
final ExternalActionManager.ICallback callback = ExternalActionManager
.getInstance().getCallback();
if ((callback != null) && (commandId != null)) {
callback.removePropertyChangeListener(commandId, actionTextListener);
}
}
// Clear the widget field.
widget = null;
disposeOldImages();
}
}
示例8: handleShowProxy
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
/**
* The proxy menu is being shown, we better get the real menu.
*
* @param proxy
* the proxy menu
* @since 3.4
*/
private void handleShowProxy(Menu proxy) {
proxy.removeListener(SWT.Show, getMenuCreatorListener());
final IMenuCreator mc = action.getMenuCreator();
menuCreatorCalled = true;
if (mc == null) {
return;
}
holdMenu = mc.getMenu(proxy.getParentMenu());
if (holdMenu == null) {
return;
}
copyMenu(holdMenu, proxy);
}
示例9: handleWidgetDispose
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
/**
* Handles a widget dispose event for the widget corresponding to this item.
*/
private void handleWidgetDispose(Event e) {
// Check if our widget is the one being disposed.
if (e.widget == widget) {
// Dispose of the menu creator.
if (action.getStyle() == IAction.AS_DROP_DOWN_MENU
&& menuCreatorCalled) {
IMenuCreator mc = action.getMenuCreator();
if (mc != null) {
mc.dispose();
}
}
// Unhook all of the listeners.
action.removePropertyChangeListener(propertyListener);
if (action != null) {
String commandId = action.getActionDefinitionId();
ExternalActionManager.ICallback callback = ExternalActionManager
.getInstance().getCallback();
if ((callback != null) && (commandId != null)) {
callback.removePropertyChangeListener(commandId,
actionTextListener);
}
}
// Clear the widget field.
widget = null;
disposeOldImages();
}
}
示例10: handleShowProxy
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
/**
* The proxy menu is being shown, we better get the real menu.
*
* @param proxy
* the proxy menu
* @since 3.4
*/
private void handleShowProxy(Menu proxy) {
proxy.removeListener(SWT.Show, getMenuCreatorListener());
IMenuCreator mc = action.getMenuCreator();
menuCreatorCalled = true;
if (mc == null) {
return;
}
holdMenu = mc.getMenu(proxy.getParentMenu());
if (holdMenu == null) {
return;
}
copyMenu(holdMenu, proxy);
}
示例11: getMenuCreator
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
public IMenuCreator getMenuCreator() {
return fOpenAction.getMenuCreator();
}
示例12: setMenuCreator
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
public void setMenuCreator(IMenuCreator creator) {
fOpenAction.setMenuCreator(creator);
}
示例13: getMenuCreator
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Override
public IMenuCreator getMenuCreator() {
// TODO Auto-generated method stub
return null;
}
示例14: setMenuCreator
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Override
public void setMenuCreator(IMenuCreator creator) {
// TODO Auto-generated method stub
}
示例15: getMenuCreator
import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Override
public IMenuCreator getMenuCreator() {
return this;
}