ui: Added plugin ports to preferences

bug id = 145
This commit is contained in:
Eberhard Graether
2016-08-26 14:41:39 +02:00
parent 401c23f572
commit ca0a1ffb89
12 changed files with 134 additions and 19 deletions
+2
View File
@@ -16,6 +16,7 @@
#include "component/view/DialogView.h"
#include "component/view/GraphViewStyle.h"
#include "component/controller/NetworkFactory.h"
#include "component/controller/IDECommunicationController.h"
#include "component/view/MainView.h"
#include "component/view/ViewFactory.h"
#include "data/StorageCache.h"
@@ -55,6 +56,7 @@ void Application::createInstance(
{
s_instance->m_ideCommunicationController =
networkFactory->createIDECommunicationController(s_instance->m_storageCache.get());
s_instance->m_ideCommunicationController->startListening();
}
s_instance->startMessagingAndScheduling();
+1
View File
@@ -271,6 +271,7 @@ add_files(
utility/messaging/type/MessageInterruptTasks.h
utility/messaging/type/MessageLoadProject.h
utility/messaging/type/MessageMoveIDECursor.h
utility/messaging/type/MessagePluginPortChange.h
utility/messaging/type/MessageProjectEdit.h
utility/messaging/type/MessageProjectNew.h
utility/messaging/type/MessageRedo.h
@@ -152,3 +152,9 @@ void IDECommunicationController::handleMessage(MessageMoveIDECursor* message)
sendMessage(networkMessage);
}
void IDECommunicationController::handleMessage(MessagePluginPortChange* message)
{
stopListening();
startListening();
}
@@ -4,17 +4,18 @@
#include <string>
#include "component/controller/Controller.h"
#include "component/controller/helper/NetworkProtocolHelper.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageMoveIDECursor.h"
#include "utility/messaging/type/MessagePluginPortChange.h"
class StorageAccess;
class IDECommunicationController
: public Controller
, public MessageListener<MessageMoveIDECursor>
, public MessageListener<MessagePluginPortChange>
{
public:
IDECommunicationController(StorageAccess* storageAccess);
@@ -22,18 +23,21 @@ public:
virtual void clear();
virtual void startListening() = 0;
virtual void stopListening() = 0;
virtual bool isListening() const = 0;
void handleIncomingMessage(const std::string& message);
bool getEnabled() const;
void setEnabled(const bool enabled);
virtual bool isListening() const = 0;
private:
void handleSetActiveTokenMessage(const NetworkProtocolHelper::SetActiveTokenMessage& message);
void handleCreateProjectMessage(const NetworkProtocolHelper::CreateProjectMessage& message);
virtual void handleMessage(MessageMoveIDECursor* message);
virtual void handleMessage(MessagePluginPortChange* message);
virtual void sendMessage(const std::string& message) const = 0;
StorageAccess* m_storageAccess;
@@ -0,0 +1,20 @@
#ifndef MESSAGE_PLUGIN_PORT_CHANGE_H
#define MESSAGE_PLUGIN_PORT_CHANGE_H
#include "utility/messaging/Message.h"
class MessagePluginPortChange
: public Message<MessagePluginPortChange>
{
public:
MessagePluginPortChange()
{
}
static const std::string getStaticType()
{
return "MessagePluginPortChange";
}
};
#endif // MESSAGE_PLUGIN_PORT_CHANGE_H
@@ -6,17 +6,35 @@ QtIDECommunicationController::QtIDECommunicationController(QObject* parent, Stor
: IDECommunicationController(storageAccess)
, m_tcpWrapper(parent)
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_tcpWrapper.setReadCallback(std::bind(&QtIDECommunicationController::handleIncomingMessage, this, std::placeholders::_1));
m_tcpWrapper.setServerPort(appSettings->getCoatiPort());
m_tcpWrapper.setClientPort(appSettings->getPluginPort());
m_tcpWrapper.startListening();
}
QtIDECommunicationController::~QtIDECommunicationController()
{}
void QtIDECommunicationController::startListening()
{
m_onQtThread(
[=]()
{
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
m_tcpWrapper.setServerPort(appSettings->getCoatiPort());
m_tcpWrapper.setClientPort(appSettings->getPluginPort());
m_tcpWrapper.startListening();
}
);
}
void QtIDECommunicationController::stopListening()
{
m_onQtThread(
[=]()
{
m_tcpWrapper.stopListening();
}
);
}
bool QtIDECommunicationController::isListening() const
{
return m_tcpWrapper.isListening();
@@ -25,4 +43,4 @@ bool QtIDECommunicationController::isListening() const
void QtIDECommunicationController::sendMessage(const std::string& message) const
{
m_tcpWrapper.sendMessage(message);
}
}
@@ -6,6 +6,7 @@
#include "QtTcpWrapper.h"
#include "component/controller/IDECommunicationController.h"
#include "qt/utility/QtThreadedFunctor.h"
#include "settings/ApplicationSettings.h"
class StorageAccess;
@@ -17,12 +18,17 @@ public:
QtIDECommunicationController(QObject* parent, StorageAccess* storageAccess);
~QtIDECommunicationController();
virtual void startListening();
virtual void stopListening();
virtual bool isListening() const;
private:
virtual void sendMessage(const std::string& message) const;
QtTcpWrapper m_tcpWrapper;
QtThreadedLambdaFunctor m_onQtThread;
};
#endif // QT_IDE_COMMUNICATION_CONTROLLER
#endif // QT_IDE_COMMUNICATION_CONTROLLER
+11 -4
View File
@@ -8,22 +8,29 @@ QtTcpWrapper::QtTcpWrapper(QObject* parent, const std::string& ip, const quint16
, m_clientPort(clientPort)
, m_ip(ip)
{
m_tcpServer = new QTcpServer(this);
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
}
void QtTcpWrapper::startListening()
{
QHostAddress address(m_ip.c_str());
m_tcpServer = new QTcpServer(this);
connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(acceptConnection()));
if (!m_tcpServer->listen(QHostAddress::LocalHost, m_serverPort))
{
LOG_ERROR_STREAM(<< "TCP server failed to start with error: \"" + m_tcpServer->errorString().toStdString() + "\". Unable to listen for IDE plugin messages.");
}
}
void QtTcpWrapper::stopListening()
{
if (isListening())
{
m_tcpServer->close();
}
}
QtTcpWrapper::~QtTcpWrapper()
{
if (m_tcpServer != NULL)
+1
View File
@@ -17,6 +17,7 @@ public:
~QtTcpWrapper();
void startListening();
void stopListening();
void sendMessage(const std::string& message) const;
@@ -21,6 +21,7 @@
#include "utility/logging/logging.h"
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "utility/messaging/type/MessagePluginPortChange.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageScrollSpeedChange.h"
#include "utility/messaging/type/MessageStatus.h"
@@ -42,6 +43,8 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent)
m_appSettings.setHeaderSearchPaths(appSettings->getHeaderSearchPaths());
m_appSettings.setFrameworkSearchPaths(appSettings->getFrameworkSearchPaths());
m_appSettings.setScrollSpeed(appSettings->getScrollSpeed());
m_appSettings.setCoatiPort(appSettings->getCoatiPort());
m_appSettings.setPluginPort(appSettings->getPluginPort());
m_parserManager = std::make_shared<SolutionParserManager>();
@@ -616,7 +619,7 @@ void QtProjectWizzard::createProject()
{
settingsChanged = !(application->getCurrentProject()->settingsEqualExceptNameAndLocation(*(m_settings.get())));
}
bool appSettingsChanged = !(m_appSettings == *ApplicationSettings::getInstance().get());
if (settingsChanged || appSettingsChanged)
@@ -641,6 +644,12 @@ void QtProjectWizzard::savePreferences()
MessageScrollSpeedChange(ApplicationSettings::getInstance()->getScrollSpeed()).dispatch();
}
if (m_appSettings.getCoatiPort() != ApplicationSettings::getInstance()->getCoatiPort() ||
m_appSettings.getPluginPort() != ApplicationSettings::getInstance()->getPluginPort())
{
MessagePluginPortChange().dispatch();
}
if (appSettingsChanged)
{
Project* currentProject = Application::getInstance()->getCurrentProject().get();
@@ -115,6 +115,7 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
layout->setRowMinimumHeight(row++, 20);
// indexing
layout->addWidget(createFormTitle("INDEXING"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++;
@@ -151,6 +152,36 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
layout->setRowMinimumHeight(row++, 20);
// Plugins
layout->addWidget(createFormTitle("PLUGIN"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++;
// Coati port
m_coatiPort = new QLineEdit();
m_coatiPort->setObjectName("name");
m_coatiPort->setAttribute(Qt::WA_MacShowFocusRect, 0);
layout->addWidget(createFormLabel("Coati Port"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_coatiPort, row, QtProjectWizzardWindow::BACK_COL);
addHelpButton("Port number that Coati uses to listen for incoming messages from plugins.", layout, row);
row++;
// Coati port
m_pluginPort = new QLineEdit();
m_pluginPort->setObjectName("name");
m_pluginPort->setAttribute(Qt::WA_MacShowFocusRect, 0);
layout->addWidget(createFormLabel("Plugin Port"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
layout->addWidget(m_pluginPort, row, QtProjectWizzardWindow::BACK_COL);
addHelpButton("Port number that Coati sends outgoing messages to.", layout, row);
row++;
layout->setRowMinimumHeight(row++, 20);
// Java
layout->addWidget(createFormTitle("JAVA"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++;
@@ -192,6 +223,7 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
layout->setRowMinimumHeight(row++, 20);
// C/C++
layout->addWidget(createFormTitle("C/C++"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
row++;
@@ -220,6 +252,9 @@ void QtProjectWizzardContentPreferences::load()
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
m_loggingEnabled->setChecked(appSettings->getLoggingEnabled());
m_coatiPort->setText(QString::number(appSettings->getCoatiPort()));
m_pluginPort->setText(QString::number(appSettings->getPluginPort()));
m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1);
m_fatalErrors->setChecked(appSettings->getShowExternalNonFatalErrors());
@@ -242,13 +277,16 @@ void QtProjectWizzardContentPreferences::save()
m_oldColorSchemeIndex = -1;
float scrollSpeed = m_scrollSpeed->text().toFloat();
if (scrollSpeed)
{
appSettings->setScrollSpeed(scrollSpeed);
}
if (scrollSpeed) appSettings->setScrollSpeed(scrollSpeed);
appSettings->setLoggingEnabled(m_loggingEnabled->isChecked());
int coatiPort = m_coatiPort->text().toInt();
if (coatiPort) appSettings->setCoatiPort(coatiPort);
int pluginPort = m_pluginPort->text().toInt();
if (pluginPort) appSettings->setPluginPort(pluginPort);
appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1);
appSettings->setShowExternalNonFatalErrors(m_fatalErrors->isChecked());
@@ -44,6 +44,9 @@ private:
QLineEdit* m_scrollSpeed;
QCheckBox* m_loggingEnabled;
QLineEdit* m_coatiPort;
QLineEdit* m_pluginPort;
QComboBox* m_threads;
QCheckBox* m_fatalErrors;