diff --git a/CMake/mitkFunctionCreatePlugin.cmake b/CMake/mitkFunctionCreatePlugin.cmake index 8044c5b978..4a871ce61e 100644 --- a/CMake/mitkFunctionCreatePlugin.cmake +++ b/CMake/mitkFunctionCreatePlugin.cmake @@ -1,342 +1,338 @@ #! \brief Creates a MITK CTK plugin. #! #! This function should be called from the plugins CMakeLists.txt file. #! The target name is available after the macro call as ${PLUGIN_TARGET} #! to add additional libraries in your CMakeLists.txt. Include paths and link #! libraries are set depending on the value of the Required-Plugins header #! in your manifest_headers.cmake file. #! #! This function internally calls ctkMacroBuildPlugin() and adds support #! for Qt Help files and installers. #! #! Options: #! \param TEST_PLUGIN Mark this plug-in as a testing plug-in. #! \param NO_INSTALL Don't install this plug-in. #! #! Parameters: #! #! \param EXPORT_DIRECTIVE (required) The export directive to use in the generated #! _Exports.h file. #! #! Multi-value parameters (all optional): #! #! \param EXPORTED_INCLUDE_SUFFIXES A list of sub-directories which should #! be added to the current source directory. The resulting directories #! will be available in the set of include directories of depending plug-ins. #! \param MODULE_DEPENDS (optional) A list of Modules this plug-in depends on. #! \param PACKAGE_DEPENDS (optional) A list of external packages this plug-in depends on. #! \param TARGET_DEPENDS (optional) A list of CMake targets this plug-in depends on. #! \param DOXYGEN_TAGFILES (optional) Which external tag files should be available for the plugin documentation #! \param MOC_OPTIONS (optional) Additional options to pass to the Qt MOC compiler #! \param WARNINGS_NO_ERRORS (optional) Do not handle compiler warnings as errors function(mitk_create_plugin) # options set(arg_options TEST_PLUGIN # Mark this plug-in as a testing plug-in NO_INSTALL # Don't install this plug-in WARNINGS_NO_ERRORS ) # single value arguments set(arg_single EXPORT_DIRECTIVE # (required) TODO: could be generated via CMake as it is done for MITK modules already ) # multiple value arguments set(arg_multiple EXPORTED_INCLUDE_SUFFIXES # (optional) additional public include directories MODULE_DEPENDS # (optional) PACKAGE_DEPENDS TARGET_DEPENDS DOXYGEN_TAGFILES MOC_OPTIONS SUBPROJECTS # deprecated ) cmake_parse_arguments(_PLUGIN "${arg_options}" "${arg_single}" "${arg_multiple}" ${ARGN}) if(_PLUGIN_TEST_PLUGIN) set(_PLUGIN_NO_INSTALL 1) set(is_test_plugin "TEST_PLUGIN") else() set(is_test_plugin) endif() set(_PLUGIN_MOC_OPTIONS "-DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED ${_PLUGIN_MOC_OPTIONS}") set(PLUGIN_TARGET ${PROJECT_NAME}) mitk_check_module_dependencies(MODULES ${_PLUGIN_MODULE_DEPENDS} PACKAGES ${_PLUGIN_PACKAGE_DEPENDS} MISSING_DEPENDENCIES_VAR _missing_deps MODULE_DEPENDENCIES_VAR _module_deps PACKAGE_DEPENDENCIES_VAR _package_deps) if(_missing_deps) if(NOT MITK_BUILD_ALL_PLUGINS) message(SEND_ERROR "${PROJECT_NAME} is missing requirements and won't be built. Missing: ${_missing_deps}") else() message(STATUS "${PROJECT_NAME} is missing requirements and won't be built. Missing: ${_missing_deps}") endif() return() endif() foreach(_module_dep ${_PLUGIN_MODULE_DEPENDS}) if(TARGET ${_module_dep}) get_target_property(AUTLOAD_DEP ${_module_dep} MITK_AUTOLOAD_DIRECTORY) if (AUTLOAD_DEP) message(SEND_ERROR "Plugin \"${PROJECT_NAME}\" has an invalid dependency on autoload module \"${_module_dep}\". Check MITK_CREATE_PLUGIN usage for \"${PROJECT_NAME}\".") endif() endif() endforeach() # -------------- All dependencies are resolved ------------------ message(STATUS "Creating CTK plugin ${PROJECT_NAME}") include(files.cmake) set(_PLUGIN_CPP_FILES ${CPP_FILES}) set(_PLUGIN_MOC_H_FILES ${MOC_H_FILES}) set(_PLUGIN_UI_FILES ${UI_FILES}) set(_PLUGIN_CACHED_RESOURCE_FILES ${CACHED_RESOURCE_FILES}) set(_PLUGIN_TRANSLATION_FILES ${TRANSLATION_FILES}) set(_PLUGIN_QRC_FILES ${QRC_FILES}) set(_PLUGIN_H_FILES ${H_FILES}) set(_PLUGIN_TXX_FILES ${TXX_FILES}) set(_PLUGIN_DOX_FILES ${DOX_FILES}) set(_PLUGIN_CMAKE_FILES ${CMAKE_FILES} files.cmake) set(_PLUGIN_FILE_DEPENDENCIES ${FILE_DEPENDENCIES}) if(CTK_PLUGINS_OUTPUT_DIR) set(_output_dir "${CTK_PLUGINS_OUTPUT_DIR}") else() set(_output_dir "") endif() # Compute the plugin dependencies ctkFunctionGetTargetLibraries(_PLUGIN_target_libraries "") #------------------------------------------------------------# #------------------ Qt Help support -------------------------# set(PLUGIN_GENERATED_QCH_FILES ) if(BLUEBERRY_USE_QT_HELP AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/documentation/UserManual") set(PLUGIN_DOXYGEN_INPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/documentation/UserManual") set(PLUGIN_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/documentation/UserManual") # Create a list of Doxygen tag files from the plug-in dependencies set(PLUGIN_DOXYGEN_TAGFILES) foreach(_dep_target ${_PLUGIN_target_libraries}) string(REPLACE _ . _dep ${_dep_target}) get_target_property(_is_imported ${_dep_target} IMPORTED) if(_is_imported) get_target_property(_import_loc_debug ${_dep_target} IMPORTED_LOCATION_DEBUG) get_target_property(_import_loc_release ${_dep_target} IMPORTED_LOCATION_RELEASE) # There is not necessarily a debug and release build if(_import_loc_release) set(_import_loc ${_import_loc_release}) else() set(_import_loc ${_import_loc_debug}) endif() get_filename_component(_target_filename "${_import_loc}" NAME) # on windows there might be a Debug or Release subdirectory string(REGEX REPLACE "/bin/plugins/(Debug/|Release/)?${_target_filename}" "/Plugins/${_dep}/documentation/UserManual" plugin_tag_dir "${_import_loc}" ) else() set(plugin_tag_dir "${CMAKE_BINARY_DIR}/Plugins/${_dep}/documentation/UserManual") endif() set(_tag_file "${plugin_tag_dir}/${_dep_target}.tag") if(EXISTS ${_tag_file}) set(PLUGIN_DOXYGEN_TAGFILES "${PLUGIN_DOXYGEN_TAGFILES} \"${_tag_file}=qthelp://${_dep}/bundle/\"") endif() endforeach() if(_PLUGIN_DOXYGEN_TAGFILES) set(PLUGIN_DOXYGEN_TAGFILES "${PLUGIN_DOXYGEN_TAGFILES} ${_PLUGIN_DOXYGEN_TAGFILES}") endif() #message("PLUGIN_DOXYGEN_TAGFILES: ${PLUGIN_DOXYGEN_TAGFILES}") _FUNCTION_CREATE_CTK_QT_COMPRESSED_HELP(PLUGIN_GENERATED_QCH_FILES) list(APPEND _PLUGIN_CACHED_RESOURCE_FILES ${PLUGIN_GENERATED_QCH_FILES}) endif() #------------------------------------------------------------# #------------------ Create Plug-in --------------------------# mitkFunctionOrganizeSources( SOURCE ${_PLUGIN_CPP_FILES} HEADER ${_PLUGIN_H_FILES} TXX ${_PLUGIN_TXX_FILES} DOC ${_PLUGIN_DOX_FILES} UI ${_PLUGIN_UI_FILES} QRC ${_PLUGIN_QRC_FILES} ${_PLUGIN_CACHED_RESOURCE_FILES} META ${_PLUGIN_META_FILES} MOC ${MY_MOC_CPP} GEN_UI ${MY_UI_CPP} GEN_QRC ${MY_QRC_SRCS} ) ctkMacroBuildPlugin( NAME ${PLUGIN_TARGET} EXPORT_DIRECTIVE ${_PLUGIN_EXPORT_DIRECTIVE} SRCS ${_PLUGIN_CPP_FILES} ${_PLUGIN_H_FILES} ${CORRESPONDING__H_FILES} ${GLOBBED__H_FILES} MOC_SRCS ${_PLUGIN_MOC_H_FILES} MOC_OPTIONS ${_PLUGIN_MOC_OPTIONS} UI_FORMS ${_PLUGIN_UI_FILES} EXPORTED_INCLUDE_SUFFIXES ${_PLUGIN_EXPORTED_INCLUDE_SUFFIXES} RESOURCES ${_PLUGIN_QRC_FILES} TARGET_LIBRARIES ${_PLUGIN_target_libraries} CACHED_RESOURCEFILES ${_PLUGIN_CACHED_RESOURCE_FILES} TRANSLATIONS ${_PLUGIN_TRANSLATION_FILES} OUTPUT_DIR ${_output_dir} NO_INSTALL # we install the plug-in ourselves ${is_test_plugin} ) mitk_use_modules(TARGET ${PLUGIN_TARGET} MODULES ${_PLUGIN_MODULE_DEPENDS} PACKAGES ${_PLUGIN_PACKAGE_DEPENDS} ) if(_PLUGIN_TARGET_DEPENDS) target_link_libraries(${PLUGIN_TARGET} ${_PLUGIN_TARGET_DEPENDS}) endif() set_property(TARGET ${PLUGIN_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS US_MODULE_NAME=${PLUGIN_TARGET}) set_property(TARGET ${PLUGIN_TARGET} PROPERTY US_MODULE_NAME ${PLUGIN_TARGET}) if(NOT CMAKE_CURRENT_SOURCE_DIR MATCHES "^${CMAKE_SOURCE_DIR}/.*") foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) if("${CMAKE_CURRENT_SOURCE_DIR}/" MATCHES "^${MITK_EXTENSION_DIR}/.*") get_filename_component(MITK_EXTENSION_ROOT_FOLDER "${MITK_EXTENSION_DIR}" NAME) set_property(TARGET ${PLUGIN_TARGET} PROPERTY FOLDER "${MITK_EXTENSION_ROOT_FOLDER}/Plugins") break() endif() endforeach() else() set_property(TARGET ${PLUGIN_TARGET} PROPERTY FOLDER "${MITK_ROOT_FOLDER}/Plugins") endif() set(plugin_c_flags) set(plugin_cxx_flags) if(NOT _PLUGIN_WARNINGS_NO_ERRORS) if(MSVC_VERSION) mitkFunctionCheckCAndCXXCompilerFlags("/WX" plugin_c_flags plugin_cxx_flags) else() mitkFunctionCheckCAndCXXCompilerFlags(-Werror plugin_c_flags plugin_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=c++0x-static-nonintegral-init" plugin_c_flags plugin_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=static-member-init" plugin_c_flags plugin_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=unknown-warning" plugin_c_flags plugin_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=gnu" plugin_c_flags plugin_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=cast-function-type" plugin_c_flags plugin_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=inconsistent-missing-override" plugin_c_flags plugin_cxx_flags) mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=deprecated-declarations" plugin_c_flags plugin_cxx_flags) endif() endif() if(plugin_c_flags) string(REPLACE " " ";" plugin_c_flags "${plugin_c_flags}") target_compile_options(${PLUGIN_TARGET} PRIVATE ${plugin_c_flags}) endif() if(plugin_cxx_flags) string(REPLACE " " ";" plugin_cxx_flags "${plugin_cxx_flags}") target_compile_options(${PLUGIN_TARGET} PRIVATE ${plugin_cxx_flags}) endif() if(_PLUGIN_TEST_PLUGIN) find_package(CppUnit REQUIRED) target_include_directories(${PLUGIN_TARGET} PRIVATE ${CppUnit_INCLUDE_DIRS}) target_link_libraries(${PLUGIN_TARGET} PRIVATE ${CppUnit_LIBRARIES}) endif() if(TARGET MitkLog) target_link_libraries(${PLUGIN_TARGET} PRIVATE MitkLog) endif() set(_PLUGIN_META_FILES "${CMAKE_CURRENT_SOURCE_DIR}/manifest_headers.cmake") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/plugin.xml") list(APPEND _PLUGIN_META_FILES "${CMAKE_CURRENT_SOURCE_DIR}/plugin.xml") endif() set(PLUGIN_TARGET ${PLUGIN_TARGET} PARENT_SCOPE) #------------------------------------------------------------# #------------------ Installer support -----------------------# if(NOT _PLUGIN_NO_INSTALL) set(install_directories "") if(NOT MACOSX_BUNDLE_NAMES) set(install_directories bin/plugins) else(NOT MACOSX_BUNDLE_NAMES) foreach(bundle_name ${MACOSX_BUNDLE_NAMES}) list(APPEND install_directories ${bundle_name}.app/Contents/MacOS/plugins) endforeach(bundle_name) endif(NOT MACOSX_BUNDLE_NAMES) foreach(install_subdir ${install_directories}) mitkFunctionInstallCTKPlugin(TARGETS ${PLUGIN_TARGET} DESTINATION ${install_subdir}) endforeach() set(_autoload_targets ) foreach(_dependency ${_module_deps}) get_target_property(_dep_autoloads ${_dependency} MITK_AUTOLOAD_TARGETS) if (_dep_autoloads) list(APPEND _autoload_targets ${_dep_autoloads}) endif() endforeach() # The MITK_AUTOLOAD_TARGETS property is used in the mitkFunctionInstallAutoLoadModules # macro which expects a list of plug-in targets. if (_autoload_targets) list(REMOVE_DUPLICATES _autoload_targets) set_target_properties(${PLUGIN_TARGET} PROPERTIES MITK_AUTOLOAD_TARGETS "${_autoload_targets}") endif() endif() endfunction() function(_FUNCTION_CREATE_CTK_QT_COMPRESSED_HELP qch_file) set(_manifest_path "${CMAKE_CURRENT_SOURCE_DIR}/manifest_headers.cmake") if(NOT EXISTS ${_manifest_path}) message(FATAL_ERROR "${_manifest_path} not found") endif() include(${_manifest_path}) string(REPLACE "_" "." Plugin-SymbolicName "${PLUGIN_TARGET}") configure_file(${MITK_SOURCE_DIR}/Documentation/doxygen_plugin_manual.conf.in ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf ) set(_generated_qhp_file "${PLUGIN_DOXYGEN_OUTPUT_DIR}/html/index.qhp") set(${qch_file} "${CMAKE_CURRENT_BINARY_DIR}/resources/${PLUGIN_TARGET}.qch") file(GLOB _file_dependencies "${PLUGIN_DOXYGEN_INPUT_DIR}/*") add_custom_command(OUTPUT ${${qch_file}} # Generate a Qt help project (index.qhp) with doxygen COMMAND ${DOXYGEN_EXECUTABLE} ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf # Generate the final Qt compressed help file (.qch) COMMAND ${QT_HELPGENERATOR_EXECUTABLE} ${_generated_qhp_file} -o ${${qch_file}} DEPENDS ${PLUGIN_DOXYGEN_OUTPUT_DIR}/doxygen.conf ${_file_dependencies} ) #set_source_files_properties(${qch_file} PROPERTIES GENERATED 1) set(${qch_file} ${${qch_file}} PARENT_SCOPE) endfunction() - -function(MACRO_CREATE_MITK_CTK_PLUGIN) - message(SEND_ERROR "The function MACRO_CREATE_MITK_CTK_PLUGIN was renamed to mitk_create_plugin in MITK 2015.05.") -endfunction() diff --git a/CMake/mitkMacroCreateCTKPlugin.cmake b/CMake/mitkMacroCreateCTKPlugin.cmake deleted file mode 100644 index c9e80e7bba..0000000000 --- a/CMake/mitkMacroCreateCTKPlugin.cmake +++ /dev/null @@ -1,7 +0,0 @@ -macro(MACRO_CREATE_MITK_CTK_PLUGIN) - - message(WARNING "The MACRO_CREATE_MITK_CTK_PLUGIN macro is deprecated since 2015.05. Use mitk_create_plugin instead.") - - mitk_create_plugin(${ARGN}) - -endmacro() diff --git a/CMakeLists.txt b/CMakeLists.txt index 93ad529af3..adb7e97452 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,1416 +1,1413 @@ #[[ When increasing the minimum required version, check if Boost_ADDITIONAL_VERSIONS in CMake/PackageDepends/MITK_Boost_Config.cmake can be removed. See the first long comment in CMakeExternals/Boost.cmake for details. ]] set(MITK_CMAKE_MINIMUM_REQUIRED_VERSION 3.18) cmake_minimum_required(VERSION ${MITK_CMAKE_MINIMUM_REQUIRED_VERSION}) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19 AND CMAKE_VERSION VERSION_LESS 3.19.2) message(FATAL_ERROR "\ CMake v${CMAKE_VERSION} is defective [1]. \ Please either downgrade to v3.18 or upgrade to at least v3.19.2.\n\ [1] https://gitlab.kitware.com/cmake/cmake/-/issues/21529") endif() #----------------------------------------------------------------------------- # Policies #----------------------------------------------------------------------------- #[[ T28060 https://cmake.org/cmake/help/v3.18/policy/CMP0091.html https://cmake.org/cmake/help/v3.18/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html We pass CMP0091 to all external projects as command-line argument: -DCMAKE_POLICY_DEFAULT_CMP0091:STRING=OLD ]] cmake_policy(SET CMP0091 OLD) if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) # https://cmake.org/cmake/help/v3.24/policy/CMP0135.html endif() #----------------------------------------------------------------------------- # Superbuild Option - Enabled by default #----------------------------------------------------------------------------- option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON) if(MITK_USE_SUPERBUILD) project(MITK-superbuild) set(MITK_SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(MITK_BINARY_DIR ${PROJECT_BINARY_DIR}) else() project(MITK VERSION 2023.12.99) include_directories(SYSTEM ${MITK_SUPERBUILD_BINARY_DIR}) endif() #----------------------------------------------------------------------------- # MITK Extension Feature #----------------------------------------------------------------------------- set(MITK_EXTENSION_DIRS "" CACHE STRING "") unset(MITK_ABSOLUTE_EXTENSION_DIRS) foreach(MITK_EXTENSION_DIR ${MITK_EXTENSION_DIRS}) get_filename_component(MITK_ABSOLUTE_EXTENSION_DIR "${MITK_EXTENSION_DIR}" ABSOLUTE) list(APPEND MITK_ABSOLUTE_EXTENSION_DIRS "${MITK_ABSOLUTE_EXTENSION_DIR}") endforeach() set(MITK_DIR_PLUS_EXTENSION_DIRS "${MITK_SOURCE_DIR}" ${MITK_ABSOLUTE_EXTENSION_DIRS}) #----------------------------------------------------------------------------- # Update CMake module path #----------------------------------------------------------------------------- set(MITK_CMAKE_DIR ${MITK_SOURCE_DIR}/CMake) set(CMAKE_MODULE_PATH ${MITK_CMAKE_DIR}) foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_CMAKE_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMake") if(EXISTS "${MITK_CMAKE_EXTENSION_DIR}") list(APPEND CMAKE_MODULE_PATH "${MITK_CMAKE_EXTENSION_DIR}") endif() endforeach() #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- # Standard CMake macros include(FeatureSummary) include(CTest) include(CMakeParseArguments) include(FindPackageHandleStandardArgs) # MITK macros include(mitkFunctionGetGccVersion) include(mitkFunctionCheckCompilerFlags) include(mitkFunctionSuppressWarnings) # includes several functions include(mitkMacroEmptyExternalProject) include(mitkFunctionEnableBuildConfiguration) include(mitkFunctionWhitelists) include(mitkFunctionAddExternalProject) include(mitkFunctionAddLibrarySearchPaths) SUPPRESS_VC_DEPRECATED_WARNINGS() #----------------------------------------------------------------------------- # Set a default build type if none was specified #----------------------------------------------------------------------------- if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'Debug' as none was specified.") set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() if(CMAKE_COMPILER_IS_GNUCXX) mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) else() set(GCC_VERSION 0) endif() set(MITK_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS 0) set(CMAKE_CXX_STANDARD ${MITK_CXX_STANDARD}) set(CMAKE_CXX_STANDARD_REQUIRED 1) # This is necessary to avoid problems with compile feature checks. # CMAKE_CXX_STANDARD seems to only set the -std=c++ flag for targets. # However, compile flag checks also need to be done with -std=c++. # The MITK_CXX_FLAG variable is also used for external projects # build during the MITK super-build. mitkFunctionCheckCompilerFlags("-std=c++${MITK_CXX_STANDARD}" MITK_CXX${MITK_CXX_STANDARD}_FLAG) #----------------------------------------------------------------------------- # Warn if source or build path is too long #----------------------------------------------------------------------------- if(WIN32) set(_src_dir_length_max 50) set(_bin_dir_length_max 50) if(MITK_USE_SUPERBUILD) set(_src_dir_length_max 34) # _src_dir_length_max - strlen(ep/src/ITK-build) set(_bin_dir_length_max 40) # _bin_dir_length_max - strlen(MITK-build) endif() string(LENGTH "${MITK_SOURCE_DIR}" _src_n) string(LENGTH "${MITK_BINARY_DIR}" _bin_n) # The warnings should be converted to errors if(_src_n GREATER _src_dir_length_max) message(WARNING "MITK source code directory path length is too long (${_src_n} > ${_src_dir_length_max})." "Please move the MITK source code directory to a directory with a shorter path." ) endif() if(_bin_n GREATER _bin_dir_length_max) message(WARNING "MITK build directory path length is too long (${_bin_n} > ${_bin_dir_length_max})." "Please move the MITK build directory to a directory with a shorter path." ) endif() endif() #----------------------------------------------------------------------------- # Additional MITK Options (also shown during superbuild) #----------------------------------------------------------------------------- # ----------------------------------------- # General build options option(BUILD_SHARED_LIBS "Build MITK with shared libraries" ON) option(WITH_COVERAGE "Enable/Disable coverage" OFF) option(BUILD_TESTING "Test the project" ON) option(MITK_FAST_TESTING "Disable long-running tests like packaging" OFF) option(MITK_XVFB_TESTING "Execute test drivers through xvfb-run" OFF) option(MITK_BUILD_ALL_APPS "Build all MITK applications" OFF) option(MITK_BUILD_EXAMPLES "Build the MITK Examples" OFF) mark_as_advanced( MITK_XVFB_TESTING MITK_FAST_TESTING MITK_BUILD_ALL_APPS ) #----------------------------------------------------------------------------- # Set UI testing flags #----------------------------------------------------------------------------- if(MITK_XVFB_TESTING) set(MITK_XVFB_TESTING_COMMAND "xvfb-run" "--auto-servernum" CACHE STRING "Command and options to test through Xvfb") mark_as_advanced(MITK_XVFB_TESTING_COMMAND) endif(MITK_XVFB_TESTING) # ----------------------------------------- # Other options set(MITK_CUSTOM_REVISION_DESC "" CACHE STRING "Override MITK revision description") mark_as_advanced(MITK_CUSTOM_REVISION_DESC) set_property(GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS "") include(CMakeExternals/ExternalProjectList.cmake) foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_CMAKE_EXTERNALS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMakeExternals") if(EXISTS "${MITK_CMAKE_EXTERNALS_EXTENSION_DIR}/ExternalProjectList.cmake") include("${MITK_CMAKE_EXTERNALS_EXTENSION_DIR}/ExternalProjectList.cmake") endif() endforeach() # ----------------------------------------- # Other MITK_USE_* options not related to # external projects build via the # MITK superbuild option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON) option(MITK_USE_OpenMP "Use OpenMP" OFF) option(MITK_USE_Python3 "Use Python 3" OFF) #----------------------------------------------------------------------------- # Build configurations #----------------------------------------------------------------------------- set(_buildConfigs "Custom") file(GLOB _buildConfigFiles CMake/BuildConfigurations/*.cmake) foreach(_buildConfigFile ${_buildConfigFiles}) get_filename_component(_buildConfigFile ${_buildConfigFile} NAME_WE) list(APPEND _buildConfigs ${_buildConfigFile}) endforeach() foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) file(GLOB _extBuildConfigFiles "${MITK_EXTENSION_DIR}/CMake/BuildConfigurations/*.cmake") foreach(_extBuildConfigFile ${_extBuildConfigFiles}) get_filename_component(_extBuildConfigFile "${_extBuildConfigFile}" NAME_WE) list(APPEND _buildConfigs "${_extBuildConfigFile}") endforeach() list(REMOVE_DUPLICATES _buildConfigs) endforeach() set(MITK_BUILD_CONFIGURATION "Custom" CACHE STRING "Use pre-defined MITK configurations") set_property(CACHE MITK_BUILD_CONFIGURATION PROPERTY STRINGS ${_buildConfigs}) mitkFunctionEnableBuildConfiguration() mitkFunctionCreateWhitelistPaths(MITK) mitkFunctionFindWhitelists(MITK) # ----------------------------------------- # Qt version related variables option(MITK_USE_Qt6 "Use Qt 6 library" ON) if(MITK_USE_Qt6) set(MITK_QT6_MINIMUM_VERSION 6.6) set(MITK_QT6_COMPONENTS Concurrent Core Core5Compat CoreTools Designer DesignerComponentsPrivate Gui Help LinguistTools Network OpenGL OpenGLWidgets Qml Sql StateMachine Svg ToolsTools UiTools WebEngineCore WebEngineWidgets Widgets Xml ) if(APPLE) list(APPEND MITK_QT6_COMPONENTS DBus) endif() # Hint at default install locations of Qt if(NOT Qt6_DIR) if(MSVC) set(_dir_candidates "C:/Qt") if(CMAKE_GENERATOR MATCHES "^Visual Studio [0-9]+ ([0-9]+)") set(_compilers "msvc${CMAKE_MATCH_1}") elseif(CMAKE_GENERATOR MATCHES "Ninja") include(mitkFunctionGetMSVCVersion) mitkFunctionGetMSVCVersion() if(VISUAL_STUDIO_PRODUCT_NAME MATCHES "^Visual Studio ([0-9]+)") set(_compilers "msvc${CMAKE_MATCH_1}") endif() endif() if(_compilers MATCHES "[0-9]+") if (CMAKE_MATCH_0 EQUAL 2022) list(APPEND _compilers "msvc2019") # Binary compatible endif() endif() else() set(_dir_candidates ~/Qt) if(APPLE) set(_compilers clang) else() list(APPEND _dir_candidates /opt/Qt) set(_compilers gcc) endif() endif() if(CMAKE_SIZEOF_VOID_P EQUAL 8) foreach(_compiler ${_compilers}) list(APPEND _compilers64 "${_compiler}_64") endforeach() set(_compilers ${_compilers64}) endif() if(APPLE) list(APPEND _compilers macos) endif() foreach(_dir_candidate ${_dir_candidates}) get_filename_component(_dir_candidate ${_dir_candidate} REALPATH) foreach(_compiler ${_compilers}) set(_glob_expression "${_dir_candidate}/6.*/${_compiler}") file(GLOB _hints ${_glob_expression}) list(SORT _hints) list(APPEND MITK_QT6_HINTS ${_hints}) endforeach() endforeach() endif() find_package(Qt6 ${MITK_QT6_MINIMUM_VERSION} COMPONENTS ${MITK_QT6_COMPONENTS} REQUIRED HINTS ${MITK_QT6_HINTS}) get_target_property(QT_QMAKE_EXECUTABLE Qt6::qmake LOCATION) get_target_property(QT_HELPGENERATOR_EXECUTABLE Qt6::qhelpgenerator LOCATION) endif() if(Qt6_DIR) list(APPEND CMAKE_PREFIX_PATH "${Qt6_DIR}/../../..") list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH) endif() # ----------------------------------------- # Custom dependency logic if(WIN32 AND Qt6_DIR) set(_dir_candidate "${Qt6_DIR}/../../../../../Tools/OpenSSLv3/Win_x64") get_filename_component(_dir_candidate ${_dir_candidate} ABSOLUTE) if(EXISTS "${_dir_candidate}") set(OPENSSL_ROOT_DIR "${_dir_candidate}") endif() endif() find_package(OpenSSL 3) if(NOT OpenSSL_FOUND) find_package(OpenSSL 1.1.1) endif() option(MITK_USE_SYSTEM_Boost "Use the system Boost" OFF) set(MITK_USE_Boost_LIBRARIES "" CACHE STRING "A semi-colon separated list of required Boost libraries") if(MITK_USE_cpprestsdk) if(NOT OpenSSL_FOUND) set(openssl_message "Could not find OpenSSL (dependency of C++ REST SDK).\n") if(UNIX) if(APPLE) set(openssl_message "${openssl_message}Please install it using your favorite package management " "system (i.e. Homebrew or MacPorts).\n") else() set(openssl_message "${openssl_message}Please install the dev package of OpenSSL (i.e. libssl-dev).\n") endif() else() set(openssl_message "${openssl_message}Please either install Win32 OpenSSL:\n" " https://slproweb.com/products/Win32OpenSSL.html\n" "Or use the Qt Maintenance tool to install:\n" " Developer and Designer Tools > OpenSSL Toolkit > OpenSSL 64-bit binaries\n") endif() set(openssl_message "${openssl_message}If it still cannot be found, you can hint CMake to find OpenSSL by " "adding/setting the OPENSSL_ROOT_DIR variable to the root directory of an " "OpenSSL installation. Make sure to clear variables of partly found " "versions of OpenSSL before, or they will be mixed up.") message(FATAL_ERROR ${openssl_message}) endif() list(APPEND MITK_USE_Boost_LIBRARIES date_time regex system) if(UNIX) list(APPEND MITK_USE_Boost_LIBRARIES atomic chrono filesystem random thread) endif() list(REMOVE_DUPLICATES MITK_USE_Boost_LIBRARIES) set(MITK_USE_Boost_LIBRARIES ${MITK_USE_Boost_LIBRARIES} CACHE STRING "A semi-colon separated list of required Boost libraries" FORCE) endif() if(MITK_USE_Python3) set(MITK_USE_ZLIB ON CACHE BOOL "" FORCE) if(APPLE) set(python3_mininum_version 3.11) else() set(python3_mininum_version 3.8) endif() find_package(Python3 ${python3_mininum_version} REQUIRED COMPONENTS Interpreter Development NumPy) if(WIN32) string(REPLACE "\\" "/" Python3_STDARCH "${Python3_STDARCH}") string(REPLACE "\\" "/" Python3_STDLIB "${Python3_STDLIB}") string(REPLACE "\\" "/" Python3_SITELIB "${Python3_SITELIB}") endif() endif() if(BUILD_TESTING AND NOT MITK_USE_CppUnit) message("> Forcing MITK_USE_CppUnit to ON because BUILD_TESTING=ON") set(MITK_USE_CppUnit ON CACHE BOOL "Use CppUnit for unit tests" FORCE) endif() if(MITK_USE_BLUEBERRY) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) mark_as_advanced(MITK_BUILD_ALL_PLUGINS) if(NOT MITK_USE_CTK) message("> Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY") set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE) endif() endif() #----------------------------------------------------------------------------- # Pixel type multiplexing #----------------------------------------------------------------------------- # Customize the default pixel types for multiplex macros set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "itk::RGBPixel, itk::RGBAPixel" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") mark_as_advanced(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES MITK_ACCESSBYITK_DIMENSIONS ) # consistency checks if(NOT MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES) set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES) set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES) set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "itk::RGBPixel, itk::RGBAPixel" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES) string(REPLACE "," ";" _integral_types ${MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES}) string(REPLACE "," ";" _floating_types ${MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES}) foreach(_scalar_type ${_integral_types} ${_floating_types}) set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}itk::VariableLengthVector<${_scalar_type}>,") endforeach() string(LENGTH "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" _length) math(EXPR _length "${_length} - 1") string(SUBSTRING "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" 0 ${_length} MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES) set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES ${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES} CACHE STRING "List of vector pixel types used in AccessByItk and InstantiateAccessFunction macros for itk::VectorImage types" FORCE) endif() if(NOT MITK_ACCESSBYITK_DIMENSIONS) set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") endif() find_package(Git REQUIRED) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(MITK_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") # Print configuration summary message("\n\n") feature_summary( DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------" WHAT ALL) return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # Organize MITK targets in folders #----------------------------------------------------------------------------- set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(MITK_ROOT_FOLDER "MITK" CACHE STRING "") mark_as_advanced(MITK_ROOT_FOLDER) #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(WriteBasicConfigVersionFile) include(CheckCXXSourceCompiles) include(GenerateExportHeader) include(mitkFunctionAddManifest) include(mitkFunctionAddCustomModuleTest) include(mitkFunctionCheckModuleDependencies) include(mitkFunctionCompileSnippets) include(mitkFunctionConfigureVisualStudioUserProjectFile) include(mitkFunctionCreateBlueBerryApplication) include(mitkFunctionCreateCommandLineApp) include(mitkFunctionCreateModule) include(mitkFunctionCreatePlugin) include(mitkFunctionCreateProvisioningFile) include(mitkFunctionGetLibrarySearchPaths) include(mitkFunctionGetVersion) include(mitkFunctionGetVersionDescription) include(mitkFunctionInstallAutoLoadModules) include(mitkFunctionInstallCTKPlugin) include(mitkFunctionInstallProvisioningFiles) include(mitkFunctionInstallThirdPartyCTKPlugins) include(mitkFunctionOrganizeSources) include(mitkFunctionUseModules) if( ${MITK_USE_MatchPoint} ) include(mitkFunctionCreateMatchPointDeployedAlgorithm) endif() include(mitkMacroConfigureItkPixelTypes) include(mitkMacroCreateExecutable) include(mitkMacroCreateModuleTests) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetLinuxDistribution) include(mitkMacroGetPMDPlatformString) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroMultiplexPicType) -# Deprecated -include(mitkMacroCreateCTKPlugin) - #----------------------------------------------------------------------------- # Global CMake variables #----------------------------------------------------------------------------- if(NOT DEFINED CMAKE_DEBUG_POSTFIX) # We can't do this yet because the CTK Plugin Framework # cannot cope with a postfix yet. #set(CMAKE_DEBUG_POSTFIX d) endif() #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- set(_default_LIBRARY_output_dir lib) set(_default_RUNTIME_output_dir bin) set(_default_ARCHIVE_output_dir lib) foreach(type LIBRARY RUNTIME ARCHIVE) # Make sure the directory exists if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY AND NOT EXISTS ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) message("Creating directory MITK_CMAKE_${type}_OUTPUT_DIRECTORY: ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") file(MAKE_DIRECTORY "${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") endif() if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) else() set(CMAKE_${type}_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${_default_${type}_output_dir}) set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY}) endif() set(CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY} CACHE INTERNAL "Output directory for ${type} files.") mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY) endforeach() #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- if(OpenSSL_FOUND AND WIN32) #[[ On Windows, CMake is able to locate the link libraries for OpenSSL but it does not look for the corresponding DLLs that we need to copy to our binary directories and include in packaging. Setting these paths manually is cumbersome so we try to use a simple heuristic to automatically set them: - Based on the link libraries (usually located in a lib folder), try to find the "../bin" binary directory. - Use the base file names of the link libraries to find corresponding DLLs like "*.dll", that usually are named like "-1_1-x64.dll" or similar. ]] set(openssl_ssl_dll "") set(openssl_crypto_dll "") if(OPENSSL_SSL_LIBRARY AND EXISTS "${OPENSSL_SSL_LIBRARY}") get_filename_component(openssl_bin_dir "${OPENSSL_SSL_LIBRARY}" DIRECTORY) get_filename_component(openssl_bin_dir "${openssl_bin_dir}" DIRECTORY) set(openssl_bin_dir "${openssl_bin_dir}/bin") if(EXISTS "${openssl_bin_dir}") get_filename_component(openssl_ssl_basename "${OPENSSL_SSL_LIBRARY}" NAME_WE) file(GLOB openssl_ssl_dll "${openssl_bin_dir}/${openssl_ssl_basename}*.dll") list(LENGTH openssl_ssl_dll num_findings) if(num_findings GREATER 1) set(openssl_ssl_dll "") endif() get_filename_component(openssl_crypto_basename "${OPENSSL_CRYPTO_LIBRARY}" NAME_WE) file(GLOB openssl_crypto_dll "${openssl_bin_dir}/${openssl_crypto_basename}*.dll") list(LENGTH openssl_crypto_dll num_findings) if(num_findings GREATER 1) set(openssl_crypto_dll "") endif() endif() endif() set(MITK_OPENSSL_SSL_DLL "${openssl_ssl_dll}" CACHE FILEPATH "") if(DEFINED CACHE{MITK_OPENSSL_SSL_DLL} AND NOT MITK_OPENSSL_SSL_DLL AND openssl_ssl_dll) set(MITK_OPENSSL_SSL_DLL "${openssl_ssl_dll}" CACHE FILEPATH "" FORCE) endif() set(MITK_OPENSSL_CRYPTO_DLL "${openssl_crypto_dll}" CACHE FILEPATH "") if(DEFINED CACHE{MITK_OPENSSL_CRYPTO_DLL} AND NOT MITK_OPENSSL_CRYPTO_DLL AND openssl_crypto_dll) set(MITK_OPENSSL_CRYPTO_DLL "${openssl_crypto_dll}" CACHE FILEPATH "" FORCE) endif() if(MITK_OPENSSL_SSL_DLL AND EXISTS "${MITK_OPENSSL_SSL_DLL}" AND MITK_OPENSSL_CRYPTO_DLL AND EXISTS "${MITK_OPENSSL_CRYPTO_DLL}") foreach(config_type ${CMAKE_CONFIGURATION_TYPES}) execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${MITK_BINARY_DIR}/bin/${config_type}") configure_file("${MITK_OPENSSL_SSL_DLL}" "${MITK_BINARY_DIR}/bin/${config_type}/" COPYONLY) configure_file("${MITK_OPENSSL_CRYPTO_DLL}" "${MITK_BINARY_DIR}/bin/${config_type}/" COPYONLY) endforeach() MITK_INSTALL(FILES "${MITK_OPENSSL_SSL_DLL}" "${MITK_OPENSSL_CRYPTO_DLL}" ) endif() endif() # Look for optional Doxygen package find_package(Doxygen) option(BLUEBERRY_DEBUG_SMARTPOINTER "Enable code for debugging smart pointers" OFF) mark_as_advanced(BLUEBERRY_DEBUG_SMARTPOINTER) # Ask the user to show the console window for applications option(MITK_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting MITK GUI Applications" ON) mark_as_advanced(MITK_SHOW_CONSOLE_WINDOW) if(NOT MITK_FAST_TESTING) if(MITK_CTEST_SCRIPT_MODE STREQUAL "Continuous" OR MITK_CTEST_SCRIPT_MODE STREQUAL "Experimental") set(MITK_FAST_TESTING ON) endif() endif() if(NOT UNIX) set(MITK_WIN32_FORCE_STATIC "STATIC" CACHE INTERNAL "Use this variable to always build static libraries on non-unix platforms") endif() if(MITK_BUILD_ALL_PLUGINS) set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL") endif() # Configure pixel types used for ITK image access multiplexing mitkMacroConfigureItkPixelTypes() # Configure module naming conventions set(MITK_MODULE_NAME_REGEX_MATCH "^[A-Z].*$") set(MITK_MODULE_NAME_REGEX_NOT_MATCH "^[Mm][Ii][Tt][Kk].*$") set(MITK_DEFAULT_MODULE_NAME_PREFIX "Mitk") set(MITK_MODULE_NAME_PREFIX ${MITK_DEFAULT_MODULE_NAME_PREFIX}) set(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME 1) #----------------------------------------------------------------------------- # Get MITK version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK) mitkFunctionGetVersionDescription(${MITK_SOURCE_DIR} MITK) # MITK_VERSION set(MITK_VERSION_STRING "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}") if(MITK_VERSION_PATCH STREQUAL "99") set(MITK_VERSION_STRING "${MITK_VERSION_STRING}-${MITK_REVISION_SHORTID}") endif() #----------------------------------------------------------------------------- # Installation preparation # # These should be set before any MITK install macros are used #----------------------------------------------------------------------------- # on macOS all BlueBerry plugins get copied into every # application bundle (.app directory) specified here if(MITK_USE_BLUEBERRY AND APPLE) foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications") if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") set(MITK_APPS "") include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 1 option_name) list(GET target_info_list 0 app_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} Mitk${app_name}) endif() endforeach() endif() endforeach() endif() #----------------------------------------------------------------------------- # Set coverage Flags #----------------------------------------------------------------------------- if(WITH_COVERAGE) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG") set(COVERAGE_CXX_FLAGS ${coverage_flags}) set(COVERAGE_C_FLAGS ${coverage_flags}) endif() endif() #----------------------------------------------------------------------------- # MITK C/CXX Flags #----------------------------------------------------------------------------- set(MITK_C_FLAGS "${COVERAGE_C_FLAGS}") set(MITK_C_FLAGS_DEBUG ) set(MITK_C_FLAGS_RELEASE ) set(MITK_CXX_FLAGS "${COVERAGE_CXX_FLAGS} ${MITK_CXX${MITK_CXX_STANDARD}_FLAG}") set(MITK_CXX_FLAGS_DEBUG ) set(MITK_CXX_FLAGS_RELEASE ) set(MITK_EXE_LINKER_FLAGS ) set(MITK_SHARED_LINKER_FLAGS ) if(WIN32) set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN -DNOMINMAX") mitkFunctionCheckCompilerFlags("/wd4005" MITK_CXX_FLAGS) # warning C4005: macro redefinition mitkFunctionCheckCompilerFlags("/wd4231" MITK_CXX_FLAGS) # warning C4231: nonstandard extension used : 'extern' before template explicit instantiation # the following line should be removed after fixing bug 17637 mitkFunctionCheckCompilerFlags("/wd4316" MITK_CXX_FLAGS) # warning C4316: object alignment on heap mitkFunctionCheckCompilerFlags("/wd4180" MITK_CXX_FLAGS) # warning C4180: qualifier applied to function type has no meaning mitkFunctionCheckCompilerFlags("/wd4251" MITK_CXX_FLAGS) # warning C4251: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2' endif() if(APPLE) set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -DGL_SILENCE_DEPRECATION") # Apple deprecated OpenGL in macOS 10.14 endif() if(NOT MSVC_VERSION) foreach(_flag -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -Wno-error=gnu -Wno-error=unknown-pragmas # The strict-overflow warning is generated by ITK template code -Wno-error=strict-overflow -Woverloaded-virtual -Wstrict-null-sentinel #-Wold-style-cast #-Wsign-promo -Wno-deprecated-copy -Wno-array-bounds -Wno-cast-function-type -Wno-maybe-uninitialized -Wno-error=stringop-overread -fdiagnostics-show-option ) mitkFunctionCheckCAndCXXCompilerFlags(${_flag} MITK_C_FLAGS MITK_CXX_FLAGS) endforeach() endif() if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" MITK_SHARED_LINKER_FLAGS) mitkFunctionCheckCompilerFlags("-Wl,--as-needed" MITK_SHARED_LINKER_FLAGS) endif() if(CMAKE_COMPILER_IS_GNUCXX) mitkFunctionCheckCAndCXXCompilerFlags("-fstack-protector-all" MITK_C_FLAGS MITK_CXX_FLAGS) set(MITK_CXX_FLAGS_RELEASE "-U_FORTIFY_SOURCES -D_FORTIFY_SOURCE=2 ${MITK_CXX_FLAGS_RELEASE}") endif() set(MITK_MODULE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS}) set(MITK_EXE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS}) #----------------------------------------------------------------------------- # MITK Packages #----------------------------------------------------------------------------- set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR}) foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_PACKAGE_DEPENDS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/CMake/PackageDepends") if(EXISTS "${MITK_PACKAGE_DEPENDS_EXTENSION_DIR}") list(APPEND MODULES_PACKAGE_DEPENDS_DIRS "${MITK_PACKAGE_DEPENDS_EXTENSION_DIR}") endif() endforeach() if(NOT MITK_USE_SYSTEM_Boost) set(Boost_NO_SYSTEM_PATHS 1) endif() set(Boost_USE_MULTITHREADED 1) set(Boost_USE_STATIC_LIBS 0) set(Boost_USE_STATIC_RUNTIME 0) set(Boost_ADDITIONAL_VERSIONS 1.74 1.74.0) # We need this later for a DCMTK workaround set(_dcmtk_dir_orig ${DCMTK_DIR}) # This property is populated at the top half of this file get_property(MITK_EXTERNAL_PROJECTS GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS) foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) if(MITK_USE_${ep} AND _package) if(_components) find_package(${_package} COMPONENTS ${_components} REQUIRED CONFIG) else() # Prefer config mode first because it finds external # Config.cmake files pointed at by _DIR variables. # Otherwise, existing Find.cmake files could fail. if(DEFINED ${_package}_DIR) #we store the information because it will be overwritten by find_package #and would get lost for all EPs that use on Find.cmake instead of config #files. set(_temp_EP_${_package}_dir ${${_package}_DIR}) endif(DEFINED ${_package}_DIR) find_package(${_package} QUIET CONFIG) string(TOUPPER "${_package}" _package_uc) if(NOT (${_package}_FOUND OR ${_package_uc}_FOUND)) if(DEFINED _temp_EP_${_package}_dir) set(${_package}_DIR ${_temp_EP_${_package}_dir} CACHE PATH "externaly set dir of the package ${_package}" FORCE) endif(DEFINED _temp_EP_${_package}_dir) find_package(${_package} REQUIRED) endif() endif() endif() endforeach() # Ensure that the MITK CMake module path comes first set(CMAKE_MODULE_PATH ${MITK_CMAKE_DIR} ${CMAKE_MODULE_PATH} ) if(MITK_USE_DCMTK) if(${_dcmtk_dir_orig} MATCHES "${MITK_EXTERNAL_PROJECT_PREFIX}.*") # Help our FindDCMTK.cmake script find our super-build DCMTK set(DCMTK_DIR ${MITK_EXTERNAL_PROJECT_PREFIX}) else() # Use the original value set(DCMTK_DIR ${_dcmtk_dir_orig}) endif() endif() if(MITK_USE_DCMQI) # Due to the preferred CONFIG mode in find_package calls above, # the DCMQIConfig.cmake file is read, which does not provide useful # package information. We explictly need MODULE mode to find DCMQI. # Help our FindDCMQI.cmake script find our super-build DCMQI set(DCMQI_DIR ${MITK_EXTERNAL_PROJECT_PREFIX}) find_package(DCMQI REQUIRED) endif() if(MITK_USE_OpenMP) find_package(OpenMP REQUIRED COMPONENTS CXX) else() find_package(OpenMP QUIET COMPONENTS CXX) if(OpenMP_FOUND) set(MITK_USE_OpenMP ON CACHE BOOL "" FORCE) elseif(APPLE AND OpenMP_libomp_LIBRARY AND NOT OpenMP_CXX_LIB_NAMES) set(OpenMP_CXX_LIB_NAMES libomp CACHE STRING "" FORCE) get_filename_component(openmp_lib_dir "${OpenMP_libomp_LIBRARY}" DIRECTORY) set(openmp_include_dir "${openmp_lib_dir}/../include") if(EXISTS "${openmp_include_dir}") get_filename_component(openmp_include_dir "${openmp_include_dir}" REALPATH) set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -I${openmp_include_dir}" CACHE STRING "" FORCE) find_package(OpenMP QUIET COMPONENTS CXX) if(OpenMP_FOUND) set(MITK_USE_OpenMP ON CACHE BOOL "" FORCE) endif() endif() endif() endif() # Qt support if(MITK_USE_Qt6) if(MITK_USE_BLUEBERRY) option(BLUEBERRY_USE_QT_HELP "Enable support for integrating plugin documentation into Qt Help" ${DOXYGEN_FOUND}) mark_as_advanced(BLUEBERRY_USE_QT_HELP) # Sanity checks for in-application BlueBerry plug-in help generation if(BLUEBERRY_USE_QT_HELP) set(_force_blueberry_use_qt_help_to_off 0) if(NOT DOXYGEN_FOUND) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen was not found.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_LESS 1.8.7) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen version 1.8.7 or newer not found.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(NOT QT_HELPGENERATOR_EXECUTABLE) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because QT_HELPGENERATOR_EXECUTABLE is empty.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(NOT MITK_USE_Qt6) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because MITK_USE_Qt6 is OFF.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(_force_blueberry_use_qt_help_to_off) set(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating plugin documentation into Qt Help" FORCE) endif() endif() if(BLUEBERRY_QT_HELP_REQUIRED AND NOT BLUEBERRY_USE_QT_HELP) message(FATAL_ERROR "BLUEBERRY_USE_QT_HELP is required to be set to ON") endif() endif() endif() #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) # Configuration for the CMake-generated test driver set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ") set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN " try {") set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " } catch (const std::exception& e) { fprintf(stderr, \"%s\\n\", e.what()); return EXIT_FAILURE; } catch (...) { printf(\"Exception caught in the test driver\\n\"); return EXIT_FAILURE; }") set(MITK_TEST_OUTPUT_DIR "${MITK_BINARY_DIR}/test_output") if(NOT EXISTS ${MITK_TEST_OUTPUT_DIR}) file(MAKE_DIRECTORY ${MITK_TEST_OUTPUT_DIR}) endif() # Test the package target include(mitkPackageTest) endif() configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h) #----------------------------------------------------------------------------- # MITK_SUPERBUILD_BINARY_DIR #----------------------------------------------------------------------------- # If MITK_SUPERBUILD_BINARY_DIR isn't defined, it means MITK is *NOT* build using Superbuild. # In that specific case, MITK_SUPERBUILD_BINARY_DIR should default to MITK_BINARY_DIR if(NOT DEFINED MITK_SUPERBUILD_BINARY_DIR) set(MITK_SUPERBUILD_BINARY_DIR ${MITK_BINARY_DIR}) endif() #----------------------------------------------------------------------------- # Set C/CXX and linker flags for MITK code #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MITK_CXX_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MITK_CXX_FLAGS_RELEASE}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MITK_C_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${MITK_C_FLAGS_RELEASE}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MITK_EXE_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MITK_SHARED_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${MITK_MODULE_LINKER_FLAGS}") #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- add_subdirectory(Utilities) add_subdirectory(Modules) include("${CMAKE_CURRENT_SOURCE_DIR}/Modules/ModuleList.cmake") mitkFunctionWhitelistModules(MITK MITK_MODULES) set(MITK_ROOT_FOLDER_BACKUP "${MITK_ROOT_FOLDER}") foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) get_filename_component(MITK_ROOT_FOLDER "${MITK_EXTENSION_DIR}" NAME) set(MITK_MODULES_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Modules") if(EXISTS "${MITK_MODULES_EXTENSION_DIR}/ModuleList.cmake") set(MITK_MODULES "") include("${MITK_MODULES_EXTENSION_DIR}/ModuleList.cmake") foreach(mitk_module ${MITK_MODULES}) add_subdirectory("${MITK_MODULES_EXTENSION_DIR}/${mitk_module}" "Modules/${mitk_module}") endforeach() endif() set(MITK_MODULE_NAME_PREFIX ${MITK_DEFAULT_MODULE_NAME_PREFIX}) endforeach() set(MITK_ROOT_FOLDER "${MITK_ROOT_FOLDER_BACKUP}") add_subdirectory(Wrapping) set(MITK_DOXYGEN_OUTPUT_DIR "${PROJECT_BINARY_DIR}/Documentation/Doxygen" CACHE PATH "Output directory for doxygen generated documentation.") if(MITK_USE_BLUEBERRY) include("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/PluginList.cmake") mitkFunctionWhitelistPlugins(MITK MITK_PLUGINS) set(mitk_plugins_fullpath "") foreach(mitk_plugin ${MITK_PLUGINS}) list(APPEND mitk_plugins_fullpath Plugins/${mitk_plugin}) endforeach() set(MITK_PLUGIN_REGEX_LIST "") foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_PLUGINS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Plugins") if(EXISTS "${MITK_PLUGINS_EXTENSION_DIR}/PluginList.cmake") set(MITK_PLUGINS "") include("${MITK_PLUGINS_EXTENSION_DIR}/PluginList.cmake") foreach(mitk_plugin ${MITK_PLUGINS}) list(APPEND mitk_plugins_fullpath "${MITK_PLUGINS_EXTENSION_DIR}/${mitk_plugin}") endforeach() endif() endforeach() if(EXISTS ${MITK_PRIVATE_MODULES}/PluginList.cmake) include(${MITK_PRIVATE_MODULES}/PluginList.cmake) foreach(mitk_plugin ${MITK_PRIVATE_PLUGINS}) list(APPEND mitk_plugins_fullpath ${MITK_PRIVATE_MODULES}/${mitk_plugin}) endforeach() endif() if(MITK_BUILD_EXAMPLES) include("${CMAKE_CURRENT_SOURCE_DIR}/Examples/Plugins/PluginList.cmake") set(mitk_example_plugins_fullpath ) foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS}) list(APPEND mitk_example_plugins_fullpath Examples/Plugins/${mitk_example_plugin}) list(APPEND mitk_plugins_fullpath Examples/Plugins/${mitk_example_plugin}) endforeach() endif() # Specify which plug-ins belong to this project macro(GetMyTargetLibraries all_target_libraries varname) set(re_ctkplugin_mitk "^org_mitk_[a-zA-Z0-9_]+$") set(re_ctkplugin_bb "^org_blueberry_[a-zA-Z0-9_]+$") set(_tmp_list) list(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin_mitk re_ctkplugin_bb MITK_PLUGIN_REGEX_LIST OUTPUT_VARIABLE ${varname}) endmacro() # Get infos about application directories and build options set(mitk_apps_fullpath "") foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications") if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") set(MITK_APPS "") include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 directory_name) list(GET target_info_list 1 option_name) if(${option_name}) list(APPEND mitk_apps_fullpath "${MITK_APPLICATIONS_EXTENSION_DIR}/${directory_name}^^${option_name}") endif() endforeach() endif() endforeach() if (mitk_plugins_fullpath) ctkMacroSetupPlugins(${mitk_plugins_fullpath} BUILD_OPTION_PREFIX MITK_BUILD_ APPS ${mitk_apps_fullpath} BUILD_ALL ${MITK_BUILD_ALL_PLUGINS} COMPACT_OPTIONS) endif() set(MITK_PLUGIN_USE_FILE "${MITK_BINARY_DIR}/MitkPluginUseFile.cmake") if(${PROJECT_NAME}_PLUGIN_LIBRARIES) ctkFunctionGeneratePluginUseFile(${MITK_PLUGIN_USE_FILE}) else() file(REMOVE ${MITK_PLUGIN_USE_FILE}) set(MITK_PLUGIN_USE_FILE ) endif() endif() #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- set(MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS) set(MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS) set(MITK_DOXYGEN_ADDITIONAL_EXAMPLE_PATHS) foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS "${MITK_DOXYGEN_ADDITIONAL_INPUT_DIRS} \"${MITK_EXTENSION_DIR}\"") set(MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS "${MITK_DOXYGEN_ADDITIONAL_IMAGE_PATHS} \"${MITK_EXTENSION_DIR}\"") # MITK_DOXYGEN_ADDITIONAL_EXAMPLE_PATHS should be modified by MITK extensions as needed endforeach() if(DOXYGEN_FOUND) foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_DOCUMENTATION_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Documentation") file(GLOB MITK_DOCUMENTATION_EXTENSION_FILES CONFIGURE_DEPENDS "${MITK_DOCUMENTATION_EXTENSION_DIR}/*.cmake") foreach(doc_file ${MITK_DOCUMENTATION_EXTENSION_FILES}) include("${doc_file}") endforeach() endforeach() # Transform list of example paths into space-separated string of quoted paths unset(example_paths) foreach(example_path ${MITK_DOXYGEN_ADDITIONAL_EXAMPLE_PATHS}) set(example_paths "${example_paths} \"${example_path}\"") endforeach() set(MITK_DOXYGEN_ADDITIONAL_EXAMPLE_PATHS "${example_paths}") add_subdirectory(Documentation) endif() #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- # set MITK cpack variables # These are the default variables, which can be overwritten ( see below ) include(mitkSetupCPack) set(use_default_config ON) set(ALL_MITK_APPS "") set(activated_apps_no 0) foreach(MITK_EXTENSION_DIR ${MITK_DIR_PLUS_EXTENSION_DIRS}) set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications") if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") set(MITK_APPS "") include("${MITK_APPLICATIONS_EXTENSION_DIR}/AppList.cmake") foreach(mitk_app ${MITK_APPS}) string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 directory_name) list(GET target_info_list 1 option_name) list(GET target_info_list 2 executable_name) list(APPEND ALL_MITK_APPS "${MITK_EXTENSION_DIR}/Applications/${directory_name}^^${option_name}^^${executable_name}") if(${option_name} OR MITK_BUILD_ALL_APPS) MATH(EXPR activated_apps_no "${activated_apps_no} + 1") endif() endforeach() endif() endforeach() list(LENGTH ALL_MITK_APPS app_count) if(app_count EQUAL 1 AND (activated_apps_no EQUAL 1 OR MITK_BUILD_ALL_APPS)) # Corner case if there is only one app in total set(use_project_cpack ON) elseif(activated_apps_no EQUAL 1 AND NOT MITK_BUILD_ALL_APPS) # Only one app is enabled (no "build all" flag set) set(use_project_cpack ON) else() # Less or more then one app is enabled set(use_project_cpack OFF) endif() foreach(mitk_app ${ALL_MITK_APPS}) # extract target_dir and option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 target_dir) list(GET target_info_list 1 option_name) list(GET target_info_list 2 executable_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) # check whether application specific configuration files will be used if(use_project_cpack) # use files if they exist if(EXISTS "${target_dir}/CPackOptions.cmake") include("${target_dir}/CPackOptions.cmake") endif() if(EXISTS "${target_dir}/CPackConfig.cmake.in") set(CPACK_PROJECT_CONFIG_FILE "${target_dir}/CPackConfig.cmake") configure_file(${target_dir}/CPackConfig.cmake.in ${CPACK_PROJECT_CONFIG_FILE} @ONLY) set(use_default_config OFF) endif() endif() # add link to the list list(APPEND CPACK_CREATE_DESKTOP_LINKS "${executable_name}") endif() endforeach() # if no application specific configuration file was used, use default if(use_default_config) configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake") endif() # include CPack model once all variables are set include(CPack) # Additional installation rules include(mitkInstallRules) #----------------------------------------------------------------------------- # Last configuration steps #----------------------------------------------------------------------------- # ---------------- Export targets ----------------- set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake") file(REMOVE ${MITK_EXPORTS_FILE}) set(targets_to_export) get_property(module_targets GLOBAL PROPERTY MITK_MODULE_TARGETS) if(module_targets) list(APPEND targets_to_export ${module_targets}) endif() if(MITK_USE_BLUEBERRY) if(MITK_PLUGIN_LIBRARIES) list(APPEND targets_to_export ${MITK_PLUGIN_LIBRARIES}) endif() endif() export(TARGETS ${targets_to_export} APPEND FILE ${MITK_EXPORTS_FILE}) set(MITK_EXPORTED_TARGET_PROPERTIES ) foreach(target_to_export ${targets_to_export}) get_target_property(autoload_targets ${target_to_export} MITK_AUTOLOAD_TARGETS) if(autoload_targets) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_TARGETS \"${autoload_targets}\")") endif() get_target_property(autoload_dir ${target_to_export} MITK_AUTOLOAD_DIRECTORY) if(autoload_dir) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_DIRECTORY \"${autoload_dir}\")") endif() get_target_property(deprecated_module ${target_to_export} MITK_MODULE_DEPRECATED_SINCE) if(deprecated_module) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_MODULE_DEPRECATED_SINCE \"${deprecated_module}\")") endif() endforeach() # ---------------- External projects ----------------- get_property(MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS_CONFIG GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS) set(MITK_CONFIG_EXTERNAL_PROJECTS ) #string(REPLACE "^^" ";" _mitk_external_projects ${MITK_EXTERNAL_PROJECTS}) foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS} set(MITK_USE_${ep} ${MITK_USE_${ep}}) set(MITK_${ep}_DIR \"${${ep}_DIR}\") set(MITK_${ep}_COMPONENTS ${_components}) ") endforeach() foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) if(_components) set(_components_arg COMPONENTS \${_components}) else() set(_components_arg) endif() if(_package) set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS} if(MITK_USE_${ep}) set(${ep}_DIR \${MITK_${ep}_DIR}) if(MITK_${ep}_COMPONENTS) mitkMacroFindDependency(${_package} COMPONENTS \${MITK_${ep}_COMPONENTS}) else() mitkMacroFindDependency(${_package}) endif() endif()") endif() endforeach() # ---------------- Tools ----------------- configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) # ---------------- Configure files ----------------- configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc) set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY) write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${MITK_VERSION_STRING} COMPATIBILITY AnyNewerVersion) #----------------------------------------------------------------------------- # MITK Applications #----------------------------------------------------------------------------- # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Applications) if(MSVC AND TARGET MitkWorkbench) set_directory_properties(PROPERTIES VS_STARTUP_PROJECT MitkWorkbench) endif() foreach(MITK_EXTENSION_DIR ${MITK_ABSOLUTE_EXTENSION_DIRS}) set(MITK_APPLICATIONS_EXTENSION_DIR "${MITK_EXTENSION_DIR}/Applications") if(EXISTS "${MITK_APPLICATIONS_EXTENSION_DIR}/CMakeLists.txt") add_subdirectory("${MITK_APPLICATIONS_EXTENSION_DIR}" "Applications") endif() endforeach() #----------------------------------------------------------------------------- # MITK Examples #----------------------------------------------------------------------------- if(MITK_BUILD_EXAMPLES) # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Examples) endif() #----------------------------------------------------------------------------- # Print configuration summary #----------------------------------------------------------------------------- message("\n\n") feature_summary( DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------" WHAT ALL ) diff --git a/Documentation/Doxygen/3-DeveloperManual/Application/BlueBerryExtensionPointReference.dox b/Documentation/Doxygen/3-DeveloperManual/Application/BlueBerryExtensionPointReference.dox index 855dc0e41a..427ca8e76e 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Application/BlueBerryExtensionPointReference.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Application/BlueBerryExtensionPointReference.dox @@ -1,1354 +1,1356 @@ /** \page BlueBerryExtPointsIndex BlueBerry Extension-Point Reference - \subpage BlueBerryExtPointsIndex_CoreExpr - \subpage BlueBerryExtPointsIndex_PlatformRuntime - \subpage BlueBerryExtPointsIndex_Workbench \page BlueBerryExtPointsIndex_CoreExpr Platform Core Expressions \tableofcontents \section BlueBerryExtPointsIndex_CoreExpr_ExprDef Expression Definitions \subsection BlueBerryExtPointsIndex_CoreExpr_ExprDef_Id Identifier \c org.blueberry.core.expressions.definitions \subsection BlueBerryExtPointsIndex_CoreExpr_ExprDef_Desc Description This extension point allows you to create reusable extensions. They can then be used in other core expression constructs. The reference element in a core expression will evaluated the expression definition with the evaluation context that is active for the reference element. \subsection BlueBerryExtPointsIndex_CoreExpr_ExprDef_ConfMarkup Configuration Markup \code{.unparsed} \endcode - point: a fully qualified identifier of the target extension point - id: an optional identifier of the extension instance - name: an optional name of the extension instance \code{.unparsed} \endcode Provides a global definition of an expression to be used with the \c \ expression element. This helps to reuse common expressions. - id: a globally unique identifier for the expression definition \code{.unparsed} \endcode A generic root element. The element can be used inside an extension point to define its enablement expression. The children of an enablement expression are combined using the and operator. \code{.unparsed} \endcode This element represent a NOT operation on the result of evaluating it's sub-element expression. \code{.unparsed} \endcode This element represent an AND operation on the result of evaluating all it's sub-elements expressions. \code{.unparsed} \endcode This element represent an OR operation on the result of evaluating all it's sub-element expressions. \code{.unparsed} \endcode This element is used to perform an instanceof check of the object in focus. The expression returns \c EvaluationResult.TRUE if the object's type is a sub type of the type specified by the attribute value. Otherwise \c EvaluationResult.FALSE is returned. - value: a fully qualified name of a class or interface \code{.unparsed} \endcode This element is used to evaluate the property state of the object in focus. The set of testable properties can be extended using the propery tester extension point. The test expression returns \c EvaluationResult.NOT_LOADED if the property tester doing the actual testing isn't loaded yet and the attribute \c forcePluginActivation is set to \c false. If \c forcePluginActivation is set to \c true and the evaluation context used to evaluate this expression support plug-in activation then evaluating the property will result in activating the plug-in defining the tester. - property: The name of an object's property to test. - args: Additional arguments passed to the property tester. Multiple arguments are seperated by commas. Each individual argument is converted into a Java base type using the same rules as defined for the value attribute of the test expression. - value: The expected value of the property. Can be omitted if the property is a boolean property. The test expression is supposed to return \c EvaluationResult.TRUE if the property matches the value and \c EvaluationResult.FALSE otherwise. The value attribute is converted into a Java base type using the following rules: - The string \c "true" is converted into \c Boolean.TRUE . - The string \c "false" is converted into \c Boolean.FALSE . - If the string contains a dot then the interpreter tries to convert the value into a \c Float object. If this fails the string is treated as a \c java.lang.String. - If the string only consists of numbers then the interpreter converts the value in an \c Integer object. - In all other cases the string is treated as a \c java.lang.String . - The conversion of the string into a \c Boolean , \c Float , or \c Integer can be suppressed by surrounding the string with single quotes. For example, the attribute \c value="'true'" is converted into the string "true". - forcePluginActivation: A flag indicating whether the plug-in contributing the property tester should be loaded if necessary. As such, this flag should be used judiciously, in order to avoid unnecessary plug-in activations. Most clients should avoid setting this flag to \c true. This flag is only honored if the evaluation context used to evaluate this expression allows plug-in activation. Otherwise the flag is ignored and no plug-in loading takes place. \code{.unparsed} \endcode Tests a system property by calling the \c System.getProperty method and compares the result with the value specified through the value attribute. - property: The name of an system property to test. - value: The expected value of the property. The value is interpreted as a string value. \code{.unparsed} \endcode This element is used to perform an equals check of the object in focus. The expression returns \c EvaluationResult.TRUE if the object is equal to the value provided by the attribute value. Otherwise \c EvaluationResult.FALSE is returned. - value: The expected value. The value provided as a string is converted into a Java base type using the same rules as for the value attribute of the test expression. \code{.unparsed} \endcode This element is used to test the number of elements in a collection. - value: An expression to specify the number of elements in a list. Following wildcard characters can be used: - *: any number of elements - ?: no elements or one element - +: one or more elements - !: no elements - integer value: the list must contain the exact number of elements \code{.unparsed} \endcode This element changes the object to be inspected for all its child element to the object referenced by the given variable. If the variable can not be resolved then the expression will throw an \c ExpressionException when evaluating it. The children of a with expression are combined using the and operator. - variable: The name of the variable to be used for further inspection. It is up to the evaluator of an extension point to provide the variable in the variable pool. \code{.unparsed} \endcode This element changes the object to be inspected for all its child element to the object referenced by the given variable. If the variable can not be resolved then the expression will throw an \c ExpressionException when evaluating it. The children of a with expression are combined using the and operator. - variable: The name of the variable to be resolved. This variable is then used as the object in focus for child element evaluation. It is up to the evaluator of an extension point to provide a corresponding variable resolver (see berry::IVariableResolver) through the evaluation context passed to the root expression element when evaluating the expression. - args: Additional arguments passed to the variable resolver. Multiple arguments are seperated by commas. Each individual argument is converted into a Java base type using the same rules as defined for the value attribute of the test expression. \code{.unparsed} \endcode This element is used to adapt the object in focus to the type specified by the attribute type. The expression returns not loaded if either the adapter or the type referenced isn't loaded yet. It throws an \c ExpressionException during evaluation if the type name doesn't exist at all. The children of an adapt expression are combined using the and operator. - type: the type to which the object in focus is to be adapted \code{.unparsed} \endcode This element is used to iterate over a variable that is of type \c java.util.Collection. If the object in focus is not of type \c java.util.Collection then an \c ExpressionException will be thrown while evaluating the expression. - operator: Either "and" or "or". The operator defines how the child elements will be combined. If not specified, "and" will be used. - ifEmpty: The value return from the iterate expression if the collection is empty. If not specified then \c true is returned when the operator equals "and" and \c false is returned if the operator equals "or". \code{.unparsed} \endcode This element is used to reference an expression from the \c org.blueberry.core.expressions.definitions extension point. The expression definition will be evaluated within the current expression element using the current evaluation context. - definitionId: the unique id of an expression from \c org.blueberry.core.expressions.definitions \subsection BlueBerryExtPointsIndex_CoreExpr_ExprDef_Examples Examples \code{.unparsed} \endcode Then this expression definition can be used when composing other expressions. \code{.unparsed} \endcode \section BlueBerryExtPointsIndex_CoreExpr_CommExpr Common Expressions \subsection BlueBerryExtPointsIndex_CoreExpr_CommExpr_Id Identifier \c org.blueberry.core.expressions.commonExpression \subsection BlueBerryExtPointsIndex_CoreExpr_CommExpr_ConfMarkup Configuration Markup \code{.unparsed} \endcode A generic root element. The element can be used inside an extension point to define its enablement expression. The children of an enablement expression are combined using the and operator. \code{.unparsed} \endcode This element represent a NOT operation on the result of evaluating it's sub-element expression. \code{.unparsed} \endcode This element represent an AND operation on the result of evaluating all it's sub-elements expressions. \code{.unparsed} \endcode This element represent an OR operation on the result of evaluating all it's sub-element expressions. \code{.unparsed} \endcode This element is used to perform an instanceof check of the object in focus. The expression returns \c EvaluationResult.TRUE if the object's type is a sub type of the type specified by the attribute value. Otherwise \c EvaluationResult.FALSE is returned. - value: a fully qualified name of a class or interface \code{.unparsed} \endcode This element is used to evaluate the property state of the object in focus. The set of testable properties can be extended using the propery tester extension point. The test expression returns \c EvaluationResult.NOT_LOADED if the property tester doing the actual testing isn't loaded yet and the attribute \c forcePluginActivation is set to false. If \c forcePluginActivation is set to \c true and the evaluation context used to evaluate this expression support plug-in activation then evaluating the property will result in activating the plug-in defining the tester. - property: The name of an object's property to test. - args: Additional arguments passed to the property tester. Multiple arguments are seperated by commas. Each individual argument is converted into a Java base type using the same rules as defined for the value attribute of the test expression. - value: The expected value of the property. Can be omitted if the property is a boolean property. The test expression is supposed to return EvaluationResult.TRUE if the property matches the value and EvaluationResult.FALSE otherwise. The value attribute is converted into a Java base type using the following rules: - The string "true" is converted into \c Boolean.TRUE - The string "false" is converted into \c Boolean.FALSE - If the string contains a dot then the interpreter tries to convert the value into a \c Float object. If this fails the string is treated as a \c java.lang.String - If the string only consists of numbers then the interpreter converts the value in an \c Integer object. - In all other cases the string is treated as a \c java.lang.String - The conversion of the string into a \c Boolean , \c Float , or \c Integer can be suppressed by surrounding the string with single quotes. For example, the attribute \c value="'true'" is converted into the string "true" - forcePluginActivation: A flag indicating whether the plug-in contributing the property tester should be loaded if necessary. As such, this flag should be used judiciously, in order to avoid unnecessary plug-in activations. Most clients should avoid setting this flag to true. This flag is only honored if the evaluation context used to evaluate this expression allows plug-in activation. Otherwise the flag is ignored and no plug-in loading takes place. \code{.unparsed} \endcode Tests a system property by calling the \c System.getProperty method and compares the result with the value specified through the value attribute. - property: The name of an system property to test. - value: The expected value of the property. The value is interpreted as a string value. \code{.unparsed} \endcode This element is used to perform an equals check of the object in focus. The expression returns \c EvaluationResult.TRUE if the object is equal to the value provided by the attribute value. Otherwise \c EvaluationResult.FALSE is returned. - value: The expected value. The value provided as a string is converted into a Java base type using the same rules as for the value attribute of the test expression. \code{.unparsed} \endcode This element is used to test the number of elements in a collection. - value: An expression to specify the number of elements in a list. Following wildcard characters can be used: - *: any number of elements - ?: no elements or one element - +: one or more elements - !: no elements - integer value: the list must contain the exact number of elements \code{.unparsed} \endcode This element changes the object to be inspected for all its child element to the object referenced by the given variable. If the variable can not be resolved then the expression will throw an \c ExpressionException when evaluating it. The children of a with expression are combined using the and operator. - variable: The name of the variable to be used for further inspection. It is up to the evaluator of an extension point to provide the variable in the variable pool. \code{.unparsed} \endcode This element changes the object to be inspected for all its child element to the object referenced by the given variable. If the variable can not be resolved then the expression will throw an \c ExpressionException when evaluating it. The children of a with expression are combined using the and operator. - variable: The name of the variable to be resolved. This variable is then used as the object in focus for child element evaluation. It is up to the evaluator of an extension point to provide a corresponding variable resolver (see berry::IVariableResolver) through the evaluation context passed to the root expression element when evaluating the expression. - args: Additional arguments passed to the variable resolver. Multiple arguments are seperated by commas. Each individual argument is converted into a Java base type using the same rules as defined for the value attribute of the test expression. \code{.unparsed} \endcode This element is used to adapt the object in focus to the type specified by the attribute type. The expression returns not loaded if either the adapter or the type referenced isn't loaded yet. It throws an \c ExpressionException during evaluation if the type name doesn't exist at all. The children of an adapt expression are combined using the and operator. - type: the type to which the object in focus is to be adapted \code{.unparsed} \endcode This element is used to iterate over a variable that is of type \c java.util.Collection. If the object in focus is not of type \c java.util.Collection then an \c ExpressionException will be thrown while evaluating the expression. - operator: Either "and" or "or". The operator defines how the child elements will be combined. If not specified, "and" will be used. - ifEmpty: The value return from the iterate expression if the collection is empty. If not specified then \c true is returned when the operator equals "and" and \c false is returned if the operator equals "or". \code{.unparsed} \endcode This element is used to reference an expression from the \c org.blueberry.core.expressions.definitions extension point. The expression definition will be evaluated within the current expression element using the current evaluation context. - definitionId: the unique id of an expression from \c org.blueberry.core.expressions.definitions \section BlueBerryExtPointsIndex_CoreExpr_PropTest Property Testers \subsection BlueBerryExtPointsIndex_CoreExpr_PropTest_Id Identifier \c org.blueberry.core.expressions.propertyTesters \subsection BlueBerryExtPointsIndex_CoreExpr_PropTest_Desc Description This extension point allows to add properties to an already existing type. Those properties can then be used inside the expression language's test expression element. \subsection BlueBerryExtPointsIndex_CoreExpr_PropTest_ConfMarkup Configuration Markup \code{.unparsed} \endcode - point: a fully qualified identifier of the target extension point - id: an optional identifier of the extension instance - name: an optional name of the extension instance \code{.unparsed} \endcode - id: Unique identifier for the property tester. - type: The type to be extended by this property tester. - namespace: A unique id determining the name space the properties are added to. - properties: A comma separated list of properties provided by this property tester. - class: The name of the class that implements the testing methods. The class must be public and extend \c org.blueberry.core.expressions.PropertyTester with a public 0-argument constructor. \subsection BlueBerryExtPointsIndex_CoreExpr_PropTest_Examples Examples \code{.unparsed} \endcode \page BlueBerryExtPointsIndex_PlatformRuntime Platform Runtime \tableofcontents \section BlueBerryExtPointsIndex_PlatformRuntime_App Applications \subsection BlueBerryExtPointsIndex_PlatformRuntime_App_Id Identifier \c org.blueberry.osgi.applications \subsection BlueBerryExtPointsIndex_PlatformRuntime_App_Desc Description The applications extension point allows plugins to contribute applications to the BlueBerry Platform. \subsection BlueBerryExtPointsIndex_PlatformRuntime_App_ConfMarkup Configuration Markup \code{.unparsed} \endcode \code{.unparsed} \endcode \code{.unparsed} \endcode \subsection BlueBerryExtPointsIndex_PlatformRuntime_App_Examples Examples \code{.unparsed} \endcode \section BlueBerryExtPointsIndex_PlatformRuntime_Prod Products \subsection BlueBerryExtPointsIndex_PlatformRuntime_Prod_Id Identifier \c org.blueberry.core.runtime.products \subsection BlueBerryExtPointsIndex_PlatformRuntime_Prod_Desc Description Products are the BlueBerry unit of branding. Product extensions are supplied by plug-ins wishing to define one or more products. There must be one product per extension as the extension id is used in processing and identifying the product. There are two possible forms of product extension, static and dynamic. Static product extensions directly contain all relevant information about the product. Dynamic product extensions identify a class (an \c IProductProvider) which is capable of defining one or more products when queried. \subsection BlueBerryExtPointsIndex_PlatformRuntime_Prod_ConfMarkup Configuration Markup \code{.unparsed} \endcode \code{.unparsed} \endcode - application: the default application to run when running this product - name: the human-readable name of this product - description: the human-readable description of this product \code{.unparsed} \endcode - name: the key under which this property is stored - value: the value of this property \code{.unparsed} \endcode \code{.unparsed} \endcode - class: the fully-qualified name of a class which implements \c IProductProvider \subsection BlueBerryExtPointsIndex_PlatformRuntime_Prod_Examples Examples \code{.unparsed} \endcode The following is an example of a dynamic product (product provider) declaration: Following is an example of an application declaration: \code{.unparsed} \endcode \subsection BlueBerryExtPointsIndex_PlatformRuntime_Prod_SupplImpl Supplied Implementation No implementations of \c IProductProvider are supplied. \page BlueBerryExtPointsIndex_Workbench Workbench \tableofcontents \section BlueBerryExtPointsIndex_Workbench_Edit Internal and External Editors \subsection BlueBerryExtPointsIndex_Workbench_Edit_Id Identifier \c org.blueberry.ui.editors \subsection BlueBerryExtPointsIndex_Workbench_Edit_Desc Description This extension point is used to add new editors to the workbench. A editor is a visual component within a workbench page. It is typically used to edit or browse a document or input object. To open an editor, the user will typically invoke "Open" on an \c IFile. When this action is performed the workbench registry is consulted to determine an appropriate editor for the file type and then a new instance of the editor type is created. The actual result depends on the type of the editor. The workbench provides support for the creation of internal editors, which are tightly integrated into the workbench, and external editors, which are launched in a separate frame window. There are also various levels of integration between these extremes. In the case of an internal editor tight integration can be achieved between the workbench window and the editor part. The workbench menu and toolbar are pre-loaded with a number of common actions, such as cut, copy, and paste. The active part, view or editor, is expected to provide the implementation for these actions. An internal editor may also define new actions which appear in the workbench window. These actions only appear when the editor is active. The integration between the workbench and external editors is more tenuous. In this case the workbench may launch an editor but after has no way of determining the state of the external editor or collaborating with it by any means except through the file system. \subsection BlueBerryExtPointsIndex_Workbench_Edit_ConfMarkup Configuration Markup \code{.unparsed} \endcode - point: a fully qualified identifier of the target extension point - id: an optional identifier of the extension instance - name: an optional name of the extension instance \code{.unparsed} \endcode - id: a unique name that will be used to identify this editor - name: a translatable name that will be used in the UI for this editor - icon: A relative name of the icon that will be used for all resources that match the specified extensions. Editors should provide an icon to make it easy for users to distinguish between different editor types. If you specify a command rather than a class, an icon is not needed. In that case, the workbench will use the icon provided by the operating system. - extensions: an optional field containing the list of file types understood by the editor. This is a string containing comma separate file extensions. For instance, an editor which understands hypertext documents may register for "htm, html". - class: the name of a class that implements berry::IEditorPart. The attributes \c class , \c command , and \c launcher are mutually exclusive. If this attribute is defined then \c contributorClass should also be defined. - command: a command to run in order to launch an external editor. The executable command must be located on the system path or in the plug-in's directory. The attributes class, command, and launcher are mutually exclusive. - launcher: the name of a class which that implements berry::IEditorLauncher. A launcher will open an external editor. The attributes \c class , \c command , and \c launcher are mutually exclusive. - contributorClass: the name of a class that implements berry::IEditorActionBarContributor. This attribute should only be defined if the \c class attribute is defined. This class is used to add new actions to the workbench menu and tool bar which reflect the features of the editor type. - default: if true, this editor will be used as the default editor for the type. This is only relevant in a case where more than one editor is registered for the same type. If an editor is not the default for the type, it can still be launched using "Open with..." submenu for the selected resource. Please note that this attribute is only honored for filename and extension associations at this time. It will not be honored for content type bindings. Content type-based resolution will occur on a first come, first serve basis and is not explicitly specified. - filenames: an optional field containing the list of file names understood by the editor. This is a string containing comma separate file names. For instance, an editor which understands specific hypertext documents may register for "ejb.htm, ejb.html". - matchingStrategy: the name of a class that implements berry::IEditorMatchingStrategy. This attribute should only be defined if the \c class attribute is defined. This allows the editor extension to provide its own algorithm for matching the input of one of its editors to a given editor input. \code{.unparsed} \endcode Advertises that the containing editor understands the given content type and is suitable for editing files of that type. - contentTypeId: The content type identifier. This is an ID defined by the \c org.blueberry.core.runtime.contentTypes extension point. \subsection BlueBerryExtPointsIndex_Workbench_Edit_Examples Examples The following is an example of an internal editor extension definition: \code{.unparsed} \endcode \subsection BlueBerryExtPointsIndex_Workbench_Edit_SupplImpl Supplied Implementation The workbench provides a "Default Text Editor". The end user product may contain other editors as part of the shipping bundle. In that case, editors will be registered as extensions using the syntax described above. \section BlueBerryExtPointsIndex_Workbench_Keywords Keywords \subsection BlueBerryExtPointsIndex_Workbench_Keywords_Id Identifier \c org.blueberry.ui.keywords \subsection BlueBerryExtPointsIndex_Workbench_Keywords_Desc Description The keywords extension point defines keywords and a unique id for reference by other schemas. See \c propertyPages and \c preferencePages . \subsection BlueBerryExtPointsIndex_Workbench_Keywords_ConfMarkup Configuration Markup \code{.unparsed} \endcode - point: a fully qualified identifier of the target extension point - id: an optional identifier of the extension instance - name: an optional name of the extension instance \code{.unparsed} \endcode - id: The id is the unique id used to reference the keyword - label: The human readable label of the keyword \subsection BlueBerryExtPointsIndex_Workbench_Keywords_Examples Examples The following is an example of a keyword extension: \code{.unparsed} \endcode \subsection BlueBerryExtPointsIndex_Workbench_Keywords_SupplImpl Supplied Implementation Keywords are used only with preference and property pages. See the \c keywordReference element of the \c org.blueberry.ui.propertyPages and \c org.blueberry.ui.preferencePages extension points. \section BlueBerryExtPointsIndex_Workbench_PerspExt Perspective Extensions \subsection BlueBerryExtPointsIndex_Workbench_PerspExt_Id Identifier \c org.blueberry.ui.perspectiveExtensions \subsection BlueBerryExtPointsIndex_Workbench_PerspExt_Desc Description This extension point is used to extend perspectives registered by other plug-ins. A perspective defines the initial contents of the window action bars (menu and toolbar) and the initial set of views and their layout within a workbench page. Other plug-ins may contribute actions or views to the perspective which appear when the perspective is selected. Optional additions by other plug-ins are appended to the initial definition. \subsection BlueBerryExtPointsIndex_Workbench_PerspExt_ConfMarkup Configuration Markup \code{.unparsed} \endcode - point: a fully qualified identifier of the target extension point - id: an optional identifier of the extension instance - name: an optional name of the extension instance \code{.unparsed} \endcode - targetID: the unique identifier of the perspective (as specified in the registry) into which the contribution is made. If the value is set to "*" the extension is applied to all perspectives. \code{.unparsed} \endcode - id: the unique identifier of the action set which will be added to the perspective. \code{.unparsed} \endcode - id: the unique identifier of the view which will be added to the perspective's "Show View" submenu of the "Window" menu. \code{.unparsed} \endcode - id: the unique identifier of the perspective which will be added to the perspective's "Open Perspective" submenu of the "Window" menu. \code{.unparsed} \endcode - id: the unique identifier of the new wizard which will be added to the perspective's "New" submenu of the "File" menu. \code{.unparsed} \endcode - id: the unique identifier of the view which will be added to the perspective's "Show In..." prompter in the Navigate menu. \code{.unparsed} \endcode - id: the unique identifier of the view which will be added to the perspective layout. - relative: the unique identifier of a view which already exists in the perspective. This will be used as a reference point for placement of the view. The relationship between these two views is defined by \c relationship . Ignored if relationship is "fast". - relationship: specifies the relationship between \c id and \c relative . The following values are supported: - fast: the view extension will be created as a fast view. - stack: the view extension will be stacked with the relative view in a folder. - left, right, top, bottom: the view extension will be placed beside the relative view. In this case a \c ratio must also be defined. - ratio: the percentage of area within the relative view which will be donated to the view extension. If the view extension is a fast view, the ratio is the percentage of the workbench the fast view will cover when active. This must be defined as a floating point value and lie between 0.05 and 0.95. - visible: whether the view is initially visible when the perspective is opened. This attribute should have a value of "true" or "false" if used. If this attribute is not used, the view will be initially visible by default. - closeable: whether the view is closeable in the target perspective. This attribute should have a value of "true" or "false" if used. If this attribute is not used, the view will be closeable, unless the perspective itself is marked as fixed. - moveable: whether the view is moveable. A non-moveable view cannot be moved either within the same folder, or moved between folders in the perspective. This attribute should have a value of "true" or "false" if used. If this attribute is not used, the view will be moveable, unless the perspective itself is marked as fixed. - standalone: whether the view is a standalone view. A standalone view cannot be docked together with others in the same folder. This attribute should have a value of "true" or "false" if used. This attribute is ignored if the relationship attribute is "fast" or "stacked". If this attribute is not used, the view will be a regular view, not a standalone view (default is "false"). - showTitle: whether the view's title is shown. This attribute should have a value of "true" or "false" if used. This attribute only applies to standalone views. If this attribute is not used, the view's title will be shown (default is "true"). - minimized: If the perspective extension will result in a new view stack being created (i.e. the 'relationship' attribute is one of left, right, top or bottom) this field determines the new stack's initial display state. \code{.unparsed} \endcode - id: The unique identifier of the Command which is to be removed from the menu. WARNING: This is considered to be a 'Product level' extension and should not be used in consumable plugins without great care. \code{.unparsed} \endcode - id: The unique identifier of the Command which is to be removed from thetoolbar. WARNING: This is considered to be a 'Product level' extension and should not be used in consumable plugins without great care. \subsection BlueBerryExtPointsIndex_Workbench_PerspExt_Examples Examples The following is an example of a perspective extension (note the subelements and the way attributes are used): \code{.unparsed} \endcode In the example above, an action set, view shortcut, new wizard shortcut, and perspective shortcut are contributed to the initial contents of the Resource Perspective. In addition, the Package Explorer view is stacked on the Resource Navigator and the Type Hierarchy View is added beside the Resource Navigator. \section BlueBerryExtPointsIndex_Workbench_Persp Perspectives \subsection BlueBerryExtPointsIndex_Workbench_Persp_Id Identifier \c org.blueberry.ui.perspective \subsection BlueBerryExtPointsIndex_Workbench_Persp_Desc Description This extension point is used to add perspective factories to the workbench. A perspective factory is used to define the initial layout and visible action sets for a perspective. The user can select a perspective by invoking the "Open Perspective" submenu of the "Window" menu. \subsection BlueBerryExtPointsIndex_Workbench_Persp_ConfMarkup Configuration Markup \code{.unparsed} \endcode - point: a fully qualified identifier of the target extension point - id: an optional identifier of the extension instance - name: an optional name of the extension instance \code{.unparsed} \endcode - id: a unique name that will be used to identify this perspective. - name: a translatable name that will be used in the workbench window menu bar to represent this perspective. - class: a fully qualified name of the class that implements berry::IPerspectiveFactory interface. - icon: a relative name of the icon that will be associated with this perspective. - fixed: indicates whether the layout of the perspective is fixed. If true, then views created by the perspective factory are not closeable, and cannot be moved. The default is false. \code{.unparsed} \endcode An optional subelement whose body should contain text providing a short description of the perspective. \subsection BlueBerryExtPointsIndex_Workbench_Persp_Examples Examples The following is an example of a perspective extension: \code{.unparsed} \endcode \subsection BlueBerryExtPointsIndex_Workbench_Persp_SupplImpl Supplied Implementation The workbench provides a "Resource Perspective". Additional perspectives may be added by plug-ins. They are selected using the "Open Perspective" submenu of the "Window" menu. \section BlueBerryExtPointsIndex_Workbench_PrefPages Preference Pages \subsection BlueBerryExtPointsIndex_Workbench_PrefPages_Id Identifier \c org.blueberry.ui.preferencePages \subsection BlueBerryExtPointsIndex_Workbench_PrefPages_Desc Description The workbench provides one common dialog box for preferences. The purpose of this extension point is to allow plug-ins to add pages to the preference dialog box. When preference dialog box is opened (initiated from the menu bar), pages contributed in this way will be added to the dialog box. \subsection BlueBerryExtPointsIndex_Workbench_PrefPages_ConfMarkup Configuration Markup \code{.unparsed} \endcode - point: a fully qualified identifier of the target extension point - id: an optional identifier of the extension instance - name: an optional name of the extension instance \code{.unparsed} \endcode - id: a unique name that will be used to identify this page. - name: a translatable name that will be used in the UI for this page. - class: a name of the fully qualified class that implements berry::IWorkbenchPreferencePage. - category: a path indicating the location of the page in the preference tree. The path may either be a parent node ID or a sequence of IDs separated by '/', representing the full path from the root node. \code{.unparsed} \endcode A reference by a preference page to a keyword. See the keywords extension point. - id: The id of the keyword being referred to. \subsection BlueBerryExtPointsIndex_Workbench_PrefPages_Examples Examples The following is an example for the preference extension point: \code{.unparsed} \endcode \subsection BlueBerryExtPointsIndex_Workbench_PrefPages_SupplImpl Supplied Implementation The workbench adds several pages for setting the preferences of the platform. Pages registered through this extension will be added after them according to their category information. \section BlueBerryExtPointsIndex_Workbench_PresFact Presentation Factories \subsection BlueBerryExtPointsIndex_Workbench_PresFact_Id Identifier \c org.blueberry.ui.presentationFactories \subsection BlueBerryExtPointsIndex_Workbench_PresFact_Desc Description This extension point is used to add presentation factories to the workbench. A presentation factory defines the overall look and feel of the workbench, including how views and editors are presented. \subsection BlueBerryExtPointsIndex_Workbench_PresFact_ConfMarkup Configuration Markup \code{.unparsed} \endcode \code{.unparsed} \endcode - class: Specify the fully qualified class to be used for the presentation factory. The specified value must implement the interface berry::IPresentationFactory. - id: a unique name that will be used to identify this presentation factory - name: a translatable name that can be used to show this presentation factory in the UI \subsection BlueBerryExtPointsIndex_Workbench_PresFact_Examples Examples The following is an example of a presentationFactory extension: \code{.unparsed} \endcode \subsection BlueBerryExtPointsIndex_Workbench_PresFact_SupplImpl Supplied Implementation If a presentation factory is not specified or is missing then the implementation in berry::QtWorkbenchPresentationFactory will be used. \section BlueBerryExtPointsIndex_Workbench_Services Services \subsection BlueBerryExtPointsIndex_Workbench_Services_Id Identifier \c org.blueberry.ui.services \subsection BlueBerryExtPointsIndex_Workbench_Services_Desc Description Define service factories so that services can be contributed declaratively and will be available through berry::IServiceLocator::GetService(Class). The implementation of \c AbstractServiceFactory must be able to return a global service and multiple child services (if applicable). \subsection BlueBerryExtPointsIndex_Workbench_Services_ConfMarkup Configuration Markup \code{.unparsed} \endcode Contribute services to the workbench. \code{.unparsed} \endcode Match a service interface to a factory that can supply a hierachical implementation of that service. - factoryClass: The factory that extends \c AbstractServiceFactory and can create the implementation for the \c serviceClass. \code{.unparsed} \endcode A service this factory can provide. - serviceClass: The interface that represents a service contract. \code{.unparsed} \endcode A Source Provider supplies source variables to the IEvaluationService. It can also notify the IEvaluationService when one or more of the variables change. - provider: This class must provide variables and call the appropriate \c fireSourceChanged(*) method when any of the variables change. \code{.unparsed} \endcode A source variable from this provider. A source provider must declare all variables that it provides. - name: The name of a contributed source variable. It is a good practice to prepend the plugin id to the variable name to avoid collisions with other source providers. - priorityLevel: For conflict resolution used by services like the \c IHandlerService , contributed source variables must assign a priority. workbench is the global default priority. See \c ISources for relative priority information. \subsection BlueBerryExtPointsIndex_Workbench_Services_Examples Examples Here is a basic definition: \code{.unparsed} \endcode The LevelServiceFactory can return an ILevelService when it is requested from the IServiceLocator: \code{.unparsed} berry::ILevelService::Pointer s = GetSite()->GetService(my::ILevelService::GetStaticClassName()); std::cout << s->GetLevel(); \endcode In this test example, the factory would instantiate three \c ILevelService implementations during the first call to \c GetSite()->GetService(*) . The global one in the workbench, one for the workbench window, and one for the site. \section BlueBerryExtPointsIndex_Workbench_Tweak Tweaklets \subsection BlueBerryExtPointsIndex_Workbench_Tweak_Id Identifier \c org.blueberry.ui.tweaklets \subsection BlueBerryExtPointsIndex_Workbench_Tweak_Desc Description Typically, although not required, the value of the \c definition attribute is the fully qualified name without colons of an abstract class defined by the workbench, and the value of the \c implementation attribute is the fully qualified name of a non-abstract class provided by the extending plug-in. \subsection BlueBerryExtPointsIndex_Workbench_Tweak_ConfMarkup Configuration Markup \code{.unparsed} \endcode \code{.unparsed} \endcode - id: a unique name that will be used to identify this tweaklet - name: a translatable name that will be used in the UI for this tweaklet - description: a translatable short description of this tweaklet, to be used in the UI - definition: an identifier of the tweaklet definition in the workbench, typically a fully qualified type name without colons - implementation: an identifier of the tweaklet implementation provided by the extender, typically a fully qualified class name \subsection BlueBerryExtPointsIndex_Workbench_Tweak_SupplImpl Supplied Implementation Tweaklets are usually used to specialize the workbench for a specific GUI toolkit. \section BlueBerryExtPointsIndex_Workbench_Views Views \subsection BlueBerryExtPointsIndex_Workbench_Views_Id Identifier \c org.blueberry.ui.views \subsection BlueBerryExtPointsIndex_Workbench_Views_Desc Description This extension point is used to define additional views for the workbench. A view is a visual component within a workbench page. It is typically used to navigate a hierarchy of information (like the workspace), open an editor, or display properties for the active editor. The user can make a view visible from the Window > Show View menu or close it from the view local title bar. In order to reduce the visual clutter in the Show View Dialog, views should be grouped using categories. \subsection BlueBerryExtPointsIndex_Workbench_Views_ConfMarkup Configuration Markup \code{.unparsed} \endcode - point: a fully qualified identifier of the target extension point - id: an optional identifier of the extension instance - name: an optional name of the extension instance \code{.unparsed} \endcode - id: a unique name that will be used to identify this category - name: a translatable name that will be used in the UI for this category - parentCategory: an optional path composed of category IDs separated by '/'. This allows the creation of a hierarchy of categories. \code{.unparsed} \endcode - id: a unique name that will be used to identify this view - name: a translatable name that will be used in the UI for this view - category: an optional attribute that is composed of the category IDs separated by '/'. Each referenced category must be declared in a corresponding category element. - class: a fully qualified name of the class that implements berry::IViewPart. A common practice is to subclass berry::ViewPart or berry::QtViewPart in order to inherit the default functionality. +- internal: a hint if the view should be considered internal, e.g., in enumerations of views in the UI. - icon: a relative name of the icon that will be associated with the view. - fastViewWidthRatio: the percentage of the width of the workbench that the view will take up as an active fast view. This must be defined as a floating point value and lie between 0.05 and 0.95. If no value is supplied, a default ratio will be used. - allowMultiple: flag indicating whether this view allows multiple instances to be created using IWorkbenchPage::ShowView(QString id, QString secondaryId). The default is false. - restorable: flag indicating whether this view allows to be restored upon workbench restart. If set to false, the view will not be open after a workbench restart. The default is true. \code{.unparsed} \endcode An optional subelement whose body should contain text providing a short description of the view. \code{.unparsed} \endcoe A sticky view is a view that will appear by default across all perspectives in a window once it is opened. Its initial placement is governemed by the location attribute, but nothing prevents it from being moved or closed by the user. Use of this element will only cause a placeholder for the view to be created, it will not show the view. Please note that usage of this element should be done with great care and should only be applied to views that truely have a need to live across perspectives. - id: the id of the view to be made sticky. - location: optional attribute that specifies the location of the sticky view relative to the editor area. If absent, the view will be docked to the right of the editor area. - closeable: optional attribute that specifies wether the view should be closeable. If absent it will be closeable. - moveable: optional attribute that specifies wether the view should be moveable. If absent it will be moveable. \subsection BlueBerryExtPointsIndex_Workbench_Views_Examples Examples The following is an example of the extension point: \code{.unparsed} \endcode The following is an example of a sticky view declaration: \code{.unparsed} \endcode \subsection BlueBerryExtPointsIndex_Workbench_Views_SupplImpl Supplied Implementation The BlueBerry Platform provides a number of standard views. From the user point of view, these views are no different from any other view provided by the plug-ins. All the views can be shown from the "Show View" submenu of the "Window" menu. The position of a view is persistent: it is saved when the view is closed and restored when the view is reopened in a single session. The position is also persisted between workbench sessions. */ diff --git a/Plugins/org.blueberry.ui.qt/plugin.xml b/Plugins/org.blueberry.ui.qt/plugin.xml index 561a9ec8a7..ab406f3bf8 100644 --- a/Plugins/org.blueberry.ui.qt/plugin.xml +++ b/Plugins/org.blueberry.ui.qt/plugin.xml @@ -1,465 +1,466 @@ + id="org.blueberry.ui.internal.introview" + internal="true"/> diff --git a/Plugins/org.blueberry.ui.qt/src/berryIViewDescriptor.h b/Plugins/org.blueberry.ui.qt/src/berryIViewDescriptor.h index 8a0337dcdf..ae1ad1321f 100644 --- a/Plugins/org.blueberry.ui.qt/src/berryIViewDescriptor.h +++ b/Plugins/org.blueberry.ui.qt/src/berryIViewDescriptor.h @@ -1,109 +1,117 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef BERRYIVIEWDESCRIPTOR_H_ #define BERRYIVIEWDESCRIPTOR_H_ #include #include "berryIWorkbenchPartDescriptor.h" #include "berryIViewPart.h" #include #include namespace berry { /** * \ingroup org_blueberry_ui_qt * * This is a view descriptor. It provides a "description" of a given * given view so that the view can later be constructed. *

