Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/BondFileAction.cpp

    r112b09 r047878  
    99
    1010#include "Actions/MoleculeAction/BondFileAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "log.hpp"
     13#include "molecule.hpp"
     14#include "verbose.hpp"
     15#include "World.hpp"
    1116
    1217#include <iostream>
     
    1823#include "UIElements/UIFactory.hpp"
    1924#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     25#include "UIElements/ValueStorage.hpp"
    2126
    22 #include "atom.hpp"
    23 #include "bondgraph.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "vector.hpp"
    29 #include "World.hpp"
    3027
    3128/****** MoleculeBondFileAction *****/
     
    5249{}
    5350
     51void MoleculeBondFile(std::string &bondfile) {
     52  ValueStorage::getInstance().setCurrentValue(MoleculeBondFileAction::NAME, bondfile);
     53  ActionRegistry::getInstance().getActionByName(MoleculeBondFileAction::NAME)->call(Action::NonInteractive);
     54};
     55
     56Dialog* MoleculeBondFileAction::fillDialog(Dialog *dialog) {
     57  ASSERT(dialog,"No Dialog given when filling action dialog");
     58
     59  dialog->queryString(NAME, MapOfActions::getInstance().getDescription(NAME));
     60
     61  return dialog;
     62}
     63
    5464Action::state_ptr MoleculeBondFileAction::performCall() {
    5565  string filename;
    56   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5766  molecule *mol = NULL;
    5867
    59   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    60   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     68  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    6169
    62   if(dialog->display()) {
     70  if(World::getInstance().countSelectedMolecules() == 1) {
     71    mol = World::getInstance().beginMoleculeSelection()->second;
    6372    DoLog(0) && (Log() << Verbose(0) << "Parsing bonds from " << filename << "." << endl);
    6473    ifstream input(filename.c_str());
    6574    mol->CreateAdjacencyListFromDbondFile(&input);
    6675    input.close();
    67     delete dialog;
    6876    return Action::success;
    69   }
    70   delete dialog;
    71   return Action::failure;
     77  } else
     78    return Action::failure;
    7279}
    7380
Note: See TracChangeset for help on using the changeset viewer.