[DEV] start creating worker for display multiple saving
This commit is contained in:
parent
dc652a6237
commit
e32253cd98
@ -16,6 +16,7 @@
|
||||
const char* const appl::Buffer::eventIsModify = "edn-is-modify";
|
||||
const char* const appl::Buffer::eventIsSave = "edn-is-save";
|
||||
const char* const appl::Buffer::eventSelectChange = "edn-select-change";
|
||||
const char* const appl::Buffer::eventChangeName = "edn-buffer-name-change";
|
||||
|
||||
appl::Buffer::Iterator& appl::Buffer::Iterator::operator++ (void) {
|
||||
m_value = etk::UChar::Null;
|
||||
@ -109,13 +110,15 @@ appl::Buffer::Buffer(void) :
|
||||
m_cursorPos(0),
|
||||
m_cursorSelectPos(-1),
|
||||
m_cursorPreferredCol(-1),
|
||||
m_nbLines(0),
|
||||
m_nbLines(1),
|
||||
m_highlight(NULL) {
|
||||
static int32_t bufferBaseId = 0;
|
||||
m_fileName = "No Name " + std::to_string(bufferBaseId);
|
||||
bufferBaseId++;
|
||||
addEventId(eventIsModify);
|
||||
addEventId(eventIsSave);
|
||||
addEventId(eventSelectChange);
|
||||
addEventId(eventChangeName);
|
||||
}
|
||||
|
||||
appl::Buffer::~Buffer(void) {
|
||||
@ -151,6 +154,7 @@ void appl::Buffer::setFileName(const std::string& _name) {
|
||||
}
|
||||
m_fileName = _name;
|
||||
m_hasFileName = true;
|
||||
generateEventId(eventChangeName);
|
||||
setModification(true);
|
||||
}
|
||||
|
||||
@ -178,6 +182,10 @@ void appl::Buffer::setModification(bool _status) {
|
||||
|
||||
|
||||
void appl::Buffer::countNumberofLine(void) {
|
||||
if (m_data.size() == 0) {
|
||||
m_nbLines = 1;
|
||||
return;
|
||||
}
|
||||
m_nbLines = 0;
|
||||
for (Iterator it = begin();
|
||||
(bool)it == true;
|
||||
@ -470,7 +478,11 @@ void appl::Buffer::copy(std::string& _data, const appl::Buffer::Iterator& _pos,
|
||||
}
|
||||
|
||||
bool appl::Buffer::write(const std::string& _data, const appl::Buffer::Iterator& _pos) {
|
||||
m_data.insert(_pos, (int8_t*)(_data.c_str()), _data.size());
|
||||
if ((esize_t)_pos <= 0) {
|
||||
m_data.insert(0, (int8_t*)(_data.c_str()), _data.size());
|
||||
} else {
|
||||
m_data.insert(_pos, (int8_t*)(_data.c_str()), _data.size());
|
||||
}
|
||||
regenerateHighLightAt(_pos, 0, _data.size());
|
||||
m_selectMode = false;
|
||||
moveCursor((esize_t)_pos+_data.size());
|
||||
|
@ -264,6 +264,7 @@ namespace appl {
|
||||
static const char* const eventIsModify;
|
||||
static const char* const eventIsSave;
|
||||
static const char* const eventSelectChange;
|
||||
static const char* const eventChangeName;
|
||||
public:
|
||||
Buffer(void);
|
||||
~Buffer(void);
|
||||
|
@ -36,12 +36,23 @@ appl::BufferManager::~BufferManager(void) {
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
|
||||
appl::Buffer* appl::BufferManager::createNewBuffer(void) {
|
||||
appl::Buffer* tmp = new appl::Buffer();
|
||||
if (tmp == NULL) {
|
||||
APPL_ERROR("Can not allocate the Buffer (empty).");
|
||||
return NULL;
|
||||
}
|
||||
m_list.push_back(tmp);
|
||||
sendMultiCast(appl::MsgSelectNewFile, tmp->getFileName());
|
||||
return tmp;
|
||||
}
|
||||
|
||||
appl::Buffer* appl::BufferManager::get(const std::string& _fileName, bool _createIfNeeded) {
|
||||
for (esize_t iii = 0; iii < m_list.size(); ++iii) {
|
||||
if (m_list[iii] == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_list[iii]->getFileName() == _fileName) {
|
||||
return m_list[iii];
|
||||
}
|
||||
|
@ -55,6 +55,11 @@ namespace appl {
|
||||
appl::Buffer* get(esize_t _id) {
|
||||
return m_list[_id];
|
||||
}
|
||||
/**
|
||||
* @brief Create a new buffer empty.
|
||||
* @return Created buffer or NULL.
|
||||
*/
|
||||
appl::Buffer* createNewBuffer(void);
|
||||
private:
|
||||
appl::Buffer* m_bufferSelected;
|
||||
public:
|
||||
|
@ -46,6 +46,7 @@ BufferView::BufferView(void) {
|
||||
registerMultiCast(ednMsgBufferId);
|
||||
registerMultiCast(appl::MsgSelectNewFile);
|
||||
registerMultiCast(appl::MsgSelectChange);
|
||||
registerMultiCast(appl::MsgNameChange);
|
||||
m_selectedID = -1;
|
||||
m_selectedIdRequested = -1;
|
||||
// load buffer manager:
|
||||
@ -87,6 +88,7 @@ void BufferView::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
}
|
||||
buffer->registerOnEvent(this, appl::Buffer::eventIsSave);
|
||||
buffer->registerOnEvent(this, appl::Buffer::eventIsModify);
|
||||
buffer->registerOnEvent(this, appl::Buffer::eventChangeName);
|
||||
appl::dataBufferStruct* tmp = new appl::dataBufferStruct(_msg.getData(), buffer);
|
||||
if (tmp == NULL) {
|
||||
APPL_ERROR("Allocation error of the tmp buffer list element");
|
||||
@ -96,6 +98,16 @@ void BufferView::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
markToRedraw();
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == appl::Buffer::eventChangeName) {
|
||||
for (auto element : m_list) {
|
||||
if (element == NULL) {
|
||||
continue;
|
||||
}
|
||||
element->m_bufferName = element->m_buffer->getFileName();
|
||||
}
|
||||
markToRedraw();
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == appl::Buffer::eventIsSave) {
|
||||
markToRedraw();
|
||||
return;
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include <ewol/renderer/eContext.h>
|
||||
#include <date/date.h>
|
||||
#include <ewol/widget/meta/StdPopUp.h>
|
||||
#include <appl/Gui/WorkerSaveFile.h>
|
||||
#include <appl/Gui/WorkerCloseFile.h>
|
||||
|
||||
namespace appl
|
||||
{
|
||||
@ -269,6 +271,7 @@ MainWindows::MainWindows(void) {
|
||||
// Generic event ...
|
||||
registerMultiCast(ednMsgGuiSaveAs);
|
||||
registerMultiCast(ednMsgProperties);
|
||||
registerMultiCast(ednMsgGuiNew);
|
||||
registerMultiCast(ednMsgGuiOpen);
|
||||
registerMultiCast(ednMsgGuiClose);
|
||||
// to update the title ...
|
||||
@ -279,9 +282,7 @@ MainWindows::MainWindows(void) {
|
||||
|
||||
|
||||
MainWindows::~MainWindows(void) {
|
||||
if (m_bufferManager != NULL) {
|
||||
appl::BufferManager::release(m_bufferManager);
|
||||
}
|
||||
appl::BufferManager::release(m_bufferManager);
|
||||
}
|
||||
|
||||
|
||||
@ -292,7 +293,7 @@ const char *const ednEventPopUpFileSaveAs = "edn-mainWindows-saveAsSelected";
|
||||
void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
ewol::Windows::onReceiveMessage(_msg);
|
||||
|
||||
//APPL_INFO("Receive Event from the main windows ... : \"" << eventId << "\" == > data=\"" << data << "\"" );
|
||||
APPL_INFO("Receive Event from the main windows: " << _msg );
|
||||
// open file Section ...
|
||||
if (_msg.getMessage() == ednMsgGuiOpen) {
|
||||
widget::FileChooser* tmpWidget = new widget::FileChooser();
|
||||
@ -315,131 +316,6 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
// apply widget pop-up ...
|
||||
popUpWidgetPush(tmpWidget);
|
||||
tmpWidget->registerOnEvent(this, widget::FileChooser::eventValidate, ednEventPopUpFileSelected);
|
||||
} else if (_msg.getMessage() == ednEventPopUpFileSelected) {
|
||||
APPL_DEBUG("Request opening the file : " << _msg.getData());
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
return;
|
||||
}
|
||||
m_bufferManager->open(_msg.getData());
|
||||
} else if (_msg.getMessage() == ednMsgGuiSave) {
|
||||
APPL_DEBUG("Request saving the file : " << _msg.getData());
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
return;
|
||||
}
|
||||
if (to_lower(_msg.getData()) == "current") {
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_WARNING("No buffer selected !!! ");
|
||||
createPopUpMessage(ewol::Windows::messageTypeError, "No buffer selected !!!");
|
||||
return;
|
||||
}
|
||||
// Note : for direct saving, we do not chack the saving status ==> all time saving ...
|
||||
if (tmpBuffer->hasFileName() == false) {
|
||||
saveAsPopUp(tmpBuffer);
|
||||
return;
|
||||
}
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
|
||||
APPL_ERROR("can not save the file !!! '" << tmpBuffer->getFileName() << "'");
|
||||
}
|
||||
return;
|
||||
} else if (to_lower(_msg.getData()) == "all") {
|
||||
APPL_TODO("Need to save all the buffers ... ");
|
||||
for (esize_t iii=0; iii < m_bufferManager->size(); ++iii) {
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(iii);
|
||||
if (tmpBuffer == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->isModify() == false) {
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->hasFileName() == false) {
|
||||
// TODO : Has no name ==> must generate a save AS !!!
|
||||
APPL_TODO("Has no name ==> must generate a save AS");
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
|
||||
APPL_ERROR("can not save the file !!! '" << tmpBuffer->getFileName() << "'");
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
APPL_ERROR("UNKNOW request : " << _msg);
|
||||
}
|
||||
} else if (_msg.getMessage() == ednMsgGuiSaveAs) {
|
||||
if (_msg.getData() == "") {
|
||||
APPL_ERROR("Null data for Save As file ... ");
|
||||
} else {
|
||||
m_currentSavingAsIdBuffer = -1;
|
||||
if (_msg.getData() == "current") {
|
||||
m_currentSavingAsIdBuffer = -1;//BufferManager::getSelected();
|
||||
} else {
|
||||
sscanf(_msg.getData().c_str(), "%d", &m_currentSavingAsIdBuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
if (false == BufferManager::exist(m_currentSavingAsIdBuffer)) {
|
||||
APPL_ERROR("Request saveAs on non existant Buffer ID=" << m_currentSavingAsIdBuffer);
|
||||
} else {
|
||||
BufferText* myBuffer = BufferManager::get(m_currentSavingAsIdBuffer);
|
||||
widget::FileChooser* tmpWidget = new widget::FileChooser();
|
||||
if (NULL == tmpWidget) {
|
||||
APPL_ERROR("Can not allocate widget == > display might be in error");
|
||||
} else {
|
||||
tmpWidget->setTitle("Save files As...");
|
||||
tmpWidget->setValidateLabel("Save");
|
||||
std::string folder = "/home/";
|
||||
std::string fileName = "";
|
||||
if (true == myBuffer->haveName()) {
|
||||
etk::FSNode tmpName = myBuffer->getFileName();
|
||||
folder = tmpName.getNameFolder();
|
||||
fileName = tmpName.getNameFile();
|
||||
}
|
||||
tmpWidget->setFolder(folder);
|
||||
tmpWidget->setFileName(fileName);
|
||||
popUpWidgetPush(tmpWidget);
|
||||
tmpWidget->registerOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSaveAs);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
} else if (_msg.getMessage() == ednEventPopUpFileSaveAs) {
|
||||
// get the filename :
|
||||
std::string tmpData = _msg.getData();
|
||||
APPL_DEBUG("Request Saving As file : " << tmpData);
|
||||
/*
|
||||
BufferManager::get(m_currentSavingAsIdBuffer)->setFileName(tmpData);
|
||||
sendMultiCast(ednMsgGuiSave, m_currentSavingAsIdBuffer);
|
||||
*/
|
||||
} else if( _msg.getMessage() == ednMsgBufferState
|
||||
|| _msg.getMessage() == ednMsgBufferId) {
|
||||
// the buffer change we need to update the widget string
|
||||
/*
|
||||
BufferText* tmpBuffer = BufferManager::get(BufferManager::getSelected());
|
||||
if (NULL != tmpBuffer) {
|
||||
etk::FSNode compleateName = tmpBuffer->getFileName();
|
||||
bool isModify = tmpBuffer->isModify();
|
||||
std::string directName = compleateName.getName();
|
||||
if (true == isModify) {
|
||||
directName += " *";
|
||||
}
|
||||
if (NULL != m_widgetLabelFileName) {
|
||||
m_widgetLabelFileName->setLabel(std::string("<left>") + directName + "</left>");
|
||||
}
|
||||
std::string windowsTitle = "edn - ";
|
||||
windowsTitle += directName;
|
||||
setTitle(windowsTitle);
|
||||
return;
|
||||
} else {
|
||||
m_widgetLabelFileName->setLabel("");
|
||||
setTitle("edn");
|
||||
}
|
||||
*/
|
||||
return;
|
||||
// TODO : set the Title ....
|
||||
} else if (_msg.getMessage() == ednMsgProperties) {
|
||||
// Request the parameter GUI
|
||||
widget::Parameter* tmpWidget = new widget::Parameter();
|
||||
@ -462,14 +338,86 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
ewol::getContext().getResourcesManager().reLoadResources();
|
||||
ewol::getContext().forceRedrawAll();
|
||||
} else if (_msg.getMessage() == ednMsgGuiExit) {
|
||||
// TODO ...
|
||||
} else if (_msg.getMessage() == ednMsgGuiClose) {
|
||||
// TODO : ...
|
||||
}
|
||||
// Note : Fore all next message we need to acces to the buffer manager ==> just check one time ...
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == ednMsgGuiNew) {
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
return;
|
||||
}
|
||||
(void)m_bufferManager->createNewBuffer();
|
||||
} else if (_msg.getMessage() == ednEventPopUpFileSelected) {
|
||||
APPL_DEBUG("Request opening the file : " << _msg.getData());
|
||||
m_bufferManager->open(_msg.getData());
|
||||
} else if (_msg.getMessage() == ednMsgGuiSave) {
|
||||
APPL_DEBUG("Request saving the file : " << _msg.getData());
|
||||
if (to_lower(_msg.getData()) == "current") {
|
||||
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile("");
|
||||
#if 0
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_WARNING("No buffer selected !!! ");
|
||||
createPopUpMessage(ewol::Windows::messageTypeError, "No buffer selected !!!");
|
||||
return;
|
||||
}
|
||||
// Note : for direct saving, we do not chack the saving status ==> all time saving ...
|
||||
if (tmpBuffer->hasFileName() == false) {
|
||||
saveAsPopUp(tmpBuffer);
|
||||
return;
|
||||
}
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
|
||||
APPL_ERROR("can not save the file !!! '" << tmpBuffer->getFileName() << "'");
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
} else if (to_lower(_msg.getData()) == "all") {
|
||||
appl::WorkerSaveAllFile* tmpWorker = new appl::WorkerSaveAllFile();
|
||||
#if 0
|
||||
APPL_TODO("Need to save all the buffers ... ");
|
||||
for (esize_t iii=0; iii < m_bufferManager->size(); ++iii) {
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(iii);
|
||||
if (tmpBuffer == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->isModify() == false) {
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->hasFileName() == false) {
|
||||
// TODO : Has no name ==> must generate a save AS !!!
|
||||
APPL_TODO("Has no name ==> must generate a save AS");
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
|
||||
APPL_ERROR("can not save the file !!! '" << tmpBuffer->getFileName() << "'");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
} else {
|
||||
APPL_ERROR("UNKNOW request : " << _msg);
|
||||
}
|
||||
} else if (_msg.getMessage() == ednMsgGuiSaveAs) {
|
||||
appl::WorkerSaveFile* tmpWorker = new appl::WorkerSaveFile("", true);
|
||||
#if 0
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer ... " << _msg.getData());
|
||||
return;
|
||||
}
|
||||
saveAsPopUp(tmpBuffer);
|
||||
#endif
|
||||
} else if (_msg.getMessage() == ednMsgGuiClose) {
|
||||
// Get a ref on the buffer selected (if null, no buffer was selected ...)
|
||||
if (_msg.getData() == "current") {
|
||||
appl::WorkerCloseFile* tmpWorker = new appl::WorkerCloseFile("");
|
||||
#if 0
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->getBufferSelected();
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer ... " << _msg.getData());
|
||||
@ -480,16 +428,16 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
} else {
|
||||
tmpBuffer->removeObject();
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// ALL !!!
|
||||
appl::WorkerCloseAllFile* tmpWorker = new appl::WorkerCloseAllFile();
|
||||
#if 0
|
||||
// TODO : How to generate the save for all ...
|
||||
APPL_TODO("Close all the buffer.");
|
||||
#endif
|
||||
}
|
||||
} else if (_msg.getMessage() == mainWindowsRequestSaveFile) { // return after a choice of close...
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
return;
|
||||
}
|
||||
if (m_bufferManager->exist(_msg.getData()) == false) {
|
||||
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
|
||||
return;
|
||||
@ -503,14 +451,12 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
APPL_ERROR("Will never arrive");
|
||||
saveAsPopUp(tmpBuffer);
|
||||
} else {
|
||||
// TODO : Save the file ...
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
APPL_ERROR("Error when loading the file " << _msg.getData());
|
||||
displayErrorMessage("Error when loading the file <br/><i>" + _msg.getData() + "</i>");
|
||||
}
|
||||
}
|
||||
} else if (_msg.getMessage() == mainWindowsRequestSaveFileAs) { // return after a choice of close...
|
||||
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
return;
|
||||
}
|
||||
if (m_bufferManager->exist(_msg.getData()) == false) {
|
||||
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
|
||||
return;
|
||||
@ -522,10 +468,6 @@ void MainWindows::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
}
|
||||
saveAsPopUp(tmpBuffer);
|
||||
} else if (_msg.getMessage() == mainWindowsRequestcloseFileNoCheck) { // return after a choice of close...
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
return;
|
||||
}
|
||||
if (m_bufferManager->exist(_msg.getData()) == false) {
|
||||
APPL_ERROR("Try to save an non-existant file :" << _msg.getData());
|
||||
return;
|
||||
@ -546,24 +488,7 @@ void MainWindows::saveAsPopUp(appl::Buffer* _buffer) {
|
||||
APPL_ERROR("Call With NULL input...");
|
||||
return;
|
||||
}
|
||||
widget::FileChooser* tmpWidget = new widget::FileChooser();
|
||||
if (NULL == tmpWidget) {
|
||||
APPL_ERROR("Can not allocate widget == > display might be in error");
|
||||
return;
|
||||
}
|
||||
tmpWidget->setTitle("Save files As...");
|
||||
tmpWidget->setValidateLabel("Save");
|
||||
std::string folder = "/home/";
|
||||
std::string fileName = "";
|
||||
/*if (true == _buffer->hasFileName()) */{
|
||||
etk::FSNode tmpName(_buffer->getFileName());
|
||||
folder = tmpName.getNameFolder();
|
||||
fileName = tmpName.getNameFile();
|
||||
}
|
||||
tmpWidget->setFolder(folder);
|
||||
tmpWidget->setFileName(fileName);
|
||||
popUpWidgetPush(tmpWidget);
|
||||
//tmpWidget->registerOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSaveAs);
|
||||
appl::WorkerSaveFile* tmpObject = new appl::WorkerSaveFile(_buffer->getFileName());
|
||||
}
|
||||
|
||||
void MainWindows::closeNotSavedFile(appl::Buffer* _buffer) {
|
||||
|
@ -38,7 +38,6 @@ class MainWindows : public ewol::Windows {
|
||||
*/
|
||||
void closeNotSavedFile(appl::Buffer* _buffer);
|
||||
public: // Derived function
|
||||
virtual const char * const getObjectType(void) { return "MainWindows"; };
|
||||
virtual void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
virtual void onObjectRemove(ewol::EObject * _removeObject);
|
||||
};
|
||||
|
@ -24,7 +24,6 @@ class Search : public widget::Sizer
|
||||
Search(void);
|
||||
~Search(void);
|
||||
public: // derived function
|
||||
virtual const char * const getObjectType(void) { return "ApplSearch"; };
|
||||
virtual void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
virtual void onObjectRemove(ewol::EObject * _removeObject);
|
||||
};
|
||||
|
@ -45,10 +45,6 @@ namespace appl {
|
||||
uint32_t getNuberOfRaw(void);
|
||||
bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
|
||||
bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
|
||||
// derived function
|
||||
const char * const getObjectType(void) {
|
||||
return "appl::TagFileList";
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* @brief add a Ctags item on the curent list
|
||||
|
@ -31,7 +31,6 @@ namespace appl {
|
||||
*/
|
||||
void addCtagsNewItem(std::string file, int32_t line);
|
||||
public: // herited function
|
||||
const char * const getObjectType(void) { return "EwolFileChooser"; };
|
||||
void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
void onObjectRemove(ewol::EObject * _removeObject);
|
||||
};
|
||||
|
@ -54,7 +54,6 @@ namespace appl {
|
||||
protected: // derived function
|
||||
virtual void onDraw(void);
|
||||
public: // Derived function
|
||||
const char * const getObjectType(void) { return "appl::TextViewer"; };
|
||||
virtual bool calculateMinSize(void);
|
||||
virtual void onRegenerateDisplay(void);
|
||||
virtual void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
|
0
sources/appl/Gui/WorkerCloseAllFile.cpp
Normal file
0
sources/appl/Gui/WorkerCloseAllFile.cpp
Normal file
0
sources/appl/Gui/WorkerCloseAllFile.h
Normal file
0
sources/appl/Gui/WorkerCloseAllFile.h
Normal file
114
sources/appl/Gui/WorkerCloseFile.cpp
Normal file
114
sources/appl/Gui/WorkerCloseFile.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/renderer/eContext.h>
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Gui/WorkerCloseFile.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "WorkerCloseFile"
|
||||
|
||||
static const char* s_saveAsValidate = "save-as-validate";
|
||||
static const char* s_saveValidate = "save-validate";
|
||||
static const char* s_closeValidate = "close-validate";
|
||||
|
||||
appl::WorkerCloseFile::WorkerCloseFile(const std::string& _bufferName) :
|
||||
m_closeAfter(_close),
|
||||
m_bufferName(_bufferName),
|
||||
m_worker(NULL),
|
||||
m_bufferManager(NULL) {
|
||||
// load buffer manager:
|
||||
m_bufferManager = appl::BufferManager::keep();
|
||||
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
if (m_bufferManager->exist(m_bufferName) == false) {
|
||||
APPL_ERROR("Try to close an non-existant file :" << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
if (tmpBuffer->isModify() == false) {
|
||||
tmpBuffer->removeObject();
|
||||
// TODO : Send message ...
|
||||
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
widget::StdPopUp* tmpPopUp = new widget::StdPopUp();
|
||||
if (tmpPopUp == NULL) {
|
||||
APPL_ERROR("Can not create a simple pop-up");
|
||||
return;
|
||||
}
|
||||
tmpPopUp->setTitle("<bold>Close un-saved file:</bold>");
|
||||
tmpPopUp->setComment("The file named : <i>\"" + tmpBuffer->getFileName() + "\"</i> is curently modify. <br/>If you don't saves these modifications,<br/>they will be definitly lost...");
|
||||
ewol::Widget* bt = NULL;
|
||||
if (tmpBuffer->hasFileName() == true) {
|
||||
bt = tmpPopUp->addButton("Save", true);
|
||||
if (bt != NULL) {
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_saveValidate, tmpBuffer->getFileName());
|
||||
}
|
||||
}
|
||||
bt = tmpPopUp->addButton("Save As", true);
|
||||
if (bt != NULL) {
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_saveAsValidate, tmpBuffer->getFileName());
|
||||
}
|
||||
bt = tmpPopUp->addButton("Close", true);
|
||||
if (bt != NULL) {
|
||||
bt->registerOnEvent(this, widget::Button::eventPressed, s_closeValidate, tmpBuffer->getFileName());
|
||||
}
|
||||
tmpPopUp->addButton("Cancel", true);
|
||||
tmpPopUp->setRemoveOnExternClick(true);
|
||||
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
|
||||
if (tmpWindows == NULL) {
|
||||
APPL_ERROR("Error to get the windows.");
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
tmpWindows->popUpWidgetPush(tmpPopUp);
|
||||
}
|
||||
|
||||
appl::WorkerCloseFile::~WorkerCloseFile(void) {
|
||||
appl::BufferManager::release(m_bufferManager);
|
||||
}
|
||||
|
||||
void appl::WorkerCloseFile::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
if (m_bufferManager == NULL) {
|
||||
// nothing to do in this case ==> can do nothing ...
|
||||
return;
|
||||
}
|
||||
APPL_DEBUG("have message : " << _msg);
|
||||
if (_msg.getMessage() == s_saveAsValidate) {
|
||||
|
||||
} else if (_msg.getMessage() == s_saveValidate) {
|
||||
|
||||
} else if (_msg.getMessage() == s_closeValidate) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void appl::WorkerCloseFile::onObjectRemove(ewol::EObject* _removeObject) {
|
||||
if (_removeObject == m_worker) {
|
||||
m_worker = NULL;
|
||||
APPL_VERBOSE("AutoRemove After closing sub widget ...");
|
||||
autoDestroy();
|
||||
} else if (_removeObject == m_bufferManager) {
|
||||
m_bufferManager = NULL;
|
||||
autoDestroy();
|
||||
}
|
||||
}
|
||||
|
32
sources/appl/Gui/WorkerCloseFile.h
Normal file
32
sources/appl/Gui/WorkerCloseFile.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __WORKER_CLOSE_FILE_H__
|
||||
#define __WORKER_CLOSE_FILE_H__
|
||||
|
||||
#include <ewol/widget/meta/FileChooser.h>
|
||||
#include <appl/BufferManager.h>
|
||||
#include <appl/Gui/WorkerSaveFile.h>
|
||||
|
||||
namespace appl {
|
||||
class WorkerCloseFile : public ewol::EObject {
|
||||
public:
|
||||
// note : if == "" ==> current ...
|
||||
WorkerCloseFile(const std::string& _bufferName);
|
||||
virtual ~WorkerCloseFile(void);
|
||||
private:
|
||||
std::string m_bufferName;
|
||||
appl::WorkerSaveFile* m_worker; //! sub-worker element...
|
||||
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
|
||||
public: // derived function
|
||||
virtual void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
virtual void onObjectRemove(ewol::EObject * _removeObject);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
96
sources/appl/Gui/WorkerSaveAllFile.cpp
Normal file
96
sources/appl/Gui/WorkerSaveAllFile.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/renderer/eContext.h>
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Gui/WorkerSaveFile.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "WorkerSaveFile"
|
||||
|
||||
static const char* s_saveAsDone = "save-as-done";
|
||||
|
||||
appl::WorkerSaveAllFile::WorkerSaveAllFile(void) :
|
||||
m_worker(NULL),
|
||||
m_bufferManager(NULL) {
|
||||
// load buffer manager:
|
||||
m_bufferManager = appl::BufferManager::keep();
|
||||
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
// List all current open file :
|
||||
for (size_t iii=0; iii<m_bufferManager->size(); ++iii) {
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(iii);
|
||||
if (tmpBuffer == NULL) {
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->isModify() == false) {
|
||||
continue;
|
||||
}
|
||||
if (tmpBuffer->hasFileName() == false) {
|
||||
m_bufferNameList.push_back(tmpBuffer->getFileName());
|
||||
} else {
|
||||
tmpBuffer->storeFile();
|
||||
}
|
||||
}
|
||||
// checkif an element has something to do in the queue
|
||||
if (m_bufferNameList.size() == 0) {
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
// create the worker :
|
||||
m_worker = new appl::WorkerSaveFile(m_bufferNameList.front());
|
||||
// remove first element :
|
||||
m_bufferNameList.pop_front();
|
||||
if (m_bufferNameList.size() == 0) {
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
|
||||
}
|
||||
|
||||
appl::WorkerSaveAllFile::~WorkerSaveAllFile(void) {
|
||||
appl::BufferManager::release(m_bufferManager);
|
||||
}
|
||||
|
||||
void appl::WorkerSaveAllFile::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
if (m_bufferManager == NULL) {
|
||||
// nothing to do in this case ==> can do nothing ...
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == s_saveAsDone) {
|
||||
if (m_bufferNameList.size() == 0) {
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
// create the worker :
|
||||
m_worker = new appl::WorkerSaveFile(m_bufferNameList.front());
|
||||
// remove first element :
|
||||
m_bufferNameList.pop_front();
|
||||
if (m_bufferNameList.size() == 0) {
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
m_worker->registerOnEvent(this, appl::WorkerSaveFile::eventSaveDone, s_saveAsDone);
|
||||
}
|
||||
}
|
||||
|
||||
void appl::WorkerSaveAllFile::onObjectRemove(ewol::EObject* _removeObject) {
|
||||
if (_removeObject == m_worker) {
|
||||
m_worker = NULL;
|
||||
APPL_VERBOSE("AutoRemove After saving sub widget ...");
|
||||
autoDestroy();
|
||||
} else if (_removeObject == m_bufferManager) {
|
||||
m_bufferManager = NULL;
|
||||
autoDestroy();
|
||||
}
|
||||
}
|
||||
|
30
sources/appl/Gui/WorkerSaveAllFile.h
Normal file
30
sources/appl/Gui/WorkerSaveAllFile.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __WORKER_SAVE_ALL_FILE_H__
|
||||
#define __WORKER_SAVE_ALL_FILE_H__
|
||||
|
||||
#include <appl/BufferManager.h>
|
||||
#include <appl/Gui/WorkerSaveFile.h>
|
||||
|
||||
namespace appl {
|
||||
class WorkerSaveAllFile : public ewol::EObject {
|
||||
public:
|
||||
WorkerSaveAllFile(void);
|
||||
virtual ~WorkerSaveAllFile(void);
|
||||
private:
|
||||
std::vector<std::string> m_bufferNameList;
|
||||
appl::WorkerSaveFile* m_worker; //! pop-up element that is open...
|
||||
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
|
||||
public: // derived function
|
||||
virtual void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
virtual void onObjectRemove(ewol::EObject * _removeObject);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
110
sources/appl/Gui/WorkerSaveFile.cpp
Normal file
110
sources/appl/Gui/WorkerSaveFile.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <ewol/renderer/eContext.h>
|
||||
#include <appl/debug.h>
|
||||
#include <appl/Gui/WorkerSaveFile.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "WorkerSaveFile"
|
||||
|
||||
static const char* appl::WorkerSaveFile::eventSaveDone = "save-file-done";
|
||||
|
||||
static const char* s_saveAsValidate = "save-as-validate";
|
||||
|
||||
appl::WorkerSaveFile::WorkerSaveFile(const std::string& _bufferName, bool _forceSaveAs) :
|
||||
m_bufferName(_bufferName),
|
||||
m_chooser(NULL),
|
||||
m_bufferManager(NULL) {
|
||||
addEventId(eventSaveDone);
|
||||
// load buffer manager:
|
||||
m_bufferManager = appl::BufferManager::keep();
|
||||
|
||||
if (m_bufferManager == NULL) {
|
||||
APPL_ERROR("can not call unexistant buffer manager ... ");
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
// TODO : if "" ==> it is current buffer selected ...
|
||||
if (m_bufferManager->exist(m_bufferName) == false) {
|
||||
APPL_ERROR("Try to save an non-existant file :" << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
m_chooser = new widget::FileChooser();
|
||||
if (NULL == m_chooser) {
|
||||
APPL_ERROR("Can not allocate widget == > display might be in error");
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
m_chooser->setTitle("Save files As...");
|
||||
m_chooser->setValidateLabel("Save");
|
||||
etk::FSNode tmpName(m_bufferName);
|
||||
m_chooser->setFolder(tmpName.getNameFolder());
|
||||
m_chooser->setFileName(tmpName.getNameFile());
|
||||
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
|
||||
if (tmpWindows == NULL) {
|
||||
APPL_ERROR("Error to get the windows.");
|
||||
autoDestroy();
|
||||
return;
|
||||
}
|
||||
tmpWindows->popUpWidgetPush(m_chooser);
|
||||
m_chooser->registerOnEvent(this, widget::FileChooser::eventValidate, s_saveAsValidate);
|
||||
}
|
||||
|
||||
appl::WorkerSaveFile::~WorkerSaveFile(void) {
|
||||
appl::BufferManager::release(m_bufferManager);
|
||||
}
|
||||
|
||||
void appl::WorkerSaveFile::onReceiveMessage(const ewol::EMessage& _msg) {
|
||||
if (m_bufferManager == NULL) {
|
||||
// nothing to do in this case ==> can do nothing ...
|
||||
return;
|
||||
}
|
||||
if (_msg.getMessage() == s_saveAsValidate) {
|
||||
if (_msg.getData() == "") {
|
||||
APPL_ERROR(" might be an error of the File chooser system...");
|
||||
return;
|
||||
}
|
||||
if (m_bufferManager->exist(m_bufferName) == false) {
|
||||
APPL_ERROR("Try to save an non-existant file :" << m_bufferName);
|
||||
return;
|
||||
}
|
||||
appl::Buffer* tmpBuffer = m_bufferManager->get(m_bufferName);
|
||||
if (tmpBuffer == NULL) {
|
||||
APPL_ERROR("Error to get the buffer : " << m_bufferName);
|
||||
return;
|
||||
}
|
||||
tmpBuffer->setFileName(_msg.getData());
|
||||
if (tmpBuffer->storeFile() == false) {
|
||||
ewol::Windows* tmpWindows = ewol::getContext().getWindows();
|
||||
if (tmpWindows == NULL) {
|
||||
return;
|
||||
}
|
||||
tmpWindows->displayWarningMessage("We can not save the file : <br/><i>" + tmpBuffer->getFileName() + "</i>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void appl::WorkerSaveFile::onObjectRemove(ewol::EObject* _removeObject) {
|
||||
if (_removeObject == m_chooser) {
|
||||
m_chooser = NULL;
|
||||
APPL_VERBOSE("AutoRemove After closing sub widget ...");
|
||||
autoDestroy();
|
||||
} else if (_removeObject == m_bufferManager) {
|
||||
m_bufferManager = NULL;
|
||||
autoDestroy();
|
||||
}
|
||||
}
|
||||
|
32
sources/appl/Gui/WorkerSaveFile.h
Normal file
32
sources/appl/Gui/WorkerSaveFile.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __WORKER_SAVE_FILE_H__
|
||||
#define __WORKER_SAVE_FILE_H__
|
||||
|
||||
#include <ewol/widget/meta/FileChooser.h>
|
||||
#include <appl/BufferManager.h>
|
||||
|
||||
namespace appl {
|
||||
class WorkerSaveFile : public ewol::EObject {
|
||||
public:
|
||||
static const char* eventSaveDone;
|
||||
public:
|
||||
WorkerSaveFile(const std::string& _bufferName, bool _forceSaveAs=false);
|
||||
virtual ~WorkerSaveFile(void);
|
||||
private:
|
||||
std::string m_bufferName;
|
||||
widget::FileChooser* m_chooser; //! pop-up element that is open...
|
||||
appl::BufferManager* m_bufferManager; //!< handle on the buffer manager
|
||||
public: // derived function
|
||||
virtual void onReceiveMessage(const ewol::EMessage& _msg);
|
||||
virtual void onObjectRemove(ewol::EObject * _removeObject);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -60,5 +60,6 @@ extern const char* const ednMsgBufferColor = "edn-Msg-Buffer-Color";
|
||||
|
||||
extern const char* const appl::MsgSelectNewFile = "edn-msg-select-new-file";
|
||||
extern const char* const appl::MsgSelectChange = "edn-msg-select-change";
|
||||
extern const char* const appl::MsgNameChange = "edn-msg-buffer-name-change";
|
||||
|
||||
|
||||
|
@ -60,6 +60,7 @@
|
||||
namespace appl {
|
||||
extern const char* const MsgSelectNewFile; // data : "buffer/name"
|
||||
extern const char* const MsgSelectChange; // data : ""
|
||||
extern const char* const MsgNameChange; // data : ""
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -34,9 +34,6 @@
|
||||
#include <regex>
|
||||
#include <etk/unicode.h>
|
||||
|
||||
char32_t mychar32;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
|
||||
* @param std IO
|
||||
|
@ -25,7 +25,11 @@ def Create(target):
|
||||
'appl/Gui/Search.cpp',
|
||||
'appl/Gui/SearchData.cpp',
|
||||
'appl/Gui/TagFileSelection.cpp',
|
||||
'appl/Gui/TagFileList.cpp'])
|
||||
'appl/Gui/TagFileList.cpp',
|
||||
'appl/Gui/WorkerSaveFile.cpp',
|
||||
'appl/Gui/WorkerSaveAllFile.cpp',
|
||||
'appl/Gui/WorkerCloseFile.cpp',
|
||||
'appl/Gui/WorkerCloseAllFile.cpp'])
|
||||
|
||||
# All needed for the buffer management :
|
||||
myModule.AddSrcFile([
|
||||
|
Loading…
x
Reference in New Issue
Block a user