Package org.openquark.gems.client.browser

Examples of org.openquark.gems.client.browser.BrowserTreeModel


        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {

            super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

            BrowserTreeModel browserTreeModel = (BrowserTreeModel) tree.getModel();
            IntellicutManager intellicutManager = gemCutter.getIntellicutManager();
       
            if (intellicutManager.getIntellicutMode() == IntellicutMode.NOTHING) {
                // If Intellicut is not active

                if (value instanceof GemTreeNode) {
                  
                    // Add scope icon (public, protected, private) to the gem icon on the bottom right corner
                    // Uses a cache to store icons already combined
                    GemEntity entity = (GemEntity) ((GemTreeNode) value).getUserObject();
                    Icon baseGemIcon = getIcon();
                    Icon overlayIcon = null;
                    Map<Icon, Icon> cache = null;
                   
                    if (entity.getScope().isPublic()) {
                        cache = imageCache_public;
                        overlayIcon = SCOPE_PUBLIC_ICON;
                  
                    } else if (entity.getScope().isProtected()) {
                        cache = imageCache_protected;
                        overlayIcon = SCOPE_PROTECTED_ICON;

                    } else { //entity.getScope().isPrivate()
                        cache = imageCache_private;
                        overlayIcon = SCOPE_PRIVATE_ICON;
                    }

                    Icon cachedImage = cache.get(baseGemIcon);
                    if (cachedImage != null) {
                        setIcon(cachedImage);

                    } else {
                        Icon newIcon = UIUtilities.combineIcons(baseGemIcon, overlayIcon);
                        setIcon(newIcon);
                        cache.put(baseGemIcon, newIcon);
                    }

                    if (((GemTreeNode) value).hasDesign()) {
                        // Add a design decal to the gem icon
                        baseGemIcon = getIcon();
                        Icon newIcon = UIUtilities.combineIcons(baseGemIcon, GEM_DESIGN_DECAL);
                        setIcon(newIcon);
                    }
                }
           
                return this;
            }

            // If Intellicut is active, use special Intellicut icons to indicate Intellicut status.
       
            if (leaf) {
           
                // This is a gem. Give it an icon and text color that indicates how intellicut can connect it.
           
                GemEntity gemEntity = (GemEntity) ((GemTreeNode) value).getUserObject();
           
                if (browserTreeModel.isVisibleGem(gemEntity)) {
               
                    IntellicutInfo intellicutInfo = intellicutManager.getIntellicutInfo(gemEntity);
                    AutoburnUnifyStatus autoburnStatus = intellicutInfo.getAutoburnUnifyStatus();

                    if (autoburnStatus == AutoburnUnifyStatus.UNAMBIGUOUS) {
                        setIcon(BURN_ICON);
                        setForeground(BURN_COLOR);
                   
                    } else if (autoburnStatus == AutoburnUnifyStatus.AMBIGUOUS) {
                        setIcon(AMBIGUOUS_ICON);
                        setForeground(AMBIGUOUS_COLOR);
                   
                    } else if (autoburnStatus == AutoburnUnifyStatus.NOT_POSSIBLE) {
                        setIcon(CANNOT_CONNECT_ICON);
                        setForeground(CANNOT_CONNECT_COLOR);

                    } else if (autoburnStatus == AutoburnUnifyStatus.UNAMBIGUOUS_NOT_NECESSARY &&                   
                               intellicutInfo.getBurnTypeCloseness() > intellicutInfo.getNoBurnTypeCloseness()) {
                              
                        setIcon(BURN_ICON);
                        setForeground(BURN_COLOR);
               
                    } else if (autoburnStatus == AutoburnUnifyStatus.AMBIGUOUS_NOT_NECESSARY &&
                               intellicutInfo.getBurnTypeCloseness() > intellicutInfo.getNoBurnTypeCloseness()) {

                        setIcon(AMBIGUOUS_ICON);
                        setForeground(AMBIGUOUS_COLOR);
                    }
               
                } else {
                    setIcon(CANNOT_CONNECT_ICON);
                    setForeground(CANNOT_CONNECT_COLOR);               
                }
   
            } else {

                // This is a folder. Determine if and how it should pulse.

                // Assume we can't connect at all to start with.
                Color folderColor = CANNOT_CONNECT_COLOR;

                Enumeration<TreeNode> subTreeEnum = UnsafeCast.<Enumeration<TreeNode>>unsafeCast(((DefaultMutableTreeNode)value).breadthFirstEnumeration());
           
                while (subTreeEnum.hasMoreElements()) {

                    DefaultMutableTreeNode childTreeNode = (DefaultMutableTreeNode) subTreeEnum.nextElement();
               
                    if (childTreeNode instanceof GemTreeNode) {

                        GemEntity gemEntity = (GemEntity) childTreeNode.getUserObject();

                        if (browserTreeModel.isVisibleGem(gemEntity)) {

                            IntellicutInfo intellicutInfo = intellicutManager.getIntellicutInfo(gemEntity);
                            AutoburnUnifyStatus autoburnStatus = intellicutInfo.getAutoburnUnifyStatus();

                            if (autoburnStatus == AutoburnUnifyStatus.NOT_NECESSARY) {
View Full Code Here


        public void leafNodeTriggered(LeafNodeTriggeredEvent evt) {

            IntellicutManager intellicutManager = gemCutter.getIntellicutManager();
            TableTop tableTop = gemCutter.getTableTop();
       
            BrowserTreeModel browserTreeModel = (BrowserTreeModel) gemCutter.getBrowserTree().getModel();
           
            if (intellicutManager.getIntellicutMode() != IntellicutMode.NOTHING) {

                // evt.getTriggeredObjects() could be empty if a module is selected
                if (!evt.getTriggeredObjects().isEmpty()){
                    Object obj = evt.getTriggeredObjects().get(0);

                    if (obj instanceof GemEntity) {

                        GemEntity gemEntity = (GemEntity) obj;
                        IntellicutInfo intellicutInfo = intellicutManager.getIntellicutInfo(gemEntity);
                        AutoburnUnifyStatus autoburnStatus = intellicutInfo.getAutoburnUnifyStatus();

                        if (autoburnStatus != AutoburnUnifyStatus.NOT_POSSIBLE) {

                            tableTop.getUndoableEditSupport().beginUpdate();

                            // Add the new gem to the table top.
                            DisplayedGem dGem = gemCutter.getTableTop().createDisplayedFunctionalAgentGem(new Point(), gemEntity);
                            Point location = tableTop.findAvailableDisplayedGemLocation(dGem);
                            tableTop.doAddGemUserAction(dGem, location);

                            intellicutManager.attemptIntellicutAutoConnect(dGem);
                            intellicutManager.stopIntellicut();

                            // Set the proper undo name.
                            tableTop.getUndoableEditSupport().setEditName(GemCutterMessages.getString("UndoText_Add", dGem.getDisplayText()));                       
                            tableTop.getUndoableEditSupport().endUpdate();
                        }
                    }
                }

            } else {

                gemCutter.getTableTop().getUndoableEditSupport().beginUpdate();

                List<Object> triggeredObjects = evt.getTriggeredObjects();
               
                for (final Object triggeredObj : triggeredObjects) {
   
                    if (triggeredObj instanceof GemEntity) {
                       
                        GemEntity gemEntity = (GemEntity) triggeredObj;
                       
                        if (browserTreeModel.isVisibleGem(gemEntity)) {
                            DisplayedGem dGem = gemCutter.getTableTop().createDisplayedFunctionalAgentGem(new Point(), gemEntity);
                            gemCutter.getTableTop().doAddGemUserAction(dGem);
                        }
                           
                        // TODO: in future we may want to warn the user if they are trying to add an entity from a module
View Full Code Here

TOP

Related Classes of org.openquark.gems.client.browser.BrowserTreeModel

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.