Exemplo n.º 1
0
void groupMarkers(Wt::WTreeTable *markerTree)
{
 	Wt::WTreeNode *parent;
	Wt::WTreeNode *newNode;
	std::set<Wt::WTreeNode*> unSortedselectedNodes =markerTree->tree()->selectedNodes();
	std::vector<Wt::WTreeNode*> selectedNodes ( unSortedselectedNodes.begin(), unSortedselectedNodes.end());
	std::sort(selectedNodes.begin(),selectedNodes.end(), fragmentAbeforeB); 
 
	std::vector< Wt::WTreeNode*> siblings;
 	
	Wt::WTreeNode *firstNode = *selectedNodes.begin();
	if(firstNode == markerTree->tree()->treeRoot())
	{
		return;
	}
	parent = firstNode->parentNode();
	newNode = MyTreeTableNode::addNode(0 ,"Group" ,-1,-1);
	siblings = parent->childNodes();
	int index = std::find(siblings.begin(), siblings.end(), firstNode) - siblings.begin();
	parent->insertChildNode(index, newNode);
	for(auto node:selectedNodes)
	{
		parent->removeChildNode(node);
		newNode->addChildNode(node);
	}

}
Exemplo n.º 2
0
void OutputItem(lua_State* lua, int i, Wt::WTreeNode* parent, stringstream& ss)
{
    switch (lua_type(lua, i)) {
    case LUA_TNUMBER:
        ss <<  lua_tonumber(lua, i);
        parent->addChildNode(new Wt::WTreeNode(ss.str()));
        break;
    case LUA_TSTRING:
        ss << "\"" << lua_tostring(lua, i) << "\"";
        parent->addChildNode(new Wt::WTreeNode(ss.str()));
        break;
    case LUA_TBOOLEAN:
        if (lua_toboolean(lua, i)) {
            ss << "true";
            parent->addChildNode(new Wt::WTreeNode(ss.str()));
        } else {
            ss << "false";
            parent->addChildNode(new Wt::WTreeNode(ss.str()));
        }
        break;
    case LUA_TTABLE:
    {
        ss << "table";
        Wt::WTreeNode* n = new Wt::WTreeNode(ss.str());
        n->setLoadPolicy(Wt::WTreeNode::NextLevelLoading);
        parent->addChildNode(n);
        OutputTable(lua, i, n);
        n->expand();
        break;
    }
    default:
        parent->addChildNode(new Wt::WTreeNode(luaL_typename(lua, i)));
        break;
    }

}
Exemplo n.º 3
0
void ungroupMarkers(Wt::WTreeTable *markerTree)
{
	std::vector< Wt::WTreeNode*> siblings;
	Wt::WTreeNode *parent;
	Wt::WTreeNode *grandparent;
	std::vector< Wt::WTreeNode*> uncles; //My parents siblings
	int index = 0;

	std::set<Wt::WTreeNode*> unSortedselectedNodes = markerTree->tree()->selectedNodes();
	std::vector<Wt::WTreeNode*> selectedNodes ( unSortedselectedNodes.begin(), unSortedselectedNodes.end());
	std::sort(selectedNodes.begin(),selectedNodes.end(), fragmentAbeforeB);
 
	Wt::WTreeNode *firstNode = *selectedNodes.begin();
	Wt::WTreeNode *lastNode = *selectedNodes.rbegin(); //Note, the reverse of the beginning is not the end
	parent = firstNode->parentNode();
	if(parent == markerTree->tree()->treeRoot())
	{
		return;
	}
	siblings = parent->childNodes();

	if(firstNode != siblings.front() and lastNode != siblings.back())
	{ 
		return;
	}
	grandparent = parent->parentNode();
	uncles = grandparent->childNodes();
	index = std::find(uncles.begin(), uncles.end(), parent) - uncles.begin();
	if (firstNode == siblings.front() and lastNode != siblings.back())
	{
		index--;
	}
	for (auto node:selectedNodes)
	{
		parent->removeChildNode(node);
		index++;
		grandparent->insertChildNode(index,node);
	}

}
Exemplo n.º 4
0
 Wt::WTreeNode * WebApp::createMenuNode(const Wt::WString& label, Wt::WTreeNode *parentNode, ShowExample f, const char * icon) {
   Wt::WIconPair *labelIcon = new Wt::WIconPair(icon, icon, false);
   labelIcon->icon1()->resize(30, 30);
   labelIcon->icon2()->resize(30, 30);
   Wt::WTreeNode *node = new Wt::WTreeNode(label, labelIcon, parentNode);
   node->label()->setFormatting(Wt::WText::PlainFormatting);
   node->label()->clicked.connect(this, f);
   node->labelIcon()->icon1Clicked.connect(this, f);
   node->labelIcon()->icon2Clicked.connect(this, f);
   node->labelIcon()->setStyleClass("licon");
   node->setSelectable(true);
   return node;
 }
