void LayerTree::object_changed(const std::string &key, const grt::ValueRef &value, mforms::TreeNodeRef node) {
  FigureNode *fn = dynamic_cast<FigureNode *>(node->get_data());

  if (key == "name")
    node->set_string(0, fn->object->name());
  else if (key == "layer") {
    model_FigureRef figure(model_FigureRef::cast_from(fn->object));
    if (figure->layer() != value) {
      fn->conn.disconnect();
      node->remove_from_parent();

      if (figure->layer() == _diagram->rootLayer()) {
        int insertion_point = 0;
        // find the last node that's not a layer
        for (int c = count(); insertion_point < c; ++insertion_point) {
          mforms::TreeNodeRef n = node_at_row(insertion_point);
          FigureNode *nn = dynamic_cast<FigureNode *>(n->get_data());
          if (!nn)
            continue;
          if (nn->is_layer)
            break;
        }
        add_figure_node(mforms::TreeNodeRef(), figure, insertion_point);
      } else {
        mforms::TreeNodeRef layer_node = node_with_tag(figure->layer().id());

        add_figure_node(layer_node, figure);
      }
    }
  }
}
void LayerTree::add_figure_node(mforms::TreeNodeRef parent, model_FigureRef figure, int insertion_point) {
  bec::IconManager *im = bec::IconManager::get_instance();
  mforms::TreeNodeRef fnode;
  FigureNode *fchild = new FigureNode();
  fchild->object = figure;
  fchild->is_layer = false;

  if (insertion_point < 0)
    fnode = parent ? parent->add_child() : add_node();
  else
    fnode = parent ? parent->insert_child(insertion_point) : root_node()->insert_child(insertion_point);

  fnode->set_data(fchild);
  fnode->set_string(0, figure->name());
  fnode->set_tag(figure->id());
  fnode->set_icon_path(0, im->get_icon_path(im->get_icon_id(figure, bec::Icon16)));

  fchild->conn = figure->signal_changed()->connect(
    std::bind(&LayerTree::object_changed, this, std::placeholders::_1, std::placeholders::_2, fnode));

  std::string conn_icon = im->get_icon_path("db.Column.fknn.16x16.png");
  std::string id = figure->id();
  std::multimap<std::string, workbench_physical_ConnectionRef>::iterator iter;
  for (iter = _figure_connections.find(id); iter != _figure_connections.end() && iter->first == id; ++iter) {
    mforms::TreeNodeRef cnode = fnode->add_child();
    FigureNode *cchild = new FigureNode();
    cchild->object = iter->second->endFigure();
    cchild->is_layer = false;
    cnode->set_data(cchild);
    cnode->set_string(0, iter->second->caption());
    cnode->set_tag(iter->second.id());
    cnode->set_icon_path(0, conn_icon);
  }
}
void DBSearchFilterPanel::cell_edited(mforms::TreeNodeRef node, int column, const std::string& value) {
  if ((_filter_tree.count() > 1) && (value == ""))
    node->remove_from_parent();

  if (column == 0) {
    node->set_string(0, value);
    if (_filter_tree.row_for_node(node) + 1 == _filter_tree.count())
      _filter_tree.add_node()->set_string(0, "Schema.Table.Column");
  }
}
예제 #4
0
int TreeNodeWrapper::get_child_index(mforms::TreeNodeRef node) const
{
  TreeNodeWrapper *child = (TreeNodeWrapper *)node.ptr();
  std::vector<TreeNodeWrapper*>::const_iterator i = std::find(_children.begin(), _children.end(), child);
  if (i == _children.end())
    return -1;

  return (int)(i - _children.begin());
}
예제 #5
0
void DBSearchPanel::load_model(mforms::TreeNodeRef tnode)
{
  _key_columns.clear();
  for (size_t c = _searcher->search_results().size(), i = tnode->count(); i < c; i++)
  {
    const DBSearch::column_data_t& rows = _searcher->search_results()[i].data;
    mforms::TreeNodeRef table_node = tnode->add_child();
    table_node->set_string(0, _searcher->search_results()[i].schema);
    table_node->set_string(1, _searcher->search_results()[i].table);
    table_node->set_string(4, base::strfmt("%i rows matched", (int)rows.size()).c_str());
    table_node->set_tag(_searcher->search_results()[i].query);
    _key_columns.insert(std::make_pair(table_node->get_tag(), _searcher->search_results()[i].keys));

    for(DBSearch::column_data_t::const_iterator It_rows = rows.begin(); It_rows != rows.end(); ++It_rows)
    {
      std::string cols;
      std::string data;
      mforms::TreeNodeRef data_node = table_node->add_child();
      std::vector<std::pair<std::string, std::string> >::const_iterator It_cols = It_rows->begin();
      data_node->set_string(2, (It_cols++)->second);
      for (; It_cols != It_rows->end(); ++It_cols)
      {
        if (It_cols->second.empty())
          continue;
        if (!cols.empty())
          cols.append(", ");
        cols.append(It_cols->first);
        if (!data.empty())
          data.append(", ");
        data.append(It_cols->second);
      }
      data_node->set_string(3, cols);
      data_node->set_string(4, data);
      }
  }
};
예제 #6
0
void TreeNodeWrapper::move_child(mforms::TreeNodeRef node, int new_index)
{
  TreeNodeWrapper *child = (TreeNodeWrapper *)node.ptr();

  std::vector<TreeNodeWrapper*>::iterator i = std::find(_children.begin(), _children.end(), child);
  if (i == _children.end())
    return;

  int old_index = int(i - _children.begin());
  if (old_index == new_index)
    return;

  _children.erase(i);
  if (old_index < new_index)
    --new_index;
  _children.insert(_children.begin() + new_index, child);
}
예제 #7
0
 void set_cell_value(mforms::TreeNodeRef node, int column, const std::string &value)
 {
   size_t offset = _offset + _tree.row_for_node(node) * 16 + (column-1);
   
   if (offset < _owner->length())
   {
     int i;
     if (sscanf(value.c_str(), "%x", &i) != 1)
       return;
     if (i < 0 || i > 255)
       return;
     node->set_string(column, base::strfmt("%02x", i));
     
     *(unsigned char*)(_owner->data() + offset) = i;
     _owner->notify_edit();
   }
 }
void LayerTree::activate_node(const mforms::TreeNodeRef &node, int column) {
  FigureNode *fnode = dynamic_cast<FigureNode *>(node->get_data());
  if (fnode)
    _form->focus_and_make_visible(fnode->object, true);
}
 void set_active(mforms::TreeNodeRef node) {
   _node = node;
   _selector.set_value(node->get_string(2));
 }