本文整理汇总了Java中org.eclipse.jface.action.LegacyActionTools类的典型用法代码示例。如果您正苦于以下问题:Java LegacyActionTools类的具体用法?Java LegacyActionTools怎么用?Java LegacyActionTools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LegacyActionTools类属于org.eclipse.jface.action包,在下文中一共展示了LegacyActionTools类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTopLevelElementsEntryNoDuplicates
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
/**
* 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);
}
示例2: getContextMenuContributions
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
/**
* 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());
}
示例3: normalizeMenuLabel
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
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();
}
示例4: AppAction
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
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;
}
示例5: PreferenceTreeNode
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
/**
* 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;
}
示例6: PreferenceTreeNode
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
/**
* 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;
}
示例7: escape
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
private String escape(String text) {
if (text == null)
return text;
return LegacyActionTools.escapeMnemonics(text);
}
示例8: removeMnemonicIndicator
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
public static String removeMnemonicIndicator(String string) {
return LegacyActionTools.removeMnemonics(string);
}
示例9: setText
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
/**
* Sets the action's label text to the given value.
*/
public void setText(String text) {
super.setText(text);
acceleratorText = LegacyActionTools.extractAcceleratorText(text);
defaultText = text;
}
示例10: doRefresh
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
/**
* 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);
}
示例11: LabelRetargetAction
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
/**
* 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);
}
示例12: getDisplayName
import org.eclipse.jface.action.LegacyActionTools; //导入依赖的package包/类
/**
* 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);
}