string CreateId(JTree <AppFunction> tree) { if (tree.Parent == null) { throw new JException("Root Can not have a Id"); } Regex mIdPattern = new Regex(String.Format(@"^{0}(\d*)$", tree.Parent.Node.Id)); int maxId = 0; foreach (var t in tree.Parent.Children) { if (t.Node.Id.IsEmpty()) { continue; } var match = mIdPattern.Match(t.Node.Id); if (match != null) { maxId = Math.Max(maxId, match.Groups[1].Value.ToInt()); } } return(tree.Parent.Node.Id + (maxId + 1).ToString("00")); }
private void InitData() { JBind.BindList(dropTypeId, JTree.GetClassTree(bll_dic.GetListByParent(1), "ParentId", "1", "DictionaryName")); if (Id > 0) { //edit model = bll.GetModel(Id.ToString()); if (model != null) { txtAddress.Text = model.EvalAble; imgPhoto.ImageUrl = model.ImagePath; chkIsTop.Checked = model.IsTop > 0; chkIsRecommend.Checked = model.IsRecommend > 0; dropTypeId.Text = model.TypeID.ToString(); txtPlanName.Text = model.PlanName; txtDescrip.Text = model.Descrip; txtBeginTime.Text = model.BEGIN_TIME.ToString("yyyy-MM-dd"); txtEndTime.Text = model.END_TIME.ToString("yyyy-MM-dd"); rbltStatus.SelectedValue = model.State.ToString(); hidUsersId.Value = model.TRAIN_ID; //txtUsers.Text = B_ecan_user.GetUserName(model.BelongTo); hidtearcherid.Value = model.TeacherIds; // txtTearcher.Text = B_ecan_user.GetUserName(model.TeacherIds); txtApplyNum.Text = model.ApplyNum.ToString(); txtCode.Text = model.KeyWords; if (model.KeyWords != "") { txtCode.Enabled = false; } } } }
private void showJTree(JScrollPane view, Point pt) { JTree tree = (JTree)view.Viewport.View; Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, tree); int row = tree.getClosestRowForLocation(p.x, p.y); TreePath path = tree.getClosestPathForLocation(p.x, p.y); Rectangle bds = tree.getPathBounds(path); if (bds == null || !bds.contains(p)) { hide(); return; } if (setCompAndRow(tree, row)) { Rectangle visible = getShowingRect(view); Rectangle[] rects = getRects(bds, visible); if (rects.Length > 0) { ensureOldPopupsHidden(); painter.configure(path.LastPathComponent, view, tree, path, row); showPopups(rects, bds, visible, tree, view); } else { hide(); } } }
public TreeTableModelAdapter(TreeTableModel treeTableModel, JTree tree) { this.tree = tree; this.treeTableModel = treeTableModel; tree.AddTreeExpansionListener(new _TreeExpansionListener_65(this)); // Don't use fireTableRowsInserted() here; the selection model // would get updated twice. // Install a TreeModelListener that can update the table when // tree changes. We use delayedFireTableDataChanged as we can // not be guaranteed the tree will have finished processing // the event before us. treeTableModel.AddTreeModelListener(new _TreeModelListener_80(this)); }
public Hider(JComponent comp, JScrollPane pane) { if (comp is JTree) { tree = (JTree)comp; list = null; } else { list = (JList)comp; tree = null; } System.Diagnostics.Debug.Assert(tree != null || list != null); this.pane = pane; attach(); }
/// <summary> /// Configures a tree cell renderer and sets up sizing and the /// backing image from it /// </summary> public bool configure(object nd, JScrollPane tv, JTree tree, TreePath path, int row) { LastRendereredObject = nd; LastRenderedScrollPane = tv; Component renderer = null; bg = tree.BackgRound; bool sel = tree.SelectionEmpty ? false : tree.SelectionModel.isPathSelected(path); bool exp = tree.isExpanded(path); bool leaf = !exp && tree.Model.isLeaf(nd); bool lead = path.Equals(tree.SelectionModel.LeadSelectionPath); renderer = tree.CellRenderer.getTreeCellRendererComponent(tree, nd, sel, exp, leaf, row, lead); if (renderer != null) { Component = renderer; } return(true); }
private void AddToMgr(JTree <AppFunction> tree) { if (tree.Node.Id.IsEmpty() && tree != mFuncTrees) { tree.Node.Id = CreateId(tree); } if (tree != mFuncTrees) { mFunctionMgr.Add(tree.Node); } int ord = 0; foreach (var child in tree.Children.OrderBy(c => c.Node.Ord).ThenBy(c => c.Node.Id)) { child.Node.Ord = ord++; child.Node.ParentId = tree.Node.Id; AddToMgr(child); } }
protected void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (helper.Request("nodeId") == "") { string appType = ui.Text("sections", helper.Request("app")).ToLower(); pane_chooseNode.Text = ui.Text("create", "chooseNode", appType, this.getUser()) + "?"; DataBind(); } else { int nodeId = int.Parse(helper.Request("nodeId")); //ensure they have access to create under this node!! if (helper.Request("app") == "media" || CheckCreatePermissions(nodeId)) { //pane_chooseName.Text = ui.Text("create", "updateData", this.getUser()); cms.businesslogic.CMSNode c = new cms.businesslogic.CMSNode(nodeId); path.Value = c.Path; pane_chooseNode.Visible = false; panel_buttons.Visible = false; pane_chooseName.Visible = true; XmlDocument createDef = new XmlDocument(); XmlTextReader defReader = new XmlTextReader(Server.MapPath(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + "/config/create/UI.xml")); createDef.Load(defReader); defReader.Close(); // Find definition for current nodeType XmlNode def = createDef.SelectSingleNode("//nodeType [@alias = '" + Request.QueryString["app"] + "']"); phCreate.Controls.Add(new UserControl().LoadControl(umbraco.IO.IOHelper.ResolveUrl(umbraco.IO.SystemDirectories.Umbraco) + def.SelectSingleNode("./usercontrol").FirstChild.Value)); } else { PageNameHolder.type = umbraco.uicontrols.Feedback.feedbacktype.error; PageNameHolder.Text = ui.GetText("rights") + " " + ui.GetText("error"); JTree.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { // Put user code to initialize the page here if (Request.GetItemAsString("nodeId") == "") { var appType = ui.Text("sections", App).ToLower(); pane_chooseNode.Text = ui.Text("create", "chooseNode", appType, UmbracoUser) + "?"; DataBind(); } else { int nodeId = Request.GetItemAs <int>("nodeId"); //ensure they have access to create under this node!! if (App.InvariantEquals(Constants.Applications.Media) || CheckCreatePermissions(nodeId)) { var c = new CMSNode(nodeId); path.Value = c.Path; pane_chooseNode.Visible = false; panel_buttons.Visible = false; pane_chooseName.Visible = true; var createDef = new XmlDocument(); var defReader = new XmlTextReader(Server.MapPath(IOHelper.ResolveUrl(SystemDirectories.Umbraco) + "/config/create/UI.xml")); createDef.Load(defReader); defReader.Close(); // Find definition for current nodeType XmlNode def = createDef.SelectSingleNode("//nodeType [@alias = '" + App + "']"); phCreate.Controls.Add(new UserControl().LoadControl(IOHelper.ResolveUrl(SystemDirectories.Umbraco) + def.SelectSingleNode("./usercontrol").FirstChild.Value)); } else { PageNameHolder.type = uicontrols.Feedback.feedbacktype.error; PageNameHolder.Text = ui.GetText("rights") + " " + ui.GetText("error"); JTree.DataBind(); } } }
private void InitData() { if (type == 1 & dis == 0) { lit.Text = "所属二维结构:"; DrpParentid2.Visible = true; JBind.BindList(DrpParentid, JTree.GetClassTree(bll.GetListByParent2(CId, chapterid, 0, 1), "Parentid2", "C_Name")); JBind.BindList(DrpParentid2, JTree.GetClassTree(bll.GetListByParent2(CId, chapterid, 0, 2), "Parentid2", "C_Name")); } else { JBind.BindList(DrpParentid, JTree.GetClassTree(0, bll.GetListByParent(CId, chapterid, 0), "Parentid", "0", "C_Name")); DrpParentid.Items.Insert(0, new ListItem("根目录", "0")); } if (Id > 0) {//edit model = bll.GetModel(Id); if (model != null) { txtA1.Text = model.A1.ToString(); txtA2.Text = model.A2.ToString(); txtA3.Text = model.A3; txtA4.Text = model.A4; txtN_OrderId.Text = model.Sort.ToString(); txtName.Text = model.C_Name; drpType.Text = model.C_Type.ToString(); drpColor.Text = model.C_Color.ToString(); DrpParentid.SelectedValue = model.Parentid.ToString(); DrpParentid2.SelectedValue = model.Parentid2.ToString(); } } else { DrpParentid.SelectedValue = LYRequest.GetInt("parentid", 0).ToString(); } }
private void InitData() { DataSet ds = bll.GetList(""); JBind.BindList(DropDownList1, JTree.GetClassTree(2, ds.Tables[0], "ParentId", "0", "C_Name")); DropDownList1.Items.Insert(0, new ListItem("根目录", "0")); if (Id > 0) {//edit model = bll.GetModel(Id); if (model != null) { txtC_Name.Text = model.C_Name; DropDownList1.SelectedValue = model.ParentId.ToString(); txtOrderby.Text = model.Orderby.ToString(); txtChangdi.SelectedValue = model.isUse.ToString(); //txtRemark.Text = model.Remark; } } else { DropDownList1.SelectedValue = parentid.ToString(); } }
/// <summary> /// Returns the path to the element that is being edited. /// </summary> abstract public TreePath getEditingPath(JTree @tree);
protected void Page_Load(object sender, EventArgs e) { JTree.DataBind(); // Put user code to initialize the page here if (IsPostBack == false) { pp_relate.Text = ui.Text("moveOrCopy", "relateToOriginal"); //Document Type copy Hack... if (CurrentApp == Constants.Applications.Settings) { pane_form.Visible = false; pane_form_notice.Visible = false; pane_settings.Visible = true; ok.Text = ui.Text("general", "ok", UmbracoUser); ok.Attributes.Add("style", "width: 60px"); var documentType = new DocumentType(int.Parse(Request.GetItemAsString("id"))); //Load master types... masterType.Attributes.Add("style", "width: 350px;"); masterType.Items.Add(new ListItem(ui.Text("none") + "...", "0")); foreach (var docT in DocumentType.GetAllAsList()) { masterType.Items.Add(new ListItem(docT.Text, docT.Id.ToString())); } masterType.SelectedValue = documentType.MasterContentType.ToString(); rename.Text = documentType.Text + " (copy)"; pane_settings.Text = "Make a copy of the document type '" + documentType.Text + "' and save it under a new name"; } else { pane_form.Visible = true; pane_form_notice.Visible = true; pane_settings.Visible = false; // Caption and properies on BUTTON ok.Text = ui.Text("general", "ok", UmbracoUser); ok.Attributes.Add("style", "width: 60px"); ok.Attributes.Add("disabled", "true"); IContentBase currContent; if (CurrentApp == "content") { currContent = Services.ContentService.GetById(Request.GetItemAs <int>("id")); } else { currContent = Services.MediaService.GetById(Request.GetItemAs <int>("id")); } var validAction = true; if (CurrentApp == Constants.Applications.Content && Umbraco.Core.Models.ContentExtensions.HasChildren(currContent, Services)) { validAction = ValidAction(currContent, Request.GetItemAsString("mode") == "cut" ? 'M' : 'O'); } if (Request.GetItemAsString("mode") == "cut") { pane_form.Text = ui.Text("moveOrCopy", "moveTo", currContent.Name, UmbracoUser); pp_relate.Visible = false; } else { pane_form.Text = ui.Text("moveOrCopy", "copyTo", currContent.Name, UmbracoUser); pp_relate.Visible = true; } if (validAction == false) { panel_buttons.Visible = false; ScriptManager.RegisterStartupScript(this, GetType(), "notvalid", "notValid();", true); } } } }
/// <summary> /// Configures the renderer based on the passed in components. /// </summary> public Component getTreeCellRendererComponent(JTree @tree, object @value, bool @sel, bool @expanded, bool @leaf, int @row, bool @hasFocus) { return(default(Component)); }
/// <summary> /// Returns the Rectangle enclosing the label portion that the /// last item in path will be drawn into. /// </summary> abstract public Rectangle getPathBounds(JTree @tree, TreePath @path);
/// <summary> /// Returns true if the tree is being edited. /// </summary> abstract public bool isEditing(JTree @tree);
/// <summary> /// Returns the path to the node that is closest to x,y. /// </summary> abstract public TreePath getClosestPathForLocation(JTree @tree, int @x, int @y);
/// <summary> /// Returns the path for passed in row. /// </summary> abstract public TreePath getPathForRow(JTree @tree, int @row);
/// <summary> /// Returns the number of rows that are being displayed. /// </summary> abstract public int getRowCount(JTree @tree);
protected void Page_Load(object sender, EventArgs e) { JTree.DataBind(); // Put user code to initialize the page here if (IsPostBack == false) { pp_relate.Text = ui.Text("moveOrCopy", "relateToOriginal"); //Document Type copy Hack... if (CurrentApp == "settings") { pane_form.Visible = false; pane_form_notice.Visible = false; pane_settings.Visible = true; ok.Text = ui.Text("general", "ok", this.getUser()); ok.Attributes.Add("style", "width: 60px"); var documentType = new DocumentType(int.Parse(helper.Request("id"))); //Load master types... masterType.Attributes.Add("style", "width: 350px;"); masterType.Items.Add(new ListItem(ui.Text("none") + "...", "0")); foreach (var docT in DocumentType.GetAllAsList()) { masterType.Items.Add(new ListItem(docT.Text, docT.Id.ToString())); } masterType.SelectedValue = documentType.MasterContentType.ToString(); rename.Text = documentType.Text + " (copy)"; pane_settings.Text = "Make a copy of the document type '" + documentType.Text + "' and save it under a new name"; } else { pane_form.Visible = true; pane_form_notice.Visible = true; pane_settings.Visible = false; // Caption and properies on BUTTON ok.Text = ui.Text("general", "ok", this.getUser()); ok.Attributes.Add("style", "width: 60px"); ok.Attributes.Add("disabled", "true"); var cmsNode = new CMSNode(int.Parse(helper.Request("id"))); var validAction = true; if (CurrentApp == "content" && cmsNode.HasChildren) { validAction = ValidAction(helper.Request("mode") == "cut" ? 'M' : 'O'); } if (helper.Request("mode") == "cut") { pane_form.Text = ui.Text("moveOrCopy", "moveTo", cmsNode.Text, base.getUser()); pp_relate.Visible = false; } else { pane_form.Text = ui.Text("moveOrCopy", "copyTo", cmsNode.Text, base.getUser()); pp_relate.Visible = true; } if (validAction == false) { ScriptManager.RegisterStartupScript(this, this.GetType(), "notvalid", "notValid();", true); } } } }
/// <summary> /// Stops the current editing session. /// </summary> abstract public bool stopEditing(JTree @tree);
/// <summary> /// Selects the last item in path and tries to edit it. /// </summary> abstract public void startEditingAtPath(JTree @tree, TreePath @path);
/// <summary> /// 根据程序集反射出所有的需权限的控制器和功能 /// </summary> /// <param name="rootTree">程序集根结点</param> /// <param name="assembly">程序集</param> void GetFunctions(JTree <AppFunction> rootTree, Assembly assembly) { var functionInfos = (from t in assembly.GetTypes() where !t.IsAbstract && t.Name.EndsWith("Controller") from m in t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly) where !m.IsSpecialName select new MvcFuncInfo() { Controller = t, Action = m, ControllerName = t.Name.Substring(0, t.Name.Length - 10), ActionName = m.Name, Parameters = m.GetParameters() }).ToList(); List <AppFunction> functionList = new List <AppFunction>(); foreach (var groupInfo in functionInfos.GroupBy(f => f.Controller)) { var menu = GetMenu(groupInfo.Key, rootTree.Node.AuthType, rootTree.Node.LogType); //生成Controller作为二级的功能项 AppFunction parent = new AppFunction() { Name = menu.Name, Location = menu.AreaName + "/" + groupInfo.First().ControllerName, ControllerName = groupInfo.Key.FullName, Visible = menu.Visible, AuthType = menu.AuthType, LogType = menu.LogType, Ord = menu.Ord, }; if (parent.AuthType == JAuthType.Ignore) { continue; } parent.LocationSamples = parent.Location; ReDefineId(menu, parent); var parentTree = rootTree.Add(parent); //生成Controller下面的Action作为三级的功能项 foreach (var info in groupInfo) { info.AuthType = parent.AuthType; //提取Attributes GetAttributes(info); menu = GetMenu(info); AppFunction child = new AppFunction() { Name = menu.Name, Location = menu.AreaName + info.ToString(), ParentId = parent.Id, Visible = menu.Visible, Method = info.HasPost ? WebMethod.POST : WebMethod.GET, Ord = menu.Ord, AuthType = menu.AuthType, Arguments = info.Parameters .ToDictionary(p => p.Name, p => p.ParameterType.Name.StartsWith("Int") ? @"\d+" : null), LogType = menu.LogType, ControllerName = parent.ControllerName, ActionName = info.ActionName }; if (child.AuthType == JAuthType.Ignore) { continue; } ReDefineId(menu, child); if (child.Method == WebMethod.GET) { MakeRegTail(child, info); } else { MakePostRegTail(child, info); } parentTree.Add(child); } } }
/// <summary> /// Returns the row that the last item identified in path is visible /// at. /// </summary> abstract public int getRowForPath(JTree @tree, TreePath @path);
protected void Page_Load(object sender, System.EventArgs e) { JTree.DataBind(); // Put user code to initialize the page here if (!IsPostBack) { //Document Type copy Hack... string app = helper.Request("app"); if (app == "settings") { pane_form.Visible = false; pane_form_notice.Visible = false; pane_settings.Visible = true; ok.Text = ui.Text("general", "ok", this.getUser()); ok.Attributes.Add("style", "width: 60px"); cms.businesslogic.web.DocumentType dt = new umbraco.cms.businesslogic.web.DocumentType(int.Parse(helper.Request("id"))); //Load master types... masterType.Attributes.Add("style", "width: 350px;"); masterType.Items.Add(new ListItem(ui.Text("none") + "...", "0")); foreach (cms.businesslogic.web.DocumentType docT in cms.businesslogic.web.DocumentType.GetAllAsList()) { masterType.Items.Add(new ListItem(docT.Text, docT.Id.ToString())); } masterType.SelectedValue = dt.MasterContentType.ToString(); //hack to close window if not a doctype... if (dt == null) { Response.Write("<script type=\"text/javascript\">javascript:parent.window.close()</script>"); } else { rename.Text = dt.Text + " (copy)"; pane_settings.Text = "Make a copy of the document type '" + dt.Text + "' and save it under a new name"; } } else { pane_form.Visible = true; pane_form_notice.Visible = true; pane_settings.Visible = false; // Caption and properies on BUTTON ok.Text = ui.Text("general", "ok", this.getUser()); ok.Attributes.Add("style", "width: 60px"); ok.Attributes.Add("disabled", "true"); string currentPath = ""; CMSNode d = new CMSNode(int.Parse(helper.Request("id"))); foreach (string s in d.Path.Split(',')) { if (int.Parse(s) > 0) { currentPath += "/" + new CMSNode(int.Parse(s)).Text; } } // bool validAction = true; // only validate permissions in content if (app == "content" && d.HasChildren) { validAction = ValidAction(helper.Request("mode") == "cut" ? 'M' : 'O'); } if (helper.Request("mode") == "cut") { pane_form.Text = ui.Text("moveOrCopy", "moveTo", d.Text, base.getUser()); pp_relate.Visible = false; } else { pane_form.Text = ui.Text("moveOrCopy", "copyTo", d.Text, base.getUser()); pp_relate.Visible = true; } if (!validAction) { ScriptManager.RegisterStartupScript(this, this.GetType(), "notvalid", "notValid();", true); } } } }
/// <summary> /// Cancels the current editing session. /// </summary> abstract public void cancelEditing(JTree @tree);