/* * SetDefaultNameAction.cpp * * Created on: May 8, 2010 * Author: heber */ #include "Helpers/MemDebug.hpp" #include "Actions/WorldAction/SetDefaultNameAction.hpp" #include "log.hpp" #include "verbose.hpp" #include "World.hpp" #include #include using namespace std; #include "UIElements/UIFactory.hpp" #include "UIElements/Dialog.hpp" #include "Actions/MapOfActions.hpp" const char WorldSetDefaultNameAction::NAME[] = "default-molname"; WorldSetDefaultNameAction::WorldSetDefaultNameAction() : Action(NAME) {} WorldSetDefaultNameAction::~WorldSetDefaultNameAction() {} Action::state_ptr WorldSetDefaultNameAction::performCall() { Dialog *dialog = UIFactory::getInstance().makeDialog(); string defaultname; defaultname = World::getInstance().getDefaultName(); dialog->queryString(NAME, &defaultname, MapOfActions::getInstance().getDescription(NAME)); if(dialog->display()) { World::getInstance().setDefaultName(defaultname); DoLog(0) && (Log() << Verbose(0) << "Default name of new molecules set to " << World::getInstance().getDefaultName() << "." << endl); delete dialog; return Action::success; } else { delete dialog; return Action::failure; } } Action::state_ptr WorldSetDefaultNameAction::performUndo(Action::state_ptr _state) { // ParserLoadXyzState *state = assert_cast(_state.get()); return Action::failure; // string newName = state->mol->getName(); // state->mol->setName(state->lastName); // // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); } Action::state_ptr WorldSetDefaultNameAction::performRedo(Action::state_ptr _state){ return Action::failure; } bool WorldSetDefaultNameAction::canUndo() { return false; } bool WorldSetDefaultNameAction::shouldUndo() { return false; } const string WorldSetDefaultNameAction::getName() { return NAME; }