/** * Tests that the Top Level Elements */ @Test public void testTopLevelElementsEntryNoDuplicates() { IActionBars actionBars = projectExplorer.getViewSite().getActionBars(); IMenuManager menuManager = actionBars.getMenuManager(); int topLevelElementsEntriesFound = 0; for (IContributionItem item : menuManager.getItems()) { if (item instanceof MenuManager) { String escapedMenuText = LegacyActionTools.removeMnemonics(((MenuManager) item).getMenuText()); if (escapedMenuText.equals("Top Level Elements")) { topLevelElementsEntriesFound++; } } } assertEquals("There was more than one 'Top Level Elements' entry in the navigator action bar.", topLevelElementsEntriesFound, 1); }
/** * Returns the menu contribution titles of the project navigator context menu. * * This only includes {@link ActionContributionItem}s and {@link MenuManager}s. */ private List<String> getContextMenuContributions() { MenuManager menu = new MenuManager(); projectExplorer.getNavigatorActionService().fillContextMenu(menu); return Arrays.asList(menu.getItems()).stream() .map(i -> { if (i instanceof ActionContributionItem) { // use action name return ((ActionContributionItem) i).getAction().getText(); } else if (i instanceof MenuManager) { // use sub-menu title return ((MenuManager) i).getMenuText(); } else { // null for other types of contributions return null; } }) .filter(t -> null != t) // remove mnemonics (e.g. Close &Project -> Close Project)) .map(text -> LegacyActionTools.removeMnemonics(text)) .collect(Collectors.toList()); }
private static String normalizeMenuLabel(String label, char mnemonic, int accel) { label = addMnemonic(label, mnemonic); int defaultSize = 30; int size = Math.max(label.length(), defaultSize); StringBuffer sb = new StringBuffer(label); while (sb.length() < size) { sb.append(' '); } if (accel != -1) { sb.append("\t").append(LegacyActionTools.convertAccelerator(accel)); } return sb.toString(); }
public AppAction(String resPrefixKey, Image image, Image bigImage, String actionCommand) { // Mnemonic mnemonic = RM.getChar(resPrefixKey + ".mnemonic"); // Accelerator String strAccel = RM.getLabel(resPrefixKey + ".accel", (String)null); if (strAccel != null) { accel = LegacyActionTools.convertAccelerator(strAccel); } // Label label = normalizeMenuLabel(RM.getLabel(resPrefixKey + ".label"), mnemonic, accel); // Icon if (image != null) { icon = image; } if (bigImage != null) { bigIcon = bigImage; } // Tooltip toolTip = RM.getLabel(resPrefixKey + ".tooltip", (String)null); command = actionCommand; }
/** * Constructs a new instance of PreferenceTreeNode according to the parameters. * <p> * The <code>label</code> and the <code>key</code> must not be <code>null</code> if the node * has a corresponding UI control. * </p> * * @param label the label text * @param key the key * @param controlType the type of UI control. * @param showAllChildren tells whether all children should be shown even if just one child * matches the filter. */ public PreferenceTreeNode(String label, Key key, int controlType, boolean showAllChildren) { super(); if (controlType != NONE && (label == null || key == null)) { throw new IllegalArgumentException(); } if (label == null) { label= ""; //$NON-NLS-1$ } fLabel= LegacyActionTools.removeMnemonics(label); fKey= key; fControlType= controlType; fShowAllChildren= showAllChildren; }
private String escape(String text) { if (text == null) return text; return LegacyActionTools.escapeMnemonics(text); }
public static String removeMnemonicIndicator(String string) { return LegacyActionTools.removeMnemonics(string); }
/** * Sets the action's label text to the given value. */ public void setText(String text) { super.setText(text); acceleratorText = LegacyActionTools.extractAcceleratorText(text); defaultText = text; }
/** * Sets the given text and image to the label. * * @param text * the new text or null * @param image * the new image */ private void doRefresh(String text, Image image) { if ( text != null ) { text = LegacyActionTools.escapeMnemonics(text); } label.setText(text); label.setImage(image); }
/** * Constructs a RetargetAction with the given action id, text and style. * * @param actionID * the retargetable action id * @param text * the action's text, or <code>null</code> if there is no text * @param style * one of <code>AS_PUSH_BUTTON</code>, <code>AS_CHECK_BOX</code>, * <code>AS_DROP_DOWN_MENU</code>, <code>AS_RADIO_BUTTON</code>, * and <code>AS_UNSPECIFIED</code>. * @since 3.0 */ public LabelRetargetAction(String actionID, String text, int style) { super(actionID, text, style); this.defaultText = text; this.defaultToolTipText = text; acceleratorText = LegacyActionTools.extractAcceleratorText(text); }
/** * Returns the name of the described extension * without mnemonic hint in order to be displayed * in a message. * * @return Returns the name */ public String getDisplayName() { return LegacyActionTools.removeMnemonics(fName); }