use of org.eclipse.jface.action.IContributionItem in project translationstudio8 by heartsome.
the class ApplicationWorkbenchWindowAdvisor method postWindowCreate.
/**
* 删除 RCP 自带的工具栏按钮
*/
public void postWindowCreate() {
IActionBarConfigurer actionBarConfigurer = getWindowConfigurer().getActionBarConfigurer();
IContributionItem[] coolItems = actionBarConfigurer.getCoolBarManager().getItems();
for (int i = 0; i < coolItems.length; i++) {
if (coolItems[i] instanceof ToolBarContributionItem) {
ToolBarContributionItem toolbarItem = (ToolBarContributionItem) coolItems[i];
if (toolbarItem.getId().equals("org.eclipse.ui.WorkingSetActionSet") || toolbarItem.getId().equals("org.eclipse.ui.edit.text.actionSet.annotationNavigation") || toolbarItem.getId().equals("org.eclipse.ui.edit.text.actionSet.navigation")) {
toolbarItem.getToolBarManager().removeAll();
}
}
}
actionBarConfigurer.getCoolBarManager().update(true);
addAutoPluginMenu();
}
use of org.eclipse.jface.action.IContributionItem in project tdi-studio-se by Talend.
the class TalendFlyoutPaletteComposite method createActionMenu.
private Menu createActionMenu(Control parent) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
final MenuManager manager = new MenuManager();
MenuManager mgr = new MenuManager(PaletteMessages.DOCK_LABEL);
changeDockActionClass.getDeclaredConstructors();
// reflect the constructor of ChangeDockAction
Constructor changeDockActionConstructor = changeDockActionClass.getDeclaredConstructor(FlyoutPaletteComposite.class, String.class, int.class);
changeDockActionConstructor.setAccessible(true);
// instance of ChangeDockAction for left
Object changeDockActionInstance = changeDockActionConstructor.newInstance(this, PaletteMessages.LEFT_LABEL, PositionConstants.WEST);
if (changeDockActionInstance instanceof IAction) {
mgr.add((IAction) changeDockActionInstance);
}
// instance of ChangeDockAction for right
changeDockActionInstance = changeDockActionConstructor.newInstance(this, PaletteMessages.RIGHT_LABEL, PositionConstants.EAST);
if (changeDockActionInstance instanceof IAction) {
mgr.add((IAction) changeDockActionInstance);
}
// instance of ResizeAction
Constructor resizeActionConstructor = resizeActionClass.getDeclaredConstructor(FlyoutPaletteComposite.class);
resizeActionConstructor.setAccessible(true);
Object resizeActionInstance = resizeActionConstructor.newInstance(this);
if (resizeActionInstance instanceof IAction) {
mgr.add((IAction) resizeActionInstance);
}
manager.add(mgr);
mgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager menuMgr) {
IContributionItem[] items = menuMgr.getItems();
for (IContributionItem item : items) {
((ActionContributionItem) item).update();
}
}
});
//
// ShowStandardAction showStandardAction = ShowStandardAction.getInstance();
// ShowFavoriteAction showFavoriteAction = ShowFavoriteAction.getInstance();
// manager.add(showStandardAction);
// manager.add(showFavoriteAction);
// if (ShowFavoriteAction.state) {
// showStandardAction.doSetEnable();
// }
OpenPaletteFilterAction openPaletteFilterAction = OpenPaletteFilterAction.getInstance();
manager.add(openPaletteFilterAction);
manager.add(mgr);
addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
manager.dispose();
}
});
return manager.createContextMenu(this);
}
use of org.eclipse.jface.action.IContributionItem in project tdi-studio-se by Talend.
the class AbstractFilteredTree method updateStatusLine.
/**
* Updates the status line.
*
* @param selection the selection
*/
public void updateStatusLine(IStructuredSelection selection) {
IStatusLineManager manager = actionBars.getStatusLineManager();
IContributionItem[] items = manager.getItems();
StatusLineContributionItem selfTimeStatusLineItem = null;
for (IContributionItem item : items) {
if (item instanceof StatusLineContributionItem) {
selfTimeStatusLineItem = (StatusLineContributionItem) item;
}
}
// create the status line
if (selfTimeStatusLineItem == null) {
//$NON-NLS-1$
selfTimeStatusLineItem = new StatusLineContributionItem("SelfTimeContributionItem");
manager.add(selfTimeStatusLineItem);
}
// clear the status line
if (selection == null) {
selfTimeStatusLineItem.setText(Util.ZERO_LENGTH_STRING);
return;
}
// set text on status line
double percentage = 0;
double time = 0;
for (Object object : selection.toArray()) {
if (object instanceof IMethodNode) {
percentage += ((IMethodNode) object).getSelfTimeInPercentage();
time += ((IMethodNode) object).getSelfTime();
}
}
String text = Util.ZERO_LENGTH_STRING;
if (percentage != 0) {
//$NON-NLS-1$
text = String.format("Self Time: %.0fms %.1f", time, percentage) + '%';
}
selfTimeStatusLineItem.setText(text);
}
use of org.eclipse.jface.action.IContributionItem in project cubrid-manager by CUBRID.
the class AbsActionAdvisor method getToolbarManaeger.
protected IToolBarManager getToolbarManaeger(ICoolBarManager coolBarManager) {
IToolBarManager newToolbarManager = null;
for (IContributionItem item : coolBarManager.getItems()) {
if (item instanceof ToolBarContributionItem && "new1".equals(item.getId())) {
ToolBarContributionItem toolBarContributionItem = (ToolBarContributionItem) item;
newToolbarManager = toolBarContributionItem.getToolBarManager();
break;
// }
}
}
return newToolbarManager;
}
use of org.eclipse.jface.action.IContributionItem in project bndtools by bndtools.
the class OpenExtConfigsContributionItem method getContributionItems.
@Override
protected IContributionItem[] getContributionItems() {
try {
IFile buildFile = Central.getWorkspaceBuildFile();
if (buildFile == null)
return EMPTY;
IContainer cnfDir = buildFile.getParent();
IFolder extDir = cnfDir.getFolder(new Path("ext"));
if (extDir == null || !extDir.exists())
return EMPTY;
IResource[] extFiles = extDir.members();
List<IContributionItem> result = new ArrayList<IContributionItem>(extFiles.length);
for (final IResource extFile : extFiles) {
if (extFile.getType() == IResource.FILE && "bnd".equalsIgnoreCase(extFile.getFileExtension())) {
Action action = new Action() {
@Override
public void run() {
try {
FileEditorInput input = new FileEditorInput((IFile) extFile);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.openEditor(input, "bndtools.bndWorkspaceConfigEditor", true);
} catch (PartInitException e) {
ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", "Unable to open editor", e.getStatus());
}
}
};
action.setText("Open " + extFile.getProjectRelativePath());
action.setImageDescriptor(extFileImg);
result.add(new ActionContributionItem(action));
}
}
return result.toArray(new IContributionItem[0]);
} catch (Exception e) {
logger.logError("Unable to find default config files", e);
return EMPTY;
}
}
Aggregations