Package SimpleOutline

Examples of SimpleOutline.BrowserDisplayNode


    public TextData getStatusLine() {
        return this.statusLine;
    }

    public void setBrowser(BrowserDisplayNode browser) {
        BrowserDisplayNode oldValue = this.browser;
        this.browser = browser;
        RootNode.set(this.getqq_Browser(), browser);
        this.qq_Listeners.firePropertyChange("browser", oldValue, this.browser);
    }
View Full Code Here


            WidgetState.set(this.getqq_AddAfterTree(), Constants.FS_DISABLE);
            WidgetState.set(this.getqq_AddBeforeTree(), Constants.FS_DISABLE);
            WidgetState.set(this.getqq_DeleteTree(), Constants.FS_DISABLE);

   
            BrowserDisplayNode node = null;
            // BrowserDisplayNode is a
            // subclass of DisplayNode
            // that we have created for  
            // this OutlineField. This
            // variable 'Node' will be used
            // by several of the event
            // handlers.
   
            this.setBrowser(new BrowserDisplayNode());
            // The mapped attribute 'Browser'
            // corresponds to the
            // OutlineField Widget's Root Node.
            // The Root Node is the top node of
            // the tree structure of DisplayNode
            // objects.
   
            this.getBrowser().setFolder(true);
            // These three attributes must
            this.getBrowser().setIsFilled(true);
            // always be set to 'TRUE' for
            this.getBrowser().setOpened(true);
            // the Root Node of an
            // OutlineField.
   
            this.getBrowser().setText(new TextData("ROOT NODE"));
            // Root Displayed is set to
            // FALSE on the OutlineField
            // property sheet, so we will
            // not see the text displayed.
   
            WidgetState.set(this.getqq_Browser_Text(), Constants.FS_DRAG);
            WidgetState.set(this.getqq_Browser_Image(), Constants.FS_DRAG);
            // This enables the 'drag' part of drag & drop.
            // The 'drop' is handled
            // in the event loop below. Note that <Browser.Text>.State
            // is not a real Widget, but is simply a syntax to refer to
            // the 'Text' column of the BrowserDisplayNode that we have
            // defined for this OutlineField. Setting this column to
            // FS_DRAG makes it so we can drag a row by clicking on
            // the text.

   
            WidgetState.set(this.getqq_AddAfter(), Constants.FS_DISABLE);
            // These buttons are dimmed
            WidgetState.set(this.getqq_AddBefore(), Constants.FS_DISABLE);
            // to begin with. They're
            WidgetState.set(this.getqq_Delete(), Constants.FS_DISABLE);
            // enabled when a node is
            // selected.
   
            this.setStatusLine(new TextData());
            // Instantiate empty status line.
   
            // Give the window an initial size.
            Height.set(this, 4000);
            Width.set(this, 4000);
   
            UserWindow.open(this);
            // The user window must be opened before the
            // event loop.
   
            this.setShowRoot(this.getqq_Browser().getTree().isRootVisible());
            this.setHasControls(HasControls.get(this.getqq_Browser()));
   
            this.setShowRootTree(TreeRootVisible.is(this.getqq_tree()));
            this.setHasControlsTree(HasControls.get(this.getqq_tree()));

   
            // ----------
            // Event Loop
            // ----------
            EventManager.startEventLoop();
            try {
                EventRegistration ToggleField_AfterValueChange_getqq_ShowRoot = ClientEventManager.register( this.getqq_ShowRoot(), "AfterValueChange" );
                EventRegistration ToggleField_AfterValueChange_getqq_HasControls = ClientEventManager.register( this.getqq_HasControls(), "AfterValueChange" );
                EventRegistration PushButton_Click_getqq_AddBefore = ClientEventManager.register( this.getqq_AddBefore(), "Click" );
                EventRegistration PushButton_Click_getqq_AddAfter = ClientEventManager.register( this.getqq_AddAfter(), "Click" );
                EventRegistration PushButton_Click_getqq_AddChild = ClientEventManager.register( this.getqq_AddChild(), "Click" );
                EventRegistration PushButton_Click_getqq_Delete = ClientEventManager.register( this.getqq_Delete(), "Click" );
                EventRegistration OutlineField_DoubleClick_getqq_Browser = ClientEventManager.register( this.getqq_Browser(), "DoubleClick" );
                EventRegistration OutlineField_AfterCurrentNodeChange_getqq_Browser = ClientEventManager.register( this.getqq_Browser(), "AfterCurrentNodeChange" );
                EventRegistration OutlineField_ObjectDrop_getqq_Browser = ClientEventManager.register( this.getqq_Browser(), "ObjectDrop" );
                EventRegistration TaskHandle_Shutdown_langThreadcurrentThread = ClientEventManager.register( Thread.currentThread(), "Shutdown" );
                EventRegistration ToggleField_AfterValueChange_getqq_ShowRootTree = ClientEventManager.register( this.getqq_ShowRootTree(), "AfterValueChange" );
                EventRegistration ToggleField_AfterValueChange_getqq_HasControlsTree = ClientEventManager.register( this.getqq_HasControlsTree(), "AfterValueChange" );
                EventRegistration PushButton_Click_getqq_AddBeforeTree = ClientEventManager.register( this.getqq_AddBeforeTree(), "Click" );
                EventRegistration PushButton_Click_getqq_AddAfterTree = ClientEventManager.register( this.getqq_AddAfterTree(), "Click" );
                EventRegistration PushButton_Click_getqq_AddChildTree = ClientEventManager.register( this.getqq_AddChildTree(), "Click" );
                EventRegistration PushButton_Click_getqq_DeleteTree = ClientEventManager.register( this.getqq_DeleteTree(), "Click" );
                EventRegistration TreeView_AfterCurrentNodeChange_getqq_tree = ClientEventManager.register( this.getqq_tree(), "AfterCurrentNodeChange" );
   
                while (true) {
   
                    UIutils.processGUIActions();
                    EventHandle qq_currentEvent = EventManager.waitForEvent();
                    if (qq_currentEvent == null)
                        break;
   
                    // ---------------------------
                    // <ShowRoot>.AfterValueChange
                    // ---------------------------
                    if (qq_currentEvent.isEvent(ToggleField_AfterValueChange_getqq_ShowRoot)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            TreeRootVisible.set(this.getqq_Browser(), this.getShowRoot());
   
                            // ================ End Forte Event Handler Translation ================
                        }
                        finally {
                            CursorMgr.endEvent();
                        }
                    }
   
                    // ------------------------------
                    // <HasControls>.AfterValueChange
                    // ------------------------------
                    else if (qq_currentEvent.isEvent(ToggleField_AfterValueChange_getqq_HasControls)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            HasControls.set(this.getqq_Browser(), this.getHasControls());
   
                            // ================ End Forte Event Handler Translation ================
                        }
                        finally {
                            CursorMgr.endEvent();
                        }
                    }
   
                    // -----------------
                    // <AddBefore>.Click
                    // -----------------
                    else if (qq_currentEvent.isEvent(PushButton_Click_getqq_AddBefore)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            node = new BrowserDisplayNode();
                            // Create a new BrowserDisplayNode object.
                            node.setText(new TextData("New Node Before ").concat(this.outlineFieldNodeCounter));
                            this.outlineFieldNodeCounter = this.outlineFieldNodeCounter+1;
   
                            node.setNextSibling(TreeFieldCurrentNode.get(this.getqq_Browser()));
                            //
                            // Note: NextSibling is a virtual attribute that causes
                            // many other attributes to be set. When we set
                            // NextSibling for this new node, it will cause
                            // PrevSibling for CurrentNode to be set to this node,
                            // and this node's Parent will be set to CurrentNode's
                            // Parent. Ths idea is that these Virtual Attributes
                            // on DisplayNode are 'assertions' that 'Make it so.'
                            // When any one gets set, the other's are rearranged
                            // to comply.
                            //
                            this.getStatusLine().setValue( "Node Added Before" );
   
                            // ================ End Forte Event Handler Translation ================
                        }
                        finally {
                            CursorMgr.endEvent();
                        }
                    }
   
                    // ----------------
                    // <AddAfter>.Click
                    // ----------------
                    else if (qq_currentEvent.isEvent(PushButton_Click_getqq_AddAfter)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            node = new BrowserDisplayNode();
                            // Create a new BrowserDisplayNode object.
                            node.setText(new TextData("New Node After ").concat(this.outlineFieldNodeCounter));
                            this.outlineFieldNodeCounter = this.outlineFieldNodeCounter+1;
                            node.setPrevSibling(TreeFieldCurrentNode.get(this.getqq_Browser()));
                            //
                            // Note: PrevSibling is a virtual attribute that causes
                            // many other attributes to be set. It functions
                            // similarly to NextSibling. See comment above.
                            //
                            this.getStatusLine().setValue( "Node Added After" );
   
                            // ================ End Forte Event Handler Translation ================
                        }
                        finally {
                            CursorMgr.endEvent();
                        }
                    }
   
                    // ----------------
                    // <AddChild>.Click
                    // ----------------
                    else if (qq_currentEvent.isEvent(PushButton_Click_getqq_AddChild)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            if (TreeFieldCurrentNode.get(this.getqq_Browser()) != null) {
                                // There is a node selected.
   
                                // The following attributes must be set for a node
                                // to have children added to it. If they are aready
                                // set, then this won't have any effect.
   
                                TreeFieldCurrentNode.get(this.getqq_Browser()).setFolder(true);
                                TreeFieldCurrentNode.get(this.getqq_Browser()).setIsFilled(true);
                                TreeFieldCurrentNode.get(this.getqq_Browser()).setOpened(true);
   
                                // Note that 'IsFolder' must be set before
                                // 'IsOpened,' because setting 'IsOpened' only has
                                // an effect on DisplayNodes that are Folders. Also
                                // 'IsFilled' must be set before 'IsOpened.'
                                // Whatever the reason, always set them in the
                                // order shown here! 
   
                                node = new BrowserDisplayNode();
                                // Create a new BrowserDisplayNode
                                // object.
                                node.setText(new TextData("New Child Node ").concat(this.outlineFieldNodeCounter));
                                this.outlineFieldNodeCounter = this.outlineFieldNodeCounter+1;
   
                                node.setParent(TreeFieldCurrentNode.get(this.getqq_Browser()));
                                // Note: Parent is a virtual attribute that causes
                                // many other attributes to be set. It functions
                                // similarly to NextSibling. See comment above.
                                // (We could have done this in several
                                // other ways, for instance, we could have set:
                                //    <Browser>.CurrentNode.LastChild = Node;
                                // and it would have done the same thing.)
   
                            }
                            else {
                                // If there is no CurrentNode, we'll add a child
                                // to the Root Node.
   
                                node = new BrowserDisplayNode();
                                // Create new BrowserDisplayNode object.
                                node.setText(new TextData("New Child Node ").concat(this.outlineFieldNodeCounter));
                                this.outlineFieldNodeCounter = this.outlineFieldNodeCounter+1;
   
                                node.setParent(this.getBrowser());
                                // Note: Browser is the BrowserDisplayNode that is
                                // the RootNode of <Browser> the OutlineField.
   
                            }
                            this.getStatusLine().setValue( "Child Node Added" );
   
                            // ================ End Forte Event Handler Translation ================
                        }
                        finally {
                            CursorMgr.endEvent();
                        }
                    }
   
                    // --------------
                    // <Delete>.Click
                    // --------------
                    else if (qq_currentEvent.isEvent(PushButton_Click_getqq_Delete)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            if (TreeFieldCurrentNode.get(this.getqq_Browser()) != null) {
                                // There is a node selected.
   
                                TreeFieldCurrentNode.get(this.getqq_Browser()).setParent(null);
                                // Setting the Parent to NIL removes the Node
                                // from the OutlineField. Nothing else is
                                // needed.
                                this.getStatusLine().setValue( "Node Deleted" );
                            }
   
                            // ================ End Forte Event Handler Translation ================
                        }
                        finally {
                            CursorMgr.endEvent();
                        }
                    }
   
                    // ---------------------
                    // <Browser>.DoubleClick
                    // ---------------------
                    else if (qq_currentEvent.isEvent(OutlineField_DoubleClick_getqq_Browser)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            DataEntryDialog dialog = new DataEntryDialog();
                            // The DataEntryDialog is a simple dialog
                            // that allows the user to enter a single line
                            // of text, then click OK or Cancel.
   
                            node = (BrowserDisplayNode)TreeFieldCurrentNode.get(this.getqq_Browser());
                            // The attribute CurrentNode is of type DisplayNode.
                            // We need to cast it to BrowserDisplayNode in order
                            // to access the Text attribute.
   
                            if (node != null) {
                                dialog.setText(node.getText());
                                // Load the node's text into the dialog.
                            }
                            else {
                                dialog.setText(new TextData());
                            }
   
                            if (dialog.displayDialog() == true) {
                                // TRUE means OK.

   
                                node.setText(dialog.getText());
                                // Dialog.Text is the
                                // text the user typed.
   
                                // The user may select an image from the PaletteList
                                // on the dialog. Dialog.Image will be an integer
                                // corresponding to the image the user selected.
                                // Then we grap the ImageData from the PaletteList
                                // by 'looking inside' the Widget with
                                // 'GetElementList.'
   
                                Array_Of_ListElement<ListElement> imageList = dialog.getqq_Image().getElementList();
                                node.setImage(imageList.get(dialog.getImage()-1).getImageValue());
   
                                // This method on DisplayNode must be invoked to
                                // update the OutlineField on the screen.
                                node.updateFieldFromData();
                            }
   
                            // ================ End Forte Event Handler Translation ================
                        }
                        finally {
                            CursorMgr.endEvent();
                        }
                    }
   
                    // --------------------------------
                    // <Browser>.AfterCurrentNodeChange
                    // --------------------------------
                    else if (qq_currentEvent.isEvent(OutlineField_AfterCurrentNodeChange_getqq_Browser)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            // This event is received whenever the value of
                            // CurrentNode has changed.
   
                            if (TreeFieldCurrentNode.get(this.getqq_Browser()) == null) {
   
                                // If this a CurrentNode is not selected, disable
                                // the AddAfter, AddBefore, and Delete buttons.
   
                                WidgetState.set(this.getqq_AddAfter(), Constants.FS_DISABLE);
                                WidgetState.set(this.getqq_AddBefore(), Constants.FS_DISABLE);
                                WidgetState.set(this.getqq_Delete(), Constants.FS_DISABLE);
                            }
                            else {
                                // Otherwise, enable them.
   
                                WidgetState.set(this.getqq_AddAfter(), Constants.FS_UPDATE);
                                WidgetState.set(this.getqq_AddBefore(), Constants.FS_UPDATE);
                                WidgetState.set(this.getqq_Delete(), Constants.FS_UPDATE);
                            }
   
                            // ================ End Forte Event Handler Translation ================
                        }
                        finally {
                            CursorMgr.endEvent();
                        }
                    }
   
                    // --------------------
                    // <Browser>.ObjectDrop
                    // --------------------
                    else if (qq_currentEvent.isEvent(OutlineField_ObjectDrop_getqq_Browser)) {
                        try {
                            CursorMgr.startEvent();
                            // ================ Begin Forte Event Handler Translation ================
                            JComponent sF = (JComponent)((ParameterHolder)qq_currentEvent.getParameter("sourceField")).getObject();
                            JComponent dF = (JComponent)((ParameterHolder)qq_currentEvent.getParameter("dropField")).getObject();
                            Object sD = (Object)((ParameterHolder)qq_currentEvent.getParameter("sourceData")).getObject();
                            int dX = ((ParameterHolder)qq_currentEvent.getParameter("dropX")).getInt();
                            int dY = ((ParameterHolder)qq_currentEvent.getParameter("dropY")).getInt();
                            // This event is recieved whenever any draggable field
                            // is dropped on any widget. The code below figures out
                            // the details.
   
                            // The source data is the object dropped, for our drag &
                            // drop feature, it must be not NIL and be a
                            // BrowserDisplayNode. The SourceField is the widget
                            // where the drag started. The DropField is the where
                            // the drop happens. For this example the SourceField
                            // and the DropField must be the same. (In other
                            // applications, there may be a more complex set of
                            // rules for drag & drop.)
   
                            this.getStatusLine().setValue( "" );
                            // Good time to blank the
                            // status line.
   
                            if (sD != null && sD instanceof BrowserDisplayNode && sF == dF) {
                                int column = 0;
                                BrowserDisplayNode sourceNode = (BrowserDisplayNode)sD;
                                BrowserDisplayNode destNode = null;
   
                                ParameterHolder qq_column = new ParameterHolder(column);
                                DisplayNode qq_tempNode = TreeField.locateNode(this.getqq_Browser(), UIutils.milsToPixels(dX), UIutils.milsToPixels(dY), qq_column);
                                column = qq_column.getInt();
                                destNode = (BrowserDisplayNode)qq_tempNode;
                                // LocateNode is the method used to determine which
                                // row the drop occured on. It returns a DisplayNode
                                // which we cast into a BrowserDisplayNode. Column
                                // is returned also, but isn't used in this example.
   
                                // Can't be dropped
                                // on itself.
                                // IsChildOf was written to protect against the  
                                // case of dropping a node on one of it's own
                                // children. This would otherwise cause serious
                                // trouble.
                                if (destNode != null && destNode != sourceNode && !(destNode.isChildOf(sourceNode))) {
                                    sourceNode.setParent(null);
                                    // Remove the dragged node from the tree.
                                    sourceNode.setPrevSibling(destNode);
                                    // Add it right after the node it was
                                    // dropped on.
View Full Code Here

TOP

Related Classes of SimpleOutline.BrowserDisplayNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.