Package org.openquark.cal.services

Examples of org.openquark.cal.services.GemEntity


                    recompileWorkspace(true);
                   
                    if (lastGemName != null) {
                       
                        // Select the last gem that was saved in the GemBrowser.
                        GemEntity newEntity = perspective.resolveGemEntity(lastGemName);
                       
                        if (newEntity != null) {
                           
                            // The entity may be null if the recompile failed
                            // or the generated source contained some sort of error.
View Full Code Here


        Status saveStatus = persistenceManager.saveGem(targetCollector, saveDialog.getScope());
       
        if (saveStatus.getSeverity() != Status.Severity.ERROR) {
            // Get the entity for the newly saved gem.
            GemEntity newGemEntity = getWorkspace().getGemEntity(gemName);
           
            BrowserTree browserTree = getGemBrowser().getBrowserTree();
            //BrowserTreeModel browserTreeModel = (BrowserTreeModel) browserTree.getModel();
           
            // Select the newly saved gem in the gem browser.
View Full Code Here

       
        if (method == NavAddress.FUNCTION_METHOD ||
            method == NavAddress.CLASS_METHOD_METHOD ||
            method == NavAddress.DATA_CONSTRUCTOR_METHOD) {

            GemEntity entity = owner.getPerspective().getWorkspace().getGemEntity(address.toFeatureName().toQualifiedName());
           
            if (entity == null) {
                return false;
            }
           
            return isMetadataValid(entity, (FunctionalAgentMetadata) metadata);
           
        } else if (method == NavAddress.INSTANCE_METHOD_METHOD) {

            CALFeatureName featureName = address.toFeatureName();
            QualifiedName typeClassName = featureName.toInstanceIdentifier().getTypeClassName();
            String methodName = featureName.toInstanceMethodName();
            QualifiedName classMethodName = QualifiedName.make(typeClassName.getModuleName(), methodName);
           
            GemEntity entity = owner.getPerspective().getWorkspace().getGemEntity(classMethodName);
           
            if (entity == null) {
                return false;
            }
           
View Full Code Here

       
        if (method == NavAddress.CLASS_METHOD_METHOD ||
            method == NavAddress.FUNCTION_METHOD ||
            method == NavAddress.DATA_CONSTRUCTOR_METHOD) {

            GemEntity entity = owner.getPerspective().getWorkspace().getGemEntity(address.toFeatureName().toQualifiedName());
            TypeExpr[] typePieces = entity.getTypeExpr().getTypePieces();
            String[] typeStrings = new String[typePieces.length];           
            PolymorphicVarContext polymorphicVarContext = PolymorphicVarContext.make();
           
            for (int i = 0; i < typePieces.length; i++) {
                typeStrings[i] = typePieces[i].toString(polymorphicVarContext, namingPolicy);
View Full Code Here

            CALFeatureName featureName = address.toFeatureName();
            ModuleName typeClassModuleName = featureName.toInstanceIdentifier().getTypeClassName().getModuleName();
            String methodName = featureName.toInstanceMethodName();
           
            CALWorkspace workspace = owner.getPerspective().getWorkspace();
            GemEntity entity = workspace.getGemEntity(QualifiedName.make(typeClassModuleName, methodName));
            ClassInstance instance = workspace.getClassInstance(CALFeatureName.getClassInstanceFeatureName(featureName.toInstanceIdentifier(), featureName.toModuleName()));
           
            adjustArgumentNames(entity, instance.getMethodCALDocComment(methodName), arguments);
           
        } else {
            GemEntity entity = owner.getPerspective().getWorkspace().getGemEntity(address.toFeatureName().toQualifiedName());
            adjustArgumentNames(entity, arguments);
        }
    }
View Full Code Here

        if (collectors.iterator().hasNext()) {
            CollectorGem collectorGem = collectors.iterator().next();
       
            // Find the gem in the working module with the same name
            GemEntity entity = gemCutter.getWorkspace().getGemEntity(designName);

            if (entity != null) {
                // Load the metadata for the gem and copy it to the collector
                FunctionMetadata gemMetadata = (FunctionMetadata)entity.getMetadata(GemCutter.getLocaleFromPreferences());
                collectorGem.setDesignMetadata(gemMetadata);
            } else {
                // Clear the metadata for the collector, since there is no gem entity for the design
                collectorGem.clearDesignMetadata();
            }
View Full Code Here

            // simply accept the colour we're given           
            return suggestedColour;
        }
   
        // Modify the colour of identifiers depending on what they actually are
        GemEntity entity = null;
       
        int periodPos = image.indexOf('.');
        if (periodPos == -1) {
            // This is an unqualified name.
           
            if (Arrays.binarySearch(argumentNames, image) > -1) {
                // This is an argument
                return ARGUMENT_COLOUR;
            }
           
            // See if this is a known type or class
           
            entity = perspective.resolveAmbiguousGemEntity(image);
            if (entity == null) {
                // Unqualified name is not a visible supercombinator or class method
                // Check if it is a type constructor, type class or local variable
            
                if (CodeAnalyser.getModulesContainingIdentifier(image, SourceIdentifier.Category.TYPE_CONSTRUCTOR, perspective.getWorkingModuleTypeInfo()).size() > 0) {
                    // This is a type constructor, found in a module
                    return USER_TYPE_COLOUR;
                } else if (CodeAnalyser.getModulesContainingIdentifier(image, SourceIdentifier.Category.TYPE_CLASS, perspective.getWorkingModuleTypeInfo()).size() > 0) {
                    // This is a class, found in a module
                    return USER_CLASS_COLOUR;
                } else if (Arrays.binarySearch(localVariableNames, image) > -1) {
                    // This is a local variable
                    return LOCAL_VARIABLE_COLOUR;
                }
            }

        } else if (QualifiedName.isValidCompoundName(image)) {
            QualifiedName rawImageName = QualifiedName.makeFromCompoundName(image);
            ModuleName resolvedModuleName = perspective.getWorkingModuleTypeInfo().getModuleNameResolver().resolve(rawImageName.getModuleName()).getResolvedModuleName();
            QualifiedName imageName = QualifiedName.make(resolvedModuleName, rawImageName.getUnqualifiedName());
           
            if (imageName.getModuleName().equals(perspective.getWorkingModuleName()) &&
                (Arrays.binarySearch(argumentNames, image) > -1)) {
                // This is an argument
                return ARGUMENT_COLOUR;
            }
           
            entity = perspective.getVisibleGemEntity(imageName);
            if (entity == null) {
                // Qualified name is not a visible supercombinator or class method
                // Check if it is a type constructor, type class, or local variable
               
                if (CodeAnalyser.getVisibleModuleEntity(imageName, SourceIdentifier.Category.TYPE_CONSTRUCTOR, perspective.getWorkingModuleTypeInfo()) != null) {
                    return USER_TYPE_COLOUR;
                   
                } else if (CodeAnalyser.getVisibleModuleEntity(imageName, SourceIdentifier.Category.TYPE_CLASS, perspective.getWorkingModuleTypeInfo()) != null) {
                    return USER_CLASS_COLOUR;
                   
                } else if (imageName.getModuleName().equals(perspective.getWorkingModuleName()) &&
                           (Arrays.binarySearch(localVariableNames, image) > -1)) {
                    return LOCAL_VARIABLE_COLOUR;
                }
            }
        }
   
        if (entity == null) {
            return suggestedColour;
        }
       
        // We have this in our environment; we should know what it is
   
        boolean cons = entity.isDataConstructor();
        //check if constructor
        if (cons) {
            // It's a constructor
            //System.out.println ("Coloured user defined constructor.");           
            return USER_CONS_COLOUR;
View Full Code Here

     * Creates a FunctionalAgentGem for the specified function, or null if the function is not found.
     * @param functionalAgentName
     * @return FunctionalAgentGem
     */
    public FunctionalAgentGem makeFunctionalAgentGem(QualifiedName functionalAgentName) {
        GemEntity gemEntity = calServices.getGemEntity(functionalAgentName);
        if (gemEntity == null)
            return null;
   
        return new FunctionalAgentGem (gemEntity);
    }
View Full Code Here

                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();
View Full Code Here

                   
            } else if (selectedNode instanceof GemTreeNode) {
                // The node represents a gem.
                // Add a 'Load Design...' menu item to load the gem design.
           
                GemEntity gemEntity = (GemEntity) selectedNode.getUserObject();
                popupMenu.add(GemCutter.makeNewMenuItem(getOpenDesignAction(gemEntity)));
                popupMenu.add(GemCutter.makeNewMenuItem(getRenameGemAction(gemEntity)));
                popupMenu.add(GemCutter.makeNewMenuItem(getSearchForGemAction(gemEntity)));
                popupMenu.add(GemCutter.makeNewMenuItem(getSearchForGemDefinitionAction(gemEntity)));
            }
View Full Code Here

TOP

Related Classes of org.openquark.cal.services.GemEntity

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.