Exemplo n.º 5
0
      Wt::WWidget * WebApp::createMenuTree() {
        Wt::WIconPair *mapIcon
            = new Wt::WIconPair("icons/yellow-folder-closed.png",
            "icons/yellow-folder-open.png", false);

        Wt::WTreeNode *rootNode = new Wt::WTreeNode("User MainMenu", mapIcon);
        rootNode->setImagePack("icons/");
        rootNode->expand();
        rootNode->setNodeVisible(false);
        rootNode->setLoadPolicy(Wt::WTreeNode::NextLevelLoading);
        createMenuNode("Account", rootNode, &WebApp::accountView, "icons/edit_user.png");
        createMenuNode("Media Data", rootNode, &WebApp::fileView, "icons/media.png");
        createMenuNode("Profiles", rootNode, &WebApp::profileView, "icons/profile.png");
        createMenuNode("Encodings", rootNode, &WebApp::encodingView, "icons/encode.png");
        createMenuNode("Watch Folder", rootNode, &WebApp::watchFolderView, "icons/folder.png");
        createMenuNode("Settings", rootNode, &WebApp::configurationView, "icons/admin.png");
        createMenuNode("Logout", rootNode, &WebApp::logout, "icons/logout.png");
        rootNode->setMargin(5);

        return rootNode;
      }
Exemplo n.º 6
0
void Tester::Match(lua_sandbox* lsb, const string& input)
{
    lua_State* lua = lsb_get_lua(lsb);
    if (!lua) return;

    if (!CreateGlobalMatch(lua)) {
        stringstream ss;
        ss << "lpeg.match is not available";
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("info") << ss.str();
        return;
    }

    if (lsb_pcall_setup(lsb, kMatchFunction)) {
        stringstream ss;
        ss << "lsb_pcall_setup() failed";
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("info") << ss.str();
        return;
    }

    lua_getglobal(lua, "grammar");
    if (!lua_isuserdata(lua, -1)) {
        stringstream ss;
        ss << "no global grammar variable was found";
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("info") << ss.str();
        return;
    }

    lua_pushstring(lua, input.c_str());
    if (lua_pcall(lua, 2, LUA_MULTRET, 0) != 0) {
        char err[LSB_ERROR_SIZE];
        int len = snprintf(err, LSB_ERROR_SIZE, "%s() %s", kMatchFunction,
                           lua_tostring(lua, -1));
        if (len >= LSB_ERROR_SIZE || len < 0) {
            err[LSB_ERROR_SIZE - 1] = 0;
        }
        stringstream ss;
        ss << err;
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("info") << ss.str();
        lsb_terminate(lsb, err);
        return;
    }
    // iterater over the results
    int results = lua_gettop(lua);
    if (LUA_TNIL == lua_type(lua, 1)) {
        stringstream ss;
        ss << "no match";
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
    } else {
        Wt::WTree* tree = new Wt::WTree(mResult);
        tree->setSelectionMode(Wt::SingleSelection);
        Wt::WTreeNode* root = new Wt::WTreeNode("Returned Values");
        root->setStyleClass("tree_results");
        tree->setTreeRoot(root);
        root->label()->setTextFormat(Wt::PlainText);
        root->setLoadPolicy(Wt::WTreeNode::NextLevelLoading);
        for (int i = 1; i <= results; ++i) {
            stringstream ss;
            OutputItem(lua, i, root, ss);
        }
        root->expand();
    }
    lua_pop(lua, lua_gettop(lua)); // clear the stack
    lsb_pcall_teardown(lsb);
}