Path: blob/main/src/netedit/dialogs/basic/GNEOverwriteElement.cpp
169684 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file GNEOverwriteElement.cpp14/// @author Pablo Alvarez Lopez15/// @date Jul 201716///17// Dialog used to ask user if overwrite elements during loading18/****************************************************************************/19#include <config.h>2021#include <netedit/GNENet.h>22#include <netedit/GNETagProperties.h>23#include <netedit/GNEViewParent.h>24#include <utils/gui/div/GUIDesigns.h>25#include <utils/handlers/CommonHandler.h>2627#include "GNEOverwriteElement.h"2829// ===========================================================================30// member method definitions31// ===========================================================================3233GNEOverwriteElement::GNEOverwriteElement(CommonHandler* commonHandler, const GNEAttributeCarrier* AC) :34GNEDialog(AC->getNet()->getViewNet()->getViewParent()->getGNEAppWindows(),35TLF("Overwrite % '%'", AC->getTagProperty()->getTagStr(), AC->getID()), GUIIcon::QUESTION_SMALL,36DialogType::OVERWRITE, GNEDialog::Buttons::YES_NO_CANCEL, GNEDialog::OpenType::MODAL, ResizeMode::STATIC),37myCommonHandler(commonHandler) {38// create dialog layout (obtained from FXMessageBox)39auto infoFrame = new FXVerticalFrame(myContentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10);40// add information label41new FXLabel(infoFrame, TLF("There is already a % '%'. Overwrite?", AC->getTagProperty()->getTagStr(), AC->getID()).c_str(),42nullptr, JUSTIFY_LEFT | ICON_BEFORE_TEXT | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y);43// add checkButton44myApplySolutionToAllCheckButon = new FXCheckButton(infoFrame, TL("Apply this solution to all conflicted elements"), nullptr, 0, GUIDesignCheckButton);45// open modal dialog46openDialog();47}484950GNEOverwriteElement::~GNEOverwriteElement() {51}525354void55GNEOverwriteElement::runInternalTest(const InternalTestStep::DialogArgument* dialogArgument) {56if (dialogArgument->getCustomAction() == "applyToAll") {57myApplySolutionToAllCheckButon->setCheck(TRUE);58}59}60616263long64GNEOverwriteElement::onCmdAccept(FXObject*, FXSelector, void*) {65if (myApplySolutionToAllCheckButon->getCheck() == TRUE) {66myCommonHandler->forceOverwriteElements();67}68return closeDialogAccepting();69}707172long73GNEOverwriteElement::onCmdCancel(FXObject*, FXSelector, void*) {74if (myApplySolutionToAllCheckButon->getCheck() == TRUE) {75myCommonHandler->forceRemainElements();76}77return closeDialogCanceling();78}798081long82GNEOverwriteElement::onCmdAbort(FXObject*, FXSelector, void*) {83myCommonHandler->abortLoading();84return closeDialogAborting();85}8687/****************************************************************************/888990