本文整理汇总了Java中org.eclipse.jface.action.ICoolBarManager类的典型用法代码示例。如果您正苦于以下问题:Java ICoolBarManager类的具体用法?Java ICoolBarManager怎么用?Java ICoolBarManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ICoolBarManager类属于org.eclipse.jface.action包,在下文中一共展示了ICoolBarManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeToolbarContribution
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/**
* Remove a list of controls from a subtoolbar inside the manager. the removed controls are disposed, the toolbar
* is not removed
*
* @param cbm The toolbar manager
* @param toolbarId the toolbar id where the controls should be
* @param itemsToRemove the list of control to remove
*/
public static void removeToolbarContribution(ICoolBarManager cbm, String toolbarId, List<IContributionItem> itemsToRemove){
IContributionItem ictb = findToolbar(cbm, toolbarId);
if (ictb instanceof ToolBarContributionItem) {
HashSet<String> itemsToRemoveIds = new HashSet<String>();
for(IContributionItem itemToRemove : itemsToRemove){
itemsToRemoveIds.add(itemToRemove.getId());
}
IToolBarManager tbmanager = ((ToolBarContributionItem) ictb).getToolBarManager();
if (tbmanager != null){
for (IContributionItem ci : tbmanager.getItems()) {
if (itemsToRemove.isEmpty()) break;
if (itemsToRemoveIds.contains(ci.getId())){
tbmanager.remove(ci);
ci.dispose();
itemsToRemoveIds.remove(ci.getId());
}
}
tbmanager.update(true);
}
}
}
示例2: fillCoolBar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
IToolBarManager toolBar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
coolBar.add(new ToolBarContributionItem(toolBar, "standard")); //$NON-NLS-1$
// For the Back and Forward actions, force their text to be shown on the toolbar,
// not just their image. For the remaining actions, the ActionContributionItem
// is created implicitly with the default presentation mode.
ActionContributionItem backCI = new ActionContributionItem(backAction);
backCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
toolBar.add(backCI);
ActionContributionItem forwardCI = new ActionContributionItem(forwardAction);
forwardCI.setMode(ActionContributionItem.MODE_FORCE_TEXT);
toolBar.add(forwardCI);
toolBar.add(stopAction);
toolBar.add(refreshAction);
}
示例3: updatePinActionToolbar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/**
* Update the pin action's tool bar
*/
void updatePinActionToolbar() {
ICoolBarManager coolBarManager = getActionBarConfigurer()
.getCoolBarManager();
IContributionItem cbItem = coolBarManager
.find(IWorkbenchActionConstants.TOOLBAR_NAVIGATE);
if (!(cbItem instanceof IToolBarContributionItem)) {
// This should not happen
IDEWorkbenchPlugin
.log("Navigation toolbar contribution item is missing"); //$NON-NLS-1$
return;
}
IToolBarContributionItem toolBarItem = (IToolBarContributionItem) cbItem;
IToolBarManager toolBarManager = toolBarItem.getToolBarManager();
if (toolBarManager == null) {
// error if this happens, navigation toolbar assumed to always exist
IDEWorkbenchPlugin.log("Navigate toolbar is missing"); //$NON-NLS-1$
return;
}
toolBarManager.update(false);
toolBarItem.update(ICoolBarManager.SIZE);
}
示例4: addContributionsToCoolbar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/**
* Add a list of controls to a toolbar
*
* @param cbm2 the toolbar manager
* @param toolBarID the toolbar id where the control will be added
* @param elementsToAdd the list of the element to add
* @param part the current editor part, that will be stored inside the elements
*/
private static void addContributionsToCoolbar(ICoolBarManager cbm2, String toolBarID, List<CommonToolbarHandler> elementsToAdd) {
//Get toolbar will build a bar with the reuqested if if it isn't already present
IContributionItem item = getToolbarContributionItem(cbm2, toolBarID);
if (item != null) {
ToolBarContributionItem tbitem = (ToolBarContributionItem) item;
IToolBarManager tbmanager = tbitem.getToolBarManager();
if (tbitem.getToolBarManager() !=null){
for(CommonToolbarHandler elementToAdd : elementsToAdd){
String id = elementToAdd.getId();
if (id != null && !isElementPresentInToolbar(tbitem, elementToAdd)){
tbmanager.add(elementToAdd);
}
}
tbmanager.update(true);
}
}
}
示例5: updatePinActionToolbar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/**
* Update the pin action's tool bar
*/
void updatePinActionToolbar()
{
ICoolBarManager coolBarManager =
getActionBarConfigurer().getCoolBarManager();
IContributionItem cbItem =
coolBarManager.find(IWorkbenchActionConstants.TOOLBAR_NAVIGATE);
if (!(cbItem instanceof IToolBarContributionItem))
{
// This should not happen
IDEWorkbenchPlugin.log("Navigation toolbar contribution item is missing"); //$NON-NLS-1$
return;
}
IToolBarContributionItem toolBarItem = (IToolBarContributionItem) cbItem;
IToolBarManager toolBarManager = toolBarItem.getToolBarManager();
if (toolBarManager == null)
{
// error if this happens, navigation toolbar assumed to always exist
IDEWorkbenchPlugin.log("Navigate toolbar is missing"); //$NON-NLS-1$
return;
}
toolBarManager.update(false);
toolBarItem.update(ICoolBarManager.SIZE);
}
示例6: fillCoolBar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
@Override
protected void fillCoolBar(ICoolBarManager cbManager) {
cbManager.add(new GroupMarker("group.file")); //$NON-NLS-1$
{ // File Group
IToolBarManager fileToolBar = new ToolBarManager(cbManager.getStyle());
fileToolBar.add(new Separator(IWorkbenchActionConstants.NEW_GROUP));
fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.OPEN_EXT));
fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.SAVE_GROUP));
fileToolBar.add(getAction(ActionFactory.SAVE.getId()));
// Add to the cool bar manager
cbManager.add(new ToolBarContributionItem(fileToolBar, IWorkbenchActionConstants.TOOLBAR_FILE));
}
cbManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
cbManager.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR));
}
示例7: fillCoolBar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
@Override
protected void fillCoolBar ( final ICoolBarManager coolBar )
{
final IToolBarManager toolbar = new ToolBarManager ( SWT.FLAT | SWT.RIGHT );
coolBar.add ( new ToolBarContributionItem ( toolbar, "main" ) );
toolbar.add ( getAction ( ActionFactory.NEW_WIZARD_DROP_DOWN.getId () ) );
coolBar.add ( new GroupMarker ( IWorkbenchActionConstants.MB_ADDITIONS ) );
}
示例8: fillCoolBar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
super.fillCoolBar(coolBar);
IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.LEFT);
coolBar.add(new ToolBarContributionItem(toolbar, HYDROGRAPH_UI_GRAPH_TOOLBAR_ID));
}
示例9: fillCoolBar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
@Override
protected void fillCoolBar(ICoolBarManager coolbar) {
///coolbar.setLockLayout(true);
// Specific to Yamcs Studio
IToolBarManager studioBar = new ToolBarManager();
studioBar.add(new CoolItemGroupMarker(COOL_GROUP_PROCESSOR_INFO));
studioBar.add(new CoolItemGroupMarker(COOL_GROUP_BOOKMARK_SHORTCUTS));
studioBar.add(new CoolItemGroupMarker(COOL_GROUP_PROCESSOR_CONTROLS));
studioBar.add(new CoolItemGroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
coolbar.add(new ToolBarContributionItem(studioBar, "studiocoolbar"));
// 'File' section of the cool bar
IToolBarManager fileBar = new ToolBarManager();
// File 'new' and 'save' actions
fileBar.add(ActionFactory.NEW.create(window));
fileBar.add(save);
fileBar.add(saveAll);
fileBar.add(new CoolItemGroupMarker(IWorkbenchActionConstants.FILE_END));
coolbar.add(new ToolBarContributionItem(fileBar, IWorkbenchActionConstants.M_FILE));
// 'User' section of the cool bar
final IToolBarManager user_bar = new ToolBarManager();
coolbar.add(new ToolBarContributionItem(user_bar, TOOLBAR_USER));
// Explicitly add "additions" and "editor" to work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=422651
// After a restart, merging of persisted model, PerspectiveSpacer, contributions resulted in re-arranged toolbar with E4.
coolbar.add(new CoolItemGroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
coolbar.add(new CoolItemGroupMarker(IWorkbenchActionConstants.GROUP_EDITOR));
}
示例10: fillCoolBar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
IToolBarManager toolbar = new ToolBarManager(coolBar.getStyle());
toolbar.add(saveAction);
toolbar.add(ContributionItemFactory.NEW_WIZARD_SHORTLIST
.create(getActionBarConfigurer().getWindowConfigurer().getWindow()));
coolBar.add(toolbar);
// allow contributions here with id "additions" (MB_ADDITIONS)
coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
}
示例11: hideUnrelatedUI
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/** Remove toolbar and menu entries unrelated to the display builder
* @param page {@link IWorkbenchPage}
*/
public static void hideUnrelatedUI(final IWorkbenchPage page)
{
// Hide BOY "Top Files" tool bar drop-down
page.hideActionSet("org.csstudio.opibuilder.actionSet");
// Hide "Search" (git, file) from tool bar
page.hideActionSet("org.eclipse.search.searchActionSet");
if (! (page.getWorkbenchWindow() instanceof WorkbenchWindow))
return;
final WorkbenchWindow window = (WorkbenchWindow)page.getWorkbenchWindow();
final ICoolBarManager toolbar = window.getCoolBarManager2();
for (IContributionItem item : toolbar.getItems())
{
// System.out.println(item.getId());
if (remove_from_toolbar.contains(item.getId()))
{ // Result of trial-and-error:
// * item.setVisible(false) has no effect
// * toolbar.remove(item) results in
// Error disposing widget for : org.eclipse.e4.ui.model.application.ui.menu.impl.ToolBarImpl
// java.lang.NullPointerException
// at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.cleanUpCopy(ToolBarManagerRenderer.java:554)
// at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.cleanUp(ToolBarManagerRenderer.java:534)
// at org.eclipse.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer$4.widgetDisposed(ToolBarManagerRenderer.java:423
// * disposing the item without removing it from the toolbar "works" ?!
item.dispose();
}
}
toolbar.update(true);
patchMenu(window);
}
示例12: updateSelection
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/**
* Method to call when the selection changes. It will update the current selection and
* refresh the toolbar removing the necessary control and adding the missing one.
* The method is visible is used to know if a control should be visible or not
*
* @param activeEditor the active editor where the selection is done
* @param selection the new selection
* @param bars the current action bars, where the new controls will be placed
*/
public static void updateSelection(final IEditorPart activeEditor, final IActionBars bars){
//Executed inside a thread to have more responsive ui
UIUtils.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (bars instanceof IActionBars2 && ((IActionBars2) bars).getCoolBarManager() instanceof SubCoolBarManager) {
ICoolBarManager cbm = (ICoolBarManager) ((SubCoolBarManager) ((IActionBars2) bars).getCoolBarManager()).getParent();
for(ToolItemsSet toolbar : JaspersoftStudioPlugin.getToolItemsManager().getSets()){
//if no item of a toolbar contribution is visible then all the toolbar is removed
boolean isToolbarVisible = false;
List<CommonToolbarHandler> visibleControls = new ArrayList<CommonToolbarHandler>();
List<IContributionItem> notVisibleControls = new ArrayList<IContributionItem>();
for(IConfigurationElement control : toolbar.getControlsConfiguration()){
CommonToolbarHandler citem = createContributionItem(control);
citem.setWorkbenchPart(activeEditor);
if (citem.isVisible()){
visibleControls.add(citem);
isToolbarVisible = true;
} else {
notVisibleControls.add(citem);
}
}
if (!isToolbarVisible){
removeToolbar(cbm, toolbar.getId());
} else {
removeToolbarContribution(cbm, toolbar.getId(), notVisibleControls);
addContributionsToCoolbar(cbm, toolbar.getId(), visibleControls);
}
}
cbm.update(true);
bars.updateActionBars();
}
}
});
}
示例13: findToolbar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/**
* Search a toolbar with a specified id inside the manager
*
* @param cbm2 the toolbar manager
* @param tbarid the id of the searched toolbar
* @return the toolbar if it is found inside the manager, otherwise null
*/
public static IContributionItem findToolbar(ICoolBarManager cbm2, String tbarid) {
for (IContributionItem ci : cbm2.getItems()) {
if (ci.getId().equals(tbarid))
return ci;
}
return null;
}
示例14: removeToolbar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/**
* Remove a toolbar from the manager. It dosen't do nothing if the toolbar is not in the manager.
* If the toolbar is found before to be removed all the controls inside are disposed. The parent
* toolbar of the item is not removed to have it's position preserved if other elements will
* be added to it with a following selection. However since it's empty it isn't visible.
* This method it is equivalent to removeToolbarContribution with all the content of the toolbar
* inside the items to remove list. But since this need to done less control it has better performance
* and it is preferred when we just want to remove all the content of the toolbar
*
* @param cbm2 the toolbar manager
* @param tbarid the id of the toolbar to remove
*/
public static void removeToolbar(ICoolBarManager cbm2, String tbarid) {
IContributionItem ictb = findToolbar(cbm2, tbarid);
if (ictb instanceof ToolBarContributionItem) {
IToolBarManager tbmanager = ((ToolBarContributionItem) ictb).getToolBarManager();
if (tbmanager != null){
//the controls inside the toolbar are disposed
for (IContributionItem ci : tbmanager.getItems()) {
tbmanager.remove(ci);
ci.dispose();
}
tbmanager.update(true);
}
}
}
示例15: fillCoolBar
import org.eclipse.jface.action.ICoolBarManager; //导入依赖的package包/类
/**
* Adds the tool bar below the application menu and contains the undo, redo, and save buttons.
*/
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
ToolBarContributionItem toolBar = createFileToolbar(coolBar);
if (toolBar != null) coolBar.add(toolBar);
toolBar = createEditToolbar(coolBar);
if (toolBar != null) coolBar.add(toolBar);
coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
coolBar.add(new GroupMarker("testStart"));
coolBar.add(new GroupMarker("testEnd"));
}