Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNECrashDialog.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Dialog used for handling crashes produced in Netedit
19/****************************************************************************/
20
27
28#ifdef _MSC_VER
29#pragma warning(push)
30#pragma warning(disable: 4266) // mask warning about hidden member function FX::FXTextCodec::utf2mblen
31#endif
32#include <FX88591Codec.h>
33#include <FXUTF16Codec.h>
34#ifdef _MSC_VER
35#pragma warning(pop)
36#endif
37
38#include "GNECrashDialog.h"
39
40// ===========================================================================
41// FOX callback mapping
42// ===========================================================================
43
44// Map
45FXDEFMAP(GNECrashDialog) GNECrashDialogMap[] = {
46 FXMAPFUNC(SEL_CLIPBOARD_REQUEST, 0, GNECrashDialog::onClipboardRequest),
47};
48
49// Object implementation
50FXIMPLEMENT(GNECrashDialog, GNEDialog, GNECrashDialogMap, ARRAYNUMBER(GNECrashDialogMap))
51
52// ===========================================================================
53// method definitions
54// ===========================================================================
55
56GNECrashDialog::GNECrashDialog(GNEApplicationWindow* applicationWindow, const ProcessError& processError) :
57 GNEDialog(applicationWindow, TL("Critical error"), GUIIcon::ERROR_SMALL,
58 DialogType::ABOUT, GNEDialog::Buttons::OK_COPY_REPORT, OpenType::MODAL, ResizeMode::RESIZABLE, 800, 600),
59 myTraceText(processError.getTrace()) {
60 // create dialog layout (obtained from FXMessageBox)
61 auto contents = new FXVerticalFrame(myContentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10);
62 // add information label
63 new FXLabel(contents, TL("Netedit found an internal critical error and will be closed:"), NULL, GUIDesignLabel(JUSTIFY_NORMAL));
64 // create text field for exception
65 myExceptionTextField = new MFXTextFieldIcon(contents, applicationWindow->getStaticTooltipMenu(), GUIIcon::EMPTY, nullptr, 0, GUIDesignTextField);
66 myExceptionTextField->setEditable(FALSE);
67 myExceptionTextField->setText(processError.what());
68 // add information label
69 new FXLabel(contents, TL("ErrorTrace:"), NULL, GUIDesignLabel(JUSTIFY_NORMAL));
70 FXText* text = new FXText(contents, nullptr, 0, TEXT_WORDWRAP | LAYOUT_FILL_X | LAYOUT_FILL_Y);
71 text->setEditable(FALSE);
72 text->setText(myTraceText.c_str());
73 // disable copy button if trace is empty
74 if (myTraceText.size() == 0) {
75 myCopyButton->disable();
76 }
77 // open modal dialog
78 openDialog();
79}
80
81
84
85
86void
88 // nothing to do
89}
90
91
92long
93GNECrashDialog::onCmdCopy(FXObject*, FXSelector, void*) {
94 FXDragType types[4];
95 types[0] = stringType;
96 types[1] = textType;
97 types[2] = utf8Type;
98 types[3] = utf16Type;
99 // Acquire clipboard in different formats
100 acquireClipboard(types, 4);
101 return 1;
102}
103
104
105long
106GNECrashDialog::onCmdReport(FXObject*, FXSelector, void*) {
107 // open new issue
108 return MFXLinkLabel::fxexecute("https://github.com/eclipse-sumo/sumo/issues/new");
109}
110
111
112long
113GNECrashDialog::onClipboardRequest(FXObject* sender, FXSelector sel, void* ptr) {
114 FXEvent* event = (FXEvent*)ptr;
115 // Perhaps the target wants to supply its own data for the clipboard
116 if (GNEDialog::onClipboardRequest(sender, sel, ptr)) {
117 return 1;
118 }
119 // Recognize the request?
120 if (event->target == stringType || event->target == textType || event->target == utf8Type || event->target == utf16Type) {
121 // Return myClippedText text as as UTF-8
122 if (event->target == utf8Type) {
123 setDNDData(FROM_CLIPBOARD, event->target, myTraceText.c_str());
124 return 1;
125 }
126 // Return myClippedText text translated to 8859-1
127 if (event->target == stringType || event->target == textType) {
128 FX88591Codec ascii;
129 setDNDData(FROM_CLIPBOARD, event->target, ascii.utf2mb(myTraceText.c_str()));
130 return 1;
131 }
132 // Return text of the selection translated to UTF-16
133 if (event->target == utf16Type) {
134 FXUTF16LECodec unicode; // FIXME maybe other endianness for unix
135 setDNDData(FROM_CLIPBOARD, event->target, unicode.utf2mb(myTraceText.c_str()));
136 return 1;
137 }
138 }
139 return 0;
140}
141
142
143/****************************************************************************/
FXDEFMAP(GNECrashDialog) GNECrashDialogMap[]
DialogType
#define GUIDesignTextField
Definition GUIDesigns.h:74
#define GUIDesignLabel(justify)
Definition GUIDesigns.h:245
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:304
The main window of Netedit.
long onCmdReport(FXObject *, FXSelector, void *)
called when report button is pressed
long onClipboardRequest(FXObject *sender, FXSelector sel, void *ptr)
called when clipboard is request
long onCmdCopy(FXObject *, FXSelector, void *)
called when copy button is pressed
~GNECrashDialog()
Destructor.
std::string myTraceText
trace text
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
OpenType
Open dialog type.
Definition GNEDialog.h:58
dialog arguments, used for certain modal dialogs that can not be edited using tab