#include <netedit/GNEApplicationWindow.h>
#include <utils/common/MsgHandler.h>
#include <utils/foxtools/MFXLinkLabel.h>
#include <utils/foxtools/MFXTextFieldIcon.h>
#include <utils/gui/images/GUIIconSubSys.h>
#include <utils/gui/div/GUIDesigns.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4266)
#endif
#include <FX88591Codec.h>
#include <FXUTF16Codec.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "GNECrashDialog.h"
FXDEFMAP(GNECrashDialog) GNECrashDialogMap[] = {
FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GNECrashDialog::onClipboardRequest),
};
FXIMPLEMENT(GNECrashDialog, GNEDialog, GNECrashDialogMap, ARRAYNUMBER(GNECrashDialogMap))
GNECrashDialog::GNECrashDialog(GNEApplicationWindow* applicationWindow, const ProcessError& processError) :
GNEDialog(applicationWindow, TL("Critical error"), GUIIcon::ERROR_SMALL,
DialogType::ABOUT, GNEDialog::Buttons::OK_COPY_REPORT, OpenType::MODAL, ResizeMode::RESIZABLE, 800, 600),
myTraceText(processError.getTrace()) {
auto contents = new FXVerticalFrame(myContentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10);
new FXLabel(contents, TL("Netedit found an internal critical error and will be closed:"), NULL, GUIDesignLabel(JUSTIFY_NORMAL));
myExceptionTextField = new MFXTextFieldIcon(contents, applicationWindow->getStaticTooltipMenu(), GUIIcon::EMPTY, nullptr, 0, GUIDesignTextField);
myExceptionTextField->setEditable(FALSE);
myExceptionTextField->setText(processError.what());
new FXLabel(contents, TL("ErrorTrace:"), NULL, GUIDesignLabel(JUSTIFY_NORMAL));
FXText* text = new FXText(contents, nullptr, 0, TEXT_WORDWRAP | LAYOUT_FILL_X | LAYOUT_FILL_Y);
text->setEditable(FALSE);
text->setText(myTraceText.c_str());
if (myTraceText.size() == 0) {
myCopyButton->disable();
}
openDialog();
}
GNECrashDialog::~GNECrashDialog() {
}
void
GNECrashDialog::runInternalTest(const InternalTestStep::DialogArgument* ) {
}
long
GNECrashDialog::onCmdCopy(FXObject*, FXSelector, void*) {
FXDragType types[4];
types[0] = stringType;
types[1] = textType;
types[2] = utf8Type;
types[3] = utf16Type;
acquireClipboard(types, 4);
return 1;
}
long
GNECrashDialog::onCmdReport(FXObject*, FXSelector, void*) {
return MFXLinkLabel::fxexecute("https://github.com/eclipse-sumo/sumo/issues/new");
}
long
GNECrashDialog::onClipboardRequest(FXObject* sender, FXSelector sel, void* ptr) {
FXEvent* event = (FXEvent*)ptr;
if (GNEDialog::onClipboardRequest(sender, sel, ptr)) {
return 1;
}
if (event->target == stringType || event->target == textType || event->target == utf8Type || event->target == utf16Type) {
if (event->target == utf8Type) {
setDNDData(FROM_CLIPBOARD, event->target, myTraceText.c_str());
return 1;
}
if (event->target == stringType || event->target == textType) {
FX88591Codec ascii;
setDNDData(FROM_CLIPBOARD, event->target, ascii.utf2mb(myTraceText.c_str()));
return 1;
}
if (event->target == utf16Type) {
FXUTF16LECodec unicode;
setDNDData(FROM_CLIPBOARD, event->target, unicode.utf2mb(myTraceText.c_str()));
return 1;
}
}
return 0;
}