Discussion:
[mitk-users] Save perspective action without experimental command contributions?
Miklos Espak
8 years ago
Permalink
Hi,

I noticed that the BlueBerry framework allows saving perspective with a
given name. This feature would be quite handy for us.

Is there a way to make BlueBerry create a Save Perspective action?

As I see, it is enabled only if the command contributions are enabled, and
for that you would need to change the
USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS static variable to true in an MITK
source file.

We have a customised workbench window advisor that derives from
QmitkExtWorkbenchWindowAdvisor. We can add new actions in
PostWindowCreate().

Cheers,
Miklos
Miklos Espak
8 years ago
Permalink
Ignore this, figured it out.

Here is the code, maybe it will be useful for someone later.

void BaseWorkbenchWindowAdvisor::PostWindowCreate()

{

QmitkExtWorkbenchWindowAdvisor::PostWindowCreate();


berry::IWorkbenchWindow::Pointer window =
this->GetWindowConfigurer()->GetWindow();

QMainWindow* mainWindow =
static_cast<QMainWindow*>(window->GetShell()->GetControl());

QMenuBar* menuBar = mainWindow->menuBar();

QList<QMenu *> menus = menuBar->findChildren<QMenu*>();


for (QMenu* menu: menus)

{

for (QAction* action: menu->actions())

{

if (action->text() == "&Reset Perspective")

{

berry::CommandContributionItemParameter::Pointer param(

new berry::CommandContributionItemParameter(

window.GetPointer(),

QString(),

berry::IWorkbenchCommandConstants::WINDOW_SAVE_PERSPECTIVE_AS,

berry::CommandContributionItem::STYLE_PUSH));

param->label = "Save Perspective &As...";

m_SavePerspectiveItem = new berry::CommandContributionItem(param);

m_SavePerspectiveItem->Fill(menu, action);

}

}

}

}


Cheers,
Miklos
...
Continue reading on narkive:
Loading...