Examples of AdvancedCALEditor


Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

     */
    public void insertAutoCompleteString(int backtrackLength, String insertion) {

        try {
            // Remove text from editor
            AdvancedCALEditor editor = gemCodePanel.getCALEditorPane();
            int caretPosition = editor.getCaretPosition();
            CodeAnalyser.AnalysedIdentifier identifier = editor.getIdentifierAtPosition(caretPosition);
            editor.getDocument().remove(caretPosition - backtrackLength, backtrackLength);
            if ((identifier == null) || (insertion.indexOf('.') < 0)) {
                // Not a qualified (ie: ambiguous) insertion, or cannot locate identifier
                // Do regular insert
                editor.getDocument().insertString(caretPosition - backtrackLength, insertion, null);
                return;
            } else {
                // Qualified completion, and type of the identifier is known
                // So do a smart insert and update the qualification map
                SourceIdentifier.Category identifierCategory = identifier.getCategory();
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

                menu.addSeparator();
            }

            // Add module change items

            AdvancedCALEditor calEditor = gemCodePanel.getCALEditorPane();
            if (isCodeQualified) {

                if (locallyResolved) {
                    // We can switch local qualifications to arguments
                    if (isQualificationFormChangeAllowed(type)) {
                        JMenuItem toArgumentItem = new ToArgumentMenuItem(unqualifiedName, moduleName, false);
                        toArgumentItem.setToolTipText(GemCutter.getResourceString("CGE_To_Argument"));
                        menu.add(toArgumentItem);
                    }

                    // Or keep in the current form
                    {
                        JCheckBoxMenuItem newItem = new ModuleChangeMenuItem(unqualifiedName, moduleName, type, true);
                        newItem.setToolTipText(calEditor.getMetadataToolTipText(unqualifiedName, moduleName, type, perspective.getWorkingModuleTypeInfo()));
                        menu.add(newItem);
                    }

                } else {
                    // Cannot change form; just display grayed current form
                    JCheckBoxMenuItem newItem = new ModuleChangeMenuItem(unqualifiedName, moduleName, type, true);
                    newItem.setToolTipText(calEditor.getMetadataToolTipText(unqualifiedName, moduleName, type, perspective.getWorkingModuleTypeInfo()));
                    newItem.setEnabled(false);
                    menu.add(newItem);
                }

            } else {
                // If this is an unqualified symbol

                // Add to-argument change item
                if (isQualificationFormChangeAllowed(type)) {
                    JMenuItem toArgumentItem = new ToArgumentMenuItem(unqualifiedName, moduleName, false);
                    toArgumentItem.setToolTipText(GemCutter.getResourceString("CGE_To_Argument"));
                    menu.add(toArgumentItem);

                }

                // Add module change items
                List<ModuleName> candidateModules = CodeAnalyser.getModulesContainingIdentifier(unqualifiedName, type,
                                perspective.getWorkingModuleTypeInfo());
                for (final ModuleName newModule : candidateModules) {
                    JCheckBoxMenuItem newItem = new ModuleChangeMenuItem(
                            unqualifiedName, newModule, type, (newModule
                                    .equals(moduleName)));
                    newItem.setToolTipText(calEditor.getMetadataToolTipText(
                            unqualifiedName, newModule, type, perspective
                                    .getWorkingModuleTypeInfo()));
                    menu.add(newItem);
                }
            }
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

            List<ModuleName> candidateModules = CodeAnalyser
                    .getModulesContainingIdentifier(
                            unqualifiedName,
                            SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD,
                            perspective.getWorkingModuleTypeInfo());
            AdvancedCALEditor calEditor = gemCodePanel.getCALEditorPane();
            if (isCodeQualified && (candidateModules.size() > 0)) {
                // If code qualified, can only be switched to the current module
                ModuleName moduleName = perspective.getWorkingModuleName();
                if ((candidateModules.iterator().next()).equals(moduleName)) {
                    JMenuItem newItem = new ToQualificationMenuItem(
                            unqualifiedName,
                            moduleName,
                            SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD,
                            true);

                    if (!changeAllowed) {
                        newItem.setToolTipText(GemCutter.getResourceString("CGE_Cannot_Transform_Argument"));
                        newItem.setEnabled(false);
                    } else {
                        newItem.setToolTipText(calEditor.getMetadataToolTipText(unqualifiedName, moduleName, SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD,
                                perspective.getWorkingModuleTypeInfo()));
                    }
                    menu.add(newItem);
                }

            } else {
                // Can be switched to any module
                for (final ModuleName moduleName : candidateModules) {
                    JMenuItem newItem = new ToQualificationMenuItem(unqualifiedName, moduleName, SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD, true);

                    if (!changeAllowed) {
                        newItem.setToolTipText(GemCutter.getResourceString("CGE_Cannot_Transform_Argument"));
                        newItem.setEnabled(false);
                    } else {
                        newItem.setToolTipText(calEditor.getMetadataToolTipText(unqualifiedName, moduleName, SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD,
                                perspective.getWorkingModuleTypeInfo()));
                    }
                    menu.add(newItem);
                }
            }
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

                toArgumentItem.setToolTipText(GemCutter
                        .getResourceString("CGE_To_Argument"));
                menu.add(toArgumentItem);
            }

            AdvancedCALEditor calEditor = gemCodePanel.getCALEditorPane();
            List<ModuleName> candidateModules = CodeAnalyser
                    .getModulesContainingIdentifier(unqualifiedName, type,
                            perspective.getWorkingModuleTypeInfo());
            for (final ModuleName moduleName : candidateModules) {
                JMenuItem newItem = new ToQualificationMenuItem(
                        unqualifiedName, moduleName, type, false);
                newItem.setToolTipText(calEditor.getMetadataToolTipText(
                        unqualifiedName, moduleName, type, perspective
                                .getWorkingModuleTypeInfo()));
                menu.add(newItem);
            }
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

         *
         * @see javax.swing.TransferHandler#createTransferable(javax.swing.JComponent)
         */
        @Override
        protected Transferable createTransferable(JComponent c) {
            AdvancedCALEditor editor = (AdvancedCALEditor) c;
            String visibleText = editor.getSelectedText();
            if (visibleText == null) {
                return null;
            }

            // Qualify the selected portion of text
            String fullyQualifiedText = editor.getQualifiedCodeText(editor.getSelectionStart(), editor.getSelectionEnd(), codeAnalyser);

            // Run through the selected identifiers, and build up a map of the
            // used qualifications and arguments.
            Set<String> argumentNames = new LinkedHashSet<String>();
            CodeQualificationMap qualificationMap = new CodeQualificationMap();
            List<AnalysedIdentifier> selectedIdentifiers = editor.getSelectedIdentifiers(editor.getSelectionStart(), editor.getSelectionEnd());
            for (final CodeAnalyser.AnalysedIdentifier identifier : selectedIdentifiers) {

                if (identifier.getQualificationType() == QualificationType.UnqualifiedResolvedTopLevelSymbol) {
                    qualificationMap.putQualification(identifier.getName(), identifier.getResolvedModuleName(), identifier.getCategory());

                } else if ((varNamesWhichAreArgs != null)
                        && (identifier.getQualificationType() == QualificationType.UnqualifiedArgument)
                        && (varNamesWhichAreArgs.contains(identifier.getName()))) {
                    argumentNames.add(identifier.getName());
                }
            }

            return new CodeTextTransferable(visibleText, fullyQualifiedText, qualificationMap, argumentNames, editor, editor.getSelectionStart(), editor.getSelectionEnd());
        }
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

                }
            }

            // Insert the text into the editor

            AdvancedCALEditor editor = (AdvancedCALEditor)c;
            if (userQualifiedIdentifiers != null) {
                editor.replaceSelection(codeTextStructure.getVisibleCode());
            } else {
                editor.replaceSelection(codeTextStructure.getFullyQualifiedCode());
            }

            return true;
        }
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

         *      java.awt.datatransfer.Transferable)
         */
        private boolean importGemEntity(JComponent c, Transferable t) throws UnsupportedFlavorException, IOException {
            GemEntity entity = (GemEntity)t.getTransferData(SingleGemEntityDataFlavor.getSingleGemEntityDataFlavor());

            AdvancedCALEditor editor = (AdvancedCALEditor)c;
            editor.getInputContext().endComposition();
            // TODO: If Gem Entities ever contain more than functional agents,
            // category needs to be updated
            SourceIdentifier.Category category = (entity.isDataConstructor()
                    ? SourceIdentifier.Category.DATA_CONSTRUCTOR
                    : SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD);
            editor.replaceSelection(" ");
            insertEditorQualification(editor, entity.getName(), category, userQualifiedIdentifiers, false);
            return true;

        }
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

             * @return boolean true if the click was a double click
             */
            @Override
            public boolean mouseReallyClicked(MouseEvent e){

                AdvancedCALEditor editor = EditorScrollPane.this.getEditor();
               
                boolean doubleClicked = super.mouseReallyClicked(e);
               
                for (final AmbiguityOffset offset : getEditor().getAmbiguityOffsets()) {

                    int y = offset.getLineNumber() * lineHeight + lineOffset;
                    Rectangle iconRect = new Rectangle(2, y+2, ambiguityIcon.getIconWidth()+2, ambiguityIcon.getIconHeight()+2);
                   
                    if (iconRect.contains(e.getPoint())) {
                        // Select ambiguity
                        editor.select(offset.getStartOffset(), offset.getEndOffset());
                       
                        // Display menu at ambiguity location
                       
                        AdvancedCALEditor.IdentifierPopupMenuProvider popupProvider = editor.getPopupMenuProvider();
                        if (popupProvider == null) {
                            break;
                        }
                       
                        Point menuPoint;
                        try {
                            Rectangle offsetRect = editor.getUI().modelToView(editor, offset.getStartOffset());
                            menuPoint = new Point(offsetRect.x, offsetRect.y + offsetRect.height);
                        } catch (BadLocationException ex) {
                            throw new IllegalStateException("bad location displaying ambiguity popup");
                        }
                       
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

        Perspective perspective = owner.getPerspective();
        this.moduleTypeInfo = perspective.getWorkingModuleTypeInfo();
       
        // Create and initialize components
       
        this.calEditor = new AdvancedCALEditor(moduleTypeInfo, perspective.getWorkspace());
        this.codeSyntaxListener = new GemCodeSyntaxListener(perspective);
        try {
            this.calEditor.addCALSyntaxStyleListener(codeSyntaxListener);
        } catch (TooManyListenersException e) {
            // The only effect this has on the editor is that custom text coloring does not work;
View Full Code Here

Examples of org.openquark.gems.client.caleditor.AdvancedCALEditor

     */
    public void insertAutoCompleteString(int backtrackLength, String insertion) {
       
        try {
            // Remove text from editor
            AdvancedCALEditor editor = getCALEditor();
            int caretPosition = editor.getCaretPosition();
            CodeAnalyser.AnalysedIdentifier identifier = editor.getIdentifierAtPosition(caretPosition);
            editor.getDocument().remove (caretPosition - backtrackLength, backtrackLength);
            if ((identifier == null) || (insertion.indexOf('.') < 0)) {
                // Not a qualified (ie: ambiguous) insetion, or cannot locate identifier
                // Do regular insert
                editor.getDocument().insertString(caretPosition - backtrackLength, insertion, null);
                return;
            } else {
                // Qualified completion, and type of the identifier is known
                // So do a smart insert and update the qualification map
                SourceIdentifier.Category identifierCategory = identifier.getCategory();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.