當前位置: 首頁>>代碼示例>>Java>>正文


Java IMenuCreator類代碼示例

本文整理匯總了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());
  }
}
 
開發者ID:Haixing-Hu,項目名稱:swt-widgets,代碼行數:24,代碼來源:DropDownAction.java

示例2: testGetMenuCreator

import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Test
public void testGetMenuCreator() {
  LaunchModeAction action = createLaunchModeAction();

  IMenuCreator menuCreator = action.getMenuCreator();

  assertThat( menuCreator ).isNull();
}
 
開發者ID:rherrmann,項目名稱:eclipse-extras,代碼行數:9,代碼來源:LaunchModeActionTest.java

示例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 );
}
 
開發者ID:rherrmann,項目名稱:eclipse-extras,代碼行數:9,代碼來源:LaunchModeDropDownActionTest.java

示例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);
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:11,代碼來源:ViewSettingsDropDownAction.java

示例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();
}
 
開發者ID:ghillairet,項目名稱:gef-gwt,代碼行數:39,代碼來源:PaletteCustomizerDialog.java

示例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);
	}
}
 
開發者ID:ghillairet,項目名稱:gef-gwt,代碼行數:46,代碼來源:ToolbarDropdownContributionItem.java

示例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();
  }
}
 
開發者ID:Haixing-Hu,項目名稱:swt-widgets,代碼行數:33,代碼來源:ActionContributionItemEx.java

示例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);
}
 
開發者ID:Haixing-Hu,項目名稱:swt-widgets,代碼行數:21,代碼來源:ActionContributionItemEx.java

示例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();
	}
}
 
開發者ID:TheWhiteShadow3,項目名稱:cuina,代碼行數:35,代碼來源:SaveActionContributionItem.java

示例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);
}
 
開發者ID:TheWhiteShadow3,項目名稱:cuina,代碼行數:21,代碼來源:SaveActionContributionItem.java

示例11: getMenuCreator

import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
public IMenuCreator getMenuCreator() {
	return fOpenAction.getMenuCreator();
}
 
開發者ID:angelozerr,項目名稱:jsbuild-eclipse,代碼行數:4,代碼來源:OpenAndExpand.java

示例12: setMenuCreator

import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
public void setMenuCreator(IMenuCreator creator) {
	fOpenAction.setMenuCreator(creator);
}
 
開發者ID:angelozerr,項目名稱:jsbuild-eclipse,代碼行數:4,代碼來源:OpenAndExpand.java

示例13: getMenuCreator

import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Override
public IMenuCreator getMenuCreator() {
    // TODO Auto-generated method stub
    return null;
}
 
開發者ID:anb0s,項目名稱:EasyShell,代碼行數:6,代碼來源:Action.java

示例14: setMenuCreator

import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Override
public void setMenuCreator(IMenuCreator creator) {
    // TODO Auto-generated method stub

}
 
開發者ID:anb0s,項目名稱:EasyShell,代碼行數:6,代碼來源:Action.java

示例15: getMenuCreator

import org.eclipse.jface.action.IMenuCreator; //導入依賴的package包/類
@Override
public IMenuCreator getMenuCreator() {
	return this;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:5,代碼來源:TemplatePlanViewAddNewItemPulldownAction.java


注:本文中的org.eclipse.jface.action.IMenuCreator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。