Example #1
0
        /// <summary>
        /// see ItemsManager#setSelectionIndex(int)
        /// </summary>
        /// <param name="number"></param>
        internal override void setSelectionIndex(int number)
        {
            Debug.Assert(Misc.IsGuiThread());
            if (number != GuiConstants.NO_ROW_SELECTED)
            {
                TreeChild treeChild = (TreeChild)controlsMap.object2Widget(_mgTreeControl, number);

                if (_prevSelectedTreeNode != null && _prevSelectedTreeNode.TreeView != null /* isDisposed()*/)
                {
                    // workaround for SWT bug. QCR #729438
                    Rectangle rect = _prevSelectedTreeNode.Bounds;
                    _treeControl.Invalidate(new Rectangle(rect.X, rect.Y, rect.Width + 10, rect.Height), true);
                }

                _treeControl.BeforeSelect -= TreeHandler.getInstance().TreeNodeBeforeSelect;

                _treeControl.SelectedNode = treeChild.getTreeNode();
                _selectedTreeNode         = treeChild.getTreeNode();
                _prevSelectedTreeNode     = _selectedTreeNode;
                showSelection();

                _treeControl.BeforeSelect += TreeHandler.getInstance().TreeNodeBeforeSelect;
            }
            else
            {
                _treeControl.SelectedNode = null;
                _prevSelectedTreeNode     = null;
            }
        }
Example #2
0
        /// <summary> open temporary editor for tree child create a text control for the editor
        /// </summary>
        /// <param name="child"></param>
        /// <returns></returns>
        internal Control showTmpEditor(TreeChild child)
        {
            Debug.Assert(Misc.IsGuiThread());
            if (_form == null)
            {
                _form = GuiUtils.FindForm(_treeControl);
            }
            GuiUtils.SetTmpEditorOnTagData(_form, _tmpEditor);
            TextBox text = (_tmpEditor.Control == null ? (TextBox)toControl(_mgTreeControl, CommandType.CREATE_EDIT) :
                            (TextBox)_tmpEditor.Control);

            text.Show(); //fixed bug #:310473, control is created as hiden we need to show the created editor.

            ControlUtils.SetBGColor(text, Color.White);
            text.BorderStyle = BorderStyle.FixedSingle;
            ControlsMap.getInstance().setMapData(_mgTreeControl, child._mgRow, text);

            if (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "ja") // JPN: IME support
            {
                child.Modifable = true;
            }

            child.setProperties(text);
            _tmpEditor.Control = text;
            _tmpEditor.Node    = child.getTreeNode();
            _tmpEditor.Layout();
            ((TagData)_form.Tag).LastFocusedControl = text;

            GuiUtils.setFocus(text, true, false);
            return(text);
        }
Example #3
0
        /// <summary>
        /// move node under parent to a location after 'afterSiblingIdx'.
        /// </summary>
        /// <param name="parentIdx">The parent node under which we are moving the node</param>
        /// <param name="afterSiblingIdx">The new location is after that sibling</param>
        /// <param name="nodeId">The node to move</param>
        internal void moveNode(int parentIdx, int afterSiblingIdx, int nodeId)
        {
            Debug.Assert(Misc.IsGuiThread());
            Object parent = controlsMap.object2Widget(_mgTreeControl, parentIdx);

            Debug.Assert(parent != null);
            int       idx          = 0;
            TreeChild afterSibling = null;
            TreeChild nodeToMove   = null;

            //get the treeChild of the node to move
            nodeToMove = (TreeChild)controlsMap.object2Widget(_mgTreeControl, nodeId);

            // get the new index under the parent
            if (afterSiblingIdx > 0)
            {
                afterSibling = (TreeChild)controlsMap.object2Widget(_mgTreeControl, afterSiblingIdx);
                idx          = afterSibling.getIndex() + 1;
            }

            //inserting an open node, raises the before expand. avoid it.
            _treeControl.BeforeExpand -= TreeHandler.getInstance().BeforeExpandHandler;

            // remove from the nodes collection and add at the new location.
            if (parent is TreeView)
            {
                //remove and insert of a root (The parent is the tree itself)
                ((TreeView)parent).Nodes.Remove(nodeToMove.getTreeNode());
                ((TreeView)parent).Nodes.Insert(idx, nodeToMove.getTreeNode());
            }
            else if (parent is TreeChild)
            {
                //remove and insert of a node with another node as a parent.
                (((TreeChild)parent).getTreeNode()).Nodes.Remove(nodeToMove.getTreeNode());
                (((TreeChild)parent).getTreeNode()).Nodes.Insert(idx, nodeToMove.getTreeNode());
            }
            else
            {
                Debug.Assert(false);
            }

            // resume handling 'Before expand'.
            _treeControl.BeforeExpand += TreeHandler.getInstance().BeforeExpandHandler;
        }