diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake index 98d70da05e..781968ee59 100644 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake +++ b/BlueBerry/Bundles/org.blueberry.ui.qt/files.cmake @@ -1,462 +1,460 @@ set(SRC_CPP_FILES berryAbstractSourceProvider.cpp berryAbstractUICTKPlugin.cpp berryConstants.cpp berryDisplay.cpp berryEditorPart.cpp berryFileEditorInput.cpp berryGeometry.cpp berryIActionBars.h berryIContextService.cpp berryIContributionRoot.h berryIDropTargetListener.cpp berryIEditorDescriptor.cpp berryIEditorInput.cpp berryIEditorMatchingStrategy.cpp berryIEditorPart.cpp berryIEditorReference.cpp berryIEditorRegistry.cpp berryIEditorSite.cpp berryIFileEditorMapping.cpp berryIFolderLayout.cpp berryImageDescriptor.cpp berryIMemento.cpp berryINullSelectionListener.cpp berryIPageLayout.cpp berryIPartListener.cpp berryIPageService.cpp berryIPartService.cpp berryIPathEditorInput.cpp berryIPerspectiveDescriptor.cpp berryIPerspectiveFactory.cpp berryIPerspectiveListener.cpp berryIPerspectiveRegistry.cpp berryIPlaceholderFolderLayout.cpp berryIPluginContribution.h berryIPostSelectionProvider.cpp berryIPreferencePage.cpp berryIPropertyChangeListener.cpp berryIQtPreferencePage.cpp berryIQtStyleManager.cpp berryIReusableEditor.cpp berryISaveablePart.cpp berryISaveablesLifecycleListener.cpp berryISaveablesSource.cpp berryISelection.cpp berryISelectionChangedListener.cpp berryISelectionListener.cpp berryISelectionProvider.cpp berryISelectionService.cpp berryIShellListener.cpp berryIShellProvider.cpp berryIShowInSource.h berryIShowInTarget.h berryISizeProvider.cpp berryISourceProvider.cpp berryISourceProviderListener.cpp berryISources.cpp berryIStickyViewDescriptor.cpp berryIStructuredSelection.cpp berryIViewCategory.cpp berryIViewDescriptor.cpp berryIViewLayout.cpp berryIViewPart.cpp berryIViewReference.cpp berryIViewRegistry.cpp berryIViewSite.cpp berryIWorkbenchCommandConstants.cpp berryIWindowListener.cpp berryIWorkbench.cpp berryIWorkbenchListener.cpp berryIWorkbenchPage.cpp berryIWorkbenchPart.cpp berryIWorkbenchPartConstants.cpp berryIWorkbenchPartDescriptor.cpp berryIWorkbenchPartReference.cpp berryIWorkbenchPartSite.cpp berryIWorkbenchSite.cpp berryIWorkbenchWindow.cpp berryMenuUtil.cpp berryPlatformUI.cpp berryPoint.cpp berryPropertyChangeEvent.cpp berryQModelIndexObject.cpp berryQtEditorPart.cpp berryQtItemSelection.cpp berryQtIntroPart.cpp berryQtPreferences.cpp berryQtSelectionProvider.cpp berryQtViewPart.cpp berryRectangle.cpp berrySameShellProvider.cpp berrySaveable.cpp berrySaveablesLifecycleEvent.cpp berrySelectionChangedEvent.cpp berryShell.cpp berryShellEvent.cpp berryShowInContext.cpp berryUIException.cpp berryViewPart.cpp berryWindow.cpp berryWorkbenchActionConstants.cpp berryWorkbenchPart.cpp berryWorkbenchPreferenceConstants.cpp berryXMLMemento.cpp #actions actions/berryAbstractContributionFactory.cpp actions/berryAbstractGroupMarker.cpp - #actions/berryAction.cpp - #actions/berryActionContributionItem.cpp actions/berryCommandContributionItem.h actions/berryCommandContributionItem.cpp actions/berryContributionItem.cpp actions/berryContributionItemFactory.cpp actions/berryContributionManager.cpp actions/berryIContributionItem.h actions/berryIContributionManager.h actions/berryIContributionManagerOverrides.cpp actions/berryIMenuManager.h #actions/berryMenuBarManager.cpp actions/berryMenuManager.cpp actions/berrySeparator.cpp actions/berrySubContributionItem.cpp #application application/berryActionBarAdvisor.cpp application/berryIActionBarConfigurer.cpp application/berryIWorkbenchConfigurer.cpp application/berryIWorkbenchWindowConfigurer.cpp application/berryWorkbenchAdvisor.cpp application/berryWorkbenchWindowAdvisor.cpp #commands commands/berryICommandImageService.cpp commands/berryICommandService.cpp commands/berryIElementReference.h commands/berryIElementUpdater.h commands/berryIMenuService.h commands/berryUIElement.cpp #guitk guitk/berryGuiTkControlEvent.cpp guitk/berryGuiTkEvent.cpp guitk/berryGuiTkIControlListener.cpp guitk/berryGuiTkIMenuListener.cpp guitk/berryGuiTkISelectionListener.cpp guitk/berryGuiTkSelectionEvent.cpp #handlers handlers/berryHandlerUtil.cpp handlers/berryIHandlerActivation.cpp handlers/berryIHandlerService.cpp handlers/berryRadioState.cpp handlers/berryRegistryToggleState.cpp handlers/berryShowViewHandler.cpp handlers/berryToggleState.cpp #intro intro/berryIIntroManager.cpp intro/berryIIntroPart.cpp intro/berryIIntroSite.cpp intro/berryIntroPart.cpp #tweaklets tweaklets/berryDnDTweaklet.cpp tweaklets/berryGuiWidgetsTweaklet.cpp tweaklets/berryImageTweaklet.cpp tweaklets/berryITracker.cpp tweaklets/berryWorkbenchPageTweaklet.cpp tweaklets/berryWorkbenchTweaklet.cpp #presentations presentations/berryIPresentablePart.cpp presentations/berryIPresentationFactory.cpp presentations/berryIPresentationSerializer.cpp presentations/berryIStackPresentationSite.cpp presentations/berryStackDropResult.cpp presentations/berryStackPresentation.cpp #services services/berryIDisposable.cpp services/berryIEvaluationReference.h services/berryIEvaluationService.cpp services/berryINestable.cpp services/berryIServiceFactory.cpp services/berryIServiceLocator.cpp services/berryIServiceScopes.cpp services/berryIServiceWithSources.cpp services/berryISourceProviderService.cpp #testing testing/berryTestableObject.cpp #util util/berryISafeRunnableRunner.cpp util/berrySafeRunnable.cpp # application application/berryQtWorkbenchAdvisor.cpp ) set(INTERNAL_CPP_FILES defaultpresentation/berryEmptyTabFolder.cpp defaultpresentation/berryEmptyTabItem.cpp defaultpresentation/berryNativeTabFolder.cpp defaultpresentation/berryNativeTabItem.cpp defaultpresentation/berryQCTabBar.cpp defaultpresentation/berryQtWorkbenchPresentationFactory.cpp util/berryAbstractTabFolder.cpp util/berryAbstractTabItem.cpp util/berryIPresentablePartList.cpp util/berryLeftToRightTabOrder.cpp util/berryPartInfo.cpp util/berryPresentablePartFolder.cpp util/berryReplaceDragHandler.cpp util/berryTabbedStackPresentation.cpp util/berryTabDragHandler.cpp util/berryTabFolderEvent.cpp util/berryTabOrder.cpp #intro intro/berryEditorIntroAdapterPart.cpp intro/berryIIntroDescriptor.cpp intro/berryIIntroRegistry.cpp intro/berryIntroConstants.cpp intro/berryIntroDescriptor.cpp intro/berryIntroPartAdapterSite.cpp intro/berryIntroRegistry.cpp intro/berryViewIntroAdapterPart.cpp intro/berryWorkbenchIntroManager.cpp berryAbstractMenuAdditionCacheEntry.cpp berryAbstractPartSelectionTracker.cpp berryAbstractSelectionService.cpp berryActivePartExpression.cpp berryAlwaysEnabledExpression.cpp berryAndExpression.cpp berryBundleUtility.cpp berryCommandContributionItemParameter.cpp berryCommandParameter.cpp berryCommandPersistence.cpp berryCommandService.cpp berryCommandServiceFactory.cpp berryCommandStateProxy.cpp berryCompositeExpression.cpp berryContainerPlaceholder.cpp berryContributionRoot.cpp berryDetachedPlaceHolder.cpp berryDefaultSaveable.cpp berryDefaultStackPresentationSite.cpp berryDetachedWindow.cpp berryDragUtil.cpp berryEditorAreaHelper.cpp berryEditorDescriptor.cpp berryEditorManager.cpp berryEditorReference.cpp berryEditorRegistry.cpp berryEditorRegistryReader.cpp berryEditorSashContainer.cpp berryEditorSite.cpp berryElementReference.cpp berryErrorViewPart.cpp berryEvaluationAuthority.cpp berryEvaluationReference.cpp berryEvaluationResultCache.cpp berryEvaluationService.cpp berryExpressionAuthority.cpp berryFileEditorMapping.cpp berryFolderLayout.cpp berryHandlerActivation.cpp berryHandlerAuthority.cpp berryHandlerPersistence.cpp berryHandlerProxy.cpp berryHandlerService.cpp berryHandlerServiceFactory.cpp berryIDragOverListener.cpp berryIDropTarget.cpp berryIEvaluationResultCache.cpp berryILayoutContainer.cpp berryInternalMenuService.h berryIServiceLocatorCreator.cpp berryIStickyViewManager.cpp berryIWorkbenchLocationService.cpp berryLayoutHelper.cpp berryLayoutPart.cpp berryLayoutPartSash.cpp berryLayoutTree.cpp berryLayoutTreeNode.cpp berryMenuServiceFactory.cpp berryMMMenuListener.cpp berryNestableHandlerService.cpp berryNullEditorInput.cpp berryPageLayout.cpp berryPagePartSelectionTracker.cpp berryPageSelectionService.cpp berryParameterValueConverterProxy.cpp berryPartList.cpp berryPartPane.cpp berryPartPlaceholder.cpp berryPartSashContainer.cpp berryPartService.cpp berryPartSite.cpp berryPartStack.cpp berryPartTester.cpp berryPersistentState.cpp berryPerspective.cpp berryPerspectiveDescriptor.cpp berryPerspectiveExtensionReader.cpp berryPerspectiveHelper.cpp berryPerspectiveRegistry.cpp berryPerspectiveRegistryReader.cpp berryPlaceholderFolderLayout.cpp berryPreferenceConstants.cpp berryPresentablePart.cpp berryPresentationFactoryUtil.cpp berryPresentationSerializer.cpp berryQtControlWidget.cpp berryQtDnDControlWidget.cpp berryQtDisplay.cpp berryQtDnDTweaklet.cpp berryQtFileImageDescriptor.cpp berryQtGlobalEventFilter.cpp berryQtIconImageDescriptor.cpp berryQtImageTweaklet.cpp berryQtMainWindowControl.cpp berryQtMissingImageDescriptor.cpp berryQtOpenPerspectiveAction.cpp berryQtPerspectiveSwitcher.cpp berryQtSafeApplication.cpp berryQtSash.cpp berryQtShell.cpp berryQtShowViewAction.cpp berryQtShowViewDialog.cpp berryQtStyleManager.cpp berryQtStylePreferencePage.cpp berryQtTracker.cpp berryQtWidgetController.cpp berryQtWidgetsTweaklet.cpp berryQtWidgetsTweakletImpl.cpp berryQtWorkbenchPageTweaklet.cpp berryQtWorkbenchTweaklet.cpp berryRegistryPersistence.cpp berryRegistryReader.cpp berrySaveablesList.cpp berryShowViewMenu.cpp berryServiceLocator.cpp berryServiceLocatorCreator.cpp berryShellPool.cpp berrySlaveCommandService.cpp berrySlaveHandlerService.cpp berrySlaveMenuService.cpp berrySourceProviderService.cpp berrySourcePriorityNameMapping.cpp berryStatusUtil.cpp berryStickyViewDescriptor.cpp berryStickyViewManager.cpp berryTweaklets.cpp berryUtil.cpp berryViewDescriptor.cpp berryViewFactory.cpp berryViewLayout.cpp berryViewReference.cpp berryViewRegistry.cpp berryViewRegistryReader.cpp berryViewSashContainer.cpp berryViewSite.cpp berryWorkbenchPage.cpp berryWindowManager.cpp berryWindowPartSelectionTracker.cpp berryWindowSelectionService.cpp berryWorkbench.cpp berryWorkbenchConfigurer.cpp berryWorkbenchConstants.cpp berryWorkbenchLocationService.cpp berryWorkbenchMenuService.cpp berryWorkbenchPagePartList.cpp berryWorkbenchPartReference.cpp berryWorkbenchPlugin.cpp berryWorkbenchRegistryConstants.cpp berryWorkbenchServiceRegistry.cpp berryWorkbenchSourceProvider.cpp berryWorkbenchTestable.cpp berryWorkbenchWindow.cpp berryWorkbenchWindowConfigurer.cpp berryWorkbenchWindowExpression.cpp berryWWinActionBars.cpp berryWWinPartService.cpp ) set(MOC_H_FILES src/berryAbstractUICTKPlugin.h src/berryEditorPart.h src/berryQtSelectionProvider.h src/berryViewPart.h src/berryWorkbenchPart.h src/actions/berryCommandContributionItem.h src/intro/berryIntroPart.h src/handlers/berryShowViewHandler.h src/internal/berryCommandServiceFactory.h src/internal/berryHandlerServiceFactory.h src/internal/berryMenuServiceFactory.h src/internal/berryMMMenuListener.h src/internal/berryQtDisplay.h src/internal/berryQtDnDTweaklet.h src/internal/berryQtGlobalEventFilter.h src/internal/berryQtImageTweaklet.h src/internal/berryQtMainWindowControl.h src/internal/berryQtOpenPerspectiveAction.h src/internal/berryQtPerspectiveSwitcher.h src/internal/berryQtSash.h src/internal/berryQtShowViewAction.h src/internal/berryQtStyleManager.h src/internal/berryQtStylePreferencePage.h src/internal/berryQtTracker.h src/internal/berryQtWidgetsTweaklet.h src/internal/berryQtWidgetsTweakletImpl.h src/internal/berryQtWorkbenchTweaklet.h src/internal/berryQtWorkbenchPageTweaklet.h src/internal/berryWorkbenchPlugin.h src/internal/berryWorkbenchSourceProvider.h src/internal/defaultpresentation/berryNativeTabFolder.h src/internal/defaultpresentation/berryNativeTabItem.h src/internal/defaultpresentation/berryQCTabBar.h src/internal/defaultpresentation/berryQtWorkbenchPresentationFactory.h src/internal/intro/berryEditorIntroAdapterPart.h ) set(UI_FILES src/internal/berryQtShowViewDialog.ui src/internal/berryQtStylePreferencePage.ui src/internal/berryQtStatusPart.ui ) set(QRC_FILES resources/org_blueberry_ui_qt.qrc ) set(CACHED_RESOURCE_FILES plugin.xml ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryAction.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryAction.cpp deleted file mode 100644 index cdfe7c6946..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryAction.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*=================================================================== - -BlueBerry Platform - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "berryAction.h" - -namespace berry { - -class ActionPrivate -{ -public: - - QString id; - -}; - -Action::Action() - : QAction(0), d(new ActionPrivate) -{} - -Action::Action(const QString& text) - : QAction(text, 0), d(new ActionPrivate) -{ -} - -Action::Action(const QString& text, const QIcon& image) - : QAction(image, text, 0), d(new ActionPrivate) -{ -} - -} diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryAction.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryAction.h deleted file mode 100644 index 3781f12b07..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryAction.h +++ /dev/null @@ -1,75 +0,0 @@ -/*=================================================================== - -BlueBerry Platform - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef BERRYACTION_H -#define BERRYACTION_H - -#include - -#include - -namespace berry { - -class ActionPrivate; - -class BERRY_UI_QT Action : public QAction -{ - -public: - - /** - * Creates a new action with no text and no image. - *

- * Configure the action later using the set methods. - *

- */ - Action(); - - /** - * Creates a new action with the given text and no image. - * - * @param text - * the string used as the text for the action, or - * null if there is no text - */ - Action(const QString& text); - - /** - * Creates a new action with the given text and image. - * - * @param text - * the action's text, or null if there is no text - * @param image - * the action's image, or null if there is no - * image - */ - Action(const QString& text, const QIcon& image); - - QString GetId() const; - void SetId(const QString& id); - -private: - - QScopedPointer d; - - Q_DISABLE_COPY(Action) - -}; - -} - -#endif // BERRYACTION_H diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryActionContributionItem.cpp b/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryActionContributionItem.cpp deleted file mode 100644 index 319bd839b1..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryActionContributionItem.cpp +++ /dev/null @@ -1,987 +0,0 @@ -/*=================================================================== - -BlueBerry Platform - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#include "berryActionContributionItem.h" - -#include -#include -#include - -#include - -namespace berry { - -ActionContributionItem::ActionContributionItem(Action* action) - : ContributionItem(action->GetId()), action(action) -{ -} - -bool ActionContributionItem::operator==(const Object* o) const -{ - if (const ActionContributionItem* aci = dynamic_cast(o)) - { - return action == aci->action; - } - return false; -} - -uint ActionContributionItem::HashCode() const -{ - return qHash(action); -} - -void ActionContributionItem::Fill(QStatusBar* parent) -{ -// if (widget == null && parent != null) { -// int flags = SWT.PUSH; -// if (action != null) { -// if (action.getStyle() == IAction.AS_CHECK_BOX) { -// flags = SWT.TOGGLE; -// } -// if (action.getStyle() == IAction.AS_RADIO_BUTTON) { -// flags = SWT.RADIO; -// } -// } - -// Button b = new Button(parent, flags); -// b.setData(this); -// b.addListener(SWT.Dispose, getButtonListener()); -// // Don't hook a dispose listener on the parent -// b.addListener(SWT.Selection, getButtonListener()); -// if (action.getHelpListener() != null) { -// b.addHelpListener(action.getHelpListener()); -// } -// widget = b; - -// update(null); - -// // Attach some extra listeners. -// action.addPropertyChangeListener(propertyListener); -// if (action != null) { -// String commandId = action.getActionDefinitionId(); -// ExternalActionManager.ICallback callback = ExternalActionManager -// .getInstance().getCallback(); - -// if ((callback != null) && (commandId != null)) { -// callback.addPropertyChangeListener(commandId, -// actionTextListener); -// } -// } -// } -} - -QAction *ActionContributionItem::Fill(QMenu* parent, QAction* before) -{ - if (parent != 0) - { - if (before) - { - parent->insertAction(before, action); - } - else - { - parent->addAction(action); - } - action->setData(QVariant::fromValue(Object::Pointer(this))); - //action.addListener(SWT.Dispose, getMenuItemListener()); - //action.addListener(SWT.Selection, getMenuItemListener()); - //if (action.getHelpListener() != null) - //{ - // mi.addHelpListener(action.getHelpListener()); - //} - - if (action->menu()) - { -// // just create a proxy for now, if the user shows it then -// // fill it in -// Menu subMenu = new Menu(parent); -// subMenu.addListener(SWT.Show, getMenuCreatorListener()); -// subMenu.addListener(SWT.Hide, getMenuCreatorListener()); -// mi.setMenu(subMenu); - } - - Update(QString()); - -// // Attach some extra listeners. -// action.addPropertyChangeListener(propertyListener); -// if (action != null) { -// String commandId = action.getActionDefinitionId(); -// ExternalActionManager.ICallback callback = ExternalActionManager -// .getInstance().getCallback(); - -// if ((callback != null) && (commandId != null)) { -// callback.addPropertyChangeListener(commandId, -// actionTextListener); -// } -// } - } - return action; -} - -QAction*ActionContributionItem::Fill(QMenuBar* menu, QAction* before) -{ - return NULL; -} - -QAction *ActionContributionItem::Fill(QToolBar* parent, QAction* before) -{ -// if (widget == null && parent != null) { -// int flags = SWT.PUSH; -// if (action != null) { -// int style = action.getStyle(); -// if (style == IAction.AS_CHECK_BOX) { -// flags = SWT.CHECK; -// } else if (style == IAction.AS_RADIO_BUTTON) { -// flags = SWT.RADIO; -// } else if (style == IAction.AS_DROP_DOWN_MENU) { -// flags = SWT.DROP_DOWN; -// } -// } - -// ToolItem ti = null; -// if (index >= 0) { -// ti = new ToolItem(parent, flags, index); -// } else { -// ti = new ToolItem(parent, flags); -// } -// ti.setData(this); -// ti.addListener(SWT.Selection, getToolItemListener()); -// ti.addListener(SWT.Dispose, getToolItemListener()); - -// widget = ti; - -// update(null); - -// // Attach some extra listeners. -// action.addPropertyChangeListener(propertyListener); -// if (action != null) { -// String commandId = action.getActionDefinitionId(); -// ExternalActionManager.ICallback callback = ExternalActionManager -// .getInstance().getCallback(); - -// if ((callback != null) && (commandId != null)) { -// callback.addPropertyChangeListener(commandId, -// actionTextListener); -// } -// } -// } - return 0; -} - -Action* ActionContributionItem::GetAction() const -{ - return action; -} - -ActionContributionItem::~ActionContributionItem() -{ - //holdMenu = null; -} - -ContributionItem::Modes ActionContributionItem::GetMode() const -{ - return mode; -} - -bool ActionContributionItem::IsDynamic() const -{ -// if (qobject_cast(action->parentWidget())) -// { -// // Optimization. Only recreate the item is the check or radio style -// // has changed. -// boolean itemIsCheck = (widget.getStyle() & SWT.CHECK) != 0; -// boolean actionIsCheck = getAction() != null -// && getAction().getStyle() == IAction.AS_CHECK_BOX; -// boolean itemIsRadio = (widget.getStyle() & SWT.RADIO) != 0; -// boolean actionIsRadio = getAction() != null -// && getAction().getStyle() == IAction.AS_RADIO_BUTTON; -// return (itemIsCheck != actionIsCheck) -// || (itemIsRadio != actionIsRadio); -// } - return false; -} - -bool ActionContributionItem::IsEnabled() const -{ - return action != 0 && action->isEnabled(); -} - -bool ActionContributionItem::IsVisible() const -{ - return ContributionItem::IsVisible() && IsCommandActive(); -} - -void ActionContributionItem::SetMode(Modes mode) -{ - this->mode = mode; - Update(); -} - -void ActionContributionItem::Update() -{ - Update(QString()); -} - -void ActionContributionItem::Update(const QString& propertyName) -{ -// if (widget != 0) -// { -// // determine what to do -// boolean textChanged = propertyName == null -// || propertyName.equals(IAction.TEXT); -// boolean imageChanged = propertyName == null -// || propertyName.equals(IAction.IMAGE); -// boolean tooltipTextChanged = propertyName == null -// || propertyName.equals(IAction.TOOL_TIP_TEXT); -// boolean enableStateChanged = propertyName == null -// || propertyName.equals(IAction.ENABLED) -// || propertyName -// .equals(IContributionManagerOverrides.P_ENABLED); -// boolean checkChanged = (action.getStyle() == IAction.AS_CHECK_BOX || action -// .getStyle() == IAction.AS_RADIO_BUTTON) -// && (propertyName == null || propertyName -// .equals(IAction.CHECKED)); - -// if (widget instanceof ToolItem) { -// ToolItem ti = (ToolItem) widget; -// String text = action.getText(); -// // the set text is shown only if there is no image or if forced -// // by MODE_FORCE_TEXT -// boolean showText = text != null -// && ((getMode() & MODE_FORCE_TEXT) != 0 || !hasImages(action)); - -// // only do the trimming if the text will be used -// if (showText && text != null) { -// text = Action.removeAcceleratorText(text); -// text = Action.removeMnemonics(text); -// } - -// if (textChanged) { -// String textToSet = showText ? text : ""; //$NON-NLS-1$ -// boolean rightStyle = (ti.getParent().getStyle() & SWT.RIGHT) != 0; -// if (rightStyle || !ti.getText().equals(textToSet)) { -// // In addition to being required to update the text if -// // it -// // gets nulled out in the action, this is also a -// // workaround -// // for bug 50151: Using SWT.RIGHT on a ToolBar leaves -// // blank space -// ti.setText(textToSet); -// } -// } - -// if (imageChanged) { -// // only substitute a missing image if it has no text -// updateImages(!showText); -// } - -// if (tooltipTextChanged || textChanged) { -// String toolTip = action.getToolTipText(); -// if ((toolTip == null) || (toolTip.length() == 0)) { -// toolTip = text; -// } - -// ExternalActionManager.ICallback callback = ExternalActionManager -// .getInstance().getCallback(); -// String commandId = action.getActionDefinitionId(); -// if ((callback != null) && (commandId != null) -// && (toolTip != null)) { -// String acceleratorText = callback -// .getAcceleratorText(commandId); -// if (acceleratorText != null -// && acceleratorText.length() != 0) { -// toolTip = JFaceResources.format( -// "Toolbar_Tooltip_Accelerator", //$NON-NLS-1$ -// new Object[] { toolTip, acceleratorText }); -// } -// } - -// // if the text is showing, then only set the tooltip if -// // different -// if (!showText || toolTip != null && !toolTip.equals(text)) { -// ti.setToolTipText(toolTip); -// } else { -// ti.setToolTipText(null); -// } -// } - -// if (enableStateChanged) { -// boolean shouldBeEnabled = action.isEnabled() -// && isEnabledAllowed(); - -// if (ti.getEnabled() != shouldBeEnabled) { -// ti.setEnabled(shouldBeEnabled); -// } -// } - -// if (checkChanged) { -// boolean bv = action.isChecked(); - -// if (ti.getSelection() != bv) { -// ti.setSelection(bv); -// } -// } -// return; -// } - -// if (widget instanceof MenuItem) { -// MenuItem mi = (MenuItem) widget; - -// if (textChanged) { -// int accelerator = 0; -// String acceleratorText = null; -// IAction updatedAction = getAction(); -// String text = null; -// accelerator = updatedAction.getAccelerator(); -// ExternalActionManager.ICallback callback = ExternalActionManager -// .getInstance().getCallback(); - -// // Block accelerators that are already in use. -// if ((accelerator != 0) && (callback != null) -// && (callback.isAcceleratorInUse(accelerator))) { -// accelerator = 0; -// } - -// /* -// * Process accelerators on GTK in a special way to avoid Bug -// * 42009. We will override the native input method by -// * allowing these reserved accelerators to be placed on the -// * menu. We will only do this for "Ctrl+Shift+[0-9A-FU]". -// */ -// final String commandId = updatedAction -// .getActionDefinitionId(); -// if ((Util.isGtk()) && (callback instanceof IBindingManagerCallback) -// && (commandId != null)) { -// final IBindingManagerCallback bindingManagerCallback = (IBindingManagerCallback) callback; -// final IKeyLookup lookup = KeyLookupFactory.getDefault(); -// final TriggerSequence[] triggerSequences = bindingManagerCallback -// .getActiveBindingsFor(commandId); -// for (int i = 0; i < triggerSequences.length; i++) { -// final TriggerSequence triggerSequence = triggerSequences[i]; -// final Trigger[] triggers = triggerSequence -// .getTriggers(); -// if (triggers.length == 1) { -// final Trigger trigger = triggers[0]; -// if (trigger instanceof KeyStroke) { -// final KeyStroke currentKeyStroke = (KeyStroke) trigger; -// final int currentNaturalKey = currentKeyStroke -// .getNaturalKey(); -// if ((currentKeyStroke.getModifierKeys() == (lookup -// .getCtrl() | lookup.getShift())) -// && ((currentNaturalKey >= '0' && currentNaturalKey <= '9') -// || (currentNaturalKey >= 'A' && currentNaturalKey <= 'F') || (currentNaturalKey == 'U'))) { -// accelerator = currentKeyStroke -// .getModifierKeys() -// | currentNaturalKey; -// acceleratorText = triggerSequence -// .format(); -// break; -// } -// } -// } -// } -// } - -// if (accelerator == 0) { -// if ((callback != null) && (commandId != null)) { -// acceleratorText = callback -// .getAcceleratorText(commandId); -// } -// } - -// IContributionManagerOverrides overrides = null; - -// if (getParent() != null) { -// overrides = getParent().getOverrides(); -// } - -// if (overrides != null) { -// text = getParent().getOverrides().getText(this); -// } - -// mi.setAccelerator(accelerator); - -// if (text == null) { -// text = updatedAction.getText(); -// } - -// if (text != null && acceleratorText == null) { -// // use extracted accelerator text in case accelerator -// // cannot be fully represented in one int (e.g. -// // multi-stroke keys) -// acceleratorText = LegacyActionTools -// .extractAcceleratorText(text); -// if (acceleratorText == null && accelerator != 0) { -// acceleratorText = Action -// .convertAccelerator(accelerator); -// } -// } - -// if (text == null) { -// text = ""; //$NON-NLS-1$ -// } else { -// text = Action.removeAcceleratorText(text); -// } - -// if (acceleratorText == null) { -// mi.setText(text); -// } else { -// mi.setText(text + '\t' + acceleratorText); -// } -// } - -// if (imageChanged) { -// updateImages(false); -// } - -// if (enableStateChanged) { -// boolean shouldBeEnabled = action.isEnabled() -// && isEnabledAllowed(); - -// if (mi.getEnabled() != shouldBeEnabled) { -// mi.setEnabled(shouldBeEnabled); -// } -// } - -// if (checkChanged) { -// boolean bv = action.isChecked(); - -// if (mi.getSelection() != bv) { -// mi.setSelection(bv); -// } -// } - -// return; -// } - -// if (widget instanceof Button) { -// Button button = (Button) widget; - -// if (imageChanged) { -// updateImages(false); -// } - -// if (textChanged) { -// String text = action.getText(); -// boolean showText = text != null && ((getMode() & MODE_FORCE_TEXT) != 0 || !hasImages(action)); -// // only do the trimming if the text will be used -// if (showText) { -// text = Action.removeAcceleratorText(text); -// } -// String textToSet = showText ? text : ""; //$NON-NLS-1$ -// button.setText(textToSet); -// } - -// if (tooltipTextChanged) { -// button.setToolTipText(action.getToolTipText()); -// } - -// if (enableStateChanged) { -// boolean shouldBeEnabled = action.isEnabled() -// && isEnabledAllowed(); - -// if (button.getEnabled() != shouldBeEnabled) { -// button.setEnabled(shouldBeEnabled); -// } -// } - -// if (checkChanged) { -// boolean bv = action.isChecked(); - -// if (button.getSelection() != bv) { -// button.setSelection(bv); -// } -// } -// return; -// } -//} -} - -bool ActionContributionItem::IsEnabledAllowed() const -{ - if (this->GetParent() == 0) - { - return true; - } - int value = GetParent()->GetOverrides()->GetEnabled(this); - return (value == -1) ? true : value; -} - -//QString ActionContributionItem::ShortenText(const QString& textValue, QToolButton* item) -//{ -//if (textValue == null) { -// return null; -//} - -//GC gc = new GC(item.getParent()); - -//int maxWidth = item.getImage().getBounds().width * 4; - -//if (gc.textExtent(textValue).x < maxWidth) { -// gc.dispose(); -// return textValue; -//} - -//for (int i = textValue.length(); i > 0; i--) { -// String test = textValue.substring(0, i); -// test = test + ellipsis; -// if (gc.textExtent(test).x < maxWidth) { -// gc.dispose(); -// return test; -// } - -//} -//gc.dispose(); -//// If for some reason we fall through abort -//return textValue; -//} - -//Listener ActionContributionItem::GetToolItemListener() -//{ -//if (toolItemListener == null) { -// toolItemListener = new Listener() { -// public void handleEvent(Event event) { -// switch (event.type) { -// case SWT.Dispose: -// handleWidgetDispose(event); -// break; -// case SWT.Selection: -// Widget ew = event.widget; -// if (ew != null) { -// handleWidgetSelection(event, ((ToolItem) ew) -// .getSelection()); -// } -// break; -// } -// } -// }; -//} -//return toolItemListener; -//} - -//void ActionContributionItem::HandleWidgetDispose(Event e) -//{ -//// Check if our widget is the one being disposed. -//if (e.widget == widget) { -// // Dispose of the menu creator. -// if (action.getStyle() == IAction.AS_DROP_DOWN_MENU -// && menuCreatorCalled) { -// IMenuCreator mc = action.getMenuCreator(); -// if (mc != null) { -// mc.dispose(); -// } -// } - -// // Unhook all of the listeners. -// action.removePropertyChangeListener(propertyListener); -// if (action != null) { -// String commandId = action.getActionDefinitionId(); -// ExternalActionManager.ICallback callback = ExternalActionManager -// .getInstance().getCallback(); - -// if ((callback != null) && (commandId != null)) { -// callback.removePropertyChangeListener(commandId, -// actionTextListener); -// } -// } - -// // Clear the widget field. -// widget = null; - -// disposeOldImages(); -//} -//} - -//void ActionContributionItem::HandleWidgetSelection(Event e, bool selection) -//{ - -//Widget item = e.widget; -//if (item != null) { -// int style = item.getStyle(); - -// if ((style & (SWT.TOGGLE | SWT.CHECK)) != 0) { -// if (action.getStyle() == IAction.AS_CHECK_BOX) { -// action.setChecked(selection); -// } -// } else if ((style & SWT.RADIO) != 0) { -// if (action.getStyle() == IAction.AS_RADIO_BUTTON) { -// action.setChecked(selection); -// } -// } else if ((style & SWT.DROP_DOWN) != 0) { -// if (e.detail == 4) { // on drop-down button -// if (action.getStyle() == IAction.AS_DROP_DOWN_MENU) { -// IMenuCreator mc = action.getMenuCreator(); -// menuCreatorCalled = true; -// ToolItem ti = (ToolItem) item; -// // we create the menu as a sub-menu of "dummy" so that -// // we can use -// // it in a cascading menu too. -// // If created on a SWT control we would get an SWT -// // error... -// // Menu dummy= new Menu(ti.getParent()); -// // Menu m= mc.getMenu(dummy); -// // dummy.dispose(); -// if (mc != null) { -// Menu m = mc.getMenu(ti.getParent()); -// if (m != null) { -// // position the menu below the drop down item -// Point point = ti.getParent().toDisplay( -// new Point(e.x, e.y)); -// m.setLocation(point.x, point.y); // waiting -// // for SWT -// // 0.42 -// m.setVisible(true); -// return; // we don't fire the action -// } -// } -// } -// } -// } - -// ExternalActionManager.IExecuteCallback callback = null; -// String actionDefinitionId = action.getActionDefinitionId(); -// if (actionDefinitionId != null) { -// Object obj = ExternalActionManager.getInstance() -// .getCallback(); -// if (obj instanceof ExternalActionManager.IExecuteCallback) { -// callback = (ExternalActionManager.IExecuteCallback) obj; -// } -// } - -// // Ensure action is enabled first. -// // See 1GAN3M6: ITPUI:WINNT - Any IAction in the workbench can be -// // executed while disabled. -// if (action.isEnabled()) { -// boolean trace = Policy.TRACE_ACTIONS; - -// long ms = 0L; -// if (trace) { -// ms = System.currentTimeMillis(); -// System.out.println("Running action: " + action.getText()); //$NON-NLS-1$ -// } - -// IPropertyChangeListener resultListener = null; -// if (callback != null) { -// resultListener = new IPropertyChangeListener() { -// public void propertyChange(PropertyChangeEvent event) { -// // Check on result -// if (event.getProperty().equals(IAction.RESULT)) { -// if (event.getNewValue() instanceof Boolean) { -// result = (Boolean) event.getNewValue(); -// } -// } -// } -// }; -// action.addPropertyChangeListener(resultListener); -// callback.preExecute(action, e); -// } - -// action.runWithEvent(e); - -// if (callback != null) { -// if (result == null || result.equals(Boolean.TRUE)) { -// callback.postExecuteSuccess(action, Boolean.TRUE); -// } else { -// callback.postExecuteFailure(action, -// new ExecutionException(action.getText() -// + " returned failure.")); //$NON-NLS-1$ -// } -// } - -// if (resultListener!=null) { -// result = null; -// action.removePropertyChangeListener(resultListener); -// } -// if (trace) { -// System.out.println((System.currentTimeMillis() - ms) -// + " ms to run action: " + action.getText()); //$NON-NLS-1$ -// } -// } else { -// if (callback != null) { -// callback.notEnabled(action, new NotEnabledException(action -// .getText() -// + " is not enabled.")); //$NON-NLS-1$ -// } -// } -//} -//} - -//bool ActionContributionItem::HasImages(Action* actionToCheck) const -//{ -// return actionToCheck.getImageDescriptor() != null -// || actionToCheck.getHoverImageDescriptor() != null -// || actionToCheck.getDisabledImageDescriptor() != null; -//} - -bool ActionContributionItem::IsCommandActive() const -{ - Action* actionToCheck = GetAction(); - - if (actionToCheck != 0) - { - QString commandId = actionToCheck->GetActionDefinitionId(); - ExternalActionManager.ICallback callback = ExternalActionManager - .getInstance().getCallback(); - - if (callback != null) { - return callback.isActive(commandId); - } - } - return true; -} - -//bool ActionContributionItem::UpdateImages(bool forceImage) -//{ - -// ResourceManager parentResourceManager = JFaceResources.getResources(); - -// if (widget instanceof ToolItem) { -// if (USE_COLOR_ICONS) { -// ImageDescriptor image = action.getHoverImageDescriptor(); -// if (image == null) { -// image = action.getImageDescriptor(); -// } -// ImageDescriptor disabledImage = action -// .getDisabledImageDescriptor(); - -// // Make sure there is a valid image. -// if (image == null && forceImage) { -// image = ImageDescriptor.getMissingImageDescriptor(); -// } - -// LocalResourceManager localManager = new LocalResourceManager( -// parentResourceManager); - -// // performance: more efficient in SWT to set disabled and hot -// // image before regular image -// ((ToolItem) widget) -// .setDisabledImage(disabledImage == null ? null -// : localManager -// .createImageWithDefault(disabledImage)); -// ((ToolItem) widget).setImage(image == null ? null -// : localManager.createImageWithDefault(image)); - -// disposeOldImages(); -// imageManager = localManager; - -// return image != null; -// } -// ImageDescriptor image = action.getImageDescriptor(); -// ImageDescriptor hoverImage = action.getHoverImageDescriptor(); -// ImageDescriptor disabledImage = action.getDisabledImageDescriptor(); - -// // If there is no regular image, but there is a hover image, -// // convert the hover image to gray and use it as the regular image. -// if (image == null && hoverImage != null) { -// image = ImageDescriptor.createWithFlags(action -// .getHoverImageDescriptor(), SWT.IMAGE_GRAY); -// } else { -// // If there is no hover image, use the regular image as the -// // hover image, -// // and convert the regular image to gray -// if (hoverImage == null && image != null) { -// hoverImage = image; -// image = ImageDescriptor.createWithFlags(action -// .getImageDescriptor(), SWT.IMAGE_GRAY); -// } -// } - -// // Make sure there is a valid image. -// if (hoverImage == null && image == null && forceImage) { -// image = ImageDescriptor.getMissingImageDescriptor(); -// } - -// // Create a local resource manager to remember the images we've -// // allocated for this tool item -// LocalResourceManager localManager = new LocalResourceManager( -// parentResourceManager); - -// // performance: more efficient in SWT to set disabled and hot image -// // before regular image -// ((ToolItem) widget).setDisabledImage(disabledImage == null ? null -// : localManager.createImageWithDefault(disabledImage)); -// ((ToolItem) widget).setHotImage(hoverImage == null ? null -// : localManager.createImageWithDefault(hoverImage)); -// ((ToolItem) widget).setImage(image == null ? null : localManager -// .createImageWithDefault(image)); - -// // Now that we're no longer referencing the old images, clear them -// // out. -// disposeOldImages(); -// imageManager = localManager; - -// return image != null; -// } else if (widget instanceof Item || widget instanceof Button) { - -// // Use hover image if there is one, otherwise use regular image. -// ImageDescriptor image = action.getHoverImageDescriptor(); -// if (image == null) { -// image = action.getImageDescriptor(); -// } -// // Make sure there is a valid image. -// if (image == null && forceImage) { -// image = ImageDescriptor.getMissingImageDescriptor(); -// } - -// // Create a local resource manager to remember the images we've -// // allocated for this widget -// LocalResourceManager localManager = new LocalResourceManager( -// parentResourceManager); - -// if (widget instanceof Item) { -// ((Item) widget).setImage(image == null ? null : localManager -// .createImageWithDefault(image)); -// } else if (widget instanceof Button) { -// ((Button) widget).setImage(image == null ? null : localManager -// .createImageWithDefault(image)); -// } - -// // Now that we're no longer referencing the old images, clear them -// // out. -// disposeOldImages(); -// imageManager = localManager; - -// return image != null; -// } -// return false; -//} - -//void ActionContributionItem::DisposeOldImages() -//{ -// if (imageManager != null) { -// imageManager.dispose(); -// imageManager = null; -// } -//} - -//Listener ActionContributionItem::getMenuCreatorListener() { -// if (menuCreatorListener == null) { -// menuCreatorListener = new Listener() { -// public void handleEvent(Event event) { -// switch (event.type) { -// case SWT.Show: -// handleShowProxy((Menu) event.widget); -// break; -// case SWT.Hide: -// handleHideProxy((Menu) event.widget); -// break; -// } -// } -// }; -// } -// return menuCreatorListener; -//} - -//void ActionContributionItem::HandleShowProxy(QMenu* proxy) -//{ -// proxy.removeListener(SWT.Show, getMenuCreatorListener()); -// IMenuCreator mc = action.getMenuCreator(); -// menuCreatorCalled = true; -// if (mc == null) { -// return; -// } -// holdMenu = mc.getMenu(proxy.getParentMenu()); -// if (holdMenu == null) { -// return; -// } -// copyMenu(holdMenu, proxy); -//} - -//void ActionContributionItem::CopyMenu(QMenu* realMenu, QMenu* proxy) { -// if (realMenu.isDisposed() || proxy.isDisposed()) { -// return; -// } - -// // we notify the real menu so it can populate itself if it was -// // listening for SWT.Show -// realMenu.notifyListeners(SWT.Show, null); - -// final Listener passThrough = new Listener() { -// public void handleEvent(Event event) { -// if (!event.widget.isDisposed()) { -// Widget realItem = (Widget) event.widget.getData(); -// if (!realItem.isDisposed()) { -// int style = event.widget.getStyle(); -// if (event.type == SWT.Selection -// && ((style & (SWT.TOGGLE | SWT.CHECK | SWT.RADIO)) != 0) -// && realItem instanceof MenuItem) { -// ((MenuItem) realItem) -// .setSelection(((MenuItem) event.widget) -// .getSelection()); -// } -// event.widget = realItem; -// realItem.notifyListeners(event.type, event); -// } -// } -// } -// }; - -// MenuItem[] items = realMenu.getItems(); -// for (int i = 0; i < items.length; i++) { -// final MenuItem realItem = items[i]; -// final MenuItem proxyItem = new MenuItem(proxy, realItem.getStyle()); -// proxyItem.setData(realItem); -// proxyItem.setAccelerator(realItem.getAccelerator()); -// proxyItem.setEnabled(realItem.getEnabled()); -// proxyItem.setImage(realItem.getImage()); -// proxyItem.setSelection(realItem.getSelection()); -// proxyItem.setText(realItem.getText()); - -// // pass through any events -// proxyItem.addListener(SWT.Selection, passThrough); -// proxyItem.addListener(SWT.Arm, passThrough); -// proxyItem.addListener(SWT.Help, passThrough); - -// final Menu itemMenu = realItem.getMenu(); -// if (itemMenu != null) { -// // create a proxy for any sub menu items -// final Menu subMenu = new Menu(proxy); -// subMenu.setData(itemMenu); -// proxyItem.setMenu(subMenu); -// subMenu.addListener(SWT.Show, new Listener() { -// public void handleEvent(Event event) { -// event.widget.removeListener(SWT.Show, this); -// if (event.type == SWT.Show) { -// copyMenu(itemMenu, subMenu); -// } -// } -// }); -// subMenu.addListener(SWT.Help, passThrough); -// subMenu.addListener(SWT.Hide, passThrough); -// } -// } -//} - -//void ActionContributionItem::HandleHideProxy(QMenu* proxy) -//{ -// proxy.removeListener(SWT.Hide, getMenuCreatorListener()); -// proxy.getDisplay().asyncExec(new Runnable() { -// public void run() { -// if (!proxy.isDisposed()) { -// MenuItem parentItem = proxy.getParentItem(); -// proxy.dispose(); -// parentItem.setMenu(holdMenu); -// } -// if (holdMenu != null && !holdMenu.isDisposed()) { -// holdMenu.notifyListeners(SWT.Hide, null); -// } -// holdMenu = null; -// } -// }); -//} - -} diff --git a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryActionContributionItem.h b/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryActionContributionItem.h deleted file mode 100644 index 474089d903..0000000000 --- a/BlueBerry/Bundles/org.blueberry.ui.qt/src/actions/berryActionContributionItem.h +++ /dev/null @@ -1,294 +0,0 @@ -/*=================================================================== - -BlueBerry Platform - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - - -#ifndef BERRYACTIONCONTRIBUTIONITEM_H -#define BERRYACTIONCONTRIBUTIONITEM_H - -#include "berryContributionItem.h" - -namespace berry { - -class Action; - -/** - * A contribution item which delegates to an action. - *

