Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/options/GNEOptionsEditorRow.cpp
169684 views
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
/****************************************************************************/
14
/// @file GNEOptionsEditorRow.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date May 2023
17
///
18
// Row used in GNEOptionsEditor to edit options
19
/****************************************************************************/
20
#include <config.h>
21
22
#include <netedit/dialogs/GNEDialog.h>
23
#include <netedit/GNEApplicationWindow.h>
24
#include <utils/common/MsgHandler.h>
25
#include <utils/common/StringTokenizer.h>
26
#include <utils/foxtools/MFXLabelTooltip.h>
27
#include <utils/gui/div/GUIDesigns.h>
28
29
#include "GNEOptionsEditorRow.h"
30
#include "GNEOptionsEditor.h"
31
32
// ===========================================================================
33
// Defines
34
// ===========================================================================
35
36
#define MARGIN 4
37
#define MINNAMEWIDTH 200
38
39
// ===========================================================================
40
// FOX callback mapping
41
// ===========================================================================
42
43
FXDEFMAP(GNEOptionsEditorRow::OptionRow) OptionRowMap[] = {
44
FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEOptionsEditorRow::OptionRow::onCmdSetOption),
45
FXMAPFUNC(SEL_COMMAND, MID_GNE_RESET, GNEOptionsEditorRow::OptionRow::onCmdResetOption),
46
};
47
48
FXDEFMAP(GNEOptionsEditorRow::OptionFilename) OptionFilenameMap[] = {
49
FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE_DIALOG, GNEOptionsEditorRow::OptionFilename::onCmdOpenDialog),
50
};
51
52
// Object implementation
53
FXIMPLEMENT_ABSTRACT(GNEOptionsEditorRow::OptionRow, FXHorizontalFrame, OptionRowMap, ARRAYNUMBER(OptionRowMap))
54
FXIMPLEMENT_ABSTRACT(GNEOptionsEditorRow::OptionFilename, GNEOptionsEditorRow::OptionRow, OptionFilenameMap, ARRAYNUMBER(OptionFilenameMap))
55
56
// ===========================================================================
57
// method definitions
58
// ===========================================================================
59
60
// ---------------------------------------------------------------------------
61
// GNEOptionsEditorRow::OptionRow - methods
62
// ---------------------------------------------------------------------------
63
64
GNEOptionsEditorRow::OptionRow::OptionRow(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
65
const std::string& name, const std::string& description, const std::string& defaultValue) :
66
FXHorizontalFrame(parent, GUIDesignAuxiliarHorizontalFrame),
67
myOptionsEditor(optionsEditor),
68
myTopic(topic),
69
myName(name),
70
myDescription(description),
71
myDefaultValue(defaultValue) {
72
// build label with name (default width 150)
73
myNameLabel = new MFXLabelTooltip(this, myOptionsEditor->myDialog->getApplicationWindow()->getStaticTooltipMenu(),
74
name.c_str(), nullptr, GUIDesignLabelThickedFixed(MINNAMEWIDTH));
75
// set description as tooltip
76
myNameLabel->setTipText(description.c_str());
77
// create content frame
78
myContentFrame = new FXHorizontalFrame(this, GUIDesignAuxiliarHorizontalFrame);
79
// Create reset button
80
myResetButton = GUIDesigns::buildFXButton(this, "", "", TL("Reset value"), GUIIconSubSys::getIcon(GUIIcon::RESET), this, MID_GNE_RESET, GUIDesignButtonIcon);
81
}
82
83
84
void
85
GNEOptionsEditorRow::OptionRow::adjustNameSize() {
86
const int nameWidth = myNameLabel->getFont()->getTextWidth(myNameLabel->getText().text(), myNameLabel->getText().length() + MARGIN);
87
if (nameWidth > MINNAMEWIDTH) {
88
myNameLabel->setWidth(nameWidth);
89
}
90
}
91
92
93
const std::string&
94
GNEOptionsEditorRow::OptionRow::getTopic() const {
95
return myTopic;
96
}
97
98
99
const std::string
100
GNEOptionsEditorRow::OptionRow::getNameLower() const {
101
return StringUtils::to_lower_case(myName);
102
}
103
104
105
const std::string
106
GNEOptionsEditorRow::OptionRow::getDescriptionLower() const {
107
return StringUtils::to_lower_case(myDescription);
108
}
109
110
111
void
112
GNEOptionsEditorRow::OptionRow::updateResetButton() {
113
if (getValue() != myDefaultValue) {
114
myResetButton->enable();
115
} else {
116
myResetButton->disable();
117
}
118
}
119
120
// ---------------------------------------------------------------------------
121
// GNEOptionsEditorRow::OptionString - methods
122
// ---------------------------------------------------------------------------
123
124
GNEOptionsEditorRow::OptionString::OptionString(GNEOptionsEditor* optionsEditor, FXComposite* parent,
125
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
126
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
127
myStringTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
128
myStringTextField->setText(myOptionsEditor->myOptionsContainer.getString(name).c_str());
129
updateOption();
130
}
131
132
133
void
134
GNEOptionsEditorRow::OptionString::updateOption() {
135
myStringTextField->setText(myOptionsEditor->myOptionsContainer.getString(myName).c_str());
136
updateResetButton();
137
}
138
139
140
void
141
GNEOptionsEditorRow::OptionString::restoreOption() {
142
myStringTextField->setText(myOptionsEditor->myOriginalOptionsContainer.getString(myName).c_str());
143
onCmdSetOption(nullptr, 0, nullptr);
144
}
145
146
147
long
148
GNEOptionsEditorRow::OptionString::onCmdSetOption(FXObject*, FXSelector, void*) {
149
myOptionsEditor->myOptionsContainer.resetWritable();
150
myOptionsEditor->myOptionsContainer.set(myName, myStringTextField->getText().text());
151
myOptionsEditor->myOptionsModified = true;
152
updateResetButton();
153
return 1;
154
}
155
156
157
long
158
GNEOptionsEditorRow::OptionString::onCmdResetOption(FXObject*, FXSelector, void*) {
159
myStringTextField->setText(myDefaultValue.c_str());
160
updateResetButton();
161
return 1;
162
}
163
164
165
std::string
166
GNEOptionsEditorRow::OptionString::getValue() const {
167
return myStringTextField->getText().text();
168
}
169
170
171
GNEOptionsEditorRow::OptionStringVector::OptionStringVector(GNEOptionsEditor* optionsEditor, FXComposite* parent,
172
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
173
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
174
myStringVectorTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
175
updateOption();
176
}
177
178
179
void
180
GNEOptionsEditorRow::OptionStringVector::updateOption() {
181
myStringVectorTextField->setText(toString(myOptionsEditor->myOptionsContainer.getStringVector(myName)).c_str());
182
updateResetButton();
183
}
184
185
186
void
187
GNEOptionsEditorRow::OptionStringVector::restoreOption() {
188
myStringVectorTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getStringVector(myName)).c_str());
189
onCmdSetOption(nullptr, 0, nullptr);
190
}
191
192
193
long
194
GNEOptionsEditorRow::OptionStringVector::onCmdSetOption(FXObject*, FXSelector, void*) {
195
myOptionsEditor->myOptionsContainer.resetWritable();
196
myOptionsEditor->myOptionsContainer.set(myName, myStringVectorTextField->getText().text());
197
myOptionsEditor->myOptionsModified = true;
198
updateResetButton();
199
return 1;
200
}
201
202
203
long
204
GNEOptionsEditorRow::OptionStringVector::onCmdResetOption(FXObject*, FXSelector, void*) {
205
myStringVectorTextField->setText(myDefaultValue.c_str());
206
updateResetButton();
207
return 1;
208
}
209
210
211
std::string
212
GNEOptionsEditorRow::OptionStringVector::getValue() const {
213
return myStringVectorTextField->getText().text();
214
}
215
216
// ---------------------------------------------------------------------------
217
// GNEOptionsEditorRow::OptionBool - methods
218
// ---------------------------------------------------------------------------
219
220
GNEOptionsEditorRow::OptionBool::OptionBool(GNEOptionsEditor* optionsEditor, FXComposite* parent,
221
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
222
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
223
myCheckButton = new FXCheckButton(myContentFrame, "", this, MID_GNE_SET_ATTRIBUTE, GUIDesignCheckButton);
224
updateOption();
225
}
226
227
228
void
229
GNEOptionsEditorRow::OptionBool::updateOption() {
230
if (myOptionsEditor->myOptionsContainer.getBool(myName)) {
231
myCheckButton->setCheck(TRUE);
232
myCheckButton->setText(TL("true"));
233
} else {
234
myCheckButton->setCheck(FALSE);
235
myCheckButton->setText(TL("false"));
236
}
237
updateResetButton();
238
}
239
240
241
void
242
GNEOptionsEditorRow::OptionBool::restoreOption() {
243
if (myOptionsEditor->myOriginalOptionsContainer.getBool(myName)) {
244
myCheckButton->setCheck(TRUE);
245
myCheckButton->setText(TL("true"));
246
} else {
247
myCheckButton->setCheck(FALSE);
248
myCheckButton->setText(TL("false"));
249
}
250
onCmdSetOption(nullptr, 0, nullptr);
251
}
252
253
254
long
255
GNEOptionsEditorRow::OptionBool::onCmdSetOption(FXObject*, FXSelector, void*) {
256
myOptionsEditor->myOptionsContainer.resetWritable();
257
if (myCheckButton->getCheck()) {
258
myOptionsEditor->myOptionsContainer.set(myName, "true");
259
myCheckButton->setText(TL("true"));
260
} else {
261
myOptionsEditor->myOptionsContainer.set(myName, "false");
262
myCheckButton->setText(TL("false"));
263
}
264
myOptionsEditor->myOptionsModified = true;
265
// special checks for Debug flags
266
if ((myName == "gui-testing-debug") && myOptionsEditor->myOptionsContainer.isSet("gui-testing-debug")) {
267
MsgHandler::enableDebugMessages(myOptionsEditor->myOptionsContainer.getBool("gui-testing-debug"));
268
}
269
if ((myName == "gui-testing-debug-gl") && myOptionsEditor->myOptionsContainer.isSet("gui-testing-debug-gl")) {
270
MsgHandler::enableDebugGLMessages(myOptionsEditor->myOptionsContainer.getBool("gui-testing-debug-gl"));
271
}
272
updateResetButton();
273
return 1;
274
}
275
276
277
long
278
GNEOptionsEditorRow::OptionBool::onCmdResetOption(FXObject*, FXSelector, void*) {
279
if (myDefaultValue.empty()) {
280
myCheckButton->setCheck(FALSE);
281
myCheckButton->setText(TL("false"));
282
} else if (StringUtils::toBool(myDefaultValue)) {
283
myCheckButton->setCheck(TRUE);
284
myCheckButton->setText(TL("true"));
285
} else {
286
myCheckButton->setCheck(FALSE);
287
myCheckButton->setText(TL("false"));
288
}
289
updateResetButton();
290
return 1;
291
}
292
293
294
std::string
295
GNEOptionsEditorRow::OptionBool::getValue() const {
296
return myCheckButton->getCheck() ? "true" : "false";
297
}
298
299
// ---------------------------------------------------------------------------
300
// GNEOptionsEditorRow::OptionInt - methods
301
// ---------------------------------------------------------------------------
302
303
GNEOptionsEditorRow::OptionInt::OptionInt(GNEOptionsEditor* optionsEditor, FXComposite* parent,
304
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
305
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
306
myIntTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_INTEGER));
307
updateOption();
308
}
309
310
311
void
312
GNEOptionsEditorRow::OptionInt::updateOption() {
313
myIntTextField->setText(toString(myOptionsEditor->myOptionsContainer.getInt(myName)).c_str());
314
updateResetButton();
315
}
316
317
318
void
319
GNEOptionsEditorRow::OptionInt::restoreOption() {
320
myIntTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getInt(myName)).c_str());
321
onCmdSetOption(nullptr, 0, nullptr);
322
}
323
324
325
long
326
GNEOptionsEditorRow::OptionInt::onCmdSetOption(FXObject*, FXSelector, void*) {
327
if (myIntTextField->getText().empty()) {
328
myIntTextField->setText(myDefaultValue.c_str());
329
} else {
330
myOptionsEditor->myOptionsContainer.resetWritable();
331
myOptionsEditor->myOptionsContainer.set(myName, myIntTextField->getText().text());
332
myOptionsEditor->myOptionsModified = true;
333
}
334
updateResetButton();
335
return 1;
336
}
337
338
339
long
340
GNEOptionsEditorRow::OptionInt::onCmdResetOption(FXObject*, FXSelector, void*) {
341
myIntTextField->setText(myDefaultValue.c_str());
342
updateResetButton();
343
return 1;
344
}
345
346
347
std::string
348
GNEOptionsEditorRow::OptionInt::getValue() const {
349
return myIntTextField->getText().text();
350
}
351
352
// ---------------------------------------------------------------------------
353
// GNEOptionsEditorRow::OptionIntVector - methods
354
// ---------------------------------------------------------------------------
355
356
GNEOptionsEditorRow::OptionIntVector::OptionIntVector(GNEOptionsEditor* optionsEditor, FXComposite* parent,
357
const std::string& topic, const std::string& name, const std::string& description, const std::string& defaultValue) :
358
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
359
myIntVectorTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
360
myIntVectorTextField->setText(toString(myOptionsEditor->myOptionsContainer.getIntVector(name)).c_str());
361
updateOption();
362
}
363
364
365
void
366
GNEOptionsEditorRow::OptionIntVector::updateOption() {
367
myIntVectorTextField->setText(toString(myOptionsEditor->myOptionsContainer.getIntVector(myName)).c_str());
368
updateResetButton();
369
}
370
371
372
void
373
GNEOptionsEditorRow::OptionIntVector::restoreOption() {
374
myIntVectorTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getIntVector(myName)).c_str());
375
onCmdSetOption(nullptr, 0, nullptr);
376
}
377
378
379
long
380
GNEOptionsEditorRow::OptionIntVector::onCmdSetOption(FXObject*, FXSelector, void*) {
381
try {
382
// check that int vector can be parsed
383
const auto intVector = StringTokenizer(myIntVectorTextField->getText().text()).getVector();
384
for (const auto& intValue : intVector) {
385
StringUtils::toInt(intValue);
386
}
387
myOptionsEditor->myOptionsContainer.resetWritable();
388
myOptionsEditor->myOptionsContainer.set(myName, myIntVectorTextField->getText().text());
389
myIntVectorTextField->setTextColor(GUIDesignTextColorBlack);
390
myOptionsEditor->myOptionsModified = true;
391
} catch (...) {
392
myIntVectorTextField->setTextColor(GUIDesignTextColorRed);
393
}
394
updateResetButton();
395
return 1;
396
}
397
398
399
long
400
GNEOptionsEditorRow::OptionIntVector::onCmdResetOption(FXObject*, FXSelector, void*) {
401
myIntVectorTextField->setText(myDefaultValue.c_str());
402
updateResetButton();
403
return 1;
404
}
405
406
407
std::string
408
GNEOptionsEditorRow::OptionIntVector::getValue() const {
409
return myIntVectorTextField->getText().text();
410
}
411
412
// ---------------------------------------------------------------------------
413
// GNEOptionsEditorRow::OptionFloat - methods
414
// ---------------------------------------------------------------------------
415
416
GNEOptionsEditorRow::OptionFloat::OptionFloat(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
417
const std::string& name, const std::string& description, const std::string& defaultValue) :
418
OptionRow(optionsEditor, parent, topic, name, description, parseFloat(defaultValue)) {
419
myFloatTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextFieldRestricted(TEXTFIELD_REAL));
420
myFloatTextField->setText(toString(myOptionsEditor->myOptionsContainer.getFloat(name)).c_str());
421
updateOption();
422
}
423
424
425
void
426
GNEOptionsEditorRow::OptionFloat::updateOption() {
427
myFloatTextField->setText(toString(myOptionsEditor->myOptionsContainer.getFloat(myName)).c_str());
428
updateResetButton();
429
}
430
431
432
void
433
GNEOptionsEditorRow::OptionFloat::restoreOption() {
434
myFloatTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getFloat(myName)).c_str());
435
onCmdSetOption(nullptr, 0, nullptr);
436
}
437
438
439
long
440
GNEOptionsEditorRow::OptionFloat::onCmdSetOption(FXObject*, FXSelector, void*) {
441
// avoid empty values
442
if (myFloatTextField->getText().empty()) {
443
myFloatTextField->setText(myDefaultValue.c_str());
444
} else {
445
myOptionsEditor->myOptionsContainer.resetWritable();
446
myOptionsEditor->myOptionsContainer.set(myName, myFloatTextField->getText().text());
447
myOptionsEditor->myOptionsModified = true;
448
}
449
updateResetButton();
450
return 1;
451
}
452
453
454
long
455
GNEOptionsEditorRow::OptionFloat::onCmdResetOption(FXObject*, FXSelector, void*) {
456
myFloatTextField->setText(myDefaultValue.c_str());
457
updateResetButton();
458
return 1;
459
}
460
461
462
std::string
463
GNEOptionsEditorRow::OptionFloat::getValue() const {
464
return myFloatTextField->getText().text();
465
}
466
467
468
std::string
469
GNEOptionsEditorRow::OptionFloat::parseFloat(const std::string& value) const {
470
try {
471
return toString(StringUtils::toDouble(value));
472
} catch (...) {
473
return value;
474
}
475
}
476
477
// ---------------------------------------------------------------------------
478
// GNEOptionsEditorRow::OptionTime - methods
479
// ---------------------------------------------------------------------------
480
481
GNEOptionsEditorRow::OptionTime::OptionTime(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
482
const std::string& name, const std::string& description, const std::string& defaultValue) :
483
OptionRow(optionsEditor, parent, topic, name, description, parseTime(defaultValue)) {
484
myTimeTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
485
myTimeTextField->setText(toString(myOptionsEditor->myOptionsContainer.getString(name)).c_str());
486
updateOption();
487
}
488
489
490
void
491
GNEOptionsEditorRow::OptionTime::updateOption() {
492
myTimeTextField->setText(toString(myOptionsEditor->myOptionsContainer.getString(myName)).c_str());
493
updateResetButton();
494
}
495
496
497
void
498
GNEOptionsEditorRow::OptionTime::restoreOption() {
499
myTimeTextField->setText(toString(myOptionsEditor->myOriginalOptionsContainer.getString(myName)).c_str());
500
onCmdSetOption(nullptr, 0, nullptr);
501
}
502
503
504
long
505
GNEOptionsEditorRow::OptionTime::onCmdSetOption(FXObject*, FXSelector, void*) {
506
// avoid empty values
507
if (myTimeTextField->getText().empty()) {
508
myTimeTextField->setText(myDefaultValue.c_str());
509
} else {
510
myOptionsEditor->myOptionsContainer.resetWritable();
511
myOptionsEditor->myOptionsContainer.set(myName, myTimeTextField->getText().text());
512
myOptionsEditor->myOptionsModified = true;
513
}
514
updateResetButton();
515
return 1;
516
}
517
518
519
long
520
GNEOptionsEditorRow::OptionTime::onCmdResetOption(FXObject*, FXSelector, void*) {
521
myTimeTextField->setText(myDefaultValue.c_str());
522
updateResetButton();
523
return 1;
524
}
525
526
527
std::string
528
GNEOptionsEditorRow::OptionTime::getValue() const {
529
return myTimeTextField->getText().text();
530
}
531
532
533
std::string
534
GNEOptionsEditorRow::OptionTime::parseTime(const std::string& value) const {
535
try {
536
return time2string(string2time(value));
537
} catch (...) {
538
return value;
539
}
540
}
541
542
// ---------------------------------------------------------------------------
543
// GNEOptionsEditorRow::OptionFilename - methods
544
// ---------------------------------------------------------------------------
545
546
GNEOptionsEditorRow::OptionFilename::OptionFilename(GNEOptionsEditor* optionsEditor, FXComposite* parent, const std::string& topic,
547
const std::string& name, const std::string& description, const std::string& defaultValue) :
548
OptionRow(optionsEditor, parent, topic, name, description, defaultValue) {
549
myOpenFilenameButton = GUIDesigns::buildFXButton(myContentFrame, "", "", TL("Select filename"),
550
GUIIconSubSys::getIcon(GUIIcon::OPEN), this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButtonIcon);
551
myFilenameTextField = new FXTextField(myContentFrame, GUIDesignTextFieldNCol, this, MID_GNE_SET_ATTRIBUTE, GUIDesignTextField);
552
updateOption();
553
}
554
555
556
void
557
GNEOptionsEditorRow::OptionFilename::updateOption() {
558
myFilenameTextField->setText(myOptionsEditor->myOptionsContainer.getString(myName).c_str());
559
updateResetButton();
560
}
561
562
563
void
564
GNEOptionsEditorRow::OptionFilename::restoreOption() {
565
myFilenameTextField->setText(myOptionsEditor->myOriginalOptionsContainer.getString(myName).c_str());
566
onCmdSetOption(nullptr, 0, nullptr);
567
}
568
569
570
long
571
GNEOptionsEditorRow::OptionFilename::onCmdOpenDialog(FXObject*, FXSelector, void*) {
572
// get open mode
573
GNEFileDialog::OpenMode openMode = (myName.find("output") != std::string::npos) ? GNEFileDialog::OpenMode::SAVE : GNEFileDialog::OpenMode::LOAD_SINGLE;
574
// open dialog
575
const auto XMLFileDialog = GNEFileDialog(myOptionsEditor->myDialog->getApplicationWindow(), TL("XML file"),
576
SUMOXMLDefinitions::XMLFileExtensions.getStrings(), openMode,
577
GNEFileDialog::ConfigType::NETEDIT);
578
// check that file is valid
579
if (XMLFileDialog.getResult() == GNEDialog::Result::ACCEPT) {
580
myFilenameTextField->setText(XMLFileDialog.getFilename().c_str(), TRUE);
581
}
582
updateResetButton();
583
return 1;
584
}
585
586
587
long
588
GNEOptionsEditorRow::OptionFilename::onCmdSetOption(FXObject*, FXSelector, void*) {
589
if (SUMOXMLDefinitions::isValidFilename(myFilenameTextField->getText().text())) {
590
myOptionsEditor->myOptionsContainer.resetWritable();
591
myOptionsEditor->myOptionsContainer.set(myName, myFilenameTextField->getText().text());
592
myFilenameTextField->setTextColor(GUIDesignTextColorBlack);
593
myOptionsEditor->myOptionsModified = true;
594
} else {
595
myFilenameTextField->setTextColor(GUIDesignTextColorRed);
596
}
597
updateResetButton();
598
return 1;
599
}
600
601
602
long
603
GNEOptionsEditorRow::OptionFilename::onCmdResetOption(FXObject*, FXSelector, void*) {
604
myFilenameTextField->setText(myDefaultValue.c_str());
605
updateResetButton();
606
return 1;
607
}
608
609
610
GNEOptionsEditorRow::OptionFilename::OptionFilename() {}
611
612
613
std::string
614
GNEOptionsEditorRow::OptionFilename::getValue() const {
615
return myFilenameTextField->getText().text();
616
}
617
618
/****************************************************************************/
619
620