* The view registry provides facilities to map from an extension * to a IViewDescriptor. *

*

* This interface is not intended to be implemented by clients. *

* * @see org.blueberry.ui.IViewRegistry */ struct BERRY_UI_QT IViewDescriptor : public IWorkbenchPartDescriptor, public IAdaptable { berryObjectMacro(berry::IViewDescriptor); ~IViewDescriptor() override; /** * Creates an instance of the view defined in the descriptor. * * @return the view part * @throws CoreException thrown if there is a problem creating the part */ virtual IViewPart::Pointer CreateView() = 0; /** * Returns a list of ids belonging to keyword reference extensions. * * The keywords listed in each referenced id can be used to filter * this view. * * @return A list of ids for keyword reference extensions. */ virtual QStringList GetKeywordReferences() const = 0; /** * Returns an array of strings that represent * view's category path. This array will be used * for hierarchical presentation of the * view in places like submenus. * @return array of category tokens or null if not specified. */ virtual QStringList GetCategoryPath() const = 0; /** * Returns the description of this view. * * @return the description */ virtual QString GetDescription() const = 0; /** * Returns the descriptor for the icon to show for this view. */ QIcon GetImageDescriptor() const override = 0; /** * Returns whether this view allows multiple instances. * * @return whether this view allows multiple instances */ virtual bool GetAllowMultiple() const = 0; /** * Returns whether this view can be restored upon workbench restart. * - * @return whether whether this view can be restored upon workbench restart + * @return whether this view can be restored upon workbench restart */ virtual bool IsRestorable() const = 0; + /** + * Return whether this view should be considered internal, e.g., + * excluded from view enumerations in the UI. + * + * @return whether this view is internal + */ + virtual bool IsInternal() const = 0; + bool operator==(const Object*) const override = 0; }; } #endif /*BERRYIVIEWDESCRIPTOR_H_*/ diff --git a/Plugins/org.blueberry.ui.qt/src/berryQtPreferences.cpp b/Plugins/org.blueberry.ui.qt/src/berryQtPreferences.cpp index 36859849c2..e2209f9243 100644 --- a/Plugins/org.blueberry.ui.qt/src/berryQtPreferences.cpp +++ b/Plugins/org.blueberry.ui.qt/src/berryQtPreferences.cpp @@ -1,23 +1,22 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "berryQtPreferences.h" namespace berry { const std::string QtPreferences::QT_STYLES_NODE = "qtstyles"; const std::string QtPreferences::QT_STYLE_NAME = "stylename"; const std::string QtPreferences::QT_STYLE_SEARCHPATHS = "searchpaths"; const std::string QtPreferences::QT_FONT_NAME = "fontname"; const std::string QtPreferences::QT_FONT_SIZE = "fontsize"; -const std::string QtPreferences::QT_SHOW_TOOLBAR_CATEGORY_NAMES = "show_toolbar_category_names"; } diff --git a/Plugins/org.blueberry.ui.qt/src/berryQtPreferences.h b/Plugins/org.blueberry.ui.qt/src/berryQtPreferences.h index 268c85a904..2a52169ac8 100644 --- a/Plugins/org.blueberry.ui.qt/src/berryQtPreferences.h +++ b/Plugins/org.blueberry.ui.qt/src/berryQtPreferences.h @@ -1,34 +1,33 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef BERRYQTPREFERENCES_H_ #define BERRYQTPREFERENCES_H_ #include #include namespace berry { struct BERRY_UI_QT QtPreferences { static const std::string QT_STYLES_NODE; // = "qtstyles"; static const std::string QT_STYLE_NAME; // = "stylename"; static const std::string QT_STYLE_SEARCHPATHS; // = "searchpaths"; static const std::string QT_FONT_NAME; // = "fontname"; static const std::string QT_FONT_SIZE; // = "fontsize"; - static const std::string QT_SHOW_TOOLBAR_CATEGORY_NAMES; // = "show_toolbar_category_names"; }; } #endif /* BERRYQTPREFERENCES_H_ */ diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.cpp b/Plugins/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.cpp index 5b8cb25bb4..a7bb211464 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.cpp +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.cpp @@ -1,272 +1,266 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "berryQtStylePreferencePage.h" #include "berryWorkbenchPlugin.h" #include #include #include #include #include namespace { mitk::IPreferences* GetPreferences() { return berry::WorkbenchPlugin::GetDefault()->GetPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE); } } namespace berry { QtStylePreferencePage::QtStylePreferencePage() { } void QtStylePreferencePage::Init(IWorkbench::Pointer ) { } void QtStylePreferencePage::CreateQtControl(QWidget* parent) { mainWidget = new QWidget(parent); controls.setupUi(mainWidget); ctkPluginContext* context = berry::WorkbenchPlugin::GetDefault()->GetPluginContext(); ctkServiceReference styleManagerRef = context->getServiceReference(); if (styleManagerRef) { styleManager = context->getService(styleManagerRef); } Update(); connect(controls.m_StylesCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(StyleChanged(int))); connect(controls.m_FontComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(FontChanged(int))); connect(controls.m_FontSizeSpinBox, SIGNAL(valueChanged(int)), this, SLOT(FontChanged(int))); connect(controls.m_PathList, SIGNAL(itemSelectionChanged()), this, SLOT(UpdatePathListButtons())); connect(controls.m_AddButton, SIGNAL(clicked(bool)), this, SLOT(AddPathClicked(bool))); connect(controls.m_EditButton, SIGNAL(clicked(bool)), this, SLOT(EditPathClicked(bool))); connect(controls.m_RemoveButton, SIGNAL(clicked(bool)), this, SLOT(RemovePathClicked(bool))); } void QtStylePreferencePage::FillStyleCombo(const berry::IQtStyleManager::Style& currentStyle) { controls.m_StylesCombo->clear(); styles.clear(); styleManager->GetStyles(styles); std::sort(styles.begin(), styles.end()); for (int i = 0; i < styles.size(); ++i) { controls.m_StylesCombo->addItem(styles.at(i).name, QVariant(styles.at(i).fileName)); } controls.m_StylesCombo->setCurrentIndex(styles.indexOf(currentStyle)); } void QtStylePreferencePage::FillFontCombo(const QString& currentFont) { controls.m_FontComboBox->clear(); QStringList fonts; styleManager->GetFonts(fonts); for (int i = 0; i < fonts.size(); ++i) { controls.m_FontComboBox->addItem(fonts.at(i)); } controls.m_FontComboBox->setCurrentIndex(fonts.indexOf(currentFont)); if (currentFont == QString("<>")) { controls.m_FontSizeSpinBox->setEnabled(false); } else { controls.m_FontSizeSpinBox->setEnabled(true); } } void QtStylePreferencePage::AddPath(const QString& path, bool updateCombo) { if (!controls.m_PathList->findItems(path, Qt::MatchCaseSensitive).isEmpty()) return; new QListWidgetItem(path, controls.m_PathList); styleManager->AddStyles(path); if (updateCombo) FillStyleCombo(oldStyle); } void QtStylePreferencePage::StyleChanged(int /*index*/) { QString fileName = controls.m_StylesCombo->itemData(controls.m_StylesCombo->currentIndex()).toString(); styleManager->SetStyle(fileName); } void QtStylePreferencePage::FontChanged(int /*index*/) { QString fontName = controls.m_FontComboBox->currentText(); int fontSize = controls.m_FontSizeSpinBox->value(); if (fontName == QString("<>")) { controls.m_FontSizeSpinBox->setEnabled(false); } else { controls.m_FontSizeSpinBox->setEnabled(true); } styleManager->SetFont(fontName); styleManager->SetFontSize(fontSize); styleManager->UpdateWorkbenchFont(); } void QtStylePreferencePage::AddPathClicked(bool /*checked*/) { QListWidgetItem* item = controls.m_PathList->currentItem(); QString initialDir; if (item) initialDir = item->text(); QString dir = QFileDialog::getExistingDirectory(mainWidget, "", initialDir); if (!dir.isEmpty()) this->AddPath(dir, true); } void QtStylePreferencePage::RemovePathClicked(bool /*checked*/) { QList selection = controls.m_PathList->selectedItems(); QListIterator it(selection); while (it.hasNext()) { QListWidgetItem* item = it.next(); QString dir = item->text(); controls.m_PathList->takeItem(controls.m_PathList->row(item)); delete item; styleManager->RemoveStyles(dir); } if (!styleManager->Contains(oldStyle.fileName)) { oldStyle = styleManager->GetDefaultStyle(); } FillStyleCombo(oldStyle); } void QtStylePreferencePage::EditPathClicked(bool checked) { QListWidgetItem* item = controls.m_PathList->currentItem(); QString initialDir = item->text(); QString dir = QFileDialog::getExistingDirectory(mainWidget, "", initialDir); if (!dir.isEmpty()) { this->RemovePathClicked(checked); this->AddPath(dir, true); } } void QtStylePreferencePage::UpdatePathListButtons() { int s = controls.m_PathList->selectedItems().size(); if (s == 0) { controls.m_EditButton->setEnabled(false); controls.m_RemoveButton->setEnabled(false); } else if (s == 1) { controls.m_EditButton->setEnabled(true); controls.m_RemoveButton->setEnabled(true); } else { controls.m_EditButton->setEnabled(false); controls.m_RemoveButton->setEnabled(true); } } QWidget* QtStylePreferencePage::GetQtControl() const { return mainWidget; } bool QtStylePreferencePage::PerformOk() { auto* prefs = GetPreferences(); prefs->Put(berry::QtPreferences::QT_STYLE_NAME, controls.m_StylesCombo->itemData(controls.m_StylesCombo->currentIndex()).toString().toStdString()); QString paths; for (int i = 0; i < controls.m_PathList->count(); ++i) { QString path = controls.m_PathList->item(i)->text() + ";"; paths += path; } prefs->Put(berry::QtPreferences::QT_STYLE_SEARCHPATHS, paths.toStdString()); prefs->Put(berry::QtPreferences::QT_FONT_NAME, controls.m_FontComboBox->currentText().toStdString()); prefs->Put(berry::QtPreferences::QT_FONT_SIZE, std::to_string(controls.m_FontSizeSpinBox->value())); - prefs->PutBool(berry::QtPreferences::QT_SHOW_TOOLBAR_CATEGORY_NAMES, - controls.m_ToolbarCategoryCheckBox->isChecked()); - return true; } void QtStylePreferencePage::PerformCancel() { Update(); } void QtStylePreferencePage::Update() { styleManager->RemoveStyles(); auto* prefs = GetPreferences(); auto paths = QString::fromStdString(prefs->Get(berry::QtPreferences::QT_STYLE_SEARCHPATHS, "")); QStringList pathList = paths.split(";", Qt::SkipEmptyParts); QStringListIterator it(pathList); while (it.hasNext()) { AddPath(it.next(), false); } auto styleName = QString::fromStdString(prefs->Get(berry::QtPreferences::QT_STYLE_NAME, "")); styleManager->SetStyle(styleName); oldStyle = styleManager->GetStyle(); FillStyleCombo(oldStyle); auto fontName = QString::fromStdString(prefs->Get(berry::QtPreferences::QT_FONT_NAME, "Open Sans")); styleManager->SetFont(fontName); auto fontSize = std::stoi(prefs->Get(berry::QtPreferences::QT_FONT_SIZE, "9")); styleManager->SetFontSize(fontSize); controls.m_FontSizeSpinBox->setValue(fontSize); styleManager->UpdateWorkbenchFont(); FillFontCombo(styleManager->GetFont()); - - controls.m_ToolbarCategoryCheckBox->setChecked( - prefs->GetBool(berry::QtPreferences::QT_SHOW_TOOLBAR_CATEGORY_NAMES, true)); } } diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.ui b/Plugins/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.ui index 6434f85b99..fdf25f2de3 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.ui +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryQtStylePreferencePage.ui @@ -1,166 +1,159 @@ QtStylePreferencePageUI 0 0 456 352 Form - - - - Show category names in toolbars (application restart required) - - - - - - Theme - - - - - - - - 1 - 0 - - - - - Font - - + + 1 0 - + 0 0 6 99 9 + + + + Theme + + + + + + + + 1 + 0 + + + + Qt::Vertical QSizePolicy::Fixed 20 10 Theme Search Paths QAbstractItemView::ExtendedSelection true Add... false Edit... false Remove Qt::Vertical 20 40 diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryViewDescriptor.cpp b/Plugins/org.blueberry.ui.qt/src/internal/berryViewDescriptor.cpp index c50c98b456..7471ff3b3b 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryViewDescriptor.cpp +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryViewDescriptor.cpp @@ -1,206 +1,211 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "berryViewDescriptor.h" #include "berryIConfigurationElement.h" #include "berryCoreException.h" #include "berryIExtension.h" #include "berryIContributor.h" #include "berryStatus.h" #include "berryRegistryReader.h" #include "berryWorkbenchRegistryConstants.h" #include "berryAbstractUICTKPlugin.h" #include "handlers/berryIHandlerActivation.h" namespace berry { ViewDescriptor::ViewDescriptor(const IConfigurationElement::Pointer& e) : configElement(e) { this->LoadFromExtension(); } IViewPart::Pointer ViewDescriptor::CreateView() { IViewPart::Pointer part(configElement->CreateExecutableExtension ( WorkbenchRegistryConstants::ATT_CLASS)); return part; } QStringList ViewDescriptor::GetCategoryPath() const { return categoryPath; } IConfigurationElement::Pointer ViewDescriptor::GetConfigurationElement() const { return configElement; } QString ViewDescriptor::GetDescription() const { return RegistryReader::GetDescription(configElement); } QString ViewDescriptor::GetId() const { return id; } bool ViewDescriptor::operator==(const Object* o) const { if (const IViewDescriptor* other = dynamic_cast(o)) return this->GetId() == other->GetId(); return false; } QIcon ViewDescriptor::GetImageDescriptor() const { if (!imageDescriptor.isNull()) { return imageDescriptor; } QString iconName = configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ICON); // If the icon attribute was omitted, use the default one if (iconName.isEmpty()) { //TODO default image descriptor //return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_DEF_VIEW); return AbstractUICTKPlugin::GetMissingIcon(); } IExtension::Pointer extension(configElement->GetDeclaringExtension()); const QString extendingPluginId(extension->GetContributor()->GetName()); imageDescriptor = AbstractUICTKPlugin::ImageDescriptorFromPlugin( extendingPluginId, iconName); // If the icon attribute was invalid, use the error icon if (imageDescriptor.isNull()) { imageDescriptor = AbstractUICTKPlugin::GetMissingIcon(); } return imageDescriptor; } QString ViewDescriptor::GetLabel() const { return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME); } QString ViewDescriptor::GetAccelerator() const { return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ACCELERATOR); } bool ViewDescriptor::GetAllowMultiple() const { return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ALLOW_MULTIPLE).compare("true", Qt::CaseInsensitive) == 0; } bool ViewDescriptor::IsRestorable() const { QString str = configElement->GetAttribute(WorkbenchRegistryConstants::ATT_RESTORABLE); return str.isNull() ? true : str.compare("true", Qt::CaseInsensitive) == 0; } +bool ViewDescriptor::IsInternal() const +{ + return configElement->GetAttribute(WorkbenchRegistryConstants::ATT_INTERNAL).compare("true", Qt::CaseInsensitive) == 0; +} + Object* ViewDescriptor::GetAdapter(const QString& adapter) const { if (adapter == qobject_interface_iid()) { return GetConfigurationElement().GetPointer(); } return nullptr; } void ViewDescriptor::ActivateHandler() { //TODO ViewDescriptor handler activation // if (!handlerActivation) // { // IHandler::Pointer handler(new ShowViewHandler(this->GetId())); // IHandlerService::Pointer handlerService( // PlatformUI::GetWorkbench()->GetService(IHandlerService::GetManifestName()).Cast()); // handlerActivation = handlerService // ->ActivateHandler(this->GetId(), handler); // } } void ViewDescriptor::DeactivateHandler() { //TODO ViewDescriptor handler deactivation // if (handlerActivation) // { // IHandlerService::Pointer handlerService( // PlatformUI::GetWorkbench()->GetService(IHandlerService::GetManifestName()).Cast()); // handlerService->DeactivateHandler(handlerActivation); // handlerActivation = 0; // } } QStringList ViewDescriptor::GetKeywordReferences() const { QStringList result; auto keywordRefs = configElement->GetChildren("keywordReference"); for (auto keywordRefsIt = keywordRefs.begin(); keywordRefsIt != keywordRefs.end(); ++keywordRefsIt) // iterate over all refs { result.push_back((*keywordRefsIt)->GetAttribute("id")); } return result; } QString ViewDescriptor::GetPluginId() const { return configElement->GetContributor()->GetName(); } QString ViewDescriptor::GetLocalId() const { return this->GetId(); } void ViewDescriptor::LoadFromExtension() { id = configElement->GetAttribute(WorkbenchRegistryConstants::ATT_ID); // Sanity check. QString name = configElement->GetAttribute(WorkbenchRegistryConstants::ATT_NAME); if (name.isEmpty() || RegistryReader::GetClassValue(configElement, WorkbenchRegistryConstants::ATT_CLASS).isEmpty()) { IStatus::Pointer status(new Status(IStatus::ERROR_TYPE, configElement->GetContributor()->GetName(), nullptr, QString("Invalid extension (missing label or class name): ") + id)); throw CoreException(status); } QString category = configElement->GetAttribute(WorkbenchRegistryConstants::TAG_CATEGORY); if (!category.isEmpty()) { // Parse the path tokens and store them foreach (QString pathElement, category.split('/', Qt::SkipEmptyParts)) { if (!pathElement.trimmed().isEmpty()) { categoryPath.push_back(pathElement.trimmed()); } } } } } // namespace berry diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryViewDescriptor.h b/Plugins/org.blueberry.ui.qt/src/internal/berryViewDescriptor.h index 4ed4499d67..ef3d0c2fba 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryViewDescriptor.h +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryViewDescriptor.h @@ -1,160 +1,162 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef BERRYVIEWDESCRIPTOR_H_ #define BERRYVIEWDESCRIPTOR_H_ #include "berryIViewPart.h" #include "berryIViewDescriptor.h" #include "berryIPluginContribution.h" #include #include namespace berry { struct IConfigurationElement; struct IHandlerActivation; /** * \ingroup org_blueberry_ui_internal * */ class ViewDescriptor : public IViewDescriptor, public IPluginContribution { private: QString id; mutable QIcon imageDescriptor; IConfigurationElement::Pointer configElement; QStringList categoryPath; /** * The activation token returned when activating the show view handler with * the workbench. */ SmartPointer handlerActivation; public: berryObjectMacro(ViewDescriptor); /** * Create a new ViewDescriptor for an extension. * * @param e the configuration element * @throws CoreException thrown if there are errors in the configuration */ ViewDescriptor(const SmartPointer& e); /* (non-Javadoc) * @see org.blueberry.ui.internal.registry.IViewDescriptor#createView() */ IViewPart::Pointer CreateView() override; /* (non-Javadoc) * @see org.blueberry.ui.internal.registry.IViewDescriptor#getCategoryPath() */ QStringList GetCategoryPath() const override; /** * Return the configuration element for this descriptor. * * @return the configuration element */ IConfigurationElement::Pointer GetConfigurationElement() const; /* (non-Javadoc) * @see org.blueberry.ui.internal.registry.IViewDescriptor#getDescription() */ QString GetDescription() const override; QStringList GetKeywordReferences() const override; /* (non-Javadoc) * @see org.blueberry.ui.IWorkbenchPartDescriptor#getId() */ QString GetId() const override; /* (non-Javadoc) * @see org.blueberry.ui.IWorkbenchPartDescriptor#getImageDescriptor() */ QIcon GetImageDescriptor() const override; /* (non-Javadoc) * @see org.blueberry.ui.IWorkbenchPartDescriptor#getLabel() */ QString GetLabel() const override; /** * Return the accelerator attribute. * * @return the accelerator attribute */ QString GetAccelerator() const; /* (non-Javadoc) * @see org.blueberry.ui.internal.registry.IViewDescriptor#getAllowMultiple() */ bool GetAllowMultiple() const override; /* (non-Javadoc) * @see org.eclipse.ui.views.IViewDescriptor#getRestorable() */ bool IsRestorable() const override; + bool IsInternal() const override; + bool operator==(const Object*) const override; /** * Activates a show view handler for this descriptor. This handler can later * be deactivated by calling {@link ViewDescriptor#deactivateHandler()}. * This method will only activate the handler if it is not currently active. * */ void ActivateHandler(); /** * Deactivates the show view handler for this descriptor. This handler was * previously activated by calling {@link ViewDescriptor#activateHandler()}. * This method will only deactivative the handler if it is currently active. * */ void DeactivateHandler(); /* * @see IPluginContribution#GetPluginId() */ QString GetPluginId() const override; /* * @see IPluginContribution#GetLocalId() */ QString GetLocalId() const override; protected: /* (non-Javadoc) * @see IAdaptable#GetAdapterImpl(const std::type_info&) */ Object* GetAdapter(const QString& adapter) const override; private: /** * load a view descriptor from the registry. */ void LoadFromExtension(); }; } #endif /*BERRYVIEWDESCRIPTOR_H_*/ diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchRegistryConstants.cpp b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchRegistryConstants.cpp index 73b8bb6c8c..ee443f29d5 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchRegistryConstants.cpp +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchRegistryConstants.cpp @@ -1,561 +1,563 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "berryWorkbenchRegistryConstants.h" #include "berryPlatformUI.h" namespace berry { const QString WorkbenchRegistryConstants::ATT_ACCELERATOR = "accelerator"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_ADAPTABLE = "adaptable"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_ADVISORID = "triggerPointAdvisorId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_ALLOW_LABEL_UPDATE = "allowLabelUpdate";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_ALLOW_MULTIPLE = "allowMultiple"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_RESTORABLE = "restorable"; const QString WorkbenchRegistryConstants::ATT_CAN_FINISH_EARLY = "canFinishEarly"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CATEGORY = "category"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CATEGORY_ID = "categoryId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CLASS = "class"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CLOSEABLE = "closeable"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_COLORFACTORY = "colorFactory"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_COMMAND = "command";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_COMMAND_ID = "commandId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CONFIGURATION = "configuration"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CONTENT_DETECTOR = "contentDetector"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CONTENT_TYPE_ID = "contentTypeId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CONTEXT_ID = "contextId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CONTRIBUTOR_CLASS = "contributorClass"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_CONVERTER = "converter"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_DEFAULT = "default";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_DEFAULT_HANDLER = "defaultHandler"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_DEFAULTS_TO = "defaultsTo"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_DEFINITION_ID = "definitionId";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_DESCRIPTION = "description"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_DESCRIPTION_IMAGE = "descriptionImage"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_DISABLEDICON = "disabledIcon";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_ENABLES_FOR = "enablesFor"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_EXTENSIONS = "extensions";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_FAST_VIEW_WIDTH_RATIO = "fastViewWidthRatio"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_FILENAMES = "filenames";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_FILL_MAJOR = "fillMajor";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_FILL_MINOR = "fillMinor";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_FIXED = "fixed";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_HAS_PAGES = "hasPages"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_HELP_CONTEXT_ID = "helpContextId";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_HELP_HREF = "helpHref"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_HOVERICON = "hoverIcon";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_ICON = "icon"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_ID = "id"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_IMAGE_STYLE = "imageStyle"; //$NON-NLS-1$ + const QString WorkbenchRegistryConstants::ATT_INTERNAL = "internal"; //$NON-NLS-1$ + const QString WorkbenchRegistryConstants::ATT_IS_EDITABLE = "isEditable"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_KEY = "key"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_KEY_CONFIGURATION_ID = "keyConfigurationId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_KEY_SEQUENCE = "keySequence"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_LABEL = "label"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_LAUNCHER = "launcher";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_LIGHTWEIGHT = "lightweight"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_LOCALE = "locale"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_LOCATION = "location"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_MATCHING_STRATEGY = "matchingStrategy"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_MENU_ID = "menuId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_MENUBAR_PATH = "menubarPath";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_MNEMONIC = "mnemonic"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_MINIMIZED = "minimized"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_MOVEABLE = "moveable"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_NAME = "name"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_NAME_FILTER = "nameFilter"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_NODE = "node"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_OBJECTCLASS = "objectClass";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_OPTIONAL = "optional"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_OS = "os"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PARENT = "parent"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PARENT_CATEGORY = "parentCategory"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PARENT_ID = "parentId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PARENT_SCOPE = "parentScope"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PATH = "path"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PLATFORM = "platform"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_POSITION = "position"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PRESENTATIONID = "presentationId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PRODUCTID = "productId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PROJECT = "project";//$NON-NLS-1$ /** const QString WorkbenchRegistryConstants::ATT_PULLDOWN = "pulldown"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_RATIO = "ratio"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_RELATIONSHIP = "relationship";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_RELATIVE = "relative";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_RELATIVE_TO = "relativeTo"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_RETARGET = "retarget";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_RETURN_TYPE_ID = "returnTypeId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_ROLE = "role"; const QString WorkbenchRegistryConstants::ATT_SCHEME_ID = "schemeId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_SCOPE = "scope"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_SEPARATORS_VISIBLE = "separatorsVisible"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_SEQUENCE = "sequence"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_SHOW_TITLE = "showTitle";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_SINGLETON = "singleton";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_SPLASH_ID = "splashId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_STANDALONE = "standalone";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_STATE = "state";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_STRING = "string"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_STYLE = "style";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_TARGET_ID = "targetID";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_TOOLBAR_PATH = "toolbarPath";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_TOOLTIP = "tooltip";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_TYPE = "type"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_TYPE_ID = "typeId"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_VALUE = "value"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_VISIBLE = "visible";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_WS = "ws"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::AUTOGENERATED_PREFIX = "AUTOGEN:::"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ACCELERATOR_CONFIGURATIONS = "acceleratorConfigurations"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ACCELERATOR_SCOPES = "acceleratorScopes"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ACTION_DEFINITIONS = "actionDefinitions"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ACTION_SET_PART_ASSOCIATIONS = "actionSetPartAssociations"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ACTION_SETS = "actionSets"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ACTIVITIES = "activities"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ACTIVITYSUPPORT = "activitySupport"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_BINDINGS = "bindings"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_BROWSER_SUPPORT = "browserSupport"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_COLOR_DEFINITIONS = "colorDefinitions"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_COMMAND_IMAGES = "commandImages"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_COMMANDS = "commands"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_CONTEXTS = "contexts"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_DECORATORS = "decorators"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_DROP_ACTIONS = "dropActions"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_EDITOR = "editors"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_EDITOR_ACTIONS = "editorActions"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ELEMENT_FACTORY = "elementFactories"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_ENCODINGS = "encodings"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_EXPORT = "exportWizards"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_FONT_DEFINITIONS = "fontDefinitions"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_HANDLERS = "handlers"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_HELPSUPPORT = "helpSupport"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_IMPORT = "importWizards"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_INTRO = "intro"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_KEYWORDS = "keywords"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_MENUS = "menus"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_MENU_CONTRIBUTION = "menuContribution"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_NEW = "newWizards"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_PERSPECTIVE_EXTENSIONS = "perspectiveExtensions"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_PERSPECTIVES = "perspectives"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_POPUP_MENU = "popupMenus"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_PREFERENCE_TRANSFER = "preferenceTransfer"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_PREFERENCES = "preferencePages"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_PRESENTATION_FACTORIES = "presentationFactories"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_PROPERTY_PAGES = "propertyPages"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_STARTUP = "startup"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_SPLASH_HANDLERS = "splashHandlers"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_SYSTEM_SUMMARY_SECTIONS = "systemSummarySections"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_THEMES = "themes"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_VIEW_ACTIONS = "viewActions"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_VIEWS = "views"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::PL_WORKINGSETS = "workingSets"; //$NON-NLS-1$ // const QString WorkbenchRegistryConstants::EXTENSION_ACCELERATOR_CONFIGURATIONS = PlatformUI::PLUGIN_ID // + '.' + PL_ACCELERATOR_CONFIGURATIONS; // // const QString WorkbenchRegistryConstants::EXTENSION_ACCELERATOR_SCOPES = PlatformUI::PLUGIN_ID // + '.' + PL_ACCELERATOR_SCOPES; const QString WorkbenchRegistryConstants::EXTENSION_ACTION_DEFINITIONS = PlatformUI::PLUGIN_ID() + '.' + PL_ACTION_DEFINITIONS; // const QString WorkbenchRegistryConstants::EXTENSION_ACTION_SETS = PlatformUI::PLUGIN_ID // + '.' + WorkbenchRegistryConstants::PL_ACTION_SETS; // // const QString WorkbenchRegistryConstants::EXTENSION_BINDINGS = PlatformUI::PLUGIN_ID + '.' // + PL_BINDINGS; // // const QString WorkbenchRegistryConstants::EXTENSION_COMMAND_IMAGES = PlatformUI::PLUGIN_ID // + '.' + PL_COMMAND_IMAGES; const QString WorkbenchRegistryConstants::EXTENSION_COMMANDS = PlatformUI::PLUGIN_ID() + '.' + PL_COMMANDS; // const QString WorkbenchRegistryConstants::EXTENSION_CONTEXTS = PlatformUI::PLUGIN_ID + '.' // + PL_CONTEXTS; // // const QString WorkbenchRegistryConstants::EXTENSION_EDITOR_ACTIONS = PlatformUI::PLUGIN_ID // + '.' + PL_EDITOR_ACTIONS; const QString WorkbenchRegistryConstants::EXTENSION_HANDLERS = PlatformUI::PLUGIN_ID() + '.' + PL_HANDLERS; const QString WorkbenchRegistryConstants::EXTENSION_MENUS = PlatformUI::PLUGIN_ID() + '.' + PL_MENUS; const QString WorkbenchRegistryConstants::COMMON_MENU_ADDITIONS = PlatformUI::PLUGIN_ID() + '.' + PL_MENUS + '2'; const QString WorkbenchRegistryConstants::EXTENSION_POPUP_MENUS = PlatformUI::PLUGIN_ID() + '.' + PL_POPUP_MENU; const QString WorkbenchRegistryConstants::EXTENSION_VIEW_ACTIONS = PlatformUI::PLUGIN_ID() + '.' + PL_VIEW_ACTIONS; const QString WorkbenchRegistryConstants::POSITION_AFTER = "after"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::POSITION_BEFORE = "before"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::POSITION_END = "end"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::POSITION_START = "start"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::STYLE_PULLDOWN = "pulldown"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::STYLE_RADIO = "radio"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::STYLE_TOGGLE = "toggle"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACCELERATOR_CONFIGURATION = "acceleratorConfiguration"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACCELERATOR_SCOPE = "acceleratorScope"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACTION = "action"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACTION_DEFINITION = "actionDefinition"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACTION_SET = "actionSet";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACTION_SET_PART_ASSOCIATION = "actionSetPartAssociation";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACTIVE_KEY_CONFIGURATION = "activeKeyConfiguration"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACTIVE_WHEN = "activeWhen"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ACTIVITY_IMAGE_BINDING = "activityImageBinding"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ADVISORPRODUCTBINDING = "triggerPointAdvisorProductBinding"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_BAR = "bar"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_CATEGORY = "category";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_CATEGORY_IMAGE_BINDING = "categoryImageBinding"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_CATEGORYDEFINITION = "themeElementCategory"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_CATEGORYPRESENTATIONBINDING = "categoryPresentationBinding"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_CLASS = ATT_CLASS; const QString WorkbenchRegistryConstants::TAG_COLORDEFINITION = "colorDefinition"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_COLOROVERRIDE = "colorOverride"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_COLORVALUE = "colorValue"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_COMMAND = "command"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_COMMAND_PARAMETER = "commandParameter"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_COMMAND_PARAMETER_TYPE = "commandParameterType"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_CONTENT_TYPE_BINDING = "contentTypeBinding"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_CONTEXT = "context"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_DATA = "data"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_DEFAULT_HANDLER = ATT_DEFAULT_HANDLER; const QString WorkbenchRegistryConstants::TAG_DESCRIPTION = "description"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_DYNAMIC = "dynamic"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_EDITOR = "editor";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_EDITOR_CONTRIBUTION = "editorContribution"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ENABLED_WHEN = "enabledWhen"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ENABLEMENT = "enablement"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ENTRY = "entry"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_FILTER = "filter"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_FONTDEFINITION = "fontDefinition"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_FONTOVERRIDE = "fontOverride"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_FONTVALUE = "fontValue"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_GROUP = "group"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_GROUP_MARKER = "groupMarker"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_HANDLER = "handler"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_HANDLER_SUBMISSION = "handlerSubmission"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_HINT = "hint"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_IMAGE = "image"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_KEY = "key"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_KEY_BINDING = "keyBinding"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_KEY_CONFIGURATION = "keyConfiguration"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_LOCATION = "location"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_LOCATION_URI = "locationURI"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_LAYOUT = "layout"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_MAPPING = "mapping"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_MENU = "menu"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_NEW_WIZARD_SHORTCUT = "newWizardShortcut";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_OBJECT_CONTRIBUTION = "objectContribution";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_ORDER = "order"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_PARAMETER = "parameter"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_PART = "part";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_PERSP_SHORTCUT = "perspectiveShortcut";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_PERSPECTIVE = "perspective";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_PERSPECTIVE_EXTENSION = "perspectiveExtension";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_PRIMARYWIZARD = "primaryWizard"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_REFERENCE = "reference"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SCHEME = "scheme"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SCOPE = "scope"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SELECTION = "selection"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SEPARATOR = "separator"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SETTINGS_TRANSFER = "settingsTransfer"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SHOW_IN_PART = "showInPart";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_STATE = "state"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SPLASH_HANDLER = "splashHandler"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SPLASH_HANDLER_PRODUCT_BINDING = "splashHandlerProductBinding"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_STICKYVIEW = "stickyView";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SUPPORT = "support"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_THEME = "theme";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_TRANSFER = "transfer";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_TRIGGERPOINT = "triggerPoint"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_TRIGGERPOINTADVISOR = "triggerPointAdvisor"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_VIEW = "view";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_VIEW_SHORTCUT = "viewShortcut";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_VIEW_CONTRIBUTION = "viewContribution"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_VIEWER_CONTRIBUTION = "viewerContribution"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_VISIBILITY = "visibility"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_VISIBLE_WHEN = "visibleWhen"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_WIDGET = "widget"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_CONTROL = "control"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_WIZARD = "wizard";//$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_WORKING_SET = "workingSet"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TYPE_GROUP = "group"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TYPE_ITEM = "item"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TYPE_MENU = "menu"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TYPE_WIDGET = "widget"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_TOOLBAR = "toolbar"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SERVICE_FACTORY = "serviceFactory"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SERVICE = "service"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATTR_FACTORY_CLASS = "factoryClass"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATTR_SERVICE_CLASS = "serviceClass"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_SOURCE_PROVIDER = "sourceProvider"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATTR_PROVIDER = "provider"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::TAG_VARIABLE = "variable"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_PRIORITY_LEVEL = "priorityLevel"; //$NON-NLS-1$ const QString WorkbenchRegistryConstants::ATT_MODE = "mode"; } // namespace berry diff --git a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchRegistryConstants.h b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchRegistryConstants.h index 18201ee809..89d2831cf3 100644 --- a/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchRegistryConstants.h +++ b/Plugins/org.blueberry.ui.qt/src/internal/berryWorkbenchRegistryConstants.h @@ -1,1318 +1,1323 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef __BERRY_WORKBENCH_REGISTRY_CONSTANTS__ #define __BERRY_WORKBENCH_REGISTRY_CONSTANTS__ #include namespace berry { /** * \ingroup org_blueberry_ui_internal * * Interface containing various registry constants (tag and attribute names). * */ struct WorkbenchRegistryConstants { /** * Accelerator attribute. Value accelerator. */ static const QString ATT_ACCELERATOR; // "accelerator"; /** * Adaptable attribute. Value adaptable. */ static const QString ATT_ADAPTABLE; // "adaptable"; /** * Advisor id attribute. Value triggerPointAdvisorId. */ static const QString ATT_ADVISORID; // "triggerPointAdvisorId"; /** * Allow label update attribute. Value allowLabelUpdate. */ static const QString ATT_ALLOW_LABEL_UPDATE; // "allowLabelUpdate"; /** * View multiple attribute. Value allowMultiple. */ static const QString ATT_ALLOW_MULTIPLE; // "allowMultiple"; /** * Attribute that specifies whether a view gets restored upon workbench restart. Value restorable. */ static const QString ATT_RESTORABLE; // = "restorable"; /** * Attribute that specifies whether a wizard is immediately capable of * finishing. Value canFinishEarly. */ static const QString ATT_CAN_FINISH_EARLY; // "canFinishEarly"; /** * The name of the category attribute, which appears on a command * definition. */ static const QString ATT_CATEGORY; // "category"; /** * Category id attribute. Value categoryId. */ static const QString ATT_CATEGORY_ID; // "categoryId"; /** * Class attribute. Value class. */ static const QString ATT_CLASS; // "class"; /** * Sticky view closable attribute. Value closable. */ static const QString ATT_CLOSEABLE; // "closeable"; /** * Color factory attribute. Value colorFactory. */ static const QString ATT_COLORFACTORY; // "colorFactory"; /** * Editor command attribute. Value command. */ static const QString ATT_COMMAND; // "command"; /** * The name of the attribute storing the command id. */ static const QString ATT_COMMAND_ID; // "commandId"; /** * The name of the configuration attribute storing the scheme id for a * binding. */ static const QString ATT_CONFIGURATION; // "configuration"; /** * Intro content detector class attribute (optional). Value contentDetector. */ static const QString ATT_CONTENT_DETECTOR; // "contentDetector"; /** * Editor content type id binding attribute. Value * contentTypeId. */ static const QString ATT_CONTENT_TYPE_ID; // "contentTypeId"; /** * The name of the attribute storing the context id for a binding. */ static const QString ATT_CONTEXT_ID; // "contextId"; /** * Editor contributor class attribute. Value contributorClass. */ static const QString ATT_CONTRIBUTOR_CLASS; // "contributorClass"; /** * The name of the attribute storing the IParameterValueConverter for * a commandParameterType. */ static const QString ATT_CONVERTER; // "converter"; /** * Perspective default attribute. Value default. */ static const QString ATT_DEFAULT; // "default"; /** * The name of the default handler attribute, which appears on a command * definition. */ static const QString ATT_DEFAULT_HANDLER; // "defaultHandler"; /** * Defaults-to attribute. Value defaultsTo. */ static const QString ATT_DEFAULTS_TO; // "defaultsTo"; /** * Action definition id attribute. Value definitionId. */ static const QString ATT_DEFINITION_ID; // "definitionId"; /** * The name of the description attribute, which appears on named handle * objects. */ static const QString ATT_DESCRIPTION; // "description"; /** * Description image attribute. Value descriptionImage. */ static const QString ATT_DESCRIPTION_IMAGE; // "descriptionImage"; /** * Disabled icon attribute. Value disabledIcon. */ static const QString ATT_DISABLEDICON; // "disabledIcon"; /** * Enables-for attribute. Value enablesFor. */ static const QString ATT_ENABLES_FOR; // "enablesFor"; /** * Editor extensions attribute. Value extensions. */ static const QString ATT_EXTENSIONS; // "extensions"; /** * View ratio attribute. Value fastViewWidthRatio. */ static const QString ATT_FAST_VIEW_WIDTH_RATIO; // "fastViewWidthRatio"; /** * Editor filenames attribute. Value filenames. */ static const QString ATT_FILENAMES; // "filenames"; /** * Trim fill major attribute. Value fillMajor. */ static const QString ATT_FILL_MAJOR; // "fillMajor"; /** * Trim fill minor attribute. Value fillMinor. */ static const QString ATT_FILL_MINOR; // "fillMinor"; /** * Perspective fixed attribute. Value fixed. */ static const QString ATT_FIXED; // "fixed"; /** * Attribute that specifies whether a wizard has any pages. Value * hasPages. */ static const QString ATT_HAS_PAGES; // "hasPages"; /** * Help context id attribute. Value helpContextId. */ static const QString ATT_HELP_CONTEXT_ID; // "helpContextId"; /** * Help url attribute. Value helpHref. */ static const QString ATT_HELP_HREF; // "helpHref"; /** * Hover icon attribute. Value hoverIcon. */ static const QString ATT_HOVERICON; // "hoverIcon"; /** * Icon attribute. Value icon. */ static const QString ATT_ICON; // "icon"; /** * Id attribute. Value id. */ static const QString ATT_ID; // "id"; /** * The name of the image style attribute, which is used on location elements * in the menus extension point. */ static const QString ATT_IMAGE_STYLE; // "imageStyle"; + /** + * Internal attribute. Value internal. + */ + static const QString ATT_INTERNAL; // "internal"; + /** * Is-editable attribute. Value isEditable. */ static const QString ATT_IS_EDITABLE; // "isEditable"; /** * Keys attribute. Value keys. */ static const QString ATT_KEY; // "key"; /** * The name of the attribute storing the identifier for the active key * configuration identifier. This provides legacy support for the * activeKeyConfiguration element in the commands extension * point. */ static const QString ATT_KEY_CONFIGURATION_ID; // "keyConfigurationId"; /** * The name of the attribute storing the trigger sequence for a binding. * This is called a 'keySequence' for legacy reasons. */ static const QString ATT_KEY_SEQUENCE; // "keySequence"; /** * Label attribute. Value label. */ static const QString ATT_LABEL; // "label"; /** * Editor launcher attribute. Value launcher. */ static const QString ATT_LAUNCHER; // "launcher"; /** * Lightweight decorator tag. Value lightweight. */ static const QString ATT_LIGHTWEIGHT; // "lightweight"; /** * The name of the attribute storing the locale for a binding. */ static const QString ATT_LOCALE; // "locale"; /** * Sticky view location attribute. Value location. */ static const QString ATT_LOCATION; // "location"; /** * Editor management strategy attribute. Value matchingStrategy. */ static const QString ATT_MATCHING_STRATEGY; // "matchingStrategy"; /** * The name of the menu identifier attribute, which appears on items. */ static const QString ATT_MENU_ID; // "menuId"; /** * Menubar path attribute. Value menubarPath. */ static const QString ATT_MENUBAR_PATH; // "menubarPath"; /** * The name of the mnemonic attribute, which appears on locations. */ static const QString ATT_MNEMONIC; // "mnemonic"; /** * The name of the minimized attribute, which appears * when adding a view in a perspectiveExtension. */ static const QString ATT_MINIMIZED; // "minimized"; /** * Sticky view moveable attribute. Value moveable. */ static const QString ATT_MOVEABLE; // "moveable"; /** * Name attribute. Value name. */ static const QString ATT_NAME; // "name"; /** * Name filter attribute. Value nameFilter. */ static const QString ATT_NAME_FILTER; // "nameFilter"; /** * Node attribute. Value node. */ static const QString ATT_NODE; // "node"; /** * Object class attribute. Value objectClass. */ static const QString ATT_OBJECTCLASS; // "objectClass"; /** * The name of the optional attribute, which appears on parameter * definitions. */ static const QString ATT_OPTIONAL; // "optional"; /** * Operating system attribute. Value os. */ static const QString ATT_OS; // "os"; /** * The name of the deprecated parent attribute, which appears on scheme * definitions. */ static const QString ATT_PARENT; // "parent"; /** * View parent category attribute. Value parentCategory. */ static const QString ATT_PARENT_CATEGORY; // "parentCategory"; /** * Parent id attribute. Value parentId. */ static const QString ATT_PARENT_ID; // "parentId"; /** * The name of the deprecated parent scope attribute, which appears on * contexts definitions. */ static const QString ATT_PARENT_SCOPE; // "parentScope"; /** * Path attribute. Value path. */ static const QString ATT_PATH; // "path"; /** * The name of the attribute storing the platform for a binding. */ static const QString ATT_PLATFORM; // "platform"; /** * The name of the position attribute, which appears on order elements. */ static const QString ATT_POSITION; // "position"; /** * Presentation id attribute. Value presentationId. */ static const QString ATT_PRESENTATIONID; // "presentationId"; /** * Product id attribute. Value productId. */ static const QString ATT_PRODUCTID; // "productId"; /** * Project attribute. Value project. */ // @issue project-specific attribute and behavior static const QString ATT_PROJECT; // "project"; /** /** * The name of the pulldown attribute, which indicates whether the class is * a pulldown delegate. */ static const QString ATT_PULLDOWN; // "pulldown"; /** * View ratio attribute. Value ratio. */ static const QString ATT_RATIO; // "ratio"; /** * Relationship attribute. Value relationship. */ static const QString ATT_RELATIONSHIP; // "relationship"; /** * Relative attribute. Value relative. */ static const QString ATT_RELATIVE; // "relative"; /** * The name of the relativeTo attribute, which appears on order elements. */ static const QString ATT_RELATIVE_TO; // "relativeTo"; /** * Retarget attribute. Value retarget. */ static const QString ATT_RETARGET; // "retarget"; /** * The name of the returnTypeId attribute, which appears on command * elements. */ static const QString ATT_RETURN_TYPE_ID; // "returnTypeId"; /** * Role attribute. Value role. */ static const QString ATT_ROLE; // "role"; /** * The name of the attribute storing the identifier for the active scheme. * This is called a 'keyConfigurationId' for legacy reasons. */ static const QString ATT_SCHEME_ID; // "schemeId"; /** * Scope attribute. Value scope. */ static const QString ATT_SCOPE; // "scope"; /** * The name of the separatorsVisible attribute, which appears on group * elements. */ static const QString ATT_SEPARATORS_VISIBLE; // "separatorsVisible"; /** * The name of the sequence attribute for a key binding. */ static const QString ATT_SEQUENCE; // "sequence"; /** * Show title attribute. Value showTitle. */ static const QString ATT_SHOW_TITLE; // "showTitle"; /** * Perspective singleton attribute. Value singleton. */ static const QString ATT_SINGLETON; // "singleton"; /** * Splash id attribute. Value splashId. * * @since 3.3 */ static const QString ATT_SPLASH_ID; // "splashId"; /** * Standalone attribute. Value standalone. */ static const QString ATT_STANDALONE; // "standalone"; /** * Action state attribute. Value state. */ static const QString ATT_STATE; // "state"; /** * The name of the string attribute (key sequence) for a binding in the * commands extension point. */ static const QString ATT_STRING; // "string"; /** * Action style attribute. Value style. */ static const QString ATT_STYLE; // "style"; /** * Target attribute. Value targetID. */ static const QString ATT_TARGET_ID; // "targetID"; /** * Toolbar path attribute. Value toolbarPath. */ static const QString ATT_TOOLBAR_PATH; // "toolbarPath"; /** * Tooltip attribute. Value tooltip. */ static const QString ATT_TOOLTIP; // "tooltip"; /** * The name of the type attribute, which appears on bar elements and * commandParameterType elements. */ static const QString ATT_TYPE; // "type"; /** * The name of the typeId attribute, which appears on commandParameter * elements. */ static const QString ATT_TYPE_ID; // "typeId"; /** * Value attribute. Value value. */ static const QString ATT_VALUE; // "value"; /** * Visible attribute. Value visible. */ // ATT_VISIBLE added by dan_rubel@instantiations.com static const QString ATT_VISIBLE; // "visible"; /** * Windowing system attribute. Value ws. */ static const QString ATT_WS; // "ws"; /** * The prefix that all auto-generated identifiers start with. This makes the * identifier recognizable as auto-generated, and further helps ensure that * it does not conflict with existing identifiers. */ static const QString AUTOGENERATED_PREFIX; // "AUTOGEN:::"; /** * The legacy extension point (2.1.x and earlier) for specifying a key * binding scheme. * * @since 3.1.1 */ static const QString PL_ACCELERATOR_CONFIGURATIONS; // "acceleratorConfigurations"; /** * The legacy extension point (2.1.x and earlier) for specifying a context. * * @since 3.1.1 */ static const QString PL_ACCELERATOR_SCOPES; // "acceleratorScopes"; /** * The legacy extension point (2.1.x and earlier) for specifying a command. * * @since 3.1.1 */ static const QString PL_ACTION_DEFINITIONS; // "actionDefinitions"; static const QString PL_ACTION_SET_PART_ASSOCIATIONS; // "actionSetPartAssociations"; static const QString PL_ACTION_SETS; // "actionSets"; static const QString PL_ACTIVITIES; // "activities"; static const QString PL_ACTIVITYSUPPORT; // "activitySupport"; /** * The extension point (3.1 and later) for specifying bindings, such as * keyboard shortcuts. * * @since 3.1.1 */ static const QString PL_BINDINGS; // "bindings"; static const QString PL_BROWSER_SUPPORT; // "browserSupport"; static const QString PL_COLOR_DEFINITIONS; // "colorDefinitions"; /** * The extension point (3.2 and later) for associating images with commands. * * @since 3.2 */ static const QString PL_COMMAND_IMAGES; // "commandImages"; /** * The extension point (2.1.x and later) for specifying a command. A lot of * other things have appeared first in this extension point and then been * moved to their own extension point. * * @since 3.1.1 */ static const QString PL_COMMANDS; // "commands"; /** * The extension point (3.0 and later) for specifying a context. * * @since 3.1.1 */ static const QString PL_CONTEXTS; // "contexts"; static const QString PL_DECORATORS; // "decorators"; static const QString PL_DROP_ACTIONS; // "dropActions"; static const QString PL_EDITOR; // "editors"; static const QString PL_EDITOR_ACTIONS; // "editorActions"; static const QString PL_ELEMENT_FACTORY; // "elementFactories"; /** * The extension point for encoding definitions. */ static const QString PL_ENCODINGS; // "encodings"; static const QString PL_EXPORT; // "exportWizards"; static const QString PL_FONT_DEFINITIONS; // "fontDefinitions"; /** * The extension point (3.1 and later) for specifying handlers. * * @since 3.1.1 */ static const QString PL_HANDLERS; // "handlers"; static const QString PL_HELPSUPPORT; // "helpSupport"; static const QString PL_IMPORT; // "importWizards"; static const QString PL_INTRO; // "intro"; /** * The extension point for keyword definitions. * * @since 3.1 */ static const QString PL_KEYWORDS; // "keywords"; /** * The extension point (3.2 and later) for specifying menu contributions. * * @since 3.2 */ static const QString PL_MENUS; // "menus"; /** * The extension point (3.3 and later) for specifying menu contributions. * * @since 3.3 */ static const QString PL_MENU_CONTRIBUTION; // "menuContribution"; static const QString PL_NEW; // "newWizards"; static const QString PL_PERSPECTIVE_EXTENSIONS; // "perspectiveExtensions"; static const QString PL_PERSPECTIVES; // "perspectives"; static const QString PL_POPUP_MENU; // "popupMenus"; static const QString PL_PREFERENCE_TRANSFER; // "preferenceTransfer"; static const QString PL_PREFERENCES; // "preferencePages"; static const QString PL_PRESENTATION_FACTORIES; // "presentationFactories"; static const QString PL_PROPERTY_PAGES; // "propertyPages"; static const QString PL_STARTUP; // "startup"; /** * @since 3.3 */ static const QString PL_SPLASH_HANDLERS; // "splashHandlers"; static const QString PL_SYSTEM_SUMMARY_SECTIONS; // "systemSummarySections"; static const QString PL_THEMES; // "themes"; static const QString PL_VIEW_ACTIONS; // "viewActions"; static const QString PL_VIEWS; // "views"; static const QString PL_WORKINGSETS; // "workingSets"; /** * The name of the deprecated accelerator configurations extension point. */ static const QString EXTENSION_ACCELERATOR_CONFIGURATIONS; /** * The name of the accelerator scopes extension point. */ static const QString EXTENSION_ACCELERATOR_SCOPES; /** * The name of the action definitions extension point. */ static const QString EXTENSION_ACTION_DEFINITIONS; /** * The name of the org.blueberry.ui.actionSets extension point. */ static const QString EXTENSION_ACTION_SETS; /** * The name of the bindings extension point. */ static const QString EXTENSION_BINDINGS; /** * The name of the commands extension point. */ static const QString EXTENSION_COMMAND_IMAGES; /** * The name of the commands extension point, and the name of the key for the * commands preferences. */ static const QString EXTENSION_COMMANDS; /** * The name of the contexts extension point. */ static const QString EXTENSION_CONTEXTS; /** * The name of the org.blueberry.ui.editorActions extension * point. */ static const QString EXTENSION_EDITOR_ACTIONS; /** * The name of the commands extension point. */ static const QString EXTENSION_HANDLERS; /** * The name of the org.blueberry.ui.menus extension point. */ static const QString EXTENSION_MENUS; /** * The name of the org.blueberry.ui.menus2 extension point. */ static const QString COMMON_MENU_ADDITIONS; /** * The name of the org.blueberry.ui.popupMenus extension point. */ static const QString EXTENSION_POPUP_MENUS; /** * The name of the org.blueberry.ui.viewActions extension * point. */ static const QString EXTENSION_VIEW_ACTIONS; /** * The constant for the position attribute corresponding to * {@link SOrder#POSITION_AFTER}. */ static const QString POSITION_AFTER; // "after"; /** * The constant for the position attribute corresponding to * {@link SOrder#POSITION_BEFORE}. */ static const QString POSITION_BEFORE; // "before"; /** * The constant for the position attribute corresponding to * {@link SOrder#POSITION_END}. */ static const QString POSITION_END; // "end"; /** * The constant for the position attribute corresponding to * {@link SOrder#POSITION_START}. */ static const QString POSITION_START; // "start"; /** * The action style for drop-down menus. */ static const QString STYLE_PULLDOWN; // "pulldown"; /** * The action style for radio buttons. */ static const QString STYLE_RADIO; // "radio"; /** * The action style for check boxes. */ static const QString STYLE_TOGGLE; // "toggle"; /** * The name of the deprecated accelerator configuration element. This * element was used in 2.1.x and earlier to define groups of what are now * called schemes. */ static const QString TAG_ACCELERATOR_CONFIGURATION; // "acceleratorConfiguration"; /** * The name of the element storing a deprecated accelerator scope. */ static const QString TAG_ACCELERATOR_SCOPE; // "acceleratorScope"; /** * Action tag. Value action. */ static const QString TAG_ACTION; // "action"; /** * The name of the element storing an action definition. This element only * existed in */ static const QString TAG_ACTION_DEFINITION; // "actionDefinition"; /** * Action set tag. Value actionSet. */ static const QString TAG_ACTION_SET; // "actionSet"; /** * Part association tag. Value actionSetPartAssociation. */ static const QString TAG_ACTION_SET_PART_ASSOCIATION; // "actionSetPartAssociation"; /** * The name of the element storing the active key configuration from the * commands extension point. */ static const QString TAG_ACTIVE_KEY_CONFIGURATION; // "activeKeyConfiguration"; /** * The name of the active when element, which appears on a handler * definition. */ static const QString TAG_ACTIVE_WHEN; // "activeWhen"; /** * Activity image binding tag. Value activityImageBindingw. */ static const QString TAG_ACTIVITY_IMAGE_BINDING; // "activityImageBinding"; /** * Advisor to product binding element. Value * triggerPointAdvisorProductBinding. */ static const QString TAG_ADVISORPRODUCTBINDING; // "triggerPointAdvisorProductBinding"; /** * The name of the bar element, which appears in a location definition. */ static const QString TAG_BAR; // "bar"; /** * Category tag. Value category. */ static const QString TAG_CATEGORY; // "category"; /** * Category image binding tag. Value categoryImageBinding. */ static const QString TAG_CATEGORY_IMAGE_BINDING; // "categoryImageBinding"; /** * Element category tag. Value themeElementCategory. */ static const QString TAG_CATEGORYDEFINITION; // "themeElementCategory"; /** * Category presentation tag. Value categoryPresentationBinding. */ static const QString TAG_CATEGORYPRESENTATIONBINDING; // "categoryPresentationBinding"; /** * The name of the class element, which appears on an executable extension. */ static const QString TAG_CLASS; // ATT_CLASS; /** * Color definition tag. Value colorDefinition. */ static const QString TAG_COLORDEFINITION; // "colorDefinition"; /** * Color override tag. Value colorOverride. */ static const QString TAG_COLOROVERRIDE; // "colorOverride"; /** * Color value tag. Value colorValue. */ static const QString TAG_COLORVALUE; // "colorValue"; /** * The name of the element storing a command. */ static const QString TAG_COMMAND; // "command"; /** * The name of the element storing a parameter. */ static const QString TAG_COMMAND_PARAMETER; // "commandParameter"; /** * The name of the element storing a parameter type. */ static const QString TAG_COMMAND_PARAMETER_TYPE; // "commandParameterType"; /** * Editor content type binding tag. Value contentTypeBinding. */ static const QString TAG_CONTENT_TYPE_BINDING; // "contentTypeBinding"; /** * The name of the element storing a context. */ static const QString TAG_CONTEXT; // "context"; /** * Data tag. Value data. */ static const QString TAG_DATA; // "data"; /** * The name of the default handler element, which appears on a command * definition. */ static const QString TAG_DEFAULT_HANDLER; // ATT_DEFAULT_HANDLER; /** * Description element. Value description. */ static const QString TAG_DESCRIPTION; // "description"; /** * The name of the dynamic menu element, which appears in a group or menu * definition. */ static const QString TAG_DYNAMIC; // "dynamic"; /** * Editor tag. Value editor. */ static const QString TAG_EDITOR; // "editor"; /** * The name of the deprecated editorContribution element. This is used for * contributing actions to the top-level menus and tool bars when particular * editors are visible. */ static const QString TAG_EDITOR_CONTRIBUTION; // "editorContribution"; /** * The name of the enabled when element, which appears on a handler * definition. */ static const QString TAG_ENABLED_WHEN; // "enabledWhen"; /** * Enablement tag. Value enablement. */ static const QString TAG_ENABLEMENT; // "enablement"; /** * Entry tag. Value entry. */ static const QString TAG_ENTRY; // "entry"; /** * Filter tag. Value filter. */ static const QString TAG_FILTER; // "filter"; /*************************************************************************** * Font definition tag. Value fontDefinition. */ static const QString TAG_FONTDEFINITION; // "fontDefinition"; /** * Font override tag. Value fontOverride. */ static const QString TAG_FONTOVERRIDE; // "fontOverride"; /** * Font value tag. Value fontValue. */ static const QString TAG_FONTVALUE; // "fontValue"; /** * The name of the element storing a group. */ static const QString TAG_GROUP; // "group"; /** * Group marker tag. Value groupMarker. */ static const QString TAG_GROUP_MARKER; // "groupMarker"; /** * The name of the element storing a handler. */ static const QString TAG_HANDLER; // "handler"; /** * The name of the element storing a handler submission. */ static const QString TAG_HANDLER_SUBMISSION; // "handlerSubmission"; /** * Trigger point hint tag. Value hint. */ static const QString TAG_HINT; // "hint"; /** * The name of the element storing an image. */ static const QString TAG_IMAGE; // "image"; /** * The name of the element storing a key binding. */ static const QString TAG_KEY; // "key"; /** * The name of the key binding element in the commands extension point. */ static const QString TAG_KEY_BINDING; // "keyBinding"; /** * The name of the deprecated key configuration element in the commands * extension point. This element has been replaced with the scheme element * in the bindings extension point. */ static const QString TAG_KEY_CONFIGURATION; // "keyConfiguration"; /** * The name of the element storing a location. */ static const QString TAG_LOCATION; // "location"; /** * The name of the element defining the insertion point for menu * additions. * * @since 3.3 */ static const QString TAG_LOCATION_URI; // "locationURI"; /** * The name of the element storing trim layout info for a widget. */ static const QString TAG_LAYOUT; // "layout"; /** * Mapping tag. Value mapping. */ static const QString TAG_MAPPING; // "mapping"; /** * Menu tag. Value menu. */ static const QString TAG_MENU; // "menu"; /** * Wizard shortcut tag. Value newWizardShortcut. */ static const QString TAG_NEW_WIZARD_SHORTCUT; // "newWizardShortcut"; /** * Object contribution tag. Value objectContribution. */ static const QString TAG_OBJECT_CONTRIBUTION; // "objectContribution"; /** * The name of the element storing the ordering information. */ static const QString TAG_ORDER; // "order"; /** * The name of the element storing a parameter. */ static const QString TAG_PARAMETER; // "parameter"; /** * Part tag. Value part. */ static const QString TAG_PART; // "part"; /** * Perspective shortcut tag. Value perspectiveShortcut. */ static const QString TAG_PERSP_SHORTCUT; // "perspectiveShortcut"; /** * Perspective tag. Value perspective. */ static const QString TAG_PERSPECTIVE; // "perspective"; /** * Perspective extension tag. Value perspectiveExtension. */ static const QString TAG_PERSPECTIVE_EXTENSION; // "perspectiveExtension"; /** * Primary wizard tag. Value primaryWizard. */ static const QString TAG_PRIMARYWIZARD; // "primaryWizard"; /** * The name of the element storing the a menu element reference. */ static const QString TAG_REFERENCE; // "reference"; /** * The name of the scheme element in the bindings extension point. */ static const QString TAG_SCHEME; // "scheme"; /** * The name of the element storing a deprecated scope. */ static const QString TAG_SCOPE; // "scope"; /** * Selectiont tag. Value selection. */ static const QString TAG_SELECTION; // "selection"; /** * Separator tag. Value separator. */ static const QString TAG_SEPARATOR; // "separator"; /** * Tag for the settings transfer entry. */ static const QString TAG_SETTINGS_TRANSFER; // "settingsTransfer"; /** * Show in part tag. Value showInPart. */ static const QString TAG_SHOW_IN_PART; // "showInPart"; /** * The name of the element storing some state. */ static const QString TAG_STATE; // "state"; /** * The name of the element describing splash handlers. Value * splashHandler. * @since 3.3 */ static const QString TAG_SPLASH_HANDLER; // "splashHandler"; /** * The name of the element describing splash handler product bindings. Value * splashHandlerProductBinding. * @since 3.3 */ static const QString TAG_SPLASH_HANDLER_PRODUCT_BINDING; // "splashHandlerProductBinding"; /** * Sticky view tag. Value stickyView. */ static const QString TAG_STICKYVIEW; // "stickyView"; /** * Browser support tag. Value support. */ static const QString TAG_SUPPORT; // "support"; /** * Theme tag. Value theme. */ static const QString TAG_THEME; // "theme"; /** * Transfer tag. Value transfer. */ static const QString TAG_TRANSFER; // "transfer"; /** * Trigger point tag. Value triggerPoint. */ static const QString TAG_TRIGGERPOINT; // "triggerPoint"; /** * Advisor tag. Value triggerPointAdvisor. */ static const QString TAG_TRIGGERPOINTADVISOR; // "triggerPointAdvisor"; /** * View tag. Value view. */ static const QString TAG_VIEW; // "view"; /** * View shortcut tag. Value viewShortcut. */ static const QString TAG_VIEW_SHORTCUT; // "viewShortcut"; /** * The name of the element storing a view contribution. */ static const QString TAG_VIEW_CONTRIBUTION; // "viewContribution"; /** * Viewer contribution tag. Value viewerContribution. */ static const QString TAG_VIEWER_CONTRIBUTION; // "viewerContribution"; /** * Visibility tag. Value visibility. */ static const QString TAG_VISIBILITY; // "visibility"; /** * The name of the element storing the visible when condition. */ static const QString TAG_VISIBLE_WHEN; // "visibleWhen"; /** * The name of the element storing a widget. */ static const QString TAG_WIDGET; // "widget"; /** * The name of the element storing a control hosted in a ToolBar. */ static const QString TAG_CONTROL; // "control"; /** * Wizard tag. Value wizard. */ static const QString TAG_WIZARD; // "wizard"; /** * Working set tag. Value workingSet. */ static const QString TAG_WORKING_SET; // "workingSet"; /** * The type of reference which refers to a group. */ static const QString TYPE_GROUP; // "group"; /** * The type of reference which refers to an item. */ static const QString TYPE_ITEM; // "item"; /** * The type of reference which refers to an menu. */ static const QString TYPE_MENU; // "menu"; /** * The type of reference which refers to the widget. */ static const QString TYPE_WIDGET; // "widget"; static const QString TAG_TOOLBAR; // "toolbar"; static const QString TAG_SERVICE_FACTORY; // "serviceFactory"; static const QString TAG_SERVICE; // "service"; static const QString ATTR_FACTORY_CLASS; // "factoryClass"; static const QString ATTR_SERVICE_CLASS; // "serviceClass"; static const QString TAG_SOURCE_PROVIDER; // "sourceProvider"; static const QString ATTR_PROVIDER; // "provider"; static const QString TAG_VARIABLE; // "variable"; static const QString ATT_PRIORITY_LEVEL; // "priorityLevel"; static const QString ATT_MODE; // "mode"; }; } // namespace berry #endif // __BERRY_WORKBENCH_REGISTRY_CONSTANTS__ diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkApplicationConstants.cpp b/Plugins/org.mitk.gui.qt.application/src/QmitkApplicationConstants.cpp index 2fa48ecae8..58cbcefb76 100644 --- a/Plugins/org.mitk.gui.qt.application/src/QmitkApplicationConstants.cpp +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkApplicationConstants.cpp @@ -1,15 +1,16 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkApplicationConstants.h" const std::string QmitkApplicationConstants::TOOL_BARS_PREFERENCES = "org.mitk.gui.qt.application/toolbars"; +const std::string QmitkApplicationConstants::TOOL_BARS_SHOW_CATEGORIES = "show categories"; diff --git a/Plugins/org.mitk.gui.qt.application/src/QmitkApplicationConstants.h b/Plugins/org.mitk.gui.qt.application/src/QmitkApplicationConstants.h index 5f352c0fec..557c5ebd44 100644 --- a/Plugins/org.mitk.gui.qt.application/src/QmitkApplicationConstants.h +++ b/Plugins/org.mitk.gui.qt.application/src/QmitkApplicationConstants.h @@ -1,19 +1,20 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include #include struct MITK_QT_APP QmitkApplicationConstants { static const std::string TOOL_BARS_PREFERENCES; + static const std::string TOOL_BARS_SHOW_CATEGORIES; }; diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkToolBarsPreferencePage.cpp b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkToolBarsPreferencePage.cpp index df04dfe6f3..4d69aee495 100644 --- a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkToolBarsPreferencePage.cpp +++ b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkToolBarsPreferencePage.cpp @@ -1,190 +1,208 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkToolBarsPreferencePage.h" #include #include #include #include #include #include #include #include namespace { mitk::IPreferences* GetPreferences() { auto prefService = mitk::CoreServices::GetPreferencesService(); return prefService->GetSystemPreferences()->Node(QmitkApplicationConstants::TOOL_BARS_PREFERENCES); } // Get views as multimap with categories as keys. // // Exclude views without category and categories that contain a literal '.', e.g. // "org.blueberry.ui" or "org.mitk.views.general", as they typically do not have // a corresponding tool bar. std::multimap GetViews() { std::multimap result; const auto workbench = berry::PlatformUI::GetWorkbench(); const auto viewRegistry = workbench->GetViewRegistry(); const auto views = viewRegistry->GetViews(); for (auto view : views) { QString category; if (auto categoryPath = view->GetCategoryPath(); !categoryPath.isEmpty()) category = categoryPath.back(); - if (!category.isEmpty() && !category.contains('.')) + if (!category.isEmpty() && !category.contains('.') && !view->IsInternal()) result.emplace(category, view); } return result; } // Get all toolbars of all (typically one) Workbench windows. std::vector GetToolBars() { std::vector result; const auto* workbench = berry::PlatformUI::GetWorkbench(); auto workbenchWindows = workbench->GetWorkbenchWindows(); for (auto workbenchWindow : workbenchWindows) { if (auto shell = workbenchWindow->GetShell(); shell.IsNotNull()) { if (const auto* mainWindow = qobject_cast(shell->GetControl()); mainWindow != nullptr) { for (auto child : mainWindow->children()) { if (auto toolBar = qobject_cast(child); toolBar != nullptr) result.push_back(toolBar); } } } } return result; } - // Find a toolbar by object name and apply visibility. - bool ApplyVisibility(const std::vector& toolBars, const QString& name, bool isVisible) + // Find a toolbar by object name and apply preferences. + bool ApplyPreferences(const std::vector& toolBars, const QString& name, bool isVisible, bool showCategory) { auto it = std::find_if(toolBars.cbegin(), toolBars.cend(), [&name](const QToolBar* toolBar) { return toolBar->objectName() == name; }); if (it != toolBars.cend()) { - (*it)->setVisible(isVisible); + auto toolBar = *it; + toolBar->setVisible(isVisible); + + for (auto action : toolBar->actions()) + { + if (action->objectName() == "category") + { + action->setVisible(showCategory); + break; + } + } + return true; } return false; } } QmitkToolBarsPreferencePage::QmitkToolBarsPreferencePage() : m_Ui(new Ui::QmitkToolBarsPreferencePage), m_Control(nullptr) { } QmitkToolBarsPreferencePage::~QmitkToolBarsPreferencePage() { } void QmitkToolBarsPreferencePage::Init(berry::IWorkbench::Pointer) { } void QmitkToolBarsPreferencePage::CreateQtControl(QWidget* parent) { m_Control = new QWidget(parent); m_Ui->setupUi(m_Control); const auto views = GetViews(); for (auto category = views.cbegin(), end = views.cend(); category != end; category = views.upper_bound(category->first)) { auto categoryItem = new QTreeWidgetItem; categoryItem->setText(0, category->first); categoryItem->setCheckState(0, Qt::Checked); const auto range = views.equal_range(category->first); for (auto view = range.first; view != range.second; ++view) { auto viewItem = new QTreeWidgetItem; viewItem->setText(0, view->second->GetLabel()); + viewItem->setIcon(0, view->second->GetImageDescriptor()); categoryItem->addChild(viewItem); } m_Ui->treeWidget->addTopLevelItem(categoryItem); } this->Update(); } QWidget* QmitkToolBarsPreferencePage::GetQtControl() const { return m_Control; } bool QmitkToolBarsPreferencePage::PerformOk() { auto prefs = GetPreferences(); + bool showCategories = m_Ui->showCategoriesCheckBox->isChecked(); + + prefs->PutBool(QmitkApplicationConstants::TOOL_BARS_SHOW_CATEGORIES, showCategories); + const auto toolBars = GetToolBars(); for (int i = 0, count = m_Ui->treeWidget->topLevelItemCount(); i < count; ++i) { const auto* item = m_Ui->treeWidget->topLevelItem(i); const auto category = item->text(0); const bool isVisible = item->checkState(0) == Qt::Checked; prefs->PutBool(category.toStdString(), isVisible); - if (!ApplyVisibility(toolBars, category, isVisible)) + if (!ApplyPreferences(toolBars, category, isVisible, showCategories)) MITK_WARN << "Could not find tool bar for category \"" << category << "\" to set its visibility!"; } return true; } void QmitkToolBarsPreferencePage::PerformCancel() { } void QmitkToolBarsPreferencePage::Update() { const auto prefs = GetPreferences(); + m_Ui->showCategoriesCheckBox->setChecked(prefs->GetBool(QmitkApplicationConstants::TOOL_BARS_SHOW_CATEGORIES, true)); + for (int i = 0, count = m_Ui->treeWidget->topLevelItemCount(); i < count; ++i) { auto item = m_Ui->treeWidget->topLevelItem(i); const auto category = item->text(0).toStdString(); const bool isVisible = prefs->GetBool(category, true); item->setCheckState(0, isVisible ? Qt::Checked : Qt::Unchecked); } } diff --git a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkToolBarsPreferencePage.ui b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkToolBarsPreferencePage.ui index 56d6c9c062..3bff6f9d84 100644 --- a/Plugins/org.mitk.gui.qt.application/src/internal/QmitkToolBarsPreferencePage.ui +++ b/Plugins/org.mitk.gui.qt.application/src/internal/QmitkToolBarsPreferencePage.ui @@ -1,46 +1,50 @@ QmitkToolBarsPreferencePage 0 0 - 640 - 480 + 609 + 312 - - 0 - - - 0 - - - 0 - - - 0 - + + + + Show category names + + + QAbstractItemView::NoEditTriggers false QAbstractItemView::NoSelection true + + + 1 + + + + showCategoriesCheckBox + treeWidget + diff --git a/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.h b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.h index afe6788eb5..0e251efd22 100644 --- a/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.h +++ b/Plugins/org.mitk.gui.qt.common/src/QmitkAbstractView.h @@ -1,356 +1,356 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QmitkAbstractView_h #define QmitkAbstractView_h //# blueberry stuff #include #include //# mitk stuff #include #include "mitkDataNodeSelection.h" #include "mitkIRenderWindowPart.h" #include #include #include #include #include namespace mitk { class DataNode; class IPreferences; } class QmitkAbstractViewPrivate; class QmitkAbstractViewSelectionProvider; /** * \ingroup org_mitk_gui_qt_common * * \brief A convenient base class for MITK related BlueBerry Views. * * QmitkAbstractView provides several convenience methods that ease the introduction of a new view: * *
    *
  1. Access to the DataStorage (~ the shared data repository) *
  2. Access to the active IRenderWindowPart *
  3. Access to and update notification for the view's preferences *
  4. Access to and update notification for the current DataNode selection / to DataNode selection events send through the SelectionService *
  5. Access to and update notification for DataNode events (added/removed/modified) *
  6. Methods to send DataNode selections through the SelectionService *
  7. Some minor important convenience methods (like changing the mouse cursor/exception handling) *
