2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-11-11 10:05:05 +01:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 17:14:20 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-11-11 10:05:05 +01:00
|
|
|
|
|
|
|
|
#include "qmljstoolsplugin.h"
|
|
|
|
|
#include "qmljsmodelmanager.h"
|
2010-11-16 13:54:50 +01:00
|
|
|
#include "qmljsfunctionfilter.h"
|
|
|
|
|
#include "qmljslocatordata.h"
|
2011-02-03 15:48:14 +01:00
|
|
|
#include "qmljscodestylesettingspage.h"
|
|
|
|
|
#include "qmljstoolsconstants.h"
|
2011-05-25 08:50:01 +02:00
|
|
|
#include "qmljstoolssettings.h"
|
2012-10-04 14:54:59 +02:00
|
|
|
#include "qmlconsolemanager.h"
|
2012-12-06 17:20:58 +01:00
|
|
|
#include "qmljsbundleprovider.h"
|
2010-11-11 10:05:05 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2011-06-23 15:12:03 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2013-05-29 14:04:33 +02:00
|
|
|
#include <coreplugin/mimedatabase.h>
|
2011-06-23 15:12:03 +02:00
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2010-11-11 10:05:05 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QMenu>
|
2010-11-11 10:05:05 +01:00
|
|
|
|
2013-08-30 09:22:42 +02:00
|
|
|
using namespace Core;
|
2012-10-04 14:54:59 +02:00
|
|
|
using namespace QmlJSTools;
|
2010-11-11 10:05:05 +01:00
|
|
|
using namespace QmlJSTools::Internal;
|
|
|
|
|
|
|
|
|
|
enum { debug = 0 };
|
|
|
|
|
|
|
|
|
|
QmlJSToolsPlugin *QmlJSToolsPlugin::m_instance = 0;
|
|
|
|
|
|
|
|
|
|
QmlJSToolsPlugin::QmlJSToolsPlugin()
|
|
|
|
|
: m_modelManager(0)
|
|
|
|
|
{
|
|
|
|
|
m_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlJSToolsPlugin::~QmlJSToolsPlugin()
|
|
|
|
|
{
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
m_modelManager = 0; // deleted automatically
|
2012-10-04 14:54:59 +02:00
|
|
|
m_consoleManager = 0; // deleted automatically
|
2010-11-11 10:05:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(arguments)
|
2011-06-23 15:12:03 +02:00
|
|
|
|
2013-08-30 16:38:57 +02:00
|
|
|
if (!MimeDatabase::addMimeTypes(QLatin1String(":/qmljstools/QmlJSTools.mimetypes.xml"), error))
|
2013-05-29 14:04:33 +02:00
|
|
|
return false;
|
|
|
|
|
|
2011-05-25 08:50:01 +02:00
|
|
|
m_settings = new QmlJSToolsSettings(this); // force registration of qmljstools settings
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
// Objects
|
|
|
|
|
m_modelManager = new ModelManager(this);
|
2012-10-04 14:54:59 +02:00
|
|
|
m_consoleManager = new QmlConsoleManager(this);
|
|
|
|
|
|
2013-08-30 09:22:42 +02:00
|
|
|
// VCSManager *vcsManager = core->vcsManager();
|
|
|
|
|
// DocumentManager *fileManager = core->fileManager();
|
2010-11-11 10:05:05 +01:00
|
|
|
// connect(vcsManager, SIGNAL(repositoryChanged(QString)),
|
|
|
|
|
// m_modelManager, SLOT(updateModifiedSourceFiles()));
|
|
|
|
|
// connect(fileManager, SIGNAL(filesChangedInternally(QStringList)),
|
|
|
|
|
// m_modelManager, SLOT(updateSourceFiles(QStringList)));
|
|
|
|
|
|
2010-11-16 13:54:50 +01:00
|
|
|
LocatorData *locatorData = new LocatorData;
|
|
|
|
|
addAutoReleasedObject(locatorData);
|
|
|
|
|
addAutoReleasedObject(new FunctionFilter(locatorData));
|
2011-05-25 08:50:01 +02:00
|
|
|
addAutoReleasedObject(new QmlJSCodeStyleSettingsPage);
|
2012-12-06 17:20:58 +01:00
|
|
|
addAutoReleasedObject(new BasicBundleProvider);
|
2011-05-25 08:50:01 +02:00
|
|
|
|
2011-06-23 15:12:03 +02:00
|
|
|
// Menus
|
2013-08-30 09:22:42 +02:00
|
|
|
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
ActionContainer *mqmljstools = ActionManager::createMenu(Constants::M_TOOLS_QMLJS);
|
2011-06-23 15:12:03 +02:00
|
|
|
QMenu *menu = mqmljstools->menu();
|
|
|
|
|
menu->setTitle(tr("&QML/JS"));
|
|
|
|
|
menu->setEnabled(true);
|
|
|
|
|
mtools->addMenu(mqmljstools);
|
|
|
|
|
|
|
|
|
|
// Update context in global context
|
|
|
|
|
m_resetCodeModelAction = new QAction(tr("Reset Code Model"), this);
|
2013-08-30 09:22:42 +02:00
|
|
|
Context globalContext(Core::Constants::C_GLOBAL);
|
|
|
|
|
Command *cmd = ActionManager::registerAction(
|
|
|
|
|
m_resetCodeModelAction, Constants::RESET_CODEMODEL, globalContext);
|
2011-06-23 15:12:03 +02:00
|
|
|
connect(m_resetCodeModelAction, SIGNAL(triggered()), m_modelManager, SLOT(resetCodeModel()));
|
|
|
|
|
mqmljstools->addAction(cmd);
|
|
|
|
|
|
|
|
|
|
// watch task progress
|
2013-09-03 15:18:37 +02:00
|
|
|
connect(ProgressManager::instance(), SIGNAL(taskStarted(Core::Id)),
|
|
|
|
|
this, SLOT(onTaskStarted(Core::Id)));
|
|
|
|
|
connect(ProgressManager::instance(), SIGNAL(allTasksFinished(Core::Id)),
|
|
|
|
|
this, SLOT(onAllTasksFinished(Core::Id)));
|
2011-06-23 15:12:03 +02:00
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlJSToolsPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2010-12-03 10:13:15 +01:00
|
|
|
m_modelManager->delayedInitialization();
|
2010-11-11 10:05:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag QmlJSToolsPlugin::aboutToShutdown()
|
|
|
|
|
{
|
|
|
|
|
return SynchronousShutdown;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-03 15:18:37 +02:00
|
|
|
void QmlJSToolsPlugin::onTaskStarted(Core::Id type)
|
2011-06-23 15:12:03 +02:00
|
|
|
{
|
2013-09-03 15:18:37 +02:00
|
|
|
if (type == QmlJSTools::Constants::TASK_INDEX)
|
2011-06-23 15:12:03 +02:00
|
|
|
m_resetCodeModelAction->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-03 15:18:37 +02:00
|
|
|
void QmlJSToolsPlugin::onAllTasksFinished(Core::Id type)
|
2011-06-23 15:12:03 +02:00
|
|
|
{
|
2013-09-03 15:18:37 +02:00
|
|
|
if (type == QmlJSTools::Constants::TASK_INDEX)
|
2011-06-23 15:12:03 +02:00
|
|
|
m_resetCodeModelAction->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 10:05:05 +01:00
|
|
|
Q_EXPORT_PLUGIN(QmlJSToolsPlugin)
|