Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Platform - User Assistance (UA) » Disable/remove eclipse cheat sheet drop down menu (Remove CheatsheetMenu pragmatically from cheatSheetview)
Disable/remove eclipse cheat sheet drop down menu [message #1426188] Thu, 18 September 2014 11:22 Go to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
HI Forum members,

I am creating a cheat sheet for a tool where the end users has no use of the drop down menu i.e. the "view menu" and the "collapse all.." button (CheatSheetExpandRestoreAction contritubion) from the CheatSheetView. But so far no clue how to remove/disable/ them from cheatsheetview programmetically.

Tried below :
Menu menu = CheatSheetViewerFactory.createCheatSheetView().getControl().getMenu();
Menu menu ViewUtilities.showCheatSheetView();.getCheatSheetViewer().getControl().getMenu();

both cases it is returning null because the menu is being lazily created.

Any pointer to disabling the cheat sheet toolbar will be of appreciated and help well.

thanks,
icon11.gif  Re: Disable/remove eclipse cheat sheet drop down menu [message #1428691 is a reply to message #1426188] Mon, 22 September 2014 07:40 Go to previous messageGo to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
I am thinking the below process. don't know if it should be a good idea to do that. Hope the expertise in the forum may comment.

Get the CheatSheetView class from cheatplugin i.e. package org.eclipse.ui.internal.cheatsheets.views

and switch-off the actionbars by overriding the contributeToActionBars() method. re-build the plugin and integrate in our product.

This is the only solution running in my brain now. Any body please comment..
Re: Disable/remove eclipse cheat sheet drop down menu [message #1429361 is a reply to message #1428691] Tue, 23 September 2014 06:08 Go to previous messageGo to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
finally got a solution to my problem Surprised thank ME!!
Below is the steps:
CheatSheetView cheatsheetview = ViewUtilities.showCheatSheetView();
cheatsheetview .setInput( "your.cheatsheet.id");

IActionBars bars = view.getViewSite().getActionBars();
menuManager //get MenuManager from bars
toolbarManager //gettoolbarmanager from bars

// remove the menu contributions
menuManager.removeAll();

//iterate the toobar manager and disable the stubborn toobar item
for ( IContributionItem iContributionItem : gettoolbarmanager.getItems() )
{

if ( iContributionItem instanceof ActionContributionItem )
{

if ( ( ( ActionContributionItem ) iContributionItem ).getAction() instanceof CheatSheetExpandRestoreAction )
{
( ( ActionContributionItem ) iContributionItem ).getAction().setEnabled( false );
break;
}
}
}

IWorkbenchPage wp = view.getSite().getWorkbenchWindow().getActivePage();
wp .bringToTop( view );
Re: Disable/remove eclipse cheat sheet drop down menu [message #1430226 is a reply to message #1429361] Wed, 24 September 2014 06:41 Go to previous messageGo to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
Guys again I am at persistence issue with this.
the issue is:
for first time when with a fresh workspace starts. When the cheatsheetview created first time. i could successfully switchoff the actions on actionbar.
So I see the menu items and toolbar is disabled.
but when the tool closed and started again, The view gets shown up again with both the actions (menu items and toobar items) enabled Embarrassed

Some how I have to restore the CheatSheetView persistent when user closes and opens the tool.

I still hope forum members might have faced view persistence issues and there could be a generic solution available for this.

Any pointer on this?
Re: Disable/remove eclipse cheat sheet drop down menu [message #1443957 is a reply to message #1430226] Mon, 13 October 2014 13:08 Go to previous messageGo to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
How can I iterate all the views when the workbench window opens for the first time?? I have ApplicationWorkbenchWindowAdvisor and has postWindowOpen () method.
The idea is to iterate all views opened and get the reference of CheatSheetView object. It is a bit annoying to replying me only Sad Sad Than what is the best way to ask questions ?? Plz..
Re: Disable/remove eclipse cheat sheet drop down menu [message #1444504 is a reply to message #1443957] Tue, 14 October 2014 06:54 Go to previous messageGo to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
Yes let me reply to me again!
finally it is done! XMLIntro is of no use and irrespective of the file change the view preference remains in-consistence.

so I went to the :void com.***.***.launcher.ApplicationWorkbenchWindowAdvisor.openIntro()
{
...........
.....................
iterate for the views :
IWorkbenchWindow[] windowsArray = PlatformUI.getWorkbench().getWorkbenchWindows();

for ( iterate the windowsArray )
{
IWorkbenchPage wrkbnchpage = windows[ i ].getActivePage();
IViewReference[] viewReferencesObj = wrkbnchpage.getViewReferences();

//look for CheatSheetView
for( iterate the viewReferencesObj)
{
if(vr.getId().equals( "org.eclipse.ui.cheatsheets.views.CheatSheetView" ))
{
CheatSheetView cheatSheetViewReference = ( CheatSheetView ) vr.getView( true );
if(cheatSheetViewReference != null)
{
//disable the tool bar and menu contributions
}
}
}

}

[Updated on: Wed, 04 March 2015 11:17]

Report message to a moderator

Re: Disable/remove eclipse cheat sheet drop down menu [message #1444507 is a reply to message #1444504] Tue, 14 October 2014 06:56 Go to previous messageGo to next message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
No Message Body
Re: Disable/remove eclipse cheat sheet drop down menu [message #1444508 is a reply to message #1444507] Tue, 14 October 2014 06:58 Go to previous message
bisoyi J is currently offline bisoyi JFriend
Messages: 12
Registered: September 2014
Junior Member
Here is the code to get the IMemento externally from the View class:
CheatSheetPlugin cheatsheetplugin = CheatSheetPlugin.getPlugin();
IPath stateLocation = cheatsheetplugin.getStateLocation();
FileReader input=null;
try {
IPath buildFilePath=stateLocation.append( File.pathSeparator+"cheatsheet.xml");
if (buildFilePath.toFile().exists()) {
input=new FileReader(buildFilePath.toFile());

XMLMemento memento=XMLMemento.createReadRoot(input);
view.saveState( memento );
}
}
catch (Exception e2)
{
e2.printStackTrace();
}
Previous Topic:Unable to aquire PluginConverter service when running Infocenter for the first time
Next Topic:ITopic2 Impementation - only standard icon shows up
Goto Forum:
  


Current Time: Mon Nov 20 00:32:20 GMT 2017

Powered by FUDForum. Page generated in 0.01547 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software