creaImageIOWxGimmickTools
creaImageIOWxCustomizeConfigPanel
creaImageIOWxListenerPanel
+ creaImageIOWxEditFieldsPanel
#
BlockScopeWxApp
mImageAdder.DeleteDriveFromOtherDB(drive);
}
+ //========================================================================
+ void Gimmick::EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val)
+ {
+ TreeHandler * handler=GetTreeHandler(d);
+ mImageAdder.SetCurrentDatabase(d);
+ mImageAdder.SetTreeHandler(handler);
+ mImageAdder.EditField(node,name,key,val);
+ }
+ //========================================================================
+
+
/////////////////////////////////////////////////////////////////////////
// add DB from Settings file //
// @param : - //
///Updates the settings file
void UpdateSetting(const std::string& name, const std::string& value);
- // add DB from Settings file
+ /// add DB from Settings file
void addDBSettings();
+ ///Edits the field described by the name and key provided with the value given
+ void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
+
///
const std::string& GetHomeDirectory();
const std::string& GetUserSettingsDirectory();
///Copies selected files
virtual void CopyFiles(const std::vector<std::string>& filenames)
{ GimmickError("INTERNAL ERROR : CopyFiles not implemented"); }
+
+ ///Edits the fields of a given node
+ virtual void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys)
+ { GimmickError("INTERNAL ERROR : EditFields not implemented"); }
///Validates the dimension compliance of the images with the maximum and minimum given, and between their sizes
bool ValidateSelected (tree::Node* sel, int min_dim, int max_dim);
static const unsigned int IDENTIFIER;
/// The attribute enters in label constitution (for printing)
static const unsigned int LABEL;
+ /// The attribute can be edited
+ static const unsigned int EDITABLE;
/// Types
/// The attribute is of numeric type
const unsigned int AttributeDescriptor::PRIVATE = 1;
/// The attribute enters in unique identifier constitution
const unsigned int AttributeDescriptor::IDENTIFIER = 2;
+ /// The attribute can be edited
+ const unsigned int AttributeDescriptor::EDITABLE = 3;
const unsigned int AttributeDescriptor::LABEL = 4;
//==================================================================
mSynchronizer->RemoveEntries("IGNORED_FILES", "PATH", "LIKE", drive+"%");
}
+ //=======================================================================
+ void TreeHandlerImageAdder::EditField(tree::Node* node, const std::string& name, const std::string& key, const std::string& val)
+ {
+ node->SetAttribute(key,val);
+ mTreeHandler->SetAttribute(node,key,val);
+ }
+
}
void DeleteDriveFromMainDB(const std::string& drive);
///Deletes the drive with the given name (use for maintenance and timestamp databases)
void DeleteDriveFromOtherDB(const std::string& drive);
+ ///Edits the given field and sets the new parameters
+ void EditField(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
+
//====================================================================
--- /dev/null
+#include <creaImageIOWxEditFieldsPanel.h>
+#include <creaImageIOSystem.h>
+#include <wx/arrstr.h>
+//using namespace tree;
+namespace creaImageIO
+{
+ const int ID_COMBO = 140;
+ // CTor
+ WxEditFieldsPanel::WxEditFieldsPanel(wxWindow *parent, wxDialog* dial, WxGimmickView* view, tree::Node* nod,
+ const std::vector<std::string> name,
+ const std::vector<std::string> key)
+ : wxPanel( parent,
+ -1, wxDefaultPosition,
+ wxDefaultSize,
+ wxRESIZE_BORDER |
+ wxSYSTEM_MENU |
+ wxCLOSE_BOX |
+ wxMAXIMIZE_BOX |
+ wxMINIMIZE_BOX |
+ wxCAPTION
+ ),
+ dialog(dial),
+ node (nod),
+ names(name),
+ keys(key),
+ mView(view)
+ {
+ GimmickDebugMessage(1,"WxCustomizeConfigPanel::WxCustomizeConfigPanel"
+ <<std::endl);
+ wxStaticText * cp=new wxStaticText(this,-1,_T(" Attribute to change: "), wxPoint(5,10));
+ wxArrayString as;
+ std::vector<std::string>::const_iterator it;
+ for(it=names.begin();it!=names.end();++it)
+ {
+ as.Add(*it);
+ }
+ attributes=new wxComboBox(this, ID_COMBO,names.front(),wxPoint(110, 10),wxDefaultSize,as);
+ std::string val=node->GetAttribute(keys[0]);
+ if(val.compare("")==0){val="?";}
+
+ wxStaticText * av=new wxStaticText(this,-1,_T(" Actual Value: "), wxPoint(5,40));
+ actualVal=new wxStaticText(this,-1,_T(val), wxPoint(110,40));
+
+ wxStaticText * nv=new wxStaticText(this,-1,_T(" New Value: "), wxPoint(5,70));
+ newVal=new wxTextCtrl(this, wxID_ANY, _T(val), wxPoint(110,70), wxSize(220,20));
+
+ wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(5,100) );
+ Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxEditFieldsPanel::OnEdit );
+
+ Layout();
+ }
+
+ /// Destructor
+ WxEditFieldsPanel::~WxEditFieldsPanel()
+ {
+ GimmickDebugMessage(1,"WxEditFieldsPanel::~WxEditFieldsPanel"
+ <<std::endl);
+ }
+
+ void WxEditFieldsPanel::OnEdit(wxCommandEvent& event)
+ {
+ std::string val=crea::wx2std(newVal->GetValue());
+ mView->OnFieldsEdited(node,names[attributes->GetSelection()],keys[attributes->GetSelection()],val);
+ dialog->Destroy();
+ }
+
+ void WxEditFieldsPanel::OnComboChange(wxCommandEvent& event)
+ {
+ std::string val=node->GetAttribute(keys[attributes->GetSelection()]);
+ if(val.compare("")==0){val="?";}
+ actualVal->SetLabel(crea::std2wx(val));
+ newVal->SetValue(crea::std2wx(val));
+ }
+
+//======================================================================
+BEGIN_EVENT_TABLE(WxEditFieldsPanel, wxPanel)
+EVT_COMBOBOX (ID_COMBO,WxEditFieldsPanel::OnComboChange)
+END_EVENT_TABLE()
+//======================================================================
+
+} // EO namespace creaImageIO
+
+
+
+
--- /dev/null
+#ifndef __creaImageIOWxEditFieldsPanel_h_INCLUDED__
+#define __creaImageIOWxEditFieldsPanel_h_INCLUDED__
+
+#ifdef USE_WXWIDGETS
+#include <creaWx.h>
+#include <creaImageIOWxGimmickView.h>
+
+
+namespace creaImageIO
+{
+ /**
+ * \ingroup GUI
+ */
+ //=====================================================================
+ //=====================================================================
+ class WxEditFieldsPanel : public wxPanel
+ {
+ public:
+ WxEditFieldsPanel();
+ WxEditFieldsPanel(wxWindow *parent,
+ wxDialog* dial,
+ WxGimmickView* view,
+ tree::Node* nod,
+ const std::vector<std::string> name,
+ const std::vector<std::string> key);
+
+ ~WxEditFieldsPanel();
+ ///Saves the configuration
+ void OnEdit(wxCommandEvent& event);
+ void OnComboChange(wxCommandEvent& event);
+
+ private :
+ tree::Node* node;
+ std::vector<std::string> names;
+ std::vector<std::string> keys;
+ wxDialog* dialog;
+ WxGimmickView* mView;
+ wxComboBox* attributes;
+ wxStaticText * actualVal;
+ wxTextCtrl* newVal;
+
+ DECLARE_EVENT_TABLE()
+
+
+ }; // class WxEditFieldsPanel
+ //=====================================================================
+
+
+} // EO namespace creaImageIO
+
+
+#endif // USE_WIDGETS
+// EOF
+#endif
\ No newline at end of file
#include <creaImageIOSystem.h>
#include <creaImageIOWxCustomizeConfigPanel.h>
#include <creaImageIOWxListenerPanel.h>
+#include <creaImageIOWxEditFieldsPanel.h>
using namespace crea;
// Icons
mListener->Pause();
}
+ //========================================================================
+ void WxGimmickView::CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys)
+ {
+ wxDialog* dial= new wxDialog (this,-1,_T("Edit Fields for node "+node->GetLabel()),wxDefaultPosition, wxSize(350,155));
+ wxBoxSizer *siz = new wxBoxSizer(wxVERTICAL);
+ WxEditFieldsPanel* ef = new WxEditFieldsPanel(dial, dial, this, node, names, keys);
+
+ siz->Add( ef,1,wxGROW ,0);
+ dial->SetSizer(siz);
+ dial->ShowModal();
+ }
+
+ //========================================================================
+ void WxGimmickView::OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val)
+ {
+ mGimmick->EditField(node, crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())), name, key, val);
+ UpdateTreeViewLevel(crea::wx2std(mNotebook->GetPageText(mNotebook->GetSelection())),1);
+ }
//=================================================
/// AddProgress Gimmick callback
///Stops the listening thread on the CD/DVD drive
void StopListeningThread();
+
+ ///Called upon when a field has been edited
+ void OnFieldsEdited(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
+
protected:
/// Called upon to refresh the viewer once there are no actions to be done
void OnInternalIdle();
- // callback to add a database
+ /// callback to add a database
void OnAddDB(wxCommandEvent& event);
- //Create a DB from an Attributes Descriptor files
+ ///Create a DB from an Attributes Descriptor files
void OnCreateDB(wxCommandEvent& event);
+ ///Edits the fields of a given node
+ void CreateEditFieldsDialog(tree::Node* node, std::vector<std::string> names, std::vector<std::string> keys);
+
/// Progress dialog
wxProgressDialog* mProgressDialog;
///The selection's maximum dimension
}
long* ptr=0;
int flag;
- long itemId=GetCtrl(level)->HitTest(wxPoint(clientpt.x,clientpt.y-8),flag,ptr);
- tree::Node* node=((ItemData*)GetCtrl(level)->GetItemData(itemId))->node;
- std::cout<<node->GetLabel()<<std::endl;
+ mLastRightLevel=level;
+ mLastRightSelected=GetCtrl(level)->HitTest(wxPoint(0,clientpt.y-8),flag,ptr);
PopupMenu(menuItem, clientpt);
}
//================================================================
void WxTreeView::OnEditField(wxCommandEvent& event)
{
-
-
-
+ if(mLastRightSelected!=-1)
+ {
+ tree::Node* node=((ItemData*)GetCtrl(mLastRightLevel)->GetItemData(mLastRightSelected))->node;
+ tree::LevelDescriptor::AttributeDescriptorListType::const_iterator a;
+ std::vector<std::string> names;
+ std::vector<std::string> keys;
+ for (a = GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).begin();
+ a != GetTreeHandler()->GetTree().GetAttributeDescriptorList(mLastRightLevel+1).end();
+ ++a)
+ {
+ if(a->GetFlags()==creaImageIO::tree::AttributeDescriptor::EDITABLE)
+ {
+ names.push_back(a->GetName());
+ keys.push_back(a->GetKey());
+ }
+ }
+ GetGimmickView()->CreateEditFieldsDialog(node,names,keys);
+ }
}
//================================================================
/// Currently Selected Column
int mColumnSelected;
- ///The last selected item on the list
+ ///The last selected item on the list (left click)
long mLastSelected;
+
+ ///The last selected item on the list (right click)
+ long mLastRightSelected;
+
+ ///The last selected level (by right click)
+ int mLastRightLevel;
///The color map
typedef std::map<tree::Node*,wxColour> ColorMap;
typedef std::pair<tree::Node*,wxColour> NodeColorPair;
int mAnonymizingID;
int mLocalCopyID;
int mEditFieldID;
+
// If set to true then OnSelectedChanged returns immediately.
// Used to do avoid useless process during multiple selections
// or sorting