- * This class may be instantiated; it is not intended to be subclassed. - *

- * @noextend This class is not intended to be subclassed by clients. - */ -class ActionContributionItem : public ContributionItem -{ - -public: - - /** - * Creates a new contribution item from the given action. The id of the - * action is used as the id of the item. - * - * @param action - * the action - */ - ActionContributionItem(Action* action); - - ~ActionContributionItem(); - - /** - * Compares this action contribution item with another object. Two action - * contribution items are equal if they refer to the identical Action. - */ - bool operator==(const Object* o) const; - - uint HashCode() const; - - /** - * The ActionContributionItem implementation of this - * IContributionItem method creates an SWT - * Button for the action using the action's style. If the - * action's checked property has been set, the button is created and primed - * to the value of the checked property. - */ - void Fill(QStatusBar* parent); - - /** - * The ActionContributionItem implementation of this - * IContributionItem method creates an SWT - * MenuItem for the action using the action's style. If the - * action's checked property has been set, a button is created and primed to - * the value of the checked property. If the action's menu creator property - * has been set, a cascading submenu is created. - */ - QAction* Fill(QMenu* parent, QAction *before); - - QAction* Fill(QMenuBar* menu, QAction* before); - - /** - * The ActionContributionItem implementation of this , - * IContributionItem method creates an SWT - * ToolItem for the action using the action's style. If the - * action's checked property has been set, a button is created and primed to - * the value of the checked property. If the action's menu creator property - * has been set, a drop-down tool item is created. - */ - QAction* Fill(QToolBar* parent, QAction* before); - - /** - * Returns the action associated with this contribution item. - * - * @return the action - */ - Action* GetAction() const; - - /** - * Returns the presentation mode, which is the bitwise-or of the - * MODE_* constants. The default mode setting is 0, meaning - * that for menu items, both text and image are shown (if present), but for - * tool items, the text is shown only if there is no image. - * - * @return the presentation mode settings - */ - Modes GetMode() const; - - /** - * The action item implementation of this IContributionItem - * method returns true for menu items and false - * for everything else. - */ - bool IsDynamic() const; - - /* - * Method declared on IContributionItem. - */ - bool IsEnabled() const; - - /** - * The ActionContributionItem implementation of this - * ContributionItem method extends the super implementation - * by also checking whether the command corresponding to this action is - * active. - */ - bool IsVisible() const; - - /** - * Sets the presentation mode, which is the bitwise-or of the - * MODE_* constants. - * - * @param mode - * the presentation mode settings - */ - void SetMode(Modes mode); - - /** - * The action item implementation of this IContributionItem - * method calls update(null). - */ - void Update(); - - /** - * Synchronizes the UI with the given property. - * - * @param propertyName - * the name of the property, or null meaning all - * applicable properties - */ - void Update(const QString& propertyName); - -protected: - - /** - * Returns true if this item is allowed to enable, - * false otherwise. - * - * @return if this item is allowed to be enabled - */ - bool IsEnabledAllowed() const; - - /** - * Shorten the given text t so that its length doesn't exceed - * the width of the given ToolItem.The default implementation replaces - * characters in the center of the original string with an ellipsis ("..."). - * Override if you need a different strategy. - * - * @param textValue - * the text to shorten - * @param item - * the tool item the text belongs to - * @return the shortened string - * - */ - //QString ShortenText(const QString& textValue, QToolButton* item); - -private: - - /** - * Returns the listener for SWT tool item widget events. - * - * @return a listener for tool item events - */ - //Listener GetToolItemListener(); - - /** - * Handles a widget dispose event for the widget corresponding to this item. - */ - //void HandleWidgetDispose(Event e); - - /** - * Handles a widget selection event. - */ - //void HandleWidgetSelection(Event e, bool selection); - - /** - * Returns whether the given action has any images. - * - * @param actionToCheck - * the action - * @return true if the action has any images, - * false if not - */ - //bool HasImages(Action* actionToCheck) const; - - /** - * Returns whether the command corresponding to this action is active. - */ - bool IsCommandActive() const; - - /** - * Updates the images for this action. - * - * @param forceImage - * true if some form of image is compulsory, and - * false if it is acceptable for this item to have - * no image - * @return true if there are images for this action, - * false if not - */ - //bool UpdateImages(bool forceImage); - - /** - * Dispose any images allocated for this contribution item - */ - //void DisposeOldImages(); - - /** - * Handle show and hide on the proxy menu for IAction.AS_DROP_DOWN_MENU - * actions. - * - * @return the appropriate listener - */ - //Listener getMenuCreatorListener(); - - /** - * The proxy menu is being shown, we better get the real menu. - * - * @param proxy - * the proxy menu - */ - //void HandleShowProxy(QMenu* proxy); - - /** - * Create MenuItems in the proxy menu that can execute the real menu items - * if selected. Create proxy menus for any real item submenus. - * - * @param realMenu - * the real menu to copy from - * @param proxy - * the proxy menu to populate - */ - //void CopyMenu(QMenu* realMenu, QMenu* proxy); - - /** - * The proxy menu is being hidden, so we need to make it go away. - * - * @param proxy - * the proxy menu - */ - //void HandleHideProxy(QMenu* proxy); - -private: - - /** - * This is the easiest way to hold the menu until we can swap it in to the - * proxy. - */ - //QMenu* holdMenu = null; - - //bool menuCreatorCalled = false; - - - /** a string inserted in the middle of text that has been shortened */ - //static const QString ellipsis = "..."; - - /** - * Stores the result of the action. False when the action returned failure. - */ - bool result; // = null; - - /** - * The presentation mode. - */ - Modes mode; // = 0; - - /** - * The action. - */ - Action* action; - -}; - -} - -#endif // BERRYACTIONCONTRIBUTIONITEM_H