- Added a "State" column
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1122 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
3ef89029ec
commit
240eb23e85
|
@ -62,11 +62,15 @@ SchedulablesTreeWidget::SchedulablesTreeWidget()
|
||||||
|
|
||||||
set_model(_model);
|
set_model(_model);
|
||||||
|
|
||||||
int idx = append_column(_("schedulables"), _cell_renderer) - 1;
|
int idx = append_column(_("Entities"), _cell_renderer) - 1;
|
||||||
Gtk::TreeViewColumn* tvc = get_column(idx);
|
Gtk::TreeViewColumn* tvc = get_column(idx);
|
||||||
tvc->set_cell_data_func(_cell_renderer, sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_cell_name_data));
|
tvc->set_cell_data_func(_cell_renderer, sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_entities_column_data));
|
||||||
|
|
||||||
set_headers_visible(false);
|
idx = append_column(_("State"), _cell_renderer) - 1;
|
||||||
|
tvc = get_column(idx);
|
||||||
|
tvc->set_cell_data_func(_cell_renderer, sigc::mem_fun(*this, &SchedulablesTreeWidget::_on_state_column_data));
|
||||||
|
|
||||||
|
set_headers_visible(true);
|
||||||
|
|
||||||
Simulation::get_instance().get_history().attach(*this);
|
Simulation::get_instance().get_history().attach(*this);
|
||||||
}
|
}
|
||||||
|
@ -579,24 +583,9 @@ SchedulablesTreeWidget::_on_remove_request()
|
||||||
Simulation::get_instance().get_history().remove(*r);
|
Simulation::get_instance().get_history().remove(*r);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void
|
|
||||||
//SchedulablesTreeWidget::_on_remove_subrequest()
|
|
||||||
//{
|
|
||||||
// SubRequest* sr = get_selected<SubRequest>();
|
|
||||||
// assert(sr != NULL);
|
|
||||||
//
|
|
||||||
// Request& owner = sr->get_request();
|
|
||||||
//
|
|
||||||
// Simulation::get_instance().get_history().remove(*sr);
|
|
||||||
//
|
|
||||||
// // empty requests are COMPLETELY useless with the current GUI
|
|
||||||
// if(owner.get_subrequests().empty())
|
|
||||||
// Simulation::get_instance().get_history().remove(owner);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SchedulablesTreeWidget::_on_cell_name_data(Gtk::CellRenderer* cr,
|
SchedulablesTreeWidget::_on_entities_column_data(Gtk::CellRenderer* cr,
|
||||||
const Gtk::TreeModel::iterator& it)
|
const Gtk::TreeModel::iterator& it)
|
||||||
{
|
{
|
||||||
CellRendererTextMarkup& crtm = static_cast<CellRendererTextMarkup&>(*cr);
|
CellRendererTextMarkup& crtm = static_cast<CellRendererTextMarkup&>(*cr);
|
||||||
|
|
||||||
|
@ -678,3 +667,90 @@ SchedulablesTreeWidget::markup_request(Request& r)
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SchedulablesTreeWidget::_on_state_column_data(Gtk::CellRenderer* cr,
|
||||||
|
const Gtk::TreeModel::iterator& it)
|
||||||
|
{
|
||||||
|
CellRendererTextMarkup& crtm = static_cast<CellRendererTextMarkup&>(*cr);
|
||||||
|
|
||||||
|
ustring marked_up;
|
||||||
|
|
||||||
|
switch(get_row_type(it))
|
||||||
|
{
|
||||||
|
case htype_process:
|
||||||
|
marked_up = markup_state(get_row_handle_as<Process>(it)->get_state());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case htype_thread:
|
||||||
|
marked_up = markup_state(get_row_handle_as<Thread>(it)->get_state());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case htype_request:
|
||||||
|
marked_up = markup_state(get_row_handle_as<Request>(it)->get_state());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
marked_up = "<small>NO STATE</small>";
|
||||||
|
}
|
||||||
|
|
||||||
|
crtm.property_markup() = marked_up;
|
||||||
|
}
|
||||||
|
|
||||||
|
ustring
|
||||||
|
SchedulablesTreeWidget::markup_state(Schedulable::state state)
|
||||||
|
{
|
||||||
|
ustring text;
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case Schedulable::state_running:
|
||||||
|
text = _("RUNNING");
|
||||||
|
break;
|
||||||
|
case Schedulable::state_ready:
|
||||||
|
text = _("READY");
|
||||||
|
break;
|
||||||
|
case Schedulable::state_blocked:
|
||||||
|
text = _("BLOCKED");
|
||||||
|
break;
|
||||||
|
case Schedulable::state_future:
|
||||||
|
text = _("FUTURE");
|
||||||
|
break;
|
||||||
|
case Schedulable::state_terminated:
|
||||||
|
text = _("TERMINATED");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
text = _("@@@ ERROR @@@");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ustring("<small>") + Markup::escape_text(text) + "</small>";
|
||||||
|
}
|
||||||
|
|
||||||
|
ustring
|
||||||
|
SchedulablesTreeWidget::markup_state(Request::state state)
|
||||||
|
{
|
||||||
|
ustring text;
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case Request::state_allocated:
|
||||||
|
text = _("ALLOCATED");
|
||||||
|
break;
|
||||||
|
case Request::state_allocable:
|
||||||
|
text = _("ALLOCABLE");
|
||||||
|
break;
|
||||||
|
case Request::state_unallocable:
|
||||||
|
text = _("UNALLOCABLE");
|
||||||
|
break;
|
||||||
|
case Request::state_future:
|
||||||
|
text = _("FUTURE");
|
||||||
|
break;
|
||||||
|
case Request::state_exhausted:
|
||||||
|
text = _("EXHAUSTED");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
text = _("@@@ ERROR @@@");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ustring("<small>") + Markup::escape_text(text) + "</small>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ namespace sgpem
|
||||||
#include <libglademm/xml.h>
|
#include <libglademm/xml.h>
|
||||||
|
|
||||||
#include <sgpemv2/history_observer.hh>
|
#include <sgpemv2/history_observer.hh>
|
||||||
|
#include <sgpemv2/schedulable.hh>
|
||||||
|
#include <sgpemv2/request.hh>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -104,12 +106,18 @@ namespace sgpem
|
||||||
void _on_remove_request();
|
void _on_remove_request();
|
||||||
// void _on_remove_subrequest();
|
// void _on_remove_subrequest();
|
||||||
|
|
||||||
void _on_cell_name_data(Gtk::CellRenderer* cr,
|
void _on_entities_column_data(Gtk::CellRenderer* cr,
|
||||||
const Gtk::TreeModel::iterator& it);
|
const Gtk::TreeModel::iterator& it);
|
||||||
|
|
||||||
|
void _on_state_column_data(Gtk::CellRenderer* cr,
|
||||||
|
const Gtk::TreeModel::iterator& it);
|
||||||
|
|
||||||
Glib::ustring markup_schedulable(const Schedulable& s);
|
Glib::ustring markup_schedulable(const Schedulable& s);
|
||||||
Glib::ustring markup_request(Request& s);
|
Glib::ustring markup_request(Request& s);
|
||||||
|
|
||||||
|
Glib::ustring markup_state(Schedulable::state state);
|
||||||
|
Glib::ustring markup_state(Request::state state);
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::TreeStore> _model;
|
Glib::RefPtr<Gtk::TreeStore> _model;
|
||||||
Gtk::TreeModelColumnRecord _columns;
|
Gtk::TreeModelColumnRecord _columns;
|
||||||
Gtk::TreeModelColumn<Glib::ustring> _main_column;
|
Gtk::TreeModelColumn<Glib::ustring> _main_column;
|
||||||
|
|
Loading…
Reference in New Issue