* * Usually all MITK Views inherit from QmitkAbstractView to achieve a consistent Workbench behavior. * * When inheriting from QmitkAbstractView, you must implement the following methods: *
    *
  • void CreateQtPartControl(QWidget* parent) *
  • void SetFocus() *
* * You may reimplement the following private virtual methods to customize your View's behavior: *
    *
  • void SetSelectionProvider() *
  • QItemSelectionModel* GetDataNodeSelectionModel() const *
* * You may reimplement the following private virtual methods to be notified about certain changes: *
    *
  • void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes) *
  • void OnNullSelection(berry::IWorkbenchPart::Pointer part) *
  • void OnPreferencesChanged(const mitk::IPreferences*) *
  • void NodeAdded(const mitk::DataNode* node) *
  • void NodeChanged(const mitk::DataNode* node) *
  • void NodeRemoved(const mitk::DataNode* node) *
  • void DataStorageModified() *
  • void DataStorageChanged(mitk::IDataStorageReference::Pointer dsRef) *
* * \see mitk::ILifecycleAwarePart * \see mitk::IZombieViewPart * \see mitk::IRenderWindowPartListener */ class MITK_QT_COMMON QmitkAbstractView : public berry::QtViewPart { public: /** * Creates smartpointer typedefs */ berryObjectMacro(QmitkAbstractView); /** * Nothing to do in the standard ctor. Initialize your GUI in CreateQtPartControl(QWidget*) * \see berry::QtViewPart::CreateQtPartControl(QWidget*) */ QmitkAbstractView(); /** * Disconnects all standard event listeners */ ~QmitkAbstractView() override; protected: /** * Informs other parts of the workbench that node is selected via the blueberry selection service. * * \note This method should not be used if you have set your own selection provider via * SetSelectionProvider() or your own QItemSelectionModel via GetDataNodeSelectionModel(). */ void FireNodeSelected(mitk::DataNode::Pointer node); /** * Informs other parts of the workbench that the nodes are selected via the blueberry selection service. * * \note This method should not be used if you have set your own selection provider via * SetSelectionProvider() or your own QItemSelectionModel via GetDataNodeSelectionModel(). */ virtual void FireNodesSelected(const QList& nodes); /** * \return The selection of the currently active part of the workbench or an empty list * if there is no selection or if it is empty. * * \see IsCurrentSelectionValid */ QList GetCurrentSelection() const; /** * Queries the state of the current selection. * * \return If the current selection is nullptr, this method returns * false and true otherwise. */ bool IsCurrentSelectionValid() const; /** * Returns the current selection made in the datamanager bundle or an empty list * if there is no selection or if it is empty. * * \see IsDataManagerSelectionValid */ QList GetDataManagerSelection() const; /** * Queries the state of the current selection of the data manager view. * * \return If the current data manager selection is nullptr, this method returns * false and true otherwise. */ bool IsDataManagerSelectionValid() const; /** * Sets the selection of the data manager view if available. * * \param selection The new selection for the data manager. * \param flags The Qt selection flags for controlling the way how the selection is updated. */ void SetDataManagerSelection(const berry::ISelection::ConstPointer& selection, QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::ClearAndSelect) const; /** * Takes the current selection and sets it on the data manager. Only matching nodes in the * data manager view will be selected. */ void SynchronizeDataManagerSelection() const; /** * Returns the Preferences object for this View. * Important: When referring to this preferences, e.g. in a PreferencePage: The ID * for this preferences object is "/", e.g. "/org.mitk.views.datamanager" */ - mitk::IPreferences* GetPreferences() const; + virtual mitk::IPreferences* GetPreferences() const; /** * Returns a reference to the currently active DataStorage. */ mitk::IDataStorageReference::Pointer GetDataStorageReference() const; /** * Returns the currently active DataStorage. */ mitk::DataStorage::Pointer GetDataStorage() const; /** * Returns the currently active mitk::IRenderWindowPart. * * \param strategies Strategies for returning a mitk::IRenderWindowPart instance if there * is currently no active one. * \return The active mitk::IRenderWindowPart. */ mitk::IRenderWindowPart* GetRenderWindowPart(mitk::WorkbenchUtil::IRenderWindowPartStrategies strategies = mitk::WorkbenchUtil::NONE) const; /** * Request an update of all render windows of the currently active IRenderWindowPart. * * \param requestType Specifies the type of render windows for which an update will be requested. */ void RequestRenderWindowUpdate(mitk::RenderingManager::RequestType requestType = mitk::RenderingManager::REQUEST_UPDATE_ALL); /** * Outputs an error message to the console and displays a message box containing * the exception description. * \param e the exception which should be handled * \param parent * \param showDialog controls, whether additionally a message box should be * displayed to inform the user that something went wrong */ void HandleException( std::exception& e, QWidget* parent = nullptr, bool showDialog = true ) const; /** * Calls HandleException ( std::exception&, QWidget*, bool ) internally * \see HandleException ( std::exception&, QWidget*, bool ) */ void HandleException( const char* str, QWidget* parent = nullptr, bool showDialog = true ) const; /** * Convenient method to set and reset a wait cursor ("hourglass") */ void WaitCursorOn(); /** * Convenient method to restore the standard cursor */ void WaitCursorOff(); /** * Convenient method to set and reset a busy cursor */ void BusyCursorOn(); /** * Convenient method to restore the standard cursor */ void BusyCursorOff(); /** * Convenient method to restore the standard cursor */ void RestoreOverrideCursor(); private: /** * Reimplement this method to set a custom selection provider. This method is * called once after CreateQtPartControl(). * * The default implementation registers a QmitkDataNodeSelectionProvider with * a QItemSelectionModel returned by GetDataNodeSelectionModel(). */ virtual void SetSelectionProvider(); /** * Reimplement this method to supply a custom Qt selection model. The custom * model will be used with the default selection provider QmitkDataNodeSelectionProvider * to inform the MITK Workbench about selection changes. * * If you reimplement this method, the methods FireNodeSelected() and FireNodesSelected() * will have no effect. Use your custom selection model to notify the MITK Workbench * about selection changes. * * The Qt item model used with the custom selection model must return mitk::DataNode::Pointer * objects for model indexes when the role is QmitkDataNodeRole. */ virtual QItemSelectionModel* GetDataNodeSelectionModel() const; /** * Called when the selection in the workbench changed. * May be reimplemented by deriving classes. * * \param part The source part responsible for the selection change. * \param nodes A list of selected nodes. * * \see OnNullSelection */ virtual void OnSelectionChanged(berry::IWorkbenchPart::Pointer part, const QList &nodes); /** * Called when a nullptr selection occurs. * * \param part The source part responsible for the selection change. */ virtual void OnNullSelection(berry::IWorkbenchPart::Pointer part); /** * Called when the preferences object of this view changed. * May be reimplemented by deriving classes. * * \see GetPreferences() */ virtual void OnPreferencesChanged(const mitk::IPreferences*); /** * Called when a DataStorage Add event was thrown. May be reimplemented * by deriving classes. */ virtual void NodeAdded(const mitk::DataNode* node); /** * Called when a DataStorage Changed event was thrown. May be reimplemented * by deriving classes. */ virtual void NodeChanged(const mitk::DataNode* node); /** * Called when a DataStorage Remove event was thrown. May be reimplemented * by deriving classes. */ virtual void NodeRemoved(const mitk::DataNode* node); /** * Called when a DataStorage add *or* remove *or* change event from the currently active * data storage is thrown. * * May be reimplemented by deriving classes. */ virtual void DataStorageModified(); /** * Called when the currently active DataStorage changed. * May be reimplemented by deriving classes. * * \param dsRef A reference to the new active DataStorage. */ virtual void DataStorageChanged(mitk::IDataStorageReference::Pointer dsRef); /** * Creates a scroll area for this view and calls CreateQtPartControl then */ void CreatePartControl(QWidget* parent) override; /** * Called immediately after CreateQtPartControl(). * Here standard event listeners for a QmitkAbstractView are registered */ void AfterCreateQtPartControl(); private: friend class QmitkAbstractViewPrivate; friend class QmitkViewCoordinator; Q_DISABLE_COPY(QmitkAbstractView) const QScopedPointer d; }; #endif diff --git a/Plugins/org.mitk.gui.qt.ext/plugin.xml b/Plugins/org.mitk.gui.qt.ext/plugin.xml index a1656fa533..2c87bf9f64 100644 --- a/Plugins/org.mitk.gui.qt.ext/plugin.xml +++ b/Plugins/org.mitk.gui.qt.ext/plugin.xml @@ -1,36 +1,37 @@ + icon="resources/ModuleView.png" + internal="true" /> diff --git a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp index 79ce40d827..b7d3a96ce9 100644 --- a/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp +++ b/Plugins/org.mitk.gui.qt.ext/src/QmitkExtWorkbenchWindowAdvisor.cpp @@ -1,1433 +1,1433 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkExtWorkbenchWindowAdvisor.h" #include "QmitkExtActionBarAdvisor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // UGLYYY #include "internal/QmitkExtWorkbenchWindowAdvisorHack.h" #include "internal/QmitkCommonExtPlugin.h" #include "mitkUndoController.h" #include "mitkVerboseLimitedLinearUndo.h" #include #include #include #include #include #include QmitkExtWorkbenchWindowAdvisorHack* QmitkExtWorkbenchWindowAdvisorHack::undohack = new QmitkExtWorkbenchWindowAdvisorHack(); QString QmitkExtWorkbenchWindowAdvisor::QT_SETTINGS_FILENAME = "QtSettings.ini"; static bool USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS = false; class PartListenerForTitle: public berry::IPartListener { public: PartListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : windowAdvisor(wa) { } Events::Types GetPartEventTypes() const override { return Events::ACTIVATED | Events::BROUGHT_TO_TOP | Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void PartActivated(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref.Cast ()) { windowAdvisor->UpdateTitle(false); } } void PartBroughtToTop(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref.Cast ()) { windowAdvisor->UpdateTitle(false); } } void PartClosed(const berry::IWorkbenchPartReference::Pointer& /*ref*/) override { windowAdvisor->UpdateTitle(false); } void PartHidden(const berry::IWorkbenchPartReference::Pointer& ref) override { auto lockedLastActiveEditor = windowAdvisor->lastActiveEditor.Lock(); if (lockedLastActiveEditor.IsNotNull() && ref->GetPart(false) == lockedLastActiveEditor) { windowAdvisor->UpdateTitle(true); } } void PartVisible(const berry::IWorkbenchPartReference::Pointer& ref) override { auto lockedLastActiveEditor = windowAdvisor->lastActiveEditor.Lock(); if (lockedLastActiveEditor.IsNotNull() && ref->GetPart(false) == lockedLastActiveEditor) { windowAdvisor->UpdateTitle(false); } } private: QmitkExtWorkbenchWindowAdvisor* windowAdvisor; }; class PartListenerForViewNavigator: public berry::IPartListener { public: PartListenerForViewNavigator(QAction* act) : viewNavigatorAction(act) { } Events::Types GetPartEventTypes() const override { return Events::OPENED | Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void PartOpened(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.viewnavigator") { viewNavigatorAction->setChecked(true); } } void PartClosed(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.viewnavigator") { viewNavigatorAction->setChecked(false); } } void PartVisible(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.viewnavigator") { viewNavigatorAction->setChecked(true); } } void PartHidden(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.viewnavigator") { viewNavigatorAction->setChecked(false); } } private: QAction* viewNavigatorAction; }; class PartListenerForImageNavigator: public berry::IPartListener { public: PartListenerForImageNavigator(QAction* act) : imageNavigatorAction(act) { } Events::Types GetPartEventTypes() const override { return Events::OPENED | Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void PartOpened(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(true); } } void PartClosed(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(false); } } void PartVisible(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(true); } } void PartHidden(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(false); } } private: QAction* imageNavigatorAction; }; class PerspectiveListenerForTitle: public berry::IPerspectiveListener { public: PerspectiveListenerForTitle(QmitkExtWorkbenchWindowAdvisor* wa) : windowAdvisor(wa) , perspectivesClosed(false) { } Events::Types GetPerspectiveEventTypes() const override { if (USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS) { return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED; } else { return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED | Events::CLOSED | Events::OPENED; } } void PerspectiveActivated(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override { windowAdvisor->UpdateTitle(false); } void PerspectiveSavedAs(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*oldPerspective*/, const berry::IPerspectiveDescriptor::Pointer& /*newPerspective*/) override { windowAdvisor->UpdateTitle(false); } void PerspectiveDeactivated(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override { windowAdvisor->UpdateTitle(false); } void PerspectiveOpened(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override { if (perspectivesClosed) { QListIterator i(windowAdvisor->viewActions); while (i.hasNext()) { i.next()->setEnabled(true); } //GetViewRegistry()->Find("org.mitk.views.imagenavigator"); if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicombrowser")) { windowAdvisor->openDicomEditorAction->setEnabled(true); } if (windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.stdmultiwidget")) { windowAdvisor->openStdMultiWidgetEditorAction->setEnabled(true); } if (windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.mxnmultiwidget")) { windowAdvisor->openMxNMultiWidgetEditorAction->setEnabled(true); } windowAdvisor->fileSaveProjectAction->setEnabled(true); windowAdvisor->closeProjectAction->setEnabled(true); windowAdvisor->undoAction->setEnabled(true); windowAdvisor->redoAction->setEnabled(true); windowAdvisor->imageNavigatorAction->setEnabled(true); windowAdvisor->viewNavigatorAction->setEnabled(true); windowAdvisor->resetPerspAction->setEnabled(true); if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) { windowAdvisor->closePerspAction->setEnabled(true); } } perspectivesClosed = false; } void PerspectiveClosed(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override { berry::IWorkbenchWindow::Pointer wnd = windowAdvisor->GetWindowConfigurer()->GetWindow(); bool allClosed = true; if (wnd->GetActivePage()) { QList perspectives(wnd->GetActivePage()->GetOpenPerspectives()); allClosed = perspectives.empty(); } if (allClosed) { perspectivesClosed = true; QListIterator i(windowAdvisor->viewActions); while (i.hasNext()) { i.next()->setEnabled(false); } if(windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicombrowser")) { windowAdvisor->openDicomEditorAction->setEnabled(false); } if (windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.stdmultiwidget")) { windowAdvisor->openStdMultiWidgetEditorAction->setEnabled(false); } if (windowAdvisor->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.mxnmultiwidget")) { windowAdvisor->openMxNMultiWidgetEditorAction->setEnabled(false); } windowAdvisor->fileSaveProjectAction->setEnabled(false); windowAdvisor->closeProjectAction->setEnabled(false); windowAdvisor->undoAction->setEnabled(false); windowAdvisor->redoAction->setEnabled(false); windowAdvisor->imageNavigatorAction->setEnabled(false); windowAdvisor->viewNavigatorAction->setEnabled(false); windowAdvisor->resetPerspAction->setEnabled(false); if( windowAdvisor->GetShowClosePerspectiveMenuItem() ) { windowAdvisor->closePerspAction->setEnabled(false); } } } private: QmitkExtWorkbenchWindowAdvisor* windowAdvisor; bool perspectivesClosed; }; class PerspectiveListenerForMenu: public berry::IPerspectiveListener { public: PerspectiveListenerForMenu(QmitkExtWorkbenchWindowAdvisor* wa) : windowAdvisor(wa) { } Events::Types GetPerspectiveEventTypes() const override { return Events::ACTIVATED | Events::DEACTIVATED; } void PerspectiveActivated(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& perspective) override { QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; if (action) { action->setChecked(true); } } void PerspectiveDeactivated(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& perspective) override { QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; if (action) { action->setChecked(false); } } private: QmitkExtWorkbenchWindowAdvisor* windowAdvisor; }; QmitkExtWorkbenchWindowAdvisor::QmitkExtWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, berry::IWorkbenchWindowConfigurer::Pointer configurer) : berry::WorkbenchWindowAdvisor(configurer) , lastInput(nullptr) , wbAdvisor(wbAdvisor) , showViewToolbar(true) , showPerspectiveToolbar(false) , showVersionInfo(true) , showMitkVersionInfo(true) , showViewMenuItem(true) , showNewWindowMenuItem(false) , showClosePerspectiveMenuItem(true) , viewNavigatorFound(false) , showMemoryIndicator(true) , dropTargetListener(new QmitkDefaultDropTargetListener) { productName = QCoreApplication::applicationName(); viewExcludeList.push_back("org.mitk.views.viewnavigator"); } QmitkExtWorkbenchWindowAdvisor::~QmitkExtWorkbenchWindowAdvisor() { } berry::ActionBarAdvisor::Pointer QmitkExtWorkbenchWindowAdvisor::CreateActionBarAdvisor(berry::IActionBarConfigurer::Pointer configurer) { if (USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS) { berry::ActionBarAdvisor::Pointer actionBarAdvisor(new QmitkExtActionBarAdvisor(configurer)); return actionBarAdvisor; } else { return berry::WorkbenchWindowAdvisor::CreateActionBarAdvisor(configurer); } } QWidget* QmitkExtWorkbenchWindowAdvisor::CreateEmptyWindowContents(QWidget* parent) { QWidget* parentWidget = static_cast(parent); auto label = new QLabel(parentWidget); label->setText("No perspectives are open. Open a perspective in the Window->Open Perspective menu."); label->setContentsMargins(10,10,10,10); label->setAlignment(Qt::AlignTop); label->setEnabled(false); parentWidget->layout()->addWidget(label); return label; } void QmitkExtWorkbenchWindowAdvisor::ShowClosePerspectiveMenuItem(bool show) { showClosePerspectiveMenuItem = show; } bool QmitkExtWorkbenchWindowAdvisor::GetShowClosePerspectiveMenuItem() { return showClosePerspectiveMenuItem; } void QmitkExtWorkbenchWindowAdvisor::ShowMemoryIndicator(bool show) { showMemoryIndicator = show; } bool QmitkExtWorkbenchWindowAdvisor::GetShowMemoryIndicator() { return showMemoryIndicator; } void QmitkExtWorkbenchWindowAdvisor::ShowNewWindowMenuItem(bool show) { showNewWindowMenuItem = show; } void QmitkExtWorkbenchWindowAdvisor::ShowViewToolbar(bool show) { showViewToolbar = show; } void QmitkExtWorkbenchWindowAdvisor::ShowViewMenuItem(bool show) { showViewMenuItem = show; } void QmitkExtWorkbenchWindowAdvisor::ShowPerspectiveToolbar(bool show) { showPerspectiveToolbar = show; } void QmitkExtWorkbenchWindowAdvisor::ShowVersionInfo(bool show) { showVersionInfo = show; } void QmitkExtWorkbenchWindowAdvisor::ShowMitkVersionInfo(bool show) { showMitkVersionInfo = show; } void QmitkExtWorkbenchWindowAdvisor::SetProductName(const QString& product) { productName = product; } void QmitkExtWorkbenchWindowAdvisor::SetWindowIcon(const QString& wndIcon) { windowIcon = wndIcon; } void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate() { // very bad hack... berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = qobject_cast (window->GetShell()->GetControl()); if (!windowIcon.isEmpty()) { mainWindow->setWindowIcon(QIcon(windowIcon)); } mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); // Load icon theme QIcon::setThemeSearchPaths(QStringList() << QStringLiteral(":/org_mitk_icons/icons/")); QIcon::setThemeName(QStringLiteral("awesome")); // ==== Application menu ============================ QMenuBar* menuBar = mainWindow->menuBar(); menuBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ menuBar->setNativeMenuBar(true); #else menuBar->setNativeMenuBar(false); #endif auto basePath = QStringLiteral(":/org_mitk_icons/icons/awesome/scalable/actions/"); auto fileOpenAction = new QmitkFileOpenAction(berry::QtStyleManager::ThemeIcon(basePath + "document-open.svg"), window); fileOpenAction->setShortcut(QKeySequence::Open); auto fileSaveAction = new QmitkFileSaveAction(berry::QtStyleManager::ThemeIcon(basePath + "document-save.svg"), window); fileSaveAction->setShortcut(QKeySequence::Save); fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); fileSaveProjectAction->setIcon(berry::QtStyleManager::ThemeIcon(basePath + "document-save.svg")); closeProjectAction = new QmitkCloseProjectAction(window); closeProjectAction->setIcon(berry::QtStyleManager::ThemeIcon(basePath + "edit-delete.svg")); auto perspGroup = new QActionGroup(menuBar); std::map VDMap; // sort elements (converting vector to map...) QList::const_iterator iter; berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); const QList viewDescriptors = viewRegistry->GetViews(); bool skip = false; for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) { // if viewExcludeList is set, it contains the id-strings of view, which // should not appear as an menu-entry in the menu if (viewExcludeList.size() > 0) { for (int i=0; iGetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") continue; if ((*iter)->GetId() == "org.mitk.views.imagenavigator") continue; if ((*iter)->GetId() == "org.mitk.views.viewnavigator") continue; std::pair p((*iter)->GetLabel(), (*iter)); VDMap.insert(p); } std::map::const_iterator MapIter; for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) { berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); viewActions.push_back(viewAction); } if (!USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS) { QMenu* fileMenu = menuBar->addMenu("&File"); fileMenu->setObjectName("FileMenu"); fileMenu->addAction(fileOpenAction); fileMenu->addAction(fileSaveAction); fileMenu->addAction(fileSaveProjectAction); fileMenu->addAction(closeProjectAction); fileMenu->addSeparator(); QAction* fileExitAction = new QmitkFileExitAction(window); fileExitAction->setIcon(berry::QtStyleManager::ThemeIcon(basePath + "system-log-out.svg")); fileExitAction->setShortcut(QKeySequence::Quit); fileExitAction->setObjectName("QmitkFileExitAction"); fileMenu->addAction(fileExitAction); // another bad hack to get an edit/undo menu... QMenu* editMenu = menuBar->addMenu("&Edit"); undoAction = editMenu->addAction( berry::QtStyleManager::ThemeIcon(basePath + "edit-undo.svg"), "&Undo", QKeySequence("CTRL+Z"), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo())); undoAction->setToolTip("Undo the last action (not supported by all modules)"); redoAction = editMenu->addAction( berry::QtStyleManager::ThemeIcon(basePath + "edit-redo.svg"), "&Redo", QKeySequence("CTRL+Y"), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo())); redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); // ==== Window Menu ========================== QMenu* windowMenu = menuBar->addMenu("Window"); if (showNewWindowMenuItem) { windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow())); windowMenu->addSeparator(); } QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); QMenu* viewMenu = nullptr; if (showViewMenuItem) { viewMenu = windowMenu->addMenu("Show &View"); viewMenu->setObjectName("Show View"); } windowMenu->addSeparator(); resetPerspAction = windowMenu->addAction("&Reset Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); if(showClosePerspectiveMenuItem) closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective())); windowMenu->addSeparator(); windowMenu->addAction("&Preferences...", QKeySequence("CTRL+P"), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences())); // fill perspective menu berry::IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry(); QList perspectives( perspRegistry->GetPerspectives()); skip = false; for (QList::iterator perspIt = perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu if (perspectiveExcludeList.size() > 0) { for (int i=0; iGetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } QAction* perspAction = new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup); mapPerspIdToAction.insert((*perspIt)->GetId(), perspAction); } perspMenu->addActions(perspGroup->actions()); if (showViewMenuItem) { for (auto viewAction : std::as_const(viewActions)) { viewMenu->addAction(viewAction); } } // ===== Help menu ==================================== QMenu* helpMenu = menuBar->addMenu("&Help"); helpMenu->addAction("&Welcome",this, SLOT(onIntro())); helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective())); helpMenu->addAction("&Context Help", QKeySequence("F1"), this, SLOT(onHelp())); helpMenu->addAction("&About",this, SLOT(onAbout())); // ===================================================== } else { undoAction = new QmitkUndoAction(berry::QtStyleManager::ThemeIcon(basePath + "edit-undo.svg"), nullptr); undoAction->setShortcut(QKeySequence::Undo); redoAction = new QmitkRedoAction(berry::QtStyleManager::ThemeIcon(basePath + "edit-redo.svg"), nullptr); redoAction->setShortcut(QKeySequence::Redo); } // toolbar for showing file open, undo, redo and other main actions auto mainActionsToolBar = new QToolBar; mainActionsToolBar->setObjectName("mainActionsToolBar"); mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); #else mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); #endif basePath = QStringLiteral(":/org.mitk.gui.qt.ext/"); imageNavigatorAction = new QAction(berry::QtStyleManager::ThemeIcon(basePath + "image_navigator.svg"), "&Image Navigator", nullptr); bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); if (this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicombrowser")) { openDicomEditorAction = new QmitkOpenDicomEditorAction(berry::QtStyleManager::ThemeIcon(basePath + "dicom.svg"), window); } if (this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.stdmultiwidget")) { openStdMultiWidgetEditorAction = new QmitkOpenStdMultiWidgetEditorAction(berry::QtStyleManager::ThemeIcon(basePath + "Editor.svg"), window); } if (this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.mxnmultiwidget")) { openMxNMultiWidgetEditorAction = new QmitkOpenMxNMultiWidgetEditorAction(berry::QtStyleManager::ThemeIcon(basePath + "Editor.svg"), window); } if (imageNavigatorViewFound) { QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); imageNavigatorAction->setCheckable(true); // add part listener for image navigator imageNavigatorPartListener.reset(new PartListenerForImageNavigator(imageNavigatorAction)); window->GetPartService()->AddPartListener(imageNavigatorPartListener.data()); berry::IViewPart::Pointer imageNavigatorView = window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); imageNavigatorAction->setChecked(false); if (imageNavigatorView) { bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) imageNavigatorAction->setChecked(true); } imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image"); } viewNavigatorAction = new QAction(berry::QtStyleManager::ThemeIcon(QStringLiteral(":/org.mitk.gui.qt.ext/view-manager.svg")),"&View Navigator", nullptr); viewNavigatorFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.viewnavigator"); if (viewNavigatorFound) { QObject::connect(viewNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onViewNavigator())); viewNavigatorAction->setCheckable(true); // add part listener for view navigator viewNavigatorPartListener.reset(new PartListenerForViewNavigator(viewNavigatorAction)); window->GetPartService()->AddPartListener(viewNavigatorPartListener.data()); berry::IViewPart::Pointer viewnavigatorview = window->GetActivePage()->FindView("org.mitk.views.viewnavigator"); viewNavigatorAction->setChecked(false); if (viewnavigatorview) { bool isViewNavigatorVisible = window->GetActivePage()->IsPartVisible(viewnavigatorview); if (isViewNavigatorVisible) viewNavigatorAction->setChecked(true); } viewNavigatorAction->setToolTip("Toggle View Navigator"); } mainActionsToolBar->addAction(fileOpenAction); mainActionsToolBar->addAction(fileSaveProjectAction); mainActionsToolBar->addAction(closeProjectAction); mainActionsToolBar->addAction(undoAction); mainActionsToolBar->addAction(redoAction); if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicombrowser")) { mainActionsToolBar->addAction(openDicomEditorAction); } if (this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.stdmultiwidget")) { mainActionsToolBar->addAction(openStdMultiWidgetEditorAction); } if (this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.mxnmultiwidget")) { mainActionsToolBar->addAction(openMxNMultiWidgetEditorAction); } if (imageNavigatorViewFound) { mainActionsToolBar->addAction(imageNavigatorAction); } if (viewNavigatorFound) { mainActionsToolBar->addAction(viewNavigatorAction); } mainWindow->addToolBar(mainActionsToolBar); // ==== Perspective Toolbar ================================== auto qPerspectiveToolbar = new QToolBar; qPerspectiveToolbar->setObjectName("perspectiveToolBar"); if (showPerspectiveToolbar) { qPerspectiveToolbar->addActions(perspGroup->actions()); mainWindow->addToolBar(qPerspectiveToolbar); } else delete qPerspectiveToolbar; if (showViewToolbar) { auto* prefService = mitk::CoreServices::GetPreferencesService(); - - auto* stylePrefs = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE); - bool showCategoryNames = stylePrefs->GetBool(berry::QtPreferences::QT_SHOW_TOOLBAR_CATEGORY_NAMES, true); - auto* toolBarsPrefs = prefService->GetSystemPreferences()->Node(QmitkApplicationConstants::TOOL_BARS_PREFERENCES); + bool showCategories = toolBarsPrefs->GetBool(QmitkApplicationConstants::TOOL_BARS_SHOW_CATEGORIES, true); // Order view descriptors by category QMultiMap categoryViewDescriptorMap; for (const auto &labelViewDescriptorPair : VDMap) { auto viewDescriptor = labelViewDescriptorPair.second; auto category = !viewDescriptor->GetCategoryPath().isEmpty() ? viewDescriptor->GetCategoryPath().back() : QString(); categoryViewDescriptorMap.insert(category, viewDescriptor); } // Create a separate toolbar for each category for (const auto &category : categoryViewDescriptorMap.uniqueKeys()) { auto viewDescriptorsInCurrentCategory = categoryViewDescriptorMap.values(category); if (!viewDescriptorsInCurrentCategory.isEmpty()) { auto toolbar = new QToolBar; toolbar->setObjectName(category); mainWindow->addToolBar(toolbar); toolbar->setVisible(toolBarsPrefs->GetBool(category.toStdString(), true)); - if (showCategoryNames && !category.isEmpty()) + if (!category.isEmpty()) { auto categoryButton = new QToolButton; categoryButton->setToolButtonStyle(Qt::ToolButtonTextOnly); categoryButton->setText(category); categoryButton->setStyleSheet("background: transparent; margin: 0; padding: 0;"); - toolbar->addWidget(categoryButton); + + auto action = toolbar->addWidget(categoryButton); + action->setObjectName("category"); + action->setVisible(showCategories); connect(categoryButton, &QToolButton::clicked, [toolbar]() { for (QWidget* widget : toolbar->findChildren()) { if (QStringLiteral("qt_toolbar_ext_button") == widget->objectName() && widget->isVisible()) { QMouseEvent pressEvent(QEvent::MouseButtonPress, QPointF(0.0f, 0.0f), QCursor::pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPointF(0.0f, 0.0f), QCursor::pos(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(widget, &pressEvent); QApplication::sendEvent(widget, &releaseEvent); } } }); } for (const auto &viewDescriptor : std::as_const(viewDescriptorsInCurrentCategory)) { auto viewAction = new berry::QtShowViewAction(window, viewDescriptor); toolbar->addAction(viewAction); } } } } QSettings settings(GetQSettingsFile(), QSettings::IniFormat); mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); auto qStatusBar = new QStatusBar(); //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar auto statusBar = new QmitkStatusBar(qStatusBar); //disabling the SizeGrip in the lower right corner statusBar->SetSizeGripEnabled(false); auto progBar = new QmitkProgressBar(); qStatusBar->addPermanentWidget(progBar, 0); progBar->hide(); // progBar->AddStepsToDo(2); // progBar->Progress(1); mainWindow->setStatusBar(qStatusBar); if (showMemoryIndicator) { auto memoryIndicator = new QmitkMemoryUsageIndicatorView(); qStatusBar->addPermanentWidget(memoryIndicator, 0); } } void QmitkExtWorkbenchWindowAdvisor::PreWindowOpen() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); // show the shortcut bar and progress indicator, which are hidden by // default //configurer->SetShowPerspectiveBar(true); //configurer->SetShowFastViewBars(true); //configurer->SetShowProgressIndicator(true); // // add the drag and drop support for the editor area // configurer.addEditorAreaTransfer(EditorInputTransfer.getInstance()); // configurer.addEditorAreaTransfer(ResourceTransfer.getInstance()); // configurer.addEditorAreaTransfer(FileTransfer.getInstance()); // configurer.addEditorAreaTransfer(MarkerTransfer.getInstance()); // configurer.configureEditorAreaDropListener(new EditorAreaDropAdapter( // configurer.getWindow())); this->HookTitleUpdateListeners(configurer); menuPerspectiveListener.reset(new PerspectiveListenerForMenu(this)); configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener.data()); configurer->AddEditorAreaTransfer(QStringList("text/uri-list")); configurer->ConfigureEditorAreaDropListener(dropTargetListener.data()); } void QmitkExtWorkbenchWindowAdvisor::PostWindowOpen() { berry::WorkbenchWindowAdvisor::PostWindowOpen(); // Force Rendering Window Creation on startup. berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); ctkServiceReference serviceRef = context->getServiceReference(); if (serviceRef) { mitk::IDataStorageService *dsService = context->getService(serviceRef); if (dsService) { mitk::IDataStorageReference::Pointer dsRef = dsService->GetDataStorage(); mitk::DataStorageEditorInput::Pointer dsInput(new mitk::DataStorageEditorInput(dsRef)); mitk::WorkbenchUtil::OpenEditor(configurer->GetWindow()->GetActivePage(),dsInput); } } auto introPart = configurer->GetWindow()->GetWorkbench()->GetIntroManager()->GetIntro(); if (introPart.IsNotNull()) { configurer->GetWindow()->GetWorkbench()->GetIntroManager()->ShowIntro(GetWindowConfigurer()->GetWindow(), false); } } void QmitkExtWorkbenchWindowAdvisor::onIntro() { QmitkExtWorkbenchWindowAdvisorHack::undohack->onIntro(); } void QmitkExtWorkbenchWindowAdvisor::onHelp() { QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelp(); } void QmitkExtWorkbenchWindowAdvisor::onHelpOpenHelpPerspective() { QmitkExtWorkbenchWindowAdvisorHack::undohack->onHelpOpenHelpPerspective(); } void QmitkExtWorkbenchWindowAdvisor::onAbout() { QmitkExtWorkbenchWindowAdvisorHack::undohack->onAbout(); } //-------------------------------------------------------------------------------- // Ugly hack from here on. Feel free to delete when command framework // and undo buttons are done. //-------------------------------------------------------------------------------- QmitkExtWorkbenchWindowAdvisorHack::QmitkExtWorkbenchWindowAdvisorHack() : QObject() { } QmitkExtWorkbenchWindowAdvisorHack::~QmitkExtWorkbenchWindowAdvisorHack() { } void QmitkExtWorkbenchWindowAdvisorHack::onUndo() { mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); if (model) { if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) { mitk::VerboseLimitedLinearUndo::StackDescription descriptions = verboseundo->GetUndoDescriptions(); if (descriptions.size() >= 1) { MITK_INFO << "Undo " << descriptions.front().second; } } model->Undo(); } else { MITK_ERROR << "No undo model instantiated"; } } void QmitkExtWorkbenchWindowAdvisorHack::onRedo() { mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); if (model) { if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast( model )) { mitk::VerboseLimitedLinearUndo::StackDescription descriptions = verboseundo->GetRedoDescriptions(); if (descriptions.size() >= 1) { MITK_INFO << "Redo " << descriptions.front().second; } } model->Redo(); } else { MITK_ERROR << "No undo model instantiated"; } } // safe calls to the complete chain // berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator"); // to cover for all possible cases of closed pages etc. static void SafeHandleNavigatorView(QString view_query_name) { berry::IWorkbench* wbench = berry::PlatformUI::GetWorkbench(); if( wbench == nullptr ) return; berry::IWorkbenchWindow::Pointer wbench_window = wbench->GetActiveWorkbenchWindow(); if( wbench_window.IsNull() ) return; berry::IWorkbenchPage::Pointer wbench_page = wbench_window->GetActivePage(); if( wbench_page.IsNull() ) return; auto wbench_view = wbench_page->FindView( view_query_name ); if( wbench_view.IsNotNull() ) { bool isViewVisible = wbench_page->IsPartVisible( wbench_view ); if( isViewVisible ) { wbench_page->HideView( wbench_view ); return; } } wbench_page->ShowView( view_query_name ); } void QmitkExtWorkbenchWindowAdvisorHack::onImageNavigator() { // show/hide ImageNavigatorView SafeHandleNavigatorView("org.mitk.views.imagenavigator"); } void QmitkExtWorkbenchWindowAdvisorHack::onViewNavigator() { // show/hide viewnavigatorView SafeHandleNavigatorView("org.mitk.views.viewnavigator"); } void QmitkExtWorkbenchWindowAdvisorHack::onEditPreferences() { QmitkPreferencesDialog _PreferencesDialog(QApplication::activeWindow()); _PreferencesDialog.exec(); } void QmitkExtWorkbenchWindowAdvisorHack::onQuit() { berry::PlatformUI::GetWorkbench()->Close(); } void QmitkExtWorkbenchWindowAdvisorHack::onResetPerspective() { berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); } void QmitkExtWorkbenchWindowAdvisorHack::onClosePerspective() { berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); page->ClosePerspective(page->GetPerspective(), true, true); } void QmitkExtWorkbenchWindowAdvisorHack::onNewWindow() { berry::PlatformUI::GetWorkbench()->OpenWorkbenchWindow(nullptr); } void QmitkExtWorkbenchWindowAdvisorHack::onIntro() { if (berry::PlatformUI::GetWorkbench()->GetIntroManager()->HasIntro()) { berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), false); } } void QmitkExtWorkbenchWindowAdvisorHack::onHelp() { ctkPluginContext* context = QmitkCommonExtPlugin::getContext(); if (context == nullptr) { MITK_WARN << "Plugin context not set, unable to open context help"; return; } // Check if the org.blueberry.ui.qt.help plug-in is installed and started QList > plugins = context->getPlugins(); foreach(QSharedPointer p, plugins) { if (p->getSymbolicName() == "org.blueberry.ui.qt.help") { if (p->getState() != ctkPlugin::ACTIVE) { // try to activate the plug-in explicitly try { p->start(ctkPlugin::START_TRANSIENT); } catch (const ctkPluginException& pe) { MITK_ERROR << "Activating org.blueberry.ui.qt.help failed: " << pe.what(); return; } } } } ctkServiceReference eventAdminRef = context->getServiceReference(); ctkEventAdmin* eventAdmin = nullptr; if (eventAdminRef) { eventAdmin = context->getService(eventAdminRef); } if (eventAdmin == nullptr) { MITK_WARN << "ctkEventAdmin service not found. Unable to open context help"; } else { ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED"); eventAdmin->postEvent(ev); } } void QmitkExtWorkbenchWindowAdvisorHack::onHelpOpenHelpPerspective() { berry::PlatformUI::GetWorkbench()->ShowPerspective("org.blueberry.perspectives.help", berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); } void QmitkExtWorkbenchWindowAdvisorHack::onAbout() { auto aboutDialog = new QmitkAboutDialog(QApplication::activeWindow(), {}); aboutDialog->open(); } void QmitkExtWorkbenchWindowAdvisor::HookTitleUpdateListeners(berry::IWorkbenchWindowConfigurer::Pointer configurer) { // hook up the listeners to update the window title titlePartListener.reset(new PartListenerForTitle(this)); titlePerspectiveListener.reset(new PerspectiveListenerForTitle(this)); editorPropertyListener.reset(new berry::PropertyChangeIntAdapter< QmitkExtWorkbenchWindowAdvisor>(this, &QmitkExtWorkbenchWindowAdvisor::PropertyChange)); // configurer.getWindow().addPageListener(new IPageListener() { // public void pageActivated(IWorkbenchPage page) { // updateTitle(false); // } // // public void pageClosed(IWorkbenchPage page) { // updateTitle(false); // } // // public void pageOpened(IWorkbenchPage page) { // // do nothing // } // }); configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener.data()); configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener.data()); } QString QmitkExtWorkbenchWindowAdvisor::ComputeTitle() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); berry::IWorkbenchPage::Pointer currentPage = configurer->GetWindow()->GetActivePage(); berry::IEditorPart::Pointer activeEditor; if (currentPage) { activeEditor = lastActiveEditor.Lock(); } QString title; berry::IProduct::Pointer product = berry::Platform::GetProduct(); if (product.IsNotNull()) { title = product->GetName(); } if (title.isEmpty()) { // instead of the product name, we use a custom variable for now title = productName; } if(showMitkVersionInfo) { QString mitkVersionInfo = MITK_REVISION_DESC; if(mitkVersionInfo.isEmpty()) mitkVersionInfo = MITK_VERSION_STRING; title += " " + mitkVersionInfo; } if (showVersionInfo) { // add version informatioin QString versions = QString(" (ITK %1.%2.%3 | VTK %4.%5.%6 | Qt %7)") .arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH) .arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION) .arg(QT_VERSION_STR); title += versions; } if (currentPage) { if (activeEditor) { lastEditorTitle = activeEditor->GetTitleToolTip(); if (!lastEditorTitle.isEmpty()) title = lastEditorTitle + " - " + title; } berry::IPerspectiveDescriptor::Pointer persp = currentPage->GetPerspective(); QString label = ""; if (persp) { label = persp->GetLabel(); } berry::IAdaptable* input = currentPage->GetInput(); if (input && input != wbAdvisor->GetDefaultPageInput()) { label = currentPage->GetLabel(); } if (!label.isEmpty()) { title = label + " - " + title; } } title += " (Not for use in diagnosis or treatment of patients)"; return title; } void QmitkExtWorkbenchWindowAdvisor::RecomputeTitle() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); QString oldTitle = configurer->GetTitle(); QString newTitle = ComputeTitle(); if (newTitle != oldTitle) { configurer->SetTitle(newTitle); } } void QmitkExtWorkbenchWindowAdvisor::UpdateTitle(bool editorHidden) { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); berry::IWorkbenchWindow::Pointer window = configurer->GetWindow(); berry::IEditorPart::Pointer activeEditor; berry::IWorkbenchPage::Pointer currentPage = window->GetActivePage(); berry::IPerspectiveDescriptor::Pointer persp; berry::IAdaptable* input = nullptr; if (currentPage) { activeEditor = currentPage->GetActiveEditor(); persp = currentPage->GetPerspective(); input = currentPage->GetInput(); } if (editorHidden) { activeEditor = nullptr; } // Nothing to do if the editor hasn't changed if (activeEditor == lastActiveEditor.Lock() && currentPage == lastActivePage.Lock() && persp == lastPerspective.Lock() && input == lastInput) { return; } auto lockedLastActiveEditor = lastActiveEditor.Lock(); if (lockedLastActiveEditor.IsNotNull()) { lockedLastActiveEditor->RemovePropertyListener(editorPropertyListener.data()); } lastActiveEditor = activeEditor; lastActivePage = currentPage; lastPerspective = persp; lastInput = input; if (activeEditor) { activeEditor->AddPropertyListener(editorPropertyListener.data()); } RecomputeTitle(); } void QmitkExtWorkbenchWindowAdvisor::PropertyChange(const berry::Object::Pointer& /*source*/, int propId) { if (propId == berry::IWorkbenchPartConstants::PROP_TITLE) { auto lockedLastActiveEditor = lastActiveEditor.Lock(); if (lockedLastActiveEditor.IsNotNull()) { QString newTitle = lockedLastActiveEditor->GetPartName(); if (lastEditorTitle != newTitle) { RecomputeTitle(); } } } } void QmitkExtWorkbenchWindowAdvisor::SetPerspectiveExcludeList(const QList& v) { this->perspectiveExcludeList = v; } QList QmitkExtWorkbenchWindowAdvisor::GetPerspectiveExcludeList() { return this->perspectiveExcludeList; } void QmitkExtWorkbenchWindowAdvisor::SetViewExcludeList(const QList& v) { this->viewExcludeList = v; } QList QmitkExtWorkbenchWindowAdvisor::GetViewExcludeList() { return this->viewExcludeList; } void QmitkExtWorkbenchWindowAdvisor::PostWindowClose() { berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); auto fileName = this->GetQSettingsFile(); if (!fileName.isEmpty()) { QSettings settings(fileName, QSettings::IniFormat); settings.setValue("ToolbarPosition", mainWindow->saveState()); } } QString QmitkExtWorkbenchWindowAdvisor::GetQSettingsFile() const { QFileInfo settingsInfo = QmitkCommonExtPlugin::getContext()->getDataFile(QT_SETTINGS_FILENAME); return settingsInfo.canonicalFilePath(); } diff --git a/Plugins/org.mitk.gui.qt.flowapplication/src/internal/QmitkFlowApplicationWorkbenchWindowAdvisor.cpp b/Plugins/org.mitk.gui.qt.flowapplication/src/internal/QmitkFlowApplicationWorkbenchWindowAdvisor.cpp index 4932ae0a6d..6c4bfb14a6 100644 --- a/Plugins/org.mitk.gui.qt.flowapplication/src/internal/QmitkFlowApplicationWorkbenchWindowAdvisor.cpp +++ b/Plugins/org.mitk.gui.qt.flowapplication/src/internal/QmitkFlowApplicationWorkbenchWindowAdvisor.cpp @@ -1,1164 +1,1164 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkFlowApplicationWorkbenchWindowAdvisor.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "QmitkExtFileSaveProjectAction.h" #include #include #include #include #include #include #include #include #include #include // UGLYYY #include "QmitkFlowApplicationWorkbenchWindowAdvisorHack.h" #include "QmitkFlowApplicationPlugin.h" #include "mitkUndoController.h" #include "mitkVerboseLimitedLinearUndo.h" #include #include #include #include #include #include QmitkFlowApplicationWorkbenchWindowAdvisorHack* QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack = new QmitkFlowApplicationWorkbenchWindowAdvisorHack(); QString QmitkFlowApplicationWorkbenchWindowAdvisor::QT_SETTINGS_FILENAME = "QtSettings.ini"; class PartListenerForTitle: public berry::IPartListener { public: PartListenerForTitle(QmitkFlowApplicationWorkbenchWindowAdvisor* wa) : windowAdvisor(wa) { } Events::Types GetPartEventTypes() const override { return Events::ACTIVATED | Events::BROUGHT_TO_TOP | Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void PartActivated(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref.Cast ()) { windowAdvisor->UpdateTitle(false); } } void PartBroughtToTop(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref.Cast ()) { windowAdvisor->UpdateTitle(false); } } void PartClosed(const berry::IWorkbenchPartReference::Pointer& /*ref*/) override { windowAdvisor->UpdateTitle(false); } void PartHidden(const berry::IWorkbenchPartReference::Pointer& ref) override { auto lockedLastActiveEditor = windowAdvisor->lastActiveEditor.Lock(); if (lockedLastActiveEditor.IsNotNull() && ref->GetPart(false) == lockedLastActiveEditor) { windowAdvisor->UpdateTitle(true); } } void PartVisible(const berry::IWorkbenchPartReference::Pointer& ref) override { auto lockedLastActiveEditor = windowAdvisor->lastActiveEditor.Lock(); if (lockedLastActiveEditor.IsNotNull() && ref->GetPart(false) == lockedLastActiveEditor) { windowAdvisor->UpdateTitle(false); } } private: QmitkFlowApplicationWorkbenchWindowAdvisor* windowAdvisor; }; class PartListenerForImageNavigator: public berry::IPartListener { public: PartListenerForImageNavigator(QAction* act) : imageNavigatorAction(act) { } Events::Types GetPartEventTypes() const override { return Events::OPENED | Events::CLOSED | Events::HIDDEN | Events::VISIBLE; } void PartOpened(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(true); } } void PartClosed(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(false); } } void PartVisible(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(true); } } void PartHidden(const berry::IWorkbenchPartReference::Pointer& ref) override { if (ref->GetId()=="org.mitk.views.imagenavigator") { imageNavigatorAction->setChecked(false); } } private: QAction* imageNavigatorAction; }; class PerspectiveListenerForTitle: public berry::IPerspectiveListener { public: PerspectiveListenerForTitle(QmitkFlowApplicationWorkbenchWindowAdvisor* wa) : windowAdvisor(wa) , perspectivesClosed(false) { } Events::Types GetPerspectiveEventTypes() const override { return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED | Events::CLOSED | Events::OPENED; } void PerspectiveActivated(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override { windowAdvisor->UpdateTitle(false); } void PerspectiveSavedAs(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*oldPerspective*/, const berry::IPerspectiveDescriptor::Pointer& /*newPerspective*/) override { windowAdvisor->UpdateTitle(false); } void PerspectiveDeactivated(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override { windowAdvisor->UpdateTitle(false); } void PerspectiveOpened(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override { if (perspectivesClosed) { QListIterator i(windowAdvisor->viewActions); while (i.hasNext()) { i.next()->setEnabled(true); } windowAdvisor->fileSaveProjectAction->setEnabled(true); windowAdvisor->undoAction->setEnabled(true); windowAdvisor->redoAction->setEnabled(true); windowAdvisor->imageNavigatorAction->setEnabled(true); windowAdvisor->resetPerspAction->setEnabled(true); } perspectivesClosed = false; } void PerspectiveClosed(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override { berry::IWorkbenchWindow::Pointer wnd = windowAdvisor->GetWindowConfigurer()->GetWindow(); bool allClosed = true; if (wnd->GetActivePage()) { QList perspectives(wnd->GetActivePage()->GetOpenPerspectives()); allClosed = perspectives.empty(); } if (allClosed) { perspectivesClosed = true; QListIterator i(windowAdvisor->viewActions); while (i.hasNext()) { i.next()->setEnabled(false); } windowAdvisor->fileSaveProjectAction->setEnabled(false); windowAdvisor->undoAction->setEnabled(false); windowAdvisor->redoAction->setEnabled(false); windowAdvisor->imageNavigatorAction->setEnabled(false); windowAdvisor->resetPerspAction->setEnabled(false); } } private: QmitkFlowApplicationWorkbenchWindowAdvisor* windowAdvisor; bool perspectivesClosed; }; class PerspectiveListenerForMenu: public berry::IPerspectiveListener { public: PerspectiveListenerForMenu(QmitkFlowApplicationWorkbenchWindowAdvisor* wa) : windowAdvisor(wa) { } Events::Types GetPerspectiveEventTypes() const override { return Events::ACTIVATED | Events::DEACTIVATED; } void PerspectiveActivated(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& perspective) override { QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; if (action) { action->setChecked(true); } } void PerspectiveDeactivated(const berry::IWorkbenchPage::Pointer& /*page*/, const berry::IPerspectiveDescriptor::Pointer& perspective) override { QAction* action = windowAdvisor->mapPerspIdToAction[perspective->GetId()]; if (action) { action->setChecked(false); } } private: QmitkFlowApplicationWorkbenchWindowAdvisor* windowAdvisor; }; QmitkFlowApplicationWorkbenchWindowAdvisor::QmitkFlowApplicationWorkbenchWindowAdvisor(berry::WorkbenchAdvisor* wbAdvisor, berry::IWorkbenchWindowConfigurer::Pointer configurer) : berry::WorkbenchWindowAdvisor(configurer) , lastInput(nullptr) , wbAdvisor(wbAdvisor) , showViewToolbar(true) , showVersionInfo(true) , showMitkVersionInfo(true) , showMemoryIndicator(true) , dropTargetListener(new QmitkDefaultDropTargetListener) { productName = QCoreApplication::applicationName(); viewExcludeList.push_back("org.mitk.views.viewnavigator"); } QmitkFlowApplicationWorkbenchWindowAdvisor::~QmitkFlowApplicationWorkbenchWindowAdvisor() { } QWidget* QmitkFlowApplicationWorkbenchWindowAdvisor::CreateEmptyWindowContents(QWidget* parent) { QWidget* parentWidget = static_cast(parent); auto label = new QLabel(parentWidget); label->setText("No perspectives are open. Open a perspective in the Window->Open Perspective menu."); label->setContentsMargins(10,10,10,10); label->setAlignment(Qt::AlignTop); label->setEnabled(false); parentWidget->layout()->addWidget(label); return label; } void QmitkFlowApplicationWorkbenchWindowAdvisor::ShowMemoryIndicator(bool show) { showMemoryIndicator = show; } bool QmitkFlowApplicationWorkbenchWindowAdvisor::GetShowMemoryIndicator() { return showMemoryIndicator; } void QmitkFlowApplicationWorkbenchWindowAdvisor::ShowViewToolbar(bool show) { showViewToolbar = show; } void QmitkFlowApplicationWorkbenchWindowAdvisor::ShowVersionInfo(bool show) { showVersionInfo = show; } void QmitkFlowApplicationWorkbenchWindowAdvisor::ShowMitkVersionInfo(bool show) { showMitkVersionInfo = show; } void QmitkFlowApplicationWorkbenchWindowAdvisor::SetProductName(const QString& product) { productName = product; } void QmitkFlowApplicationWorkbenchWindowAdvisor::SetWindowIcon(const QString& wndIcon) { windowIcon = wndIcon; } void QmitkFlowApplicationWorkbenchWindowAdvisor::PostWindowCreate() { // very bad hack... berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = qobject_cast (window->GetShell()->GetControl()); if (!windowIcon.isEmpty()) { mainWindow->setWindowIcon(QIcon(windowIcon)); } mainWindow->setContextMenuPolicy(Qt::PreventContextMenu); // Load icon theme QIcon::setThemeSearchPaths(QStringList() << QStringLiteral(":/org_mitk_icons/icons/")); QIcon::setThemeName(QStringLiteral("awesome")); // ==== Application menu ============================ QMenuBar* menuBar = mainWindow->menuBar(); menuBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ menuBar->setNativeMenuBar(true); #else menuBar->setNativeMenuBar(false); #endif auto basePath = QStringLiteral(":/org_mitk_icons/icons/awesome/scalable/actions/"); fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window); fileSaveProjectAction->setIcon(berry::QtStyleManager::ThemeIcon(basePath + "document-save.svg")); auto perspGroup = new QActionGroup(menuBar); std::map VDMap; // sort elements (converting vector to map...) QList::const_iterator iter; berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); const QList viewDescriptors = viewRegistry->GetViews(); bool skip = false; for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter) { // if viewExcludeList is set, it contains the id-strings of view, which // should not appear as an menu-entry in the menu if (viewExcludeList.size() > 0) { for (int i=0; iGetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } if ((*iter)->GetId() == "org.blueberry.ui.internal.introview") continue; if ((*iter)->GetId() == "org.mitk.views.imagenavigator") continue; if ((*iter)->GetId() == "org.mitk.views.viewnavigator") continue; std::pair p((*iter)->GetLabel(), (*iter)); VDMap.insert(p); } std::map::const_iterator MapIter; for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter) { berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window, (*MapIter).second); viewActions.push_back(viewAction); } QMenu* fileMenu = menuBar->addMenu("&File"); fileMenu->setObjectName("FileMenu"); fileMenu->addAction(fileSaveProjectAction); fileMenu->addSeparator(); QAction* fileExitAction = new QmitkFileExitAction(window); fileExitAction->setIcon(berry::QtStyleManager::ThemeIcon(basePath + "system-log-out.svg")); fileExitAction->setShortcut(QKeySequence::Quit); fileExitAction->setObjectName("QmitkFileExitAction"); fileMenu->addAction(fileExitAction); // another bad hack to get an edit/undo menu... QMenu* editMenu = menuBar->addMenu("&Edit"); undoAction = editMenu->addAction(berry::QtStyleManager::ThemeIcon(basePath + "edit-undo.svg"), "&Undo", QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()), QKeySequence("CTRL+Z")); undoAction->setToolTip("Undo the last action (not supported by all modules)"); redoAction = editMenu->addAction(berry::QtStyleManager::ThemeIcon(basePath + "edit-redo.svg"), "&Redo", QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()), QKeySequence("CTRL+Y")); redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)"); // ==== Window Menu ========================== QMenu* windowMenu = menuBar->addMenu("Window"); QMenu* perspMenu = windowMenu->addMenu("&Open Perspective"); windowMenu->addSeparator(); resetPerspAction = windowMenu->addAction("&Reset Perspective", QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective())); windowMenu->addSeparator(); windowMenu->addAction("&Preferences...", QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()), QKeySequence("CTRL+P")); // fill perspective menu berry::IPerspectiveRegistry* perspRegistry = window->GetWorkbench()->GetPerspectiveRegistry(); QList perspectives( perspRegistry->GetPerspectives()); skip = false; for (QList::iterator perspIt = perspectives.begin(); perspIt != perspectives.end(); ++perspIt) { // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which // should not appear as an menu-entry in the perspective menu if (perspectiveExcludeList.size() > 0) { for (int i=0; iGetId()) { skip = true; break; } } if (skip) { skip = false; continue; } } QAction* perspAction = new berry::QtOpenPerspectiveAction(window, *perspIt, perspGroup); mapPerspIdToAction.insert((*perspIt)->GetId(), perspAction); } perspMenu->addActions(perspGroup->actions()); // ===== Help menu ==================================== QMenu* helpMenu = menuBar->addMenu("&Help"); helpMenu->addAction("&Welcome",this, SLOT(onIntro())); helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective())); helpMenu->addAction("&Context Help",this, SLOT(onHelp()), QKeySequence("F1")); helpMenu->addAction("&About",this, SLOT(onAbout())); // ===================================================== // toolbar for showing file open, undo, redo and other main actions auto mainActionsToolBar = new QToolBar; mainActionsToolBar->setObjectName("mainActionsToolBar"); mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu); #ifdef __APPLE__ mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon ); #else mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon ); #endif basePath = QStringLiteral(":/org.mitk.gui.qt.ext/"); imageNavigatorAction = new QAction(berry::QtStyleManager::ThemeIcon(basePath + "image_navigator.svg"), "&Image Navigator", nullptr); bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator"); if (imageNavigatorViewFound) { QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator())); imageNavigatorAction->setCheckable(true); // add part listener for image navigator imageNavigatorPartListener.reset(new PartListenerForImageNavigator(imageNavigatorAction)); window->GetPartService()->AddPartListener(imageNavigatorPartListener.data()); berry::IViewPart::Pointer imageNavigatorView = window->GetActivePage()->FindView("org.mitk.views.imagenavigator"); imageNavigatorAction->setChecked(false); if (imageNavigatorView) { bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView); if (isImageNavigatorVisible) imageNavigatorAction->setChecked(true); } imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image"); } mainActionsToolBar->addAction(undoAction); mainActionsToolBar->addAction(redoAction); if (imageNavigatorViewFound) { mainActionsToolBar->addAction(imageNavigatorAction); } mainWindow->addToolBar(mainActionsToolBar); // ==== View Toolbar ================================== if (showViewToolbar) { auto* prefService = mitk::CoreServices::GetPreferencesService(); - - auto* stylePrefs = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE); - bool showCategoryNames = stylePrefs->GetBool(berry::QtPreferences::QT_SHOW_TOOLBAR_CATEGORY_NAMES, true); - auto* toolBarsPrefs = prefService->GetSystemPreferences()->Node(QmitkApplicationConstants::TOOL_BARS_PREFERENCES); + bool showCategories = toolBarsPrefs->GetBool(QmitkApplicationConstants::TOOL_BARS_SHOW_CATEGORIES, true); // Order view descriptors by category QMultiMap categoryViewDescriptorMap; for (auto labelViewDescriptorPair : VDMap) { auto viewDescriptor = labelViewDescriptorPair.second; auto category = !viewDescriptor->GetCategoryPath().isEmpty() ? viewDescriptor->GetCategoryPath().back() : QString(); categoryViewDescriptorMap.insert(category, viewDescriptor); } // Create a separate toolbar for each category for (auto category : categoryViewDescriptorMap.uniqueKeys()) { auto viewDescriptorsInCurrentCategory = categoryViewDescriptorMap.values(category); QList > relevantViewDescriptors; for (auto viewDescriptor : viewDescriptorsInCurrentCategory) { if (viewDescriptor->GetId() != "org.mitk.views.flow.control" && viewDescriptor->GetId() != "org.mitk.views.segmentationtasklist") { relevantViewDescriptors.push_back(viewDescriptor); } } if (!relevantViewDescriptors.isEmpty()) { auto toolbar = new QToolBar; toolbar->setObjectName(category); mainWindow->addToolBar(toolbar); toolbar->setVisible(toolBarsPrefs->GetBool(category.toStdString(), true)); - if (showCategoryNames && !category.isEmpty()) + if (!category.isEmpty()) { auto categoryButton = new QToolButton; categoryButton->setToolButtonStyle(Qt::ToolButtonTextOnly); categoryButton->setText(category); categoryButton->setStyleSheet("background: transparent; margin: 0; padding: 0;"); - toolbar->addWidget(categoryButton); + + auto action = toolbar->addWidget(categoryButton); + action->setObjectName("category"); + action->setVisible(showCategories); connect(categoryButton, &QToolButton::clicked, [toolbar]() { for (QWidget* widget : toolbar->findChildren()) { if (QStringLiteral("qt_toolbar_ext_button") == widget->objectName() && widget->isVisible()) { QMouseEvent pressEvent(QEvent::MouseButtonPress, QPointF(0.0f, 0.0f), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPointF(0.0f, 0.0f), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); QApplication::sendEvent(widget, &pressEvent); QApplication::sendEvent(widget, &releaseEvent); } } }); } for (auto viewDescriptor : relevantViewDescriptors) { auto viewAction = new berry::QtShowViewAction(window, viewDescriptor); toolbar->addAction(viewAction); } } } } QSettings settings(GetQSettingsFile(), QSettings::IniFormat); mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray()); auto qStatusBar = new QStatusBar(); //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar auto statusBar = new QmitkStatusBar(qStatusBar); //disabling the SizeGrip in the lower right corner statusBar->SetSizeGripEnabled(false); auto progBar = new QmitkProgressBar(); qStatusBar->addPermanentWidget(progBar, 0); progBar->hide(); mainWindow->setStatusBar(qStatusBar); if (showMemoryIndicator) { auto memoryIndicator = new QmitkMemoryUsageIndicatorView(); qStatusBar->addPermanentWidget(memoryIndicator, 0); } } void QmitkFlowApplicationWorkbenchWindowAdvisor::PreWindowOpen() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); this->HookTitleUpdateListeners(configurer); menuPerspectiveListener.reset(new PerspectiveListenerForMenu(this)); configurer->GetWindow()->AddPerspectiveListener(menuPerspectiveListener.data()); configurer->AddEditorAreaTransfer(QStringList("text/uri-list")); configurer->ConfigureEditorAreaDropListener(dropTargetListener.data()); } void QmitkFlowApplicationWorkbenchWindowAdvisor::PostWindowOpen() { berry::WorkbenchWindowAdvisor::PostWindowOpen(); // Force Rendering Window Creation on startup. berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); ctkPluginContext* context = QmitkFlowApplicationPlugin::GetDefault()->GetPluginContext(); ctkServiceReference serviceRef = context->getServiceReference(); if (serviceRef) { mitk::IDataStorageService *dsService = context->getService(serviceRef); if (dsService) { mitk::IDataStorageReference::Pointer dsRef = dsService->GetDataStorage(); mitk::DataStorageEditorInput::Pointer dsInput(new mitk::DataStorageEditorInput(dsRef)); mitk::WorkbenchUtil::OpenEditor(configurer->GetWindow()->GetActivePage(),dsInput); } } } void QmitkFlowApplicationWorkbenchWindowAdvisor::onIntro() { QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack->onIntro(); } void QmitkFlowApplicationWorkbenchWindowAdvisor::onHelp() { QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack->onHelp(); } void QmitkFlowApplicationWorkbenchWindowAdvisor::onHelpOpenHelpPerspective() { QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack->onHelpOpenHelpPerspective(); } void QmitkFlowApplicationWorkbenchWindowAdvisor::onAbout() { QmitkFlowApplicationWorkbenchWindowAdvisorHack::undohack->onAbout(); } void QmitkFlowApplicationWorkbenchWindowAdvisor::HookTitleUpdateListeners(berry::IWorkbenchWindowConfigurer::Pointer configurer) { // hook up the listeners to update the window title titlePartListener.reset(new PartListenerForTitle(this)); titlePerspectiveListener.reset(new PerspectiveListenerForTitle(this)); editorPropertyListener.reset(new berry::PropertyChangeIntAdapter< QmitkFlowApplicationWorkbenchWindowAdvisor>(this, &QmitkFlowApplicationWorkbenchWindowAdvisor::PropertyChange)); configurer->GetWindow()->AddPerspectiveListener(titlePerspectiveListener.data()); configurer->GetWindow()->GetPartService()->AddPartListener(titlePartListener.data()); } QString QmitkFlowApplicationWorkbenchWindowAdvisor::ComputeTitle() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); berry::IWorkbenchPage::Pointer currentPage = configurer->GetWindow()->GetActivePage(); berry::IEditorPart::Pointer activeEditor; if (currentPage) { activeEditor = lastActiveEditor.Lock(); } QString title; berry::IProduct::Pointer product = berry::Platform::GetProduct(); if (product.IsNotNull()) { title = product->GetName(); } if (title.isEmpty()) { // instead of the product name, we use a custom variable for now title = productName; } if(showMitkVersionInfo) { QString mitkVersionInfo = MITK_REVISION_DESC; if(mitkVersionInfo.isEmpty()) mitkVersionInfo = MITK_VERSION_STRING; title += " " + mitkVersionInfo; } if (showVersionInfo) { // add version informatioin QString versions = QString(" (ITK %1.%2.%3 | VTK %4.%5.%6 | Qt %7)") .arg(ITK_VERSION_MAJOR).arg(ITK_VERSION_MINOR).arg(ITK_VERSION_PATCH) .arg(VTK_MAJOR_VERSION).arg(VTK_MINOR_VERSION).arg(VTK_BUILD_VERSION) .arg(QT_VERSION_STR); title += versions; } if (currentPage) { if (activeEditor) { lastEditorTitle = activeEditor->GetTitleToolTip(); if (!lastEditorTitle.isEmpty()) title = lastEditorTitle + " - " + title; } berry::IPerspectiveDescriptor::Pointer persp = currentPage->GetPerspective(); QString label = ""; if (persp) { label = persp->GetLabel(); } berry::IAdaptable* input = currentPage->GetInput(); if (input && input != wbAdvisor->GetDefaultPageInput()) { label = currentPage->GetLabel(); } if (!label.isEmpty()) { title = label + " - " + title; } } title += " (Not for use in diagnosis or treatment of patients)"; return title; } void QmitkFlowApplicationWorkbenchWindowAdvisor::RecomputeTitle() { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); QString oldTitle = configurer->GetTitle(); QString newTitle = ComputeTitle(); if (newTitle != oldTitle) { configurer->SetTitle(newTitle); } } void QmitkFlowApplicationWorkbenchWindowAdvisor::UpdateTitle(bool editorHidden) { berry::IWorkbenchWindowConfigurer::Pointer configurer = GetWindowConfigurer(); berry::IWorkbenchWindow::Pointer window = configurer->GetWindow(); berry::IEditorPart::Pointer activeEditor; berry::IWorkbenchPage::Pointer currentPage = window->GetActivePage(); berry::IPerspectiveDescriptor::Pointer persp; berry::IAdaptable* input = nullptr; if (currentPage) { activeEditor = currentPage->GetActiveEditor(); persp = currentPage->GetPerspective(); input = currentPage->GetInput(); } if (editorHidden) { activeEditor = nullptr; } // Nothing to do if the editor hasn't changed if (activeEditor == lastActiveEditor.Lock() && currentPage == lastActivePage.Lock() && persp == lastPerspective.Lock() && input == lastInput) { return; } auto lockedLastActiveEditor = lastActiveEditor.Lock(); if (lockedLastActiveEditor.IsNotNull()) { lockedLastActiveEditor->RemovePropertyListener(editorPropertyListener.data()); } lastActiveEditor = activeEditor; lastActivePage = currentPage; lastPerspective = persp; lastInput = input; if (activeEditor) { activeEditor->AddPropertyListener(editorPropertyListener.data()); } RecomputeTitle(); } void QmitkFlowApplicationWorkbenchWindowAdvisor::PropertyChange(const berry::Object::Pointer& /*source*/, int propId) { if (propId == berry::IWorkbenchPartConstants::PROP_TITLE) { auto lockedLastActiveEditor = lastActiveEditor.Lock(); if (lockedLastActiveEditor.IsNotNull()) { QString newTitle = lockedLastActiveEditor->GetPartName(); if (lastEditorTitle != newTitle) { RecomputeTitle(); } } } } void QmitkFlowApplicationWorkbenchWindowAdvisor::SetPerspectiveExcludeList(const QList& v) { this->perspectiveExcludeList = v; } QList QmitkFlowApplicationWorkbenchWindowAdvisor::GetPerspectiveExcludeList() { return this->perspectiveExcludeList; } void QmitkFlowApplicationWorkbenchWindowAdvisor::SetViewExcludeList(const QList& v) { this->viewExcludeList = v; } QList QmitkFlowApplicationWorkbenchWindowAdvisor::GetViewExcludeList() { return this->viewExcludeList; } void QmitkFlowApplicationWorkbenchWindowAdvisor::PostWindowClose() { berry::IWorkbenchWindow::Pointer window = this->GetWindowConfigurer()->GetWindow(); QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); auto fileName = this->GetQSettingsFile(); if (!fileName.isEmpty()) { QSettings settings(fileName, QSettings::IniFormat); settings.setValue("ToolbarPosition", mainWindow->saveState()); } } QString QmitkFlowApplicationWorkbenchWindowAdvisor::GetQSettingsFile() const { QFileInfo settingsInfo = QmitkFlowApplicationPlugin::GetDefault()->GetPluginContext()->getDataFile(QT_SETTINGS_FILENAME); return settingsInfo.canonicalFilePath(); } //-------------------------------------------------------------------------------- // Ugly hack from here on. Feel free to delete when command framework // and undo buttons are done. //-------------------------------------------------------------------------------- QmitkFlowApplicationWorkbenchWindowAdvisorHack::QmitkFlowApplicationWorkbenchWindowAdvisorHack() : QObject() { } QmitkFlowApplicationWorkbenchWindowAdvisorHack::~QmitkFlowApplicationWorkbenchWindowAdvisorHack() { } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onUndo() { mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); if (model) { if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast(model)) { mitk::VerboseLimitedLinearUndo::StackDescription descriptions = verboseundo->GetUndoDescriptions(); if (descriptions.size() >= 1) { MITK_INFO << "Undo " << descriptions.front().second; } } model->Undo(); } else { MITK_ERROR << "No undo model instantiated"; } } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onRedo() { mitk::UndoModel* model = mitk::UndoController::GetCurrentUndoModel(); if (model) { if (mitk::VerboseLimitedLinearUndo* verboseundo = dynamic_cast(model)) { mitk::VerboseLimitedLinearUndo::StackDescription descriptions = verboseundo->GetRedoDescriptions(); if (descriptions.size() >= 1) { MITK_INFO << "Redo " << descriptions.front().second; } } model->Redo(); } else { MITK_ERROR << "No undo model instantiated"; } } // safe calls to the complete chain // berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->FindView("org.mitk.views.imagenavigator"); // to cover for all possible cases of closed pages etc. static void SafeHandleNavigatorView(QString view_query_name) { berry::IWorkbench* wbench = berry::PlatformUI::GetWorkbench(); if (wbench == nullptr) return; berry::IWorkbenchWindow::Pointer wbench_window = wbench->GetActiveWorkbenchWindow(); if (wbench_window.IsNull()) return; berry::IWorkbenchPage::Pointer wbench_page = wbench_window->GetActivePage(); if (wbench_page.IsNull()) return; auto wbench_view = wbench_page->FindView(view_query_name); if (wbench_view.IsNotNull()) { bool isViewVisible = wbench_page->IsPartVisible(wbench_view); if (isViewVisible) { wbench_page->HideView(wbench_view); return; } } wbench_page->ShowView(view_query_name); } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onImageNavigator() { // show/hide ImageNavigatorView SafeHandleNavigatorView("org.mitk.views.imagenavigator"); } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onEditPreferences() { QmitkPreferencesDialog _PreferencesDialog(QApplication::activeWindow()); _PreferencesDialog.exec(); } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onQuit() { berry::PlatformUI::GetWorkbench()->Close(); } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onResetPerspective() { berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage()->ResetPerspective(); } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onClosePerspective() { berry::IWorkbenchPage::Pointer page = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); page->ClosePerspective(page->GetPerspective(), true, true); } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onIntro() { bool hasIntro = berry::PlatformUI::GetWorkbench()->GetIntroManager()->HasIntro(); if (!hasIntro) { QRegularExpression reg("(.*)(\\n)*"); QRegularExpression reg2("(\\n)*(.*)"); QFile file(":/org.mitk.gui.qt.ext/index.html"); file.open(QIODevice::ReadOnly | QIODevice::Text); //text file only for reading QString text = QString(file.readAll()); file.close(); QString title = text; title.replace(reg, ""); title.replace(reg2, ""); std::cout << title.toStdString() << std::endl; QMessageBox::information(nullptr, title, text, "Close"); } else { berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(), false); } } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onHelp() { ctkPluginContext* context = QmitkFlowApplicationPlugin::GetDefault()->GetPluginContext(); if (context == nullptr) { MITK_WARN << "Plugin context not set, unable to open context help"; return; } // Check if the org.blueberry.ui.qt.help plug-in is installed and started QList > plugins = context->getPlugins(); foreach(QSharedPointer p, plugins) { if (p->getSymbolicName() == "org.blueberry.ui.qt.help") { if (p->getState() != ctkPlugin::ACTIVE) { // try to activate the plug-in explicitly try { p->start(ctkPlugin::START_TRANSIENT); } catch (const ctkPluginException& pe) { MITK_ERROR << "Activating org.blueberry.ui.qt.help failed: " << pe.what(); return; } } } } ctkServiceReference eventAdminRef = context->getServiceReference(); ctkEventAdmin* eventAdmin = nullptr; if (eventAdminRef) { eventAdmin = context->getService(eventAdminRef); } if (eventAdmin == nullptr) { MITK_WARN << "ctkEventAdmin service not found. Unable to open context help"; } else { ctkEvent ev("org/blueberry/ui/help/CONTEXTHELP_REQUESTED"); eventAdmin->postEvent(ev); } } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onHelpOpenHelpPerspective() { berry::PlatformUI::GetWorkbench()->ShowPerspective("org.blueberry.perspectives.help", berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); } void QmitkFlowApplicationWorkbenchWindowAdvisorHack::onAbout() { auto aboutDialog = new QmitkAboutDialog(QApplication::activeWindow()); aboutDialog->open(); } diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/CMakeLists.txt b/Plugins/org.mitk.gui.qt.viewnavigator/CMakeLists.txt index a759507265..205e7b49fd 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/CMakeLists.txt +++ b/Plugins/org.mitk.gui.qt.viewnavigator/CMakeLists.txt @@ -1,7 +1,6 @@ project(org_mitk_gui_qt_viewnavigator) mitk_create_plugin( EXPORT_DIRECTIVE VIEWNAVIGATOR_EXPORT EXPORTED_INCLUDE_SUFFIXES src - MODULE_DEPENDS MitkQtWidgetsExt ) diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigator.dox b/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigator.dox index 15584ad31d..adcbae6588 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigator.dox +++ b/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigator.dox @@ -1,43 +1,16 @@ /** \page org_mitk_views_viewnavigator The View Navigator -\imageMacro{view-manager.png,"Icon of the view navigator",2.00} - -\tableofcontents +\imageMacro{view-manager.png, "Icon of the view navigator", 2.00} \section org_mitk_views_viewnavigatorOverview Overview -This view allows for the easy navigation of the available views. - -You can select which view to open by double-clicking the name of the view in the view navigator. It provides a keyworded, grouped and searchable list of views. - -\section org_mitk_views_viewnavigatorUsage Usage - -You can toggle the View Navigator on and off by clicking on its icon in the menu bar. Alternatively it is also available via the Window->Show Views dialog. - -\imageMacro{QmitkViewNavigatorGUI.png,"The View Navigator GUI",6.00} - -Once the View Navigator has been opened you will see a list divided in workflows/perspectives and views. Via this list you can access any view or perspective provided by the application. They are further organized based on their associated category. - -An entry on the list is opened by a double left-click. - -\subsection org_mitk_views_viewnavigatorSearch Search - -You can search the lists for view/workflow names, keywords or categories. - -\imageMacro{QmitkViewNavigatorSearch.png,"Search the View Navigator",4.00} - -\subsection org_mitk_views_viewnavigatorCustomWorkflows Custom Workflows - -\imageMacro{QmitkViewNavigatorContextMenuWorkflows.png,"The workflow context menu",4.00} - -A right click on a workflow opens a context menu that allows you to copy that workflow to create your own custom one. -\note The duplicated workflow will look like the basic state of the original workflow. Any changes to the original workflow will not be copied. - -\imageMacro{QmitkViewNavigatorNewWorkflow.png,"Custom workflow creation dialog",4.00} +The View Navigator allows for easy navigation of available views. +To open a view, double-click on it in the grouped and searchable list of views. -Your new workflow will appear in the list and you can modify it independently of the original workflow. Any changes will be stored for future sessions unless the workflow is deleted. -\note Resetting a custom perspective will return it to the original state after duplicating. +Some views are tagged with certain keywords behind the scenes, which are considered when searching for views. +Hence, also try typing the action you want to perform. +For example, typing in "thres" will already reduce the list of shown views to a small subset including the Segmentation view, as it provides thresholding as functionality. -\imageMacro{QmitkViewNavigatorContextMenuCustomWorkflow.png,"Custom workflow context menu",4.00} +The visibility of view/tool bar categories can be set in the preferences, which will not only show or hide their tool bar but also their entry in the View Navigator. */ diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorContextMenuCustomWorkflow.png b/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorContextMenuCustomWorkflow.png deleted file mode 100644 index ae0c73fd45..0000000000 Binary files a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorContextMenuCustomWorkflow.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorContextMenuWorkflows.png b/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorContextMenuWorkflows.png deleted file mode 100644 index 35e2689844..0000000000 Binary files a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorContextMenuWorkflows.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorGUI.png b/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorGUI.png deleted file mode 100644 index d72d37ba82..0000000000 Binary files a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorGUI.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorNewWorkflow.png b/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorNewWorkflow.png deleted file mode 100644 index a94adc04f9..0000000000 Binary files a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorNewWorkflow.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorSearch.png b/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorSearch.png deleted file mode 100644 index ae0c8e6378..0000000000 Binary files a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/UserManual/QmitkViewNavigatorSearch.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/doxygen/modules.dox b/Plugins/org.mitk.gui.qt.viewnavigator/documentation/doxygen/modules.dox deleted file mode 100644 index 52de3fc0c2..0000000000 --- a/Plugins/org.mitk.gui.qt.viewnavigator/documentation/doxygen/modules.dox +++ /dev/null @@ -1,16 +0,0 @@ -/** - \defgroup org_mitk_gui_qt_viewnavigator org.mitk.gui.qt.viewnavigator - \ingroup MITKPlugins - - \brief Describe your plugin here. - -*/ - -/** - \defgroup org_mitk_gui_qt_viewnavigator_internal Internal - \ingroup org_mitk_gui_qt_viewnavigator - - \brief This subcategory includes the internal classes of the org.mitk.gui.qt.viewnavigator plugin. Other - plugins must not rely on these classes. They contain implementation details and their interface - may change at any time. We mean it. -*/ diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/files.cmake b/Plugins/org.mitk.gui.qt.viewnavigator/files.cmake index a4e8dac4c9..31ef356114 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/files.cmake +++ b/Plugins/org.mitk.gui.qt.viewnavigator/files.cmake @@ -1,45 +1,26 @@ -set(SRC_CPP_FILES - QmitkViewNavigatorWidget.cpp - QmitkPerspectiveItem.h - QmitkViewItem.h +set(CPP_FILES + src/internal/mitkPluginActivator.cpp + src/QmitkCategoryItem.cpp + src/QmitkCategoryItem.h + src/QmitkViewItem.cpp + src/QmitkViewItem.h + src/QmitkViewNavigatorView.cpp + src/QmitkViewModel.cpp + src/QmitkViewModel.h + src/QmitkViewProxyModel.cpp + src/QmitkViewProxyModel.h ) -set(INTERNAL_CPP_FILES - mitkPluginActivator.cpp - QmitkViewNavigatorView.cpp +set(MOC_H_FILES + src/internal/mitkPluginActivator.h + src/QmitkViewNavigatorView.h ) set(UI_FILES - src/QmitkViewNavigatorWidgetControls.ui -) - -set(MOC_H_FILES - src/internal/mitkPluginActivator.h - src/internal/QmitkViewNavigatorView.h - src/QmitkViewNavigatorWidget.h + src/QmitkViewNavigatorView.ui ) -# list of resource files which can be used by the plug-in -# system without loading the plug-ins shared library, -# for example the icon used in the menu and tabs for the -# plug-in views in the workbench set(CACHED_RESOURCE_FILES resources/view-manager.svg plugin.xml ) - -# list of Qt .qrc files which contain additional resources -# specific to this plugin -set(QRC_FILES - -) - -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/Plugins/org.mitk.gui.qt.viewnavigator/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.viewnavigator/manifest_headers.cmake index 5fcab65742..b2b03c1ba2 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/manifest_headers.cmake +++ b/Plugins/org.mitk.gui.qt.viewnavigator/manifest_headers.cmake @@ -1,5 +1,9 @@ set(Plugin-Name "View Navigator") set(Plugin-Version "0.1") set(Plugin-Vendor "German Cancer Research Center (DKFZ)") set(Plugin-ContactAddress "") -set(Require-Plugin org.mitk.gui.qt.common) + +set(Require-Plugin + org.mitk.gui.qt.application + org.mitk.gui.qt.common +) diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/plugin.xml b/Plugins/org.mitk.gui.qt.viewnavigator/plugin.xml index f08d78ca51..f2347f33a4 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/plugin.xml +++ b/Plugins/org.mitk.gui.qt.viewnavigator/plugin.xml @@ -1,12 +1,9 @@ - + icon="resources/view-manager.svg" /> - diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkCategoryItem.cpp b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkCategoryItem.cpp new file mode 100644 index 0000000000..a5e9a5d6b2 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkCategoryItem.cpp @@ -0,0 +1,59 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#include "QmitkCategoryItem.h" +#include "QmitkViewItem.h" + +#include + +QmitkCategoryItem::QmitkCategoryItem(const QString& category) + : QStandardItem(category) +{ + auto font = this->font(); + font.setPointSizeF(font.pointSizeF() * 1.25); + this->setFont(font); + + this->SetVisible(true); +} + +QmitkCategoryItem::~QmitkCategoryItem() +{ +} + +bool QmitkCategoryItem::HasMatch(const QRegularExpression& re) const +{ + if (!this->hasChildren()) + return false; + + const int rowCount = this->rowCount(); + + for (int row = 0; row < rowCount; ++row) + { + if (const auto* viewItem = dynamic_cast(this->child(row)); viewItem != nullptr) + { + if (viewItem->Match(re)) + return true; + } + } + + return false; +} + +bool QmitkCategoryItem::GetVisible() const +{ + return this->data().toBool(); +} + +void QmitkCategoryItem::SetVisible(bool visible) +{ + this->setData(visible); +} diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkCategoryItem.h b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkCategoryItem.h new file mode 100644 index 0000000000..b872d74701 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkCategoryItem.h @@ -0,0 +1,40 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#ifndef QmitkCategoryItem_h +#define QmitkCategoryItem_h + +#include +#include + +class QmitkCategoryItem : public QStandardItem +{ +public: + explicit QmitkCategoryItem(const QString& category); + ~QmitkCategoryItem() override; + + /** \brief Check if any view item child of this category item matches the given regular expression. + * + * \sa QmitkViewItem::Match() + */ + bool HasMatch(const QRegularExpression& re) const; + + /** \brief Get visibility of this item including its children. + */ + bool GetVisible() const; + + /** \brief Enable or disable visibility of this item including its children. + */ + void SetVisible(bool visible); +}; + +#endif diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkPerspectiveItem.h b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkPerspectiveItem.h deleted file mode 100644 index 660263f08c..0000000000 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkPerspectiveItem.h +++ /dev/null @@ -1,38 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QmitkPerspectiveItem_h -#define QmitkPerspectiveItem_h - -#include -#include - -class QmitkPerspectiveItem : public QStandardItem -{ -public: - - QmitkPerspectiveItem(const QString& string) - : QStandardItem(string) - { - } - - QmitkPerspectiveItem(const QIcon& icon, const QString& string) - : QStandardItem(icon, string) - { - } - - berry::IPerspectiveDescriptor::Pointer m_ItemDescriptor; - QStringList m_Tags; - QString m_Description; -}; - -#endif diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewItem.cpp b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewItem.cpp new file mode 100644 index 0000000000..331b48524b --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewItem.cpp @@ -0,0 +1,94 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#include "QmitkViewItem.h" + +#include +#include +#include + +namespace +{ + QStringList GetKeywordsFromView(const berry::IViewDescriptor* view) + { + QStringList result; + + const auto* extensionRegistry = berry::Platform::GetExtensionRegistry(); + const auto configElems = extensionRegistry->GetConfigurationElementsFor("org.blueberry.ui.keywords"); + + const auto keywordRefs = view->GetKeywordReferences(); + + for (const auto& keywordRef : keywordRefs) + { + for (const auto& configElem : configElems) + { + auto id = configElem->GetAttribute("id"); + + if (id != keywordRef) + continue; + + auto keyword = configElem->GetAttribute("label"); + + if (!keyword.isEmpty()) + result.append(keyword); + } + } + + return result; + } +} + +QmitkViewItem::QmitkViewItem(const berry::IViewDescriptor* view) + : QStandardItem(view->GetImageDescriptor(), view->GetLabel()) +{ + this->setData(view->GetId()); + this->setToolTip(view->GetDescription()); + this->SetKeywords(GetKeywordsFromView(view)); +} + +QmitkViewItem::~QmitkViewItem() +{ +} + +void QmitkViewItem::SetBoldFont(bool enable) +{ + auto font = this->font(); + font.setBold(enable); + this->setFont(font); +} + +QStringList QmitkViewItem::GetKeywords() const +{ + return this->data(KeywordsRole).toStringList(); +} + +void QmitkViewItem::SetKeywords(const QStringList& keywords) +{ + this->setData(keywords, KeywordsRole); +} + +bool QmitkViewItem::Match(const QRegularExpression& re) const +{ + if (this->text().contains(re)) + return true; + + if (this->toolTip().contains(re)) + return true; + + for (const auto& keyword : this->GetKeywords()) + { + if (keyword.contains(re)) + return true; + } + + return false; +} diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewItem.h b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewItem.h index 5776623c47..ff19471ca7 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewItem.h +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewItem.h @@ -1,38 +1,51 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QmitkViewItem_h #define QmitkViewItem_h +#include #include -#include +#include + +namespace berry +{ + struct IViewDescriptor; +} class QmitkViewItem : public QStandardItem { public: + static constexpr int KeywordsRole = Qt::UserRole + 2; + + explicit QmitkViewItem(const berry::IViewDescriptor* view); + ~QmitkViewItem() override; + + /** \brief Enable or disable bold font for this item. + */ + void SetBoldFont(bool enable); - QmitkViewItem(const QString& string) - : QStandardItem(string) - { - } + /** \brief Get view keywords as optionally specified in a corresponding plugin.xml file. + */ + QStringList GetKeywords() const; - QmitkViewItem(const QIcon& icon, const QString& string) - : QStandardItem(icon, string) - { - } + /** \brief Match item against regular expression. + * + * View name (text), description (tool tip), and keywords are considered. + */ + bool Match(const QRegularExpression& re) const; - berry::IViewDescriptor::Pointer m_ItemDescriptor; - QStringList m_Tags; - QString m_Description; +private: + void SetKeywords(const QStringList& keywords); }; #endif diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewModel.cpp b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewModel.cpp new file mode 100644 index 0000000000..dfadb23077 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewModel.cpp @@ -0,0 +1,96 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#include "QmitkViewModel.h" + +#include "QmitkCategoryItem.h" +#include "QmitkViewItem.h" + +#include +#include + +namespace +{ + QString GetCategory(const berry::IViewDescriptor* view) + { + auto categoryPath = view->GetCategoryPath(); + + return !categoryPath.isEmpty() + ? categoryPath.first() + : ""; + } +} + +QmitkViewModel::QmitkViewModel(QObject* parent) + : QStandardItemModel(parent) +{ + const auto viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); + const auto views = viewRegistry->GetViews(); + + for (const auto& view : views) + { + // Ignore internal views and self (View Navigator). + if (view->IsInternal() || view->GetId() == "org.mitk.views.viewnavigator") + continue; + + auto category = GetCategory(view.GetPointer()); + + // If a view is not categorized, put it into a virtual "Other" category. + if (category.isEmpty()) + category = "Other"; + + // Get corresponding category item or create it on the fly as needed. + auto categoryItem = this->GetCategoryItem(category); + + if (categoryItem == nullptr) + categoryItem = this->CreateCategoryItem(category); + + // Add the new view item as child node to the corresponding category item. + categoryItem->appendRow(new QmitkViewItem(view.GetPointer())); + } +} + +QmitkViewModel::~QmitkViewModel() +{ +} + +QmitkCategoryItem* QmitkViewModel::CreateCategoryItem(const QString& category) +{ + auto categoryItem = new QmitkCategoryItem(category); + this->appendRow(categoryItem); + + return categoryItem; +} + +QmitkCategoryItem* QmitkViewModel::GetCategoryItem(const QString& category) const +{ + auto items = this->findItems(category); + + for (auto item : items) + { + auto categoryItem = dynamic_cast(item); + + if (categoryItem != nullptr) + return categoryItem; + } + + return nullptr; +} + +QmitkViewItem* QmitkViewModel::GetViewItemFromId(const QString& id) const +{ + const auto indices = this->match(this->index(0, 0), Qt::UserRole + 1, id, 1, Qt::MatchRecursive); + + return !indices.isEmpty() + ? dynamic_cast(this->itemFromIndex(indices.first())) + : nullptr; +} diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewModel.h b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewModel.h new file mode 100644 index 0000000000..fb0182ea73 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewModel.h @@ -0,0 +1,43 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#ifndef QmitkViewModel_h +#define QmitkViewModel_h + +#include + +class QmitkCategoryItem; +class QmitkViewItem; + +class QmitkViewModel : public QStandardItemModel +{ +public: + explicit QmitkViewModel(QObject* parent = nullptr); + ~QmitkViewModel() override; + + /** \brief Get category item by category name. + * + * \sa QmitkCategoryItem + */ + QmitkCategoryItem* GetCategoryItem(const QString& category) const; + + /** \brief Get view item by view id. + * + * \sa QmitkViewItem + */ + QmitkViewItem* GetViewItemFromId(const QString& id) const; + +private: + QmitkCategoryItem* CreateCategoryItem(const QString& category); +}; + +#endif diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.cpp b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.cpp new file mode 100644 index 0000000000..0eb0ae1219 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.cpp @@ -0,0 +1,165 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#include "QmitkViewNavigatorView.h" + +#include "QmitkCategoryItem.h" +#include "QmitkViewItem.h" +#include "QmitkViewModel.h" +#include "QmitkViewProxyModel.h" + +#include + +#include +#include +#include + +#include + +#include + +QmitkViewNavigatorView::QmitkViewNavigatorView() + : m_Ui(new Ui::QmitkViewNavigatorView), + m_Model(nullptr), + m_ProxyModel(nullptr) +{ +} + +QmitkViewNavigatorView::~QmitkViewNavigatorView() +{ + this->GetPartService()->RemovePartListener(this); +} + +void QmitkViewNavigatorView::CreateQtPartControl(QWidget* parent) +{ + m_Ui->setupUi(parent); + + m_Model = new QmitkViewModel(parent); + + m_ProxyModel = new QmitkViewProxyModel(parent); + m_ProxyModel->setSourceModel(m_Model); + + m_Ui->viewTreeView->setModel(m_ProxyModel); + + connect(m_Ui->filterLineEdit, &QLineEdit::textChanged, this, &QmitkViewNavigatorView::OnFilterTextChanged); + connect(m_Ui->viewTreeView, &QTreeView::doubleClicked, this, &QmitkViewNavigatorView::OnItemDoubleClicked); + + this->GetPartService()->AddPartListener(this); // The part service is not available earlier (e.g. in the constructor). +} + +void QmitkViewNavigatorView::SetFocus() +{ + m_Ui->filterLineEdit->setFocus(); +} + +mitk::IPreferences* QmitkViewNavigatorView::GetPreferences() const +{ + auto prefService = mitk::CoreServices::GetPreferencesService(); + return prefService->GetSystemPreferences()->Node(QmitkApplicationConstants::TOOL_BARS_PREFERENCES); +} + +void QmitkViewNavigatorView::OnPreferencesChanged(const mitk::IPreferences* prefs) +{ + for (const auto& category : prefs->Keys()) + { + if (auto* categoryItem = m_Model->GetCategoryItem(QString::fromStdString(category)); categoryItem != nullptr) + categoryItem->SetVisible(prefs->GetBool(category, true)); + } + + m_Ui->viewTreeView->expandAll(); +} + +berry::IWorkbenchPage* QmitkViewNavigatorView::GetActivePage() const +{ + if (auto site = this->GetSite(); site.IsNotNull()) + { + if (auto workbenchWindow = site->GetWorkbenchWindow(); workbenchWindow.IsNotNull()) + return workbenchWindow->GetActivePage().GetPointer(); + } + + return nullptr; +} + +berry::IPartService* QmitkViewNavigatorView::GetPartService() const +{ + if (auto site = this->GetSite(); site.IsNotNull()) + { + if (auto workbenchWindow = site->GetWorkbenchWindow(); workbenchWindow.IsNotNull()) + return workbenchWindow->GetPartService(); + } + + return nullptr; +} + +void QmitkViewNavigatorView::OnFilterTextChanged(const QString& filter) +{ + m_ProxyModel->setFilterFixedString(filter); + m_Ui->viewTreeView->expandAll(); +} + +void QmitkViewNavigatorView::OnItemDoubleClicked(const QModelIndex& index) +{ + auto viewItem = dynamic_cast(m_Model->itemFromIndex(m_ProxyModel->mapToSource(index))); + + if (viewItem != nullptr) + { + if (auto activePage = this->GetActivePage(); activePage != nullptr) + { + try + { + activePage->ShowView(viewItem->data().toString()); + } + catch (const berry::PartInitException& e) + { + MITK_ERROR << e.what(); + } + } + } +} + +berry::IPartListener::Events::Types QmitkViewNavigatorView::GetPartEventTypes() const +{ + return Events::OPENED | Events::CLOSED; +} + +void QmitkViewNavigatorView::PartOpened(const berry::IWorkbenchPartReference::Pointer& partRef) +{ + if (partRef->GetId() != "org.mitk.views.viewnavigator") + { + auto viewItem = m_Model->GetViewItemFromId(partRef->GetId()); + + if (viewItem != nullptr) + viewItem->SetBoldFont(true); + } + else if (auto activePage = this->GetActivePage(); activePage != nullptr) + { + // The active page is not available during view initialization. Hence, we hook + // into PartOpened() for the View Navigator itself, which is called shortly after, + // to initialize the state of all views. + + for (const auto& view : activePage->GetViews()) + { + auto viewItem = m_Model->GetViewItemFromId(view->GetSite()->GetId()); + + if (viewItem != nullptr) + viewItem->SetBoldFont(true); + } + } +} + +void QmitkViewNavigatorView::PartClosed(const berry::IWorkbenchPartReference::Pointer& partRef) +{ + auto viewItem = m_Model->GetViewItemFromId(partRef->GetId()); + + if (viewItem != nullptr) + viewItem->SetBoldFont(false); +} diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.h b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.h new file mode 100644 index 0000000000..911440e1f7 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.h @@ -0,0 +1,62 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#ifndef QmitkViewNavigatorView_h +#define QmitkViewNavigatorView_h + +#include +#include + +class QmitkViewModel; +class QmitkViewProxyModel; + +namespace berry +{ + struct IPartService; + struct IWorkbenchPage; +} + +namespace Ui +{ + class QmitkViewNavigatorView; +} + +class QmitkViewNavigatorView : public QmitkAbstractView, public berry::IPartListener +{ + Q_OBJECT + +public: + QmitkViewNavigatorView(); + ~QmitkViewNavigatorView() override; + +private: + void CreateQtPartControl(QWidget* parent) override; + void SetFocus() override; + mitk::IPreferences* GetPreferences() const override; + void OnPreferencesChanged(const mitk::IPreferences* prefs) override; + + Events::Types GetPartEventTypes() const override; + void PartOpened(const berry::IWorkbenchPartReference::Pointer& partRef) override; + void PartClosed(const berry::IWorkbenchPartReference::Pointer& partRef) override; + + berry::IWorkbenchPage* GetActivePage() const; + berry::IPartService* GetPartService() const; + + void OnFilterTextChanged(const QString& filter); + void OnItemDoubleClicked(const QModelIndex& index); + + Ui::QmitkViewNavigatorView* m_Ui; + QmitkViewModel* m_Model; + QmitkViewProxyModel* m_ProxyModel; +}; + +#endif diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.ui b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.ui new file mode 100644 index 0000000000..d2792b28a5 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorView.ui @@ -0,0 +1,52 @@ + + + QmitkViewNavigatorView + + + + 0 + 0 + 390 + 600 + + + + Form + + + + + + + + Filter: + + + filterLineEdit + + + + + + + true + + + + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + + + + + + diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidget.cpp b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidget.cpp deleted file mode 100644 index 007c9f6457..0000000000 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidget.cpp +++ /dev/null @@ -1,727 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -// View navigator plugin -#include -#include -#include - -// Blueberry -#include -#include -#include -#include -#include -#include -#include -#include - -// MITK -#include - -// Qt -#include -#include -#include -#include -#include - -namespace -{ - QFont getLargeFont() - { - QFont font = qApp->font(); - font.setPointSizeF(font.pointSizeF() * 1.25f); - return font; - } -} - -class KeywordRegistry -{ -public: - - KeywordRegistry() - { - berry::IExtensionRegistry* extensionPointService = berry::Platform::GetExtensionRegistry(); - auto keywordExts = extensionPointService->GetConfigurationElementsFor("org.blueberry.ui.keywords"); - for (auto keywordExtsIt = keywordExts.begin(); keywordExtsIt != keywordExts.end(); ++keywordExtsIt) - { - QString keywordId = (*keywordExtsIt)->GetAttribute("id"); - QString keywordLabels = (*keywordExtsIt)->GetAttribute("label"); - m_Keywords[keywordId].push_back(keywordLabels); - } - } - - QStringList GetKeywords(const QString& id) - { - return m_Keywords[id]; - } - - QStringList GetKeywords(const QStringList& ids) - { - QStringList result; - for (const auto& id : ids) - { - result.append(this->GetKeywords(id)); - } - return result; - } - -private: - - QHash m_Keywords; -}; - -class ClassFilterProxyModel : public QSortFilterProxyModel -{ -public: - - ClassFilterProxyModel(QObject* parent = nullptr) - : QSortFilterProxyModel(parent) - { - } - - bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override - { - QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); - - return hasToBeDisplayed(index); - } - -private: - - bool displayElement(const QModelIndex index) const - { - QString type = sourceModel()->data(index, Qt::DisplayRole).toString(); - QStandardItem* item = dynamic_cast(sourceModel())->itemFromIndex(index); - - if (type.contains(filterRegularExpression())) - { - return true; - } - - QmitkViewItem* viewItem = dynamic_cast(item); - if (nullptr != viewItem) - { - for (const auto& tag : viewItem->m_Tags) - { - if (tag.contains(filterRegularExpression())) - { - return true; - } - } - if (viewItem->m_Description.contains(filterRegularExpression())) - { - return true; - } - } - - QmitkPerspectiveItem* perspectiveItem = dynamic_cast(item); - if (nullptr != perspectiveItem) - { - for (const auto& tag : perspectiveItem->m_Tags) - { - if (tag.contains(filterRegularExpression())) - { - return true; - } - } - if (perspectiveItem->m_Description.contains(filterRegularExpression())) - { - return true; - } - } - - return false; - } - - bool hasToBeDisplayed(const QModelIndex index) const - { - bool result = false; - if (sourceModel()->rowCount(index) > 0) - { - for (int i = 0; i < sourceModel()->rowCount(index); i++) - { - QModelIndex childIndex = sourceModel()->index(i, 0, index); - if (!childIndex.isValid()) - { - break; - } - - result = hasToBeDisplayed(childIndex); - result |= displayElement(index); - - if (result) - { - break; - } - } - } - else - { - result = displayElement(index); - } - return result; - } -}; - -class ViewNavigatorPerspectiveListener: public berry::IPerspectiveListener -{ -public: - - ViewNavigatorPerspectiveListener(QmitkViewNavigatorWidget* parent) - : m_ParentWidget(parent) - { - } - - Events::Types GetPerspectiveEventTypes() const override - { - return Events::ACTIVATED | Events::SAVED_AS | Events::DEACTIVATED - // remove the following line when command framework is finished - | Events::CLOSED | Events::OPENED | Events::PART_CHANGED; - } - - void PerspectiveActivated(const berry::IWorkbenchPage::Pointer& /*page*/, - const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override - { - m_ParentWidget->UpdateTreeList(); - } - - void PerspectiveSavedAs(const berry::IWorkbenchPage::Pointer& /*page*/, - const berry::IPerspectiveDescriptor::Pointer& /*oldPerspective*/, - const berry::IPerspectiveDescriptor::Pointer& /*newPerspective*/) override - { - m_ParentWidget->UpdateTreeList(); - } - - void PerspectiveDeactivated(const berry::IWorkbenchPage::Pointer& /*page*/, - const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override - { - m_ParentWidget->m_ActivePerspective = nullptr; - } - - void PerspectiveOpened(const berry::IWorkbenchPage::Pointer& /*page*/, - const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override - { - m_ParentWidget->UpdateTreeList(); - } - - void PerspectiveClosed(const berry::IWorkbenchPage::Pointer& /*page*/, - const berry::IPerspectiveDescriptor::Pointer& /*perspective*/) override - { - m_ParentWidget->m_ActivePerspective = nullptr; - } - - using IPerspectiveListener::PerspectiveChanged; - - void PerspectiveChanged(const berry::IWorkbenchPage::Pointer& /*page*/, - const berry::IPerspectiveDescriptor::Pointer& /*perspective*/, - const berry::IWorkbenchPartReference::Pointer& partRef, const std::string& changeId) - { - if (changeId == "viewHide" && partRef->GetId() == "org.mitk.views.viewnavigator") - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->RemovePerspectiveListener(m_ParentWidget->m_PerspectiveListener.data()); - else - m_ParentWidget->UpdateTreeList(); - } - -private: - - QmitkViewNavigatorWidget* m_ParentWidget; -}; - -class ViewNavigatorViewListener: public berry::IPartListener -{ -public: - - ViewNavigatorViewListener(QmitkViewNavigatorWidget* parent) - : m_ParentWidget(parent) - { - } - - Events::Types GetPartEventTypes() const override - { - return Events::OPENED | Events::CLOSED; - } - - void PartOpened(const berry::IWorkbenchPartReference::Pointer& partRef) override - { - if (partRef->GetId() != "org.mitk.views.viewnavigator") - { - m_ParentWidget->UpdateTreeList((partRef->GetPart(false)).GetPointer()); - } - else - { - m_ParentWidget->FillTreeList(); - m_ParentWidget->UpdateTreeList(); - } - } - - void PartClosed(const berry::IWorkbenchPartReference::Pointer& partRef) override - { - if (partRef->GetId() != "org.mitk.views.viewnavigator") - { - m_ParentWidget->UpdateTreeList(); - } - } - -private: - - QmitkViewNavigatorWidget* m_ParentWidget; -}; - -bool compareViews(const berry::IViewDescriptor::Pointer& a, const berry::IViewDescriptor::Pointer& b) -{ - if (a.IsNull() || b.IsNull()) - { - return false; - } - - return a->GetLabel().compare(b->GetLabel()) < 0; -} - -bool comparePerspectives(const berry::IPerspectiveDescriptor::Pointer& a, const berry::IPerspectiveDescriptor::Pointer& b) -{ - if (a.IsNull() || b.IsNull()) - { - return false; - } - - return a->GetLabel().compare(b->GetLabel()) < 0; -} - -bool compareQStandardItems(const QStandardItem* a, const QStandardItem* b) -{ - if (nullptr == a || nullptr== b) - { - return false; - } - - return a->text().compare(b->text()) < 0; -} - -QmitkViewNavigatorWidget::QmitkViewNavigatorWidget(berry::IWorkbenchWindow::Pointer window, - QWidget* parent, - Qt::WindowFlags) - : QWidget(parent) - , m_Window(window) -{ - this->CreateQtPartControl(this); -} - -QmitkViewNavigatorWidget::~QmitkViewNavigatorWidget() -{ - m_Window->RemovePerspectiveListener(m_PerspectiveListener.data()); - m_Window->GetPartService()->RemovePartListener(m_ViewPartListener.data()); -} - -void QmitkViewNavigatorWidget::SetFocus() -{ - m_Controls.lineEdit->setFocus(); -} - -void QmitkViewNavigatorWidget::UpdateTreeList(berry::IWorkbenchPart* workbenchPart) -{ - berry::IWorkbenchPage::Pointer page = m_Window->GetActivePage(); - if (page.IsNull()) - { - return; - } - - m_ActivePerspective = page->GetPerspective(); - QList viewParts = page->GetViews(); - - // iterate over all tree items - for (const auto& item : m_TreeModel->findItems("*", Qt::MatchWildcard | Qt::MatchRecursive)) - { - QFont font = qApp->font(); - // check if the item is a view item and if it is equal to any opened view - QmitkViewItem* viewItem = dynamic_cast(item); - if (nullptr != viewItem) - { - if (nullptr != workbenchPart && workbenchPart->GetPartName() == viewItem->m_ItemDescriptor->GetLabel()) - { - font.setBold(true); - } - else - { - for (const auto& viewPart : viewParts) - { - if (viewPart->GetPartName() == viewItem->m_ItemDescriptor->GetLabel()) - { - font.setBold(true); - break; - } - } - } - - viewItem->setFont(font); - } - else - { - // check if the item is a perspective item and if it is equal to the current perspective - QmitkPerspectiveItem* perspectiveItem = dynamic_cast(item); - if (nullptr != perspectiveItem) - { - if (m_ActivePerspective.IsNotNull() && m_ActivePerspective->GetId() == perspectiveItem->m_ItemDescriptor->GetId()) - { - font.setBold(true); - } - - perspectiveItem->setFont(font); - } - } - } -} - -bool QmitkViewNavigatorWidget::FillTreeList() -{ - // initialize tree model - m_TreeModel->clear(); - - // add all available views - this->AddViewsToTree(); - - // add all available perspectives - this->AddPerspectivesToTree(); - - m_Controls.m_PluginTreeView->expandAll(); - - return true; -} - -void QmitkViewNavigatorWidget::FilterChanged() -{ - m_Controls.m_PluginTreeView->expandAll(); - - auto pattern = m_Controls.lineEdit->text(); - QRegularExpression regExp(pattern, QRegularExpression::CaseInsensitiveOption); - m_FilterProxyModel->setFilterRegularExpression(regExp); -} - -void QmitkViewNavigatorWidget::ItemClicked(const QModelIndex &index) -{ - QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index)); - - QmitkPerspectiveItem* perspectiveItem = dynamic_cast(item); - if (nullptr != perspectiveItem) - { - try - { - berry::PlatformUI::GetWorkbench()->ShowPerspective( - perspectiveItem->m_ItemDescriptor->GetId(), berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()); - } - catch (...) - { - QMessageBox::critical(nullptr, "Opening Perspective Failed", - QString("The requested perspective could not be opened.\nSee the log for details.")); - } - - return; - } - - QmitkViewItem* viewItem = dynamic_cast(item); - if (nullptr != viewItem) - { - berry::IWorkbenchPage::Pointer page = - berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow()->GetActivePage(); - - if (page.IsNotNull()) - { - try - { - page->ShowView(viewItem->m_ItemDescriptor->GetId()); - } - catch (const berry::PartInitException& e) - { - BERRY_ERROR << "Error: " << e.what() << std::endl; - } - } - } -} - -void QmitkViewNavigatorWidget::SaveCurrentPerspectiveAs() -{ - berry::IWorkbenchPage::Pointer page = m_Window->GetActivePage(); - berry::IPerspectiveDescriptor::Pointer currentPerspective = page->GetPerspective(); - - bool ok = false; - QString perspectiveLabel = QInputDialog::getText(this, "Save perspective as ...", - "New perspective name:", QLineEdit::Normal, - "", &ok); - - if (!ok) - { - return; - } - - if (perspectiveLabel.isEmpty()) - { - QMessageBox::information(this, "Save perspective as ...", "Please select a valid perspective name."); - return; - } - - berry::IPerspectiveRegistry* perspectiveRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); - berry::IPerspectiveDescriptor::Pointer newPerspective = perspectiveRegistry->CreatePerspective(perspectiveLabel, currentPerspective); - - if (nullptr == newPerspective) - { - QMessageBox::information(this, "Save perspective as ...", "The selected perspective name is already in use."); - return; - } - - page->SavePerspectiveAs(newPerspective); - - this->FillTreeList(); - this->UpdateTreeList(); -} - -void QmitkViewNavigatorWidget::ResetCurrentPerspective() -{ - if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", - "Do you really want to reset the current perspective?", - QMessageBox::Yes | QMessageBox::No).exec()) - { - berry::IWorkbenchPage::Pointer page = m_Window->GetActivePage(); - page->ResetPerspective(); - } -} - -void QmitkViewNavigatorWidget::ClosePerspective() -{ - if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", - "Do you really want to close the current perspective?", - QMessageBox::Yes | QMessageBox::No).exec()) - { - berry::IWorkbenchPage::Pointer page = m_Window->GetActivePage(); - page->ClosePerspective(page->GetPerspective(), true, true); - } -} - -void QmitkViewNavigatorWidget::CloseAllPerspectives() -{ - if (QMessageBox::Yes == QMessageBox(QMessageBox::Question, "Please confirm", - "Do you really want to close all perspectives?", - QMessageBox::Yes | QMessageBox::No).exec()) - { - berry::IWorkbenchPage::Pointer page = m_Window->GetActivePage(); - page->CloseAllPerspectives(true, true); - } -} - -void QmitkViewNavigatorWidget::ExpandAll() -{ - m_Controls.m_PluginTreeView->expandAll(); -} - -void QmitkViewNavigatorWidget::CollapseAll() -{ - m_Controls.m_PluginTreeView->collapseAll(); -} - -void QmitkViewNavigatorWidget::CustomMenuRequested(QPoint pos) -{ - QModelIndex index = m_Controls.m_PluginTreeView->indexAt(pos); - QStandardItem* item = m_TreeModel->itemFromIndex(m_FilterProxyModel->mapToSource(index)); - - if (nullptr == m_ContextMenu) - return; - - m_ContextMenu->clear(); - - QmitkPerspectiveItem* perspectiveItem = dynamic_cast(item); - if (nullptr != perspectiveItem) - { - berry::IPerspectiveDescriptor::Pointer perspectiveDescriptor = perspectiveItem->m_ItemDescriptor; - if (this->m_ActivePerspective.IsNotNull() && this->m_ActivePerspective == perspectiveDescriptor) - { - QAction* saveAsAction = new QAction("Save perspective as ...", this); - m_ContextMenu->addAction(saveAsAction); - connect(saveAsAction, SIGNAL(triggered()), SLOT(SaveCurrentPerspectiveAs())); - m_ContextMenu->addSeparator(); - } - } - - QAction* resetAction = new QAction("Reset current perspective", this); - m_ContextMenu->addAction(resetAction); - connect(resetAction, SIGNAL(triggered()), SLOT(ResetCurrentPerspective())); - - QAction* closeAction = new QAction("Close perspective", this); - m_ContextMenu->addAction(closeAction); - connect(closeAction, SIGNAL(triggered()), SLOT(ClosePerspective())); - - QAction* closeAllAction = new QAction("Close all perspectives", this); - m_ContextMenu->addAction(closeAllAction); - connect(closeAllAction, SIGNAL(triggered()), SLOT(CloseAllPerspectives())); - - m_ContextMenu->addSeparator(); - - QAction* expandAction = new QAction("Expand tree", this); - m_ContextMenu->addAction(expandAction); - connect(expandAction, SIGNAL(triggered()), SLOT(ExpandAll())); - - QAction* collapseAction = new QAction("Collapse tree", this); - m_ContextMenu->addAction(collapseAction); - connect(collapseAction, SIGNAL(triggered()), SLOT(CollapseAll())); - - m_ContextMenu->popup(m_Controls.m_PluginTreeView->viewport()->mapToGlobal(pos)); -} - -void QmitkViewNavigatorWidget::CreateQtPartControl(QWidget* parent) -{ - // active workbench window available? - if (m_Window.IsNull()) - { - return; - } - - m_Controls.setupUi(parent); - connect(m_Controls.m_PluginTreeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(CustomMenuRequested(QPoint))); - connect(m_Controls.m_PluginTreeView, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(ItemClicked(const QModelIndex&))); - connect(m_Controls.lineEdit, SIGNAL(textChanged(QString)), SLOT(FilterChanged())); - - m_ContextMenu = new QMenu(m_Controls.m_PluginTreeView); - m_Controls.m_PluginTreeView->setContextMenuPolicy(Qt::CustomContextMenu); - - // Create a new TreeModel for the data - m_TreeModel = new QStandardItemModel(); - m_FilterProxyModel = new ClassFilterProxyModel(this); - m_FilterProxyModel->setSourceModel(m_TreeModel); - m_Controls.m_PluginTreeView->setModel(m_FilterProxyModel); - - m_PerspectiveListener.reset(new ViewNavigatorPerspectiveListener(this)); - m_Window->AddPerspectiveListener(m_PerspectiveListener.data()); - - m_ViewPartListener.reset(new ViewNavigatorViewListener(this)); - m_Window->GetPartService()->AddPartListener(m_ViewPartListener.data()); -} - -void QmitkViewNavigatorWidget::AddPerspectivesToTree() -{ - berry::IPerspectiveRegistry* perspRegistry = berry::PlatformUI::GetWorkbench()->GetPerspectiveRegistry(); - QList perspectiveDescriptors(perspRegistry->GetPerspectives()); - std::sort(perspectiveDescriptors.begin(), perspectiveDescriptors.end(), comparePerspectives); - - QStandardItem* perspectiveRootItem = new QStandardItem("Perspectives"); - perspectiveRootItem->setFont(getLargeFont()); - perspectiveRootItem->setEditable(false); - QStandardItem* treeRootItem = m_TreeModel->invisibleRootItem(); - treeRootItem->appendRow(perspectiveRootItem); - - this->AddItemsToTree, QmitkPerspectiveItem>( - perspectiveDescriptors, perspectiveRootItem); -} - -void QmitkViewNavigatorWidget::AddViewsToTree() -{ - berry::IViewRegistry* viewRegistry = berry::PlatformUI::GetWorkbench()->GetViewRegistry(); - QList viewDescriptors(viewRegistry->GetViews()); - std::sort(viewDescriptors.begin(), viewDescriptors.end(), compareViews); - - auto largeFont = getLargeFont(); - - QStandardItem* viewRootItem = new QStandardItem("Views"); - viewRootItem->setFont(largeFont); - viewRootItem->setEditable(false); - QStandardItem* treeRootItem = m_TreeModel->invisibleRootItem(); - treeRootItem->appendRow(viewRootItem); - - QStandardItem* miscellaneousCategoryItem = new QStandardItem("Miscellaneous"); - miscellaneousCategoryItem->setFont(largeFont); - miscellaneousCategoryItem->setEditable(false); - - QStringList viewExcludeList; - // internal view used for the intro screen, will crash when opened directly, see T22352 - viewExcludeList.append(QString("org.blueberry.ui.internal.introview")); - viewExcludeList.append(QString("org.mitk.views.controlvisualizationpropertiesview")); - viewExcludeList.append(QString("org.mitk.views.modules")); - viewExcludeList.append(QString("org.mitk.views.viewnavigator")); - - this->AddItemsToTree, QmitkViewItem>( - viewDescriptors, viewRootItem, miscellaneousCategoryItem, viewExcludeList); -} - -template -void QmitkViewNavigatorWidget::AddItemsToTree(D itemDescriptors, QStandardItem* rootItem, - QStandardItem* miscellaneousItem, const QStringList& itemExcludeList) -{ - KeywordRegistry keywordRegistry; - std::vector categoryItems; - - for (const auto& itemDescriptor : itemDescriptors) - { - bool excludeView = itemExcludeList.contains(itemDescriptor->GetId()); - if (excludeView) - { - continue; - } - - QIcon icon = itemDescriptor->GetImageDescriptor(); - I* item = new I(icon, itemDescriptor->GetLabel()); - item->m_ItemDescriptor = itemDescriptor; - item->m_Description = itemDescriptor->GetDescription(); - item->setToolTip(itemDescriptor->GetDescription()); - - QStringList keylist = itemDescriptor->GetKeywordReferences(); - item->m_Tags = keywordRegistry.GetKeywords(keylist); - item->setEditable(false); - - QStringList categoryPath = itemDescriptor->GetCategoryPath(); - if (categoryPath.empty()) - { - // If a root item for general / non-categorized item views is given, use it. - // Otherwise put the non-categorized item views into the top root item. - if (nullptr != miscellaneousItem) - { - miscellaneousItem->appendRow(item); - } - else - { - rootItem->appendRow(item); - } - } - else - { - QStandardItem* categoryItem = nullptr; - for (const auto& currentCategoryItem : categoryItems) - { - if (currentCategoryItem->text() == categoryPath.front()) - { - categoryItem = currentCategoryItem; - break; - } - } - - if (nullptr == categoryItem) - { - categoryItem = new QStandardItem(QIcon(), categoryPath.front()); - categoryItems.push_back(categoryItem); - } - - auto font = getLargeFont(); - - categoryItem->setFont(font); - categoryItem->setEditable(false); - categoryItem->appendRow(item); - } - } - - std::sort(categoryItems.begin(), categoryItems.end(), compareQStandardItems); - for (const auto& categoryItem : categoryItems) - { - rootItem->appendRow(categoryItem); - } - - if (nullptr != miscellaneousItem && miscellaneousItem->hasChildren()) - { - rootItem->appendRow(miscellaneousItem); - } -} diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidget.h b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidget.h deleted file mode 100644 index c27effebe0..0000000000 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidget.h +++ /dev/null @@ -1,87 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ -#ifndef QmitkViewNavigatorWidget_h -#define QmitkViewNavigatorWidget_h - -#include "ui_QmitkViewNavigatorWidgetControls.h" - -//QT headers -#include -#include -#include - -#include -#include -#include - -class ClassFilterProxyModel; - -/** -* @brief -* -*/ -class QmitkViewNavigatorWidget : public QWidget -{ - Q_OBJECT - -public: - - QmitkViewNavigatorWidget(berry::IWorkbenchWindow::Pointer window, - QWidget* parent = nullptr, - Qt::WindowFlags f = {}); - ~QmitkViewNavigatorWidget() override; - - void SetFocus(); - -public Q_SLOTS: - - void FilterChanged(); - void ItemClicked(const QModelIndex& index); - void SaveCurrentPerspectiveAs(); - void ResetCurrentPerspective(); - void ClosePerspective(); - void CloseAllPerspectives(); - void ExpandAll(); - void CollapseAll(); - void CustomMenuRequested(QPoint pos); - -protected: - - friend class ViewNavigatorPerspectiveListener; - friend class ViewNavigatorViewListener; - - berry::IPerspectiveDescriptor::Pointer m_ActivePerspective; - -private: - - void CreateQtPartControl(QWidget* parent); - bool FillTreeList(); - void UpdateTreeList(berry::IWorkbenchPart* workbenchPart = nullptr); - - void AddPerspectivesToTree(); - void AddViewsToTree(); - template - void AddItemsToTree(D itemDescriptors, QStandardItem* rootItem, - QStandardItem* miscellaneousItem = nullptr, const QStringList& itemExcludeList = QStringList()); - - Ui::QmitkViewNavigatorWidgetControls m_Controls; - QStandardItemModel* m_TreeModel; - ClassFilterProxyModel* m_FilterProxyModel; - QMenu* m_ContextMenu; - - QScopedPointer m_PerspectiveListener; - QScopedPointer m_ViewPartListener; - - berry::IWorkbenchWindow::Pointer m_Window; -}; - -#endif diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidgetControls.ui b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidgetControls.ui deleted file mode 100644 index 464c881007..0000000000 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewNavigatorWidgetControls.ui +++ /dev/null @@ -1,64 +0,0 @@ - - - QmitkViewNavigatorWidgetControls - - - - 0 - 0 - 752 - 974 - - - - - 0 - 0 - - - - QmitkTemplate - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Filter... - - - - - - - true - - - false - - - - - - - - - ctkSearchBox - QLineEdit -
ctkSearchBox.h
-
-
- - -
diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewProxyModel.cpp b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewProxyModel.cpp new file mode 100644 index 0000000000..c34d600409 --- /dev/null +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewProxyModel.cpp @@ -0,0 +1,77 @@ +/*============================================================================ + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center (DKFZ) +All rights reserved. + +Use of this source code is governed by a 3-clause BSD license that can be +found in the LICENSE file. + +============================================================================*/ + +#include "QmitkViewProxyModel.h" + +#include "QmitkCategoryItem.h" +#include "QmitkViewItem.h" + +#include + +QmitkViewProxyModel::QmitkViewProxyModel(QObject* parent) + : QSortFilterProxyModel(parent) +{ + this->setFilterCaseSensitivity(Qt::CaseInsensitive); + this->setSortCaseSensitivity(Qt::CaseInsensitive); +} + +QmitkViewProxyModel::~QmitkViewProxyModel() +{ +} + +bool QmitkViewProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const +{ + // Primarily filter view items. Include their parent category items, though. Consider only + // views of visible categories. + + auto model = dynamic_cast(this->sourceModel()); + + if (model == nullptr) + return true; + + const auto re = this->filterRegularExpression(); + + auto index = model->index(sourceRow, 0, sourceParent); + const auto* item = model->itemFromIndex(index); + + if (auto viewItem = dynamic_cast(item); viewItem != nullptr) + { + if (auto categoryItem = dynamic_cast(viewItem->parent()); categoryItem != nullptr) + { + if (!categoryItem->GetVisible()) + return false; + } + + return viewItem->Match(re); + } + else if (auto categoryItem = dynamic_cast(item); categoryItem != nullptr) + { + if (!categoryItem->GetVisible()) + return false; + + return categoryItem->HasMatch(re); + } + + return true; +} + +bool QmitkViewProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const +{ + // Sort by item text in ascending order. + + auto model = this->sourceModel(); + auto leftText = model->data(left).toString(); + auto rightText = model->data(right).toString(); + auto caseSensitivity = this->sortCaseSensitivity(); + + return leftText.compare(rightText, caseSensitivity) > 0; +} diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/QmitkViewNavigatorView.h b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewProxyModel.h similarity index 50% rename from Plugins/org.mitk.gui.qt.viewnavigator/src/internal/QmitkViewNavigatorView.h rename to Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewProxyModel.h index 7c3c7cfc07..1d7a2ffd2b 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/QmitkViewNavigatorView.h +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/QmitkViewProxyModel.h @@ -1,44 +1,29 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ -#ifndef QmitkViewNavigatorView_h -#define QmitkViewNavigatorView_h +#ifndef QmitkViewProxyModel_h +#define QmitkViewProxyModel_h -#include +#include -class QmitkViewNavigatorWidget; - -/** -* @brief -* -*/ -class QmitkViewNavigatorView : public QmitkAbstractView +class QmitkViewProxyModel : public QSortFilterProxyModel { - Q_OBJECT - public: - - static const std::string VIEW_ID; - -protected: - - void CreateQtPartControl(QWidget *parent) override; - - void SetFocus() override; + explicit QmitkViewProxyModel(QObject* parent = nullptr); + ~QmitkViewProxyModel() override; private: - - QmitkViewNavigatorWidget* m_ViewNavigatorWidget; - + bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override; + bool lessThan(const QModelIndex& left, const QModelIndex& right) const override; }; #endif diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/QmitkViewNavigatorView.cpp b/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/QmitkViewNavigatorView.cpp deleted file mode 100644 index 3443fe6ba3..0000000000 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/QmitkViewNavigatorView.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkViewNavigatorView.h" -#include "QmitkViewNavigatorWidget.h" - -// BlueBerry -#include - -#include - -const std::string QmitkViewNavigatorView::VIEW_ID = "org.mitk.views.viewnavigator"; - -void QmitkViewNavigatorView::SetFocus() -{ - m_ViewNavigatorWidget->SetFocus(); -} - -void QmitkViewNavigatorView::CreateQtPartControl(QWidget* parent) -{ - parent->setLayout(new QVBoxLayout); - parent->layout()->setContentsMargins(0, 0, 0, 0); - m_ViewNavigatorWidget = new QmitkViewNavigatorWidget(this->GetSite()->GetWorkbenchWindow(), parent); - parent->layout()->addWidget(m_ViewNavigatorWidget); -} diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/mitkPluginActivator.cpp b/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/mitkPluginActivator.cpp index c0312d1037..e0fd3cac1d 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/mitkPluginActivator.cpp +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/mitkPluginActivator.cpp @@ -1,24 +1,28 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "mitkPluginActivator.h" -#include "QmitkViewNavigatorView.h" + +#include + +#include + +US_INITIALIZE_MODULE void mitk::PluginActivator::start(ctkPluginContext* context) { BERRY_REGISTER_EXTENSION_CLASS(QmitkViewNavigatorView, context) } -void mitk::PluginActivator::stop(ctkPluginContext* context) +void mitk::PluginActivator::stop(ctkPluginContext*) { - Q_UNUSED(context) } diff --git a/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/mitkPluginActivator.h b/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/mitkPluginActivator.h index ff406fe77d..fbff7926f3 100644 --- a/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/mitkPluginActivator.h +++ b/Plugins/org.mitk.gui.qt.viewnavigator/src/internal/mitkPluginActivator.h @@ -1,33 +1,32 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkPluginActivator_h #define mitkPluginActivator_h #include namespace mitk { class PluginActivator : public QObject, public ctkPluginActivator { Q_OBJECT Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_viewnavigator") Q_INTERFACES(ctkPluginActivator) public: - void start(ctkPluginContext *context) override; - void stop(ctkPluginContext *context) override; - + void start(ctkPluginContext* context) override; + void stop(ctkPluginContext* context) override; }; } #endif