ui: vs plugin integration
Reworked vs solution based project setup to utilize new CDB feature
This commit is contained in:
@@ -281,6 +281,7 @@ add_files(
|
||||
utility/messaging/type/MessageGraphNodeBundleSplit.h
|
||||
utility/messaging/type/MessageGraphNodeExpand.h
|
||||
utility/messaging/type/MessageGraphNodeMove.h
|
||||
utility/messaging/type/MessageIDECreateCDB.h
|
||||
utility/messaging/type/MessageInterruptTasks.h
|
||||
utility/messaging/type/MessageLoadProject.h
|
||||
utility/messaging/type/MessageMoveIDECursor.h
|
||||
@@ -307,7 +308,7 @@ add_files(
|
||||
utility/messaging/type/MessageWindowClosed.h
|
||||
utility/messaging/type/MessageWindowFocus.h
|
||||
utility/messaging/type/MessageZoom.h
|
||||
|
||||
|
||||
utility/messaging/Message.h
|
||||
utility/messaging/MessageBase.h
|
||||
utility/messaging/MessageInterruptTasksCounter.cpp
|
||||
|
||||
@@ -44,6 +44,10 @@ void IDECommunicationController::handleIncomingMessage(const std::string& messag
|
||||
{
|
||||
handleSetActiveTokenMessage(NetworkProtocolHelper::parseSetActiveTokenMessage(message));
|
||||
}
|
||||
else if (type == NetworkProtocolHelper::MESSAGE_TYPE::CREATE_CDB_MESSAGE)
|
||||
{
|
||||
handleCreateCDBProjectMessage(NetworkProtocolHelper::parseCreateCDBProjectMessage(message));
|
||||
}
|
||||
else
|
||||
{
|
||||
handleCreateProjectMessage(NetworkProtocolHelper::parseCreateProjectMessage(message));
|
||||
@@ -139,9 +143,37 @@ void IDECommunicationController::handleCreateProjectMessage(const NetworkProtoco
|
||||
}
|
||||
}
|
||||
|
||||
void IDECommunicationController::handleCreateCDBProjectMessage(const NetworkProtocolHelper::CreateCDBProjectMessage& message)
|
||||
{
|
||||
if (message.valid)
|
||||
{
|
||||
std::shared_ptr<MessageProjectNew> msg = std::make_shared<MessageProjectNew>();
|
||||
msg->setSolutionPath(message.cdbFileLocation);
|
||||
msg->setHeaderPaths(message.headerPaths);
|
||||
msg->ideId = message.ideId;
|
||||
|
||||
bool foo = msg->fromCDB();
|
||||
|
||||
MessageDispatchWhenLicenseValid(msg).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Unable to parse provided CDB, invalid data received");
|
||||
}
|
||||
}
|
||||
|
||||
void IDECommunicationController::handleMessage(MessageIDECreateCDB* message)
|
||||
{
|
||||
std::string networkMessage = NetworkProtocolHelper::buildCreateCDBMessage();
|
||||
|
||||
MessageStatus("Requesting IDE to create CDB.").dispatch();
|
||||
|
||||
sendMessage(networkMessage);
|
||||
}
|
||||
|
||||
void IDECommunicationController::handleMessage(MessageMoveIDECursor* message)
|
||||
{
|
||||
std::string networkMessage = NetworkProtocolHelper::buildMessage(
|
||||
std::string networkMessage = NetworkProtocolHelper::buildSetIDECursorMessage(
|
||||
message->FilePosition, message->Row, message->Column
|
||||
);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "component/controller/helper/NetworkProtocolHelper.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageIDECreateCDB.h"
|
||||
#include "utility/messaging/type/MessageMoveIDECursor.h"
|
||||
#include "utility/messaging/type/MessagePluginPortChange.h"
|
||||
|
||||
@@ -14,6 +15,7 @@ class StorageAccess;
|
||||
|
||||
class IDECommunicationController
|
||||
: public Controller
|
||||
, public MessageListener<MessageIDECreateCDB>
|
||||
, public MessageListener<MessageMoveIDECursor>
|
||||
, public MessageListener<MessagePluginPortChange>
|
||||
{
|
||||
@@ -35,7 +37,9 @@ public:
|
||||
private:
|
||||
void handleSetActiveTokenMessage(const NetworkProtocolHelper::SetActiveTokenMessage& message);
|
||||
void handleCreateProjectMessage(const NetworkProtocolHelper::CreateProjectMessage& message);
|
||||
void handleCreateCDBProjectMessage(const NetworkProtocolHelper::CreateCDBProjectMessage& message);
|
||||
|
||||
virtual void handleMessage(MessageIDECreateCDB* message);
|
||||
virtual void handleMessage(MessageMoveIDECursor* message);
|
||||
virtual void handleMessage(MessagePluginPortChange* message);
|
||||
virtual void sendMessage(const std::string& message) const = 0;
|
||||
|
||||
@@ -14,6 +14,8 @@ std::string NetworkProtocolHelper::m_setActiveTokenPrefix = "setActiveToken";
|
||||
std::string NetworkProtocolHelper::m_moveCursorPrefix = "moveCursor";
|
||||
std::string NetworkProtocolHelper::m_endOfMessageToken = "<EOM>";
|
||||
std::string NetworkProtocolHelper::m_createProjectPrefix = "createProject";
|
||||
std::string NetworkProtocolHelper::m_createCDBProjectPrefix = "createCDBProject";
|
||||
std::string NetworkProtocolHelper::m_createCDBPrefix = "createCDB";
|
||||
|
||||
NetworkProtocolHelper::MESSAGE_TYPE NetworkProtocolHelper::getMessageType(const std::string& message)
|
||||
{
|
||||
@@ -29,6 +31,10 @@ NetworkProtocolHelper::MESSAGE_TYPE NetworkProtocolHelper::getMessageType(const
|
||||
{
|
||||
return MESSAGE_TYPE::CREATE_PROJECT;
|
||||
}
|
||||
else if (subMessages[0] == m_createCDBProjectPrefix)
|
||||
{
|
||||
return MESSAGE_TYPE::CREATE_CDB_MESSAGE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MESSAGE_TYPE::UNKNOWN;
|
||||
@@ -74,7 +80,7 @@ NetworkProtocolHelper::SetActiveTokenMessage NetworkProtocolHelper::parseSetActi
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token");
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token: " << subMessages[0] << ". Expected " << m_setActiveTokenPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,18 +117,88 @@ NetworkProtocolHelper::CreateProjectMessage NetworkProtocolHelper::parseCreatePr
|
||||
|
||||
networkMessage.valid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Failed to parse ide ID string. Is " << ideId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token");
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token: " << subMessages[0] << ". Expected " << m_createProjectPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return networkMessage;
|
||||
}
|
||||
|
||||
std::string NetworkProtocolHelper::buildMessage(const std::string& fileLocation, const unsigned int row, const unsigned int column)
|
||||
NetworkProtocolHelper::CreateCDBProjectMessage NetworkProtocolHelper::parseCreateCDBProjectMessage(const std::string& message)
|
||||
{
|
||||
std::vector<std::string> subMessages = divideMessage(message);
|
||||
|
||||
NetworkProtocolHelper::CreateCDBProjectMessage networkMessage;
|
||||
|
||||
if (subMessages.size() > 0)
|
||||
{
|
||||
if (subMessages[0] == m_createCDBProjectPrefix)
|
||||
{
|
||||
if (subMessages.size() < 4)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse createCDBProject message, too few tokens");
|
||||
}
|
||||
else
|
||||
{
|
||||
int subMessageCount = subMessages.size();
|
||||
|
||||
std::string cdbPath = subMessages[1];
|
||||
if (cdbPath.length() > 0)
|
||||
{
|
||||
networkMessage.cdbFileLocation = cdbPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "CDB file path is not set.");
|
||||
}
|
||||
|
||||
std::vector<std::string> headerPaths;
|
||||
for (int i = 2; i < subMessageCount - 2; i++)
|
||||
{
|
||||
if (subMessages[i].length() > 0)
|
||||
{
|
||||
headerPaths.push_back(subMessages[i]);
|
||||
}
|
||||
}
|
||||
networkMessage.headerPaths = headerPaths;
|
||||
|
||||
std::string ideId = subMessages[subMessageCount - 2];
|
||||
if (ideId.length() > 0)
|
||||
{
|
||||
std::string nonConstId = ideId;
|
||||
boost::algorithm::to_lower(nonConstId);
|
||||
|
||||
networkMessage.ideId = nonConstId;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING_STREAM(<< "Failed to parse ide ID string. Is " << ideId);
|
||||
}
|
||||
|
||||
if (networkMessage.cdbFileLocation.length() > 0 && networkMessage.ideId.length() > 0)
|
||||
{
|
||||
networkMessage.valid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Failed to parse message, invalid type token: " << subMessages[0] << ". Expected " << m_createCDBProjectPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return networkMessage;
|
||||
}
|
||||
|
||||
std::string NetworkProtocolHelper::buildSetIDECursorMessage(const std::string& fileLocation, const unsigned int row, const unsigned int column)
|
||||
{
|
||||
std::stringstream messageStream;
|
||||
|
||||
@@ -138,6 +214,16 @@ std::string NetworkProtocolHelper::buildMessage(const std::string& fileLocation,
|
||||
return messageStream.str();
|
||||
}
|
||||
|
||||
std::string NetworkProtocolHelper::buildCreateCDBMessage()
|
||||
{
|
||||
std::stringstream messageStream;
|
||||
|
||||
messageStream << m_createCDBPrefix;
|
||||
messageStream << m_endOfMessageToken;
|
||||
|
||||
return messageStream.str();
|
||||
}
|
||||
|
||||
std::vector<std::string> NetworkProtocolHelper::divideMessage(const std::string& message)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
@@ -37,19 +37,38 @@ public:
|
||||
bool valid;
|
||||
};
|
||||
|
||||
struct CreateCDBProjectMessage
|
||||
{
|
||||
public:
|
||||
CreateCDBProjectMessage()
|
||||
: cdbFileLocation("")
|
||||
, headerPaths()
|
||||
, ideId("")
|
||||
, valid(false)
|
||||
{}
|
||||
|
||||
std::string cdbFileLocation;
|
||||
std::vector<std::string> headerPaths;
|
||||
std::string ideId;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
enum MESSAGE_TYPE
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
SET_ACTIVE_TOKEN,
|
||||
CREATE_PROJECT
|
||||
CREATE_PROJECT,
|
||||
CREATE_CDB_MESSAGE
|
||||
};
|
||||
|
||||
static MESSAGE_TYPE getMessageType(const std::string& message);
|
||||
|
||||
static SetActiveTokenMessage parseSetActiveTokenMessage(const std::string& message);
|
||||
static CreateProjectMessage parseCreateProjectMessage(const std::string& message);
|
||||
static CreateCDBProjectMessage parseCreateCDBProjectMessage(const std::string& message);
|
||||
|
||||
static std::string buildMessage(const std::string& fileLocation, const unsigned int row, const unsigned int column);
|
||||
static std::string buildSetIDECursorMessage(const std::string& fileLocation, const unsigned int row, const unsigned int column);
|
||||
static std::string buildCreateCDBMessage();
|
||||
|
||||
private:
|
||||
static std::vector<std::string> divideMessage(const std::string& message);
|
||||
@@ -64,6 +83,8 @@ private:
|
||||
static std::string m_moveCursorPrefix;
|
||||
static std::string m_endOfMessageToken;
|
||||
static std::string m_createProjectPrefix;
|
||||
static std::string m_createCDBProjectPrefix;
|
||||
static std::string m_createCDBPrefix;
|
||||
};
|
||||
|
||||
#endif // NETWORK_PROTOCOL_HELPER_H
|
||||
@@ -0,0 +1,24 @@
|
||||
#ifndef MESSAGE_IDE_CREATE_CDB_H
|
||||
#define MESSAGE_IDE_CREATE_CDB_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageIDECreateCDB : public Message<MessageIDECreateCDB>
|
||||
{
|
||||
public:
|
||||
MessageIDECreateCDB()
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageIDECreateCDB";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << "Create CDB from current solution";
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MESSAGE_IDE_CREATE_CDB_H
|
||||
@@ -9,6 +9,7 @@ class MessageProjectNew
|
||||
public:
|
||||
MessageProjectNew()
|
||||
: solutionPath("")
|
||||
, headerPaths()
|
||||
, ideId("")
|
||||
{
|
||||
}
|
||||
@@ -23,12 +24,38 @@ public:
|
||||
return solutionPath.size() > 0;
|
||||
}
|
||||
|
||||
bool fromCDB() const
|
||||
{
|
||||
if (solutionPath.length() > 0)
|
||||
{
|
||||
size_t pos = solutionPath.find_last_of('.');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
std::string extension = solutionPath.substr(pos + 1);
|
||||
|
||||
return (extension == "json");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void setSolutionPath(const std::string& path)
|
||||
{
|
||||
solutionPath = path;
|
||||
}
|
||||
|
||||
void setHeaderPaths(const std::vector<std::string>& headerPaths)
|
||||
{
|
||||
this->headerPaths = headerPaths;
|
||||
}
|
||||
|
||||
std::string solutionPath;
|
||||
std::vector<std::string> headerPaths;
|
||||
std::string ideId;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user