Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.SourcePosition$CompareByPosition


            saveButton.setEnabled(false);
        }
       
        private void selectTargetAtCurrentPosition(SourceRange sourceRange) {
            Document doc = editorPane.getDocument();
            SourcePosition startPosition = sourceRange.getStartSourcePosition();
            SourcePosition endPosition = sourceRange.getEndSourcePosition();
           
            try {
               
                int len = doc.getLength();
                String text = doc.getText(0, len);
                int startIndex = startPosition.getPosition(text);
                int endIndex = endPosition.getPosition(text, startPosition, startIndex);

                editorPane.select(startIndex, endIndex);
               
            } catch (BadLocationException e1) {
                e1.printStackTrace();
View Full Code Here


                this.searchResult = searchResult;
            }
           
            @Override
            public String toString() {
                SourcePosition sourcePosition = searchResult.getSourcePosition();
                return GemCutterMessages.getString("SD_SearchResultTemplateLong", new Object[] {
                    sourcePosition.getSourceName(),
                    Integer.valueOf(sourcePosition.getLine()),
                    Integer.valueOf(sourcePosition.getColumn()),
                    searchResult.getName().toSourceText()
                });
            }
View Full Code Here

         * Sets the text and selection of the dialog based on a SourcePosition.
         * @param searchResultItem Specification of the hit to highlight
         */
        void setResult(SearchResultItem.Precise searchResultItem) {
           
            SourcePosition sourcePosition = searchResultItem.getSourcePosition();
           
            // Update text if necessary
            String sourceName = sourcePosition.getSourceName();
            if(currentSourcePosition == null || !currentSourcePosition.getSourceName().equals(sourceName)) {
           
                Reader sourceReader = perspective.getWorkspace().getSourceDefinition(ModuleName.make(sourceName)).getSourceReader(new Status("reading source for search hit display"));
                if (sourceReader == null) {
                    System.err.println("Could not read source definition for source: " + sourceName);
                    return;
                }
                sourceReader = new BufferedReader(sourceReader);
               
                try {
                    editorPane.read(sourceReader, null);
                } catch (IOException e) {
                    e.printStackTrace();
                    return;
                } finally {
                    try {
                        sourceReader.close();
                    } catch (IOException e) {
                    }
                }
            }
           
            currentSourcePosition = sourcePosition;
           
            selectTargetAtCurrentPosition(searchResultItem.getSourceRange());
           
            isEditable = isModuleWriteable();
            String modulePath = getModulePath();
           
            // Title depends on whether the module is readOnly
            if(isEditable) {
                setTitle(GemCutterMessages.getString("SD_SearchResultsTitle", sourcePosition.getSourceName(), modulePath));
            } else if (modulePath != null) {
                setTitle(GemCutterMessages.getString("SD_SearchResultsTitleReadOnly", sourcePosition.getSourceName(), modulePath));
            } else {
                setTitle(GemCutterMessages.getString("SD_SearchResultsTitleReadOnlyWithoutFile", sourcePosition.getSourceName()));
            }

            editorPane.setEditable(isEditable);
            saveButton.setEnabled(false);
        }
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.SourcePosition$CompareByPosition

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.