1 /* === S I N F G =========================================================== */
2 /*! \file action_layerremove.cpp
3 ** \brief Template File
5 ** $Id: grouprename.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "grouprename.h"
32 #include <sinfgapp/canvasinterface.h>
38 using namespace sinfg;
39 using namespace sinfgapp;
40 using namespace Action;
42 /* === M A C R O S ========================================================= */
44 ACTION_INIT(Action::GroupRename);
45 ACTION_SET_NAME(Action::GroupRename,"group_rename");
46 ACTION_SET_LOCAL_NAME(Action::GroupRename,"Rename Group");
47 ACTION_SET_TASK(Action::GroupRename,"rename");
48 ACTION_SET_CATEGORY(Action::GroupRename,Action::CATEGORY_GROUP);
49 ACTION_SET_PRIORITY(Action::GroupRename,0);
50 ACTION_SET_VERSION(Action::GroupRename,"0.0");
51 ACTION_SET_CVS_ID(Action::GroupRename,"$Id: grouprename.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
53 /* === G L O B A L S ======================================================= */
55 /* === P R O C E D U R E S ================================================= */
57 /* === M E T H O D S ======================================================= */
59 Action::GroupRename::GroupRename()
64 Action::GroupRename::get_param_vocab()
66 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
68 ret.push_back(ParamDesc("group",Param::TYPE_STRING)
69 .set_local_name(_("Old Group"))
70 .set_desc(_("Name of the Group to rename"))
73 ret.push_back(ParamDesc("new_group",Param::TYPE_STRING)
74 .set_local_name(_("New Group"))
75 .set_desc(_("New name for group"))
82 Action::GroupRename::is_canidate(const ParamList &x)
84 return canidate_check(get_param_vocab(),x);
88 Action::GroupRename::set_param(const sinfg::String& name, const Action::Param ¶m)
90 if(name=="group" && param.get_type()==Param::TYPE_STRING)
92 old_group_name=param.get_string();
97 if(name=="new_group" && param.get_type()==Param::TYPE_STRING)
99 new_group_name=param.get_string();
104 return Action::CanvasSpecific::set_param(name,param);
108 Action::GroupRename::is_ready()const
110 if(old_group_name.empty()||new_group_name.empty())
112 return Action::CanvasSpecific::is_ready();
116 Action::GroupRename::perform()
118 if(get_canvas()->get_groups().count(new_group_name)!=0)
120 throw Error(_("A group with the name \"%s\" already exists!"),new_group_name.c_str());
122 get_canvas()->rename_group(old_group_name,new_group_name);
126 Action::GroupRename::undo()
128 get_canvas()->rename_group(new_group_name,old_group_name);