1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Author: Nicolas Arnaud-Cormos, KDAB (nicolas.arnaud-cormos@kdab.com)
9 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** No Commercial Usage
13 ** This file contains pre-release code and may not be distributed.
14 ** You may use this file in accordance with the terms and conditions
15 ** contained in the Technology Preview License Agreement accompanying
18 ** GNU Lesser General Public License Usage
20 ** Alternatively, this file may be used under the terms of the GNU Lesser
21 ** General Public License version 2.1 as published by the Free Software
22 ** Foundation and appearing in the file LICENSE.LGPL included in the
23 ** packaging of this file. Please review the following information to
24 ** ensure the GNU Lesser General Public License version 2.1 requirements
25 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
27 ** In addition, as a special exception, Nokia gives you certain additional
28 ** rights. These rights are described in the Nokia Qt LGPL Exception
29 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
31 ** If you have questions regarding the use of this file, please contact
32 ** Nokia at qt-info@nokia.com.
34 **************************************************************************/
36 #include "analyzerplugin.h"
37 #include "analyzerconstants.h"
38 #include "analyzermanager.h"
39 #include "analyzeroutputpane.h"
41 #include <coreplugin/imode.h>
42 #include <coreplugin/coreconstants.h>
43 #include <coreplugin/editormanager/editormanager.h>
45 #include <extensionsystem/pluginmanager.h>
46 #include <projectexplorer/task.h>
47 #include <projectexplorer/taskhub.h>
49 #include <QtCore/QtPlugin>
50 #include <QtGui/QMessageBox>
51 #include <QtGui/QMainWindow>
52 #include <QtGui/QApplication>
54 using namespace Analyzer;
55 using namespace Analyzer::Internal;
58 AnalyzerPlugin *AnalyzerPlugin::m_instance = 0;
61 // AnalyzerPluginPrivate ////////////////////////////////////////////////////
62 class AnalyzerPlugin::AnalyzerPluginPrivate
65 AnalyzerPluginPrivate(AnalyzerPlugin *qq):
70 void initialize(const QStringList &arguments, QString *errorString);
73 AnalyzerManager *m_manager;
76 void AnalyzerPlugin::AnalyzerPluginPrivate::initialize(const QStringList &arguments, QString *errorString)
80 AnalyzerOutputPane *outputPane = new AnalyzerOutputPane;
81 q->addAutoReleasedObject(outputPane);
82 m_manager = new AnalyzerManager(outputPane, q);
86 // AnalyzerPlugin ////////////////////////////////////////////////////
87 AnalyzerPlugin::AnalyzerPlugin()
88 : d(new AnalyzerPluginPrivate(this))
93 AnalyzerPlugin::~AnalyzerPlugin()
95 // Unregister objects from the plugin manager's object pool
101 bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorString)
103 // Register objects in the plugin manager's object pool
105 // connect to other plugins' signals
106 // "In the initialize method, a plugin can be sure that the plugins it
107 // depends on have initialized their members."
110 Q_UNUSED(errorString)
112 d->initialize(arguments, errorString);
115 ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
116 ProjectExplorer::TaskHub *hub = pm->getObject<ProjectExplorer::TaskHub>();
117 //: Category under which Analyzer tasks are listed in build issues view
118 hub->addCategory(QLatin1String(Constants::ANALYZERTASK_ID), tr("Analyzer"));
120 ///TODO: select last used tool or default tool
121 // d->m_manager->selectTool(memcheckTool);
126 void AnalyzerPlugin::extensionsInitialized()
128 // Retrieve objects from the plugin manager's object pool
129 // "In the extensionsInitialized method, a plugin can be sure that all
130 // plugins that depend on it are completely initialized."
133 ExtensionSystem::IPlugin::ShutdownFlag AnalyzerPlugin::aboutToShutdown()
135 d->m_manager->shutdown();
137 // Disconnect from signals that are not needed during shutdown
138 // Hide UI (if you add UI that is not in the main window directly)
139 return SynchronousShutdown;
142 AnalyzerPlugin *AnalyzerPlugin::instance()
147 Q_EXPORT_PLUGIN(AnalyzerPlugin)