Extend GroovyEditor -> support none-file resources

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Extend GroovyEditor -> support none-file resources

Edvin Syse
Hi,

I've extended GroovyEditor and uses it to edit groovy-scripts stored in
a database. Hence, I use a custom DocumentProvider and the EditorInput
does not extend IFileEditorInput. I suspect that for this reason I don't
get syntax highlight and code assist.

Can someone point towards a workaround for this? It's really a pain
having to support IFileEditorInput when I don't need it :)

Sincerely,
Edvin Syse



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Andrew Eisenberg
I don't think that would be the problem.  It could be any number of
reasons.  Is the GroovyConfiguration class being instantiated in the
"createJavaSourceViewerConfiguration()" method?

Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
this class being instantiated?  What highlighting rules are being sent
to it?

On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse <[hidden email]> wrote:

> Hi,
>
> I've extended GroovyEditor and uses it to edit groovy-scripts stored in a
> database. Hence, I use a custom DocumentProvider and the EditorInput does
> not extend IFileEditorInput. I suspect that for this reason I don't get
> syntax highlight and code assist.
>
> Can someone point towards a workaround for this? It's really a pain having
> to support IFileEditorInput when I don't need it :)
>
> Sincerely,
> Edvin Syse
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Edvin Syse
Thanks for your reply.

Yes, createJavaSourceViewerConfiguration is not overriden, so a
GroovyConfiguration object is returned from the implementation in
GroovyEditor.

The GroovyTagScanner is also instantiated. There are no additionalRules,
additionalGroovyKeywords or additionalGJDKKeywords sent to it, but the
IColorManager contains:

[groovy.editor.highlight.javatypes.color=RGB {0, 0, 0}, java_keyword=RGB
{127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63, 127,
95}, java_multi_line_comment=RGB {63, 127, 95},
groovy.editor.highlight.strings.color=RGB {0, 0, 0},
groovy.editor.groovyDoc.link.color=RGB {0, 0, 0}, java_operator=RGB {0,
0, 0}, java_keyword_return=RGB {127, 0, 85},
groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
groovy.editor.highlight.gjdk.color=RGB {0, 0, 0}, java_doc_default=RGB
{63, 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
semanticHighlighting.annotation.color=RGB {100, 100, 100},
java_doc_tag=RGB {127, 127, 159},
groovy.editor.groovyDoc.keyword.color=RGB {0, 0, 0},
groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0},
java_string=RGB {42, 0, 255}, java_default=RGB {0, 0, 0},
groovy.editor.highlight.default.color=RGB {0, 0, 0}]

Here is my complete implementation:

public class GlobalControllerEditor extends GroovyEditor {

     public GlobalControllerEditor() {
         super();
         setDocumentProvider(new GlobalControllerDocumentProvider());
     }

     public JavaSourceViewerConfiguration
createJavaSourceViewerConfiguration() {
         return super.createJavaSourceViewerConfiguration();
     }

     protected IVerticalRulerColumn createLineNumberRulerColumn() {
         fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
         ((IChangeRulerColumn)
fLineNumberRulerColumn).setHover(createChangeHover());
         initializeLineNumberRulerColumn(fLineNumberRulerColumn);
         return fLineNumberRulerColumn;
     }

     protected IVerticalRuler createVerticalRuler() {
         return new VerticalRuler(50);
     }

     public void init(IEditorSite site, IEditorInput input) throws
PartInitException {
         super.init(site, input);
         setPartName("Global kontroller");
     }

     public void doSave(IProgressMonitor progressMonitor) {
         super.doSave(progressMonitor);
         TornadoEditorInput input = (TornadoEditorInput) getEditorInput();
         
BeanLocator.getCmsService().updateController((String)input.getModelObject());
     }
}


I had to override createLineNumerRulerColumn and createVerticalRuler to
avoid some NPE's. I can send the stacktraces without these if it would help.

The GlobalControllerDocumentProvider basically extends
FileDocumentProvider and implements createDocument and doSaveDocument,
nothing special there.

Sincerely,
Edvin Syse

Den 23.03.10 15:05, skrev Andrew Eisenberg:

> I don't think that would be the problem.  It could be any number of
> reasons.  Is the GroovyConfiguration class being instantiated in the
> "createJavaSourceViewerConfiguration()" method?
>
> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
> this class being instantiated?  What highlighting rules are being sent
> to it?
>
> On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse<[hidden email]>  wrote:
>    
>> Hi,
>>
>> I've extended GroovyEditor and uses it to edit groovy-scripts stored in a
>> database. Hence, I use a custom DocumentProvider and the EditorInput does
>> not extend IFileEditorInput. I suspect that for this reason I don't get
>> syntax highlight and code assist.
>>
>> Can someone point towards a workaround for this? It's really a pain having
>> to support IFileEditorInput when I don't need it :)
>>
>> Sincerely,
>> Edvin Syse
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>    

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Andrew Eisenberg
It's possible that the content type of the document that you are
creating is not groovySource.  This means that your document is not
being partitiioned properly and so none of the groovy syntax
highlighting will apply. (But not sure exactly how to do this in your
situation.)

Also, I think that you should be using a
org.eclipse.ui.editors.documentProviders extension point instead of
explicitly setting the document provider for your editor.

On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse <[hidden email]> wrote:

> Thanks for your reply.
>
> Yes, createJavaSourceViewerConfiguration is not overriden, so a
> GroovyConfiguration object is returned from the implementation in
> GroovyEditor.
>
> The GroovyTagScanner is also instantiated. There are no additionalRules,
> additionalGroovyKeywords or additionalGJDKKeywords sent to it, but the
> IColorManager contains:
>
> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0}, java_keyword=RGB
> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63, 127, 95},
> java_multi_line_comment=RGB {63, 127, 95},
> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0}, java_operator=RGB {0, 0,
> 0}, java_keyword_return=RGB {127, 0, 85},
> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0}, java_doc_default=RGB {63,
> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
> semanticHighlighting.annotation.color=RGB {100, 100, 100}, java_doc_tag=RGB
> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0, 0},
> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0}, java_string=RGB
> {42, 0, 255}, java_default=RGB {0, 0, 0},
> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>
> Here is my complete implementation:
>
> public class GlobalControllerEditor extends GroovyEditor {
>
>    public GlobalControllerEditor() {
>        super();
>        setDocumentProvider(new GlobalControllerDocumentProvider());
>    }
>
>    public JavaSourceViewerConfiguration
> createJavaSourceViewerConfiguration() {
>        return super.createJavaSourceViewerConfiguration();
>    }
>
>    protected IVerticalRulerColumn createLineNumberRulerColumn() {
>        fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>        ((IChangeRulerColumn)
> fLineNumberRulerColumn).setHover(createChangeHover());
>        initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>        return fLineNumberRulerColumn;
>    }
>
>    protected IVerticalRuler createVerticalRuler() {
>        return new VerticalRuler(50);
>    }
>
>    public void init(IEditorSite site, IEditorInput input) throws
> PartInitException {
>        super.init(site, input);
>        setPartName("Global kontroller");
>    }
>
>    public void doSave(IProgressMonitor progressMonitor) {
>        super.doSave(progressMonitor);
>        TornadoEditorInput input = (TornadoEditorInput) getEditorInput();
>
>  BeanLocator.getCmsService().updateController((String)input.getModelObject());
>    }
> }
>
>
> I had to override createLineNumerRulerColumn and createVerticalRuler to
> avoid some NPE's. I can send the stacktraces without these if it would help.
>
> The GlobalControllerDocumentProvider basically extends FileDocumentProvider
> and implements createDocument and doSaveDocument, nothing special there.
>
> Sincerely,
> Edvin Syse
>
> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>
>> I don't think that would be the problem.  It could be any number of
>> reasons.  Is the GroovyConfiguration class being instantiated in the
>> "createJavaSourceViewerConfiguration()" method?
>>
>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>> this class being instantiated?  What highlighting rules are being sent
>> to it?
>>
>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse<[hidden email]>  wrote:
>>
>>>
>>> Hi,
>>>
>>> I've extended GroovyEditor and uses it to edit groovy-scripts stored in a
>>> database. Hence, I use a custom DocumentProvider and the EditorInput does
>>> not extend IFileEditorInput. I suspect that for this reason I don't get
>>> syntax highlight and code assist.
>>>
>>> Can someone point towards a workaround for this? It's really a pain
>>> having
>>> to support IFileEditorInput when I don't need it :)
>>>
>>> Sincerely,
>>> Edvin Syse
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>   http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Edvin Syse
I think you are right. Thanks for the insight, I'll post back with a
solution when I find it :) I think I'll try to make my DocumentProvider
implement IGroovyDocumentProvider and make my db-document implement
ICompilationUnit.. Painful :)

Sincerely,
Edvin Syse

Den 23.03.10 16:47, skrev Andrew Eisenberg:

> It's possible that the content type of the document that you are
> creating is not groovySource.  This means that your document is not
> being partitiioned properly and so none of the groovy syntax
> highlighting will apply. (But not sure exactly how to do this in your
> situation.)
>
> Also, I think that you should be using a
> org.eclipse.ui.editors.documentProviders extension point instead of
> explicitly setting the document provider for your editor.
>
> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>  wrote:
>    
>> Thanks for your reply.
>>
>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>> GroovyConfiguration object is returned from the implementation in
>> GroovyEditor.
>>
>> The GroovyTagScanner is also instantiated. There are no additionalRules,
>> additionalGroovyKeywords or additionalGJDKKeywords sent to it, but the
>> IColorManager contains:
>>
>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0}, java_keyword=RGB
>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63, 127, 95},
>> java_multi_line_comment=RGB {63, 127, 95},
>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0}, java_operator=RGB {0, 0,
>> 0}, java_keyword_return=RGB {127, 0, 85},
>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0}, java_doc_default=RGB {63,
>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>> semanticHighlighting.annotation.color=RGB {100, 100, 100}, java_doc_tag=RGB
>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0, 0},
>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0}, java_string=RGB
>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>
>> Here is my complete implementation:
>>
>> public class GlobalControllerEditor extends GroovyEditor {
>>
>>     public GlobalControllerEditor() {
>>         super();
>>         setDocumentProvider(new GlobalControllerDocumentProvider());
>>     }
>>
>>     public JavaSourceViewerConfiguration
>> createJavaSourceViewerConfiguration() {
>>         return super.createJavaSourceViewerConfiguration();
>>     }
>>
>>     protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>         fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>         ((IChangeRulerColumn)
>> fLineNumberRulerColumn).setHover(createChangeHover());
>>         initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>         return fLineNumberRulerColumn;
>>     }
>>
>>     protected IVerticalRuler createVerticalRuler() {
>>         return new VerticalRuler(50);
>>     }
>>
>>     public void init(IEditorSite site, IEditorInput input) throws
>> PartInitException {
>>         super.init(site, input);
>>         setPartName("Global kontroller");
>>     }
>>
>>     public void doSave(IProgressMonitor progressMonitor) {
>>         super.doSave(progressMonitor);
>>         TornadoEditorInput input = (TornadoEditorInput) getEditorInput();
>>
>>   BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>     }
>> }
>>
>>
>> I had to override createLineNumerRulerColumn and createVerticalRuler to
>> avoid some NPE's. I can send the stacktraces without these if it would help.
>>
>> The GlobalControllerDocumentProvider basically extends FileDocumentProvider
>> and implements createDocument and doSaveDocument, nothing special there.
>>
>> Sincerely,
>> Edvin Syse
>>
>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>      
>>> I don't think that would be the problem.  It could be any number of
>>> reasons.  Is the GroovyConfiguration class being instantiated in the
>>> "createJavaSourceViewerConfiguration()" method?
>>>
>>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>>> this class being instantiated?  What highlighting rules are being sent
>>> to it?
>>>
>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse<[hidden email]>    wrote:
>>>
>>>        
>>>> Hi,
>>>>
>>>> I've extended GroovyEditor and uses it to edit groovy-scripts stored in a
>>>> database. Hence, I use a custom DocumentProvider and the EditorInput does
>>>> not extend IFileEditorInput. I suspect that for this reason I don't get
>>>> syntax highlight and code assist.
>>>>
>>>> Can someone point towards a workaround for this? It's really a pain
>>>> having
>>>> to support IFileEditorInput when I don't need it :)
>>>>
>>>> Sincerely,
>>>> Edvin Syse
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>>          
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>      http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>>        
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>    

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Andrew Eisenberg
Careful there!  IGroovyDocumentProvider is not used for the editor.
It is a legacy class used for refactoring and will likely be removed
once I start reworking refactoring support in Groovy-Eclipse.

As for your db-document implementing ICompilationUnit, that will open
up a world of complications if this is really necessary.
GroovyCompilationUnit objects are only instantiated from within the
groovy-jdt integration plugin.  So, if you need to subclass GCU, it
will never be instantiated.

So, I can't say exactly what you need to do (partially because I don't
know what you are trying to do), but I think you are on the right
track if you take into account what I say above.

On Tue, Mar 23, 2010 at 9:09 AM, Edvin Syse <[hidden email]> wrote:

> I think you are right. Thanks for the insight, I'll post back with a
> solution when I find it :) I think I'll try to make my DocumentProvider
> implement IGroovyDocumentProvider and make my db-document implement
> ICompilationUnit.. Painful :)
>
> Sincerely,
> Edvin Syse
>
> Den 23.03.10 16:47, skrev Andrew Eisenberg:
>>
>> It's possible that the content type of the document that you are
>> creating is not groovySource.  This means that your document is not
>> being partitiioned properly and so none of the groovy syntax
>> highlighting will apply. (But not sure exactly how to do this in your
>> situation.)
>>
>> Also, I think that you should be using a
>> org.eclipse.ui.editors.documentProviders extension point instead of
>> explicitly setting the document provider for your editor.
>>
>> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>  wrote:
>>
>>>
>>> Thanks for your reply.
>>>
>>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>>> GroovyConfiguration object is returned from the implementation in
>>> GroovyEditor.
>>>
>>> The GroovyTagScanner is also instantiated. There are no additionalRules,
>>> additionalGroovyKeywords or additionalGJDKKeywords sent to it, but the
>>> IColorManager contains:
>>>
>>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0}, java_keyword=RGB
>>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63, 127,
>>> 95},
>>> java_multi_line_comment=RGB {63, 127, 95},
>>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0}, java_operator=RGB {0,
>>> 0,
>>> 0}, java_keyword_return=RGB {127, 0, 85},
>>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0}, java_doc_default=RGB
>>> {63,
>>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>>> semanticHighlighting.annotation.color=RGB {100, 100, 100},
>>> java_doc_tag=RGB
>>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0, 0},
>>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0}, java_string=RGB
>>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>>
>>> Here is my complete implementation:
>>>
>>> public class GlobalControllerEditor extends GroovyEditor {
>>>
>>>    public GlobalControllerEditor() {
>>>        super();
>>>        setDocumentProvider(new GlobalControllerDocumentProvider());
>>>    }
>>>
>>>    public JavaSourceViewerConfiguration
>>> createJavaSourceViewerConfiguration() {
>>>        return super.createJavaSourceViewerConfiguration();
>>>    }
>>>
>>>    protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>>        fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>>        ((IChangeRulerColumn)
>>> fLineNumberRulerColumn).setHover(createChangeHover());
>>>        initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>>        return fLineNumberRulerColumn;
>>>    }
>>>
>>>    protected IVerticalRuler createVerticalRuler() {
>>>        return new VerticalRuler(50);
>>>    }
>>>
>>>    public void init(IEditorSite site, IEditorInput input) throws
>>> PartInitException {
>>>        super.init(site, input);
>>>        setPartName("Global kontroller");
>>>    }
>>>
>>>    public void doSave(IProgressMonitor progressMonitor) {
>>>        super.doSave(progressMonitor);
>>>        TornadoEditorInput input = (TornadoEditorInput) getEditorInput();
>>>
>>>
>>>  BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>>    }
>>> }
>>>
>>>
>>> I had to override createLineNumerRulerColumn and createVerticalRuler to
>>> avoid some NPE's. I can send the stacktraces without these if it would
>>> help.
>>>
>>> The GlobalControllerDocumentProvider basically extends
>>> FileDocumentProvider
>>> and implements createDocument and doSaveDocument, nothing special there.
>>>
>>> Sincerely,
>>> Edvin Syse
>>>
>>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>>
>>>>
>>>> I don't think that would be the problem.  It could be any number of
>>>> reasons.  Is the GroovyConfiguration class being instantiated in the
>>>> "createJavaSourceViewerConfiguration()" method?
>>>>
>>>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>>>> this class being instantiated?  What highlighting rules are being sent
>>>> to it?
>>>>
>>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse<[hidden email]>    wrote:
>>>>
>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I've extended GroovyEditor and uses it to edit groovy-scripts stored in
>>>>> a
>>>>> database. Hence, I use a custom DocumentProvider and the EditorInput
>>>>> does
>>>>> not extend IFileEditorInput. I suspect that for this reason I don't get
>>>>> syntax highlight and code assist.
>>>>>
>>>>> Can someone point towards a workaround for this? It's really a pain
>>>>> having
>>>>> to support IFileEditorInput when I don't need it :)
>>>>>
>>>>> Sincerely,
>>>>> Edvin Syse
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>   http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>   http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Edvin Syse
Maybe I need to rethink this. To simplify my usecase:

I have a String containing a Groovy script, and I want to edit it with
the GroovyEditor. The string comees form a database, and should be saved
back to the database when changed.

Maybe I should create a normal workspace file, put the content of the
string into that and open it with the GroovyEditor programatically. Then
I would need to intercept save/change to the file somehow, so that I can
update the database with the new content.

What do you think of that approach?

Den 23.03.10 18:41, skrev Andrew Eisenberg:

> Careful there!  IGroovyDocumentProvider is not used for the editor.
> It is a legacy class used for refactoring and will likely be removed
> once I start reworking refactoring support in Groovy-Eclipse.
>
> As for your db-document implementing ICompilationUnit, that will open
> up a world of complications if this is really necessary.
> GroovyCompilationUnit objects are only instantiated from within the
> groovy-jdt integration plugin.  So, if you need to subclass GCU, it
> will never be instantiated.
>
> So, I can't say exactly what you need to do (partially because I don't
> know what you are trying to do), but I think you are on the right
> track if you take into account what I say above.
>
> On Tue, Mar 23, 2010 at 9:09 AM, Edvin Syse<[hidden email]>  wrote:
>    
>> I think you are right. Thanks for the insight, I'll post back with a
>> solution when I find it :) I think I'll try to make my DocumentProvider
>> implement IGroovyDocumentProvider and make my db-document implement
>> ICompilationUnit.. Painful :)
>>
>> Sincerely,
>> Edvin Syse
>>
>> Den 23.03.10 16:47, skrev Andrew Eisenberg:
>>      
>>> It's possible that the content type of the document that you are
>>> creating is not groovySource.  This means that your document is not
>>> being partitiioned properly and so none of the groovy syntax
>>> highlighting will apply. (But not sure exactly how to do this in your
>>> situation.)
>>>
>>> Also, I think that you should be using a
>>> org.eclipse.ui.editors.documentProviders extension point instead of
>>> explicitly setting the document provider for your editor.
>>>
>>> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>    wrote:
>>>
>>>        
>>>> Thanks for your reply.
>>>>
>>>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>>>> GroovyConfiguration object is returned from the implementation in
>>>> GroovyEditor.
>>>>
>>>> The GroovyTagScanner is also instantiated. There are no additionalRules,
>>>> additionalGroovyKeywords or additionalGJDKKeywords sent to it, but the
>>>> IColorManager contains:
>>>>
>>>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0}, java_keyword=RGB
>>>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>>>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>>>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63, 127,
>>>> 95},
>>>> java_multi_line_comment=RGB {63, 127, 95},
>>>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>>>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0}, java_operator=RGB {0,
>>>> 0,
>>>> 0}, java_keyword_return=RGB {127, 0, 85},
>>>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>>>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>>>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0}, java_doc_default=RGB
>>>> {63,
>>>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>>>> semanticHighlighting.annotation.color=RGB {100, 100, 100},
>>>> java_doc_tag=RGB
>>>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0, 0},
>>>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0}, java_string=RGB
>>>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>>>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>>>
>>>> Here is my complete implementation:
>>>>
>>>> public class GlobalControllerEditor extends GroovyEditor {
>>>>
>>>>     public GlobalControllerEditor() {
>>>>         super();
>>>>         setDocumentProvider(new GlobalControllerDocumentProvider());
>>>>     }
>>>>
>>>>     public JavaSourceViewerConfiguration
>>>> createJavaSourceViewerConfiguration() {
>>>>         return super.createJavaSourceViewerConfiguration();
>>>>     }
>>>>
>>>>     protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>>>         fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>>>         ((IChangeRulerColumn)
>>>> fLineNumberRulerColumn).setHover(createChangeHover());
>>>>         initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>>>         return fLineNumberRulerColumn;
>>>>     }
>>>>
>>>>     protected IVerticalRuler createVerticalRuler() {
>>>>         return new VerticalRuler(50);
>>>>     }
>>>>
>>>>     public void init(IEditorSite site, IEditorInput input) throws
>>>> PartInitException {
>>>>         super.init(site, input);
>>>>         setPartName("Global kontroller");
>>>>     }
>>>>
>>>>     public void doSave(IProgressMonitor progressMonitor) {
>>>>         super.doSave(progressMonitor);
>>>>         TornadoEditorInput input = (TornadoEditorInput) getEditorInput();
>>>>
>>>>
>>>>   BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>>>     }
>>>> }
>>>>
>>>>
>>>> I had to override createLineNumerRulerColumn and createVerticalRuler to
>>>> avoid some NPE's. I can send the stacktraces without these if it would
>>>> help.
>>>>
>>>> The GlobalControllerDocumentProvider basically extends
>>>> FileDocumentProvider
>>>> and implements createDocument and doSaveDocument, nothing special there.
>>>>
>>>> Sincerely,
>>>> Edvin Syse
>>>>
>>>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>>>
>>>>          
>>>>> I don't think that would be the problem.  It could be any number of
>>>>> reasons.  Is the GroovyConfiguration class being instantiated in the
>>>>> "createJavaSourceViewerConfiguration()" method?
>>>>>
>>>>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>>>>> this class being instantiated?  What highlighting rules are being sent
>>>>> to it?
>>>>>
>>>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse<[hidden email]>      wrote:
>>>>>
>>>>>
>>>>>            
>>>>>> Hi,
>>>>>>
>>>>>> I've extended GroovyEditor and uses it to edit groovy-scripts stored in
>>>>>> a
>>>>>> database. Hence, I use a custom DocumentProvider and the EditorInput
>>>>>> does
>>>>>> not extend IFileEditorInput. I suspect that for this reason I don't get
>>>>>> syntax highlight and code assist.
>>>>>>
>>>>>> Can someone point towards a workaround for this? It's really a pain
>>>>>> having
>>>>>> to support IFileEditorInput when I don't need it :)
>>>>>>
>>>>>> Sincerely,
>>>>>> Edvin Syse
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>              
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>      http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>            
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>>>          
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>      http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>>        
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>    

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Edvin Syse
I had some luck with this rudimentary approach:

             IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject("groovy");
             if (!project.exists()) {
                 project.create(monitor);
                 project.open(monitor);
                 ProjectDescription pdesc = new ProjectDescription();
                 pdesc.setNatureIds(new String[] {
"org.eclipse.jdt.groovy.core.groovyNature" } );
                 project.setDescription(pdesc, monitor);
             }

             if (!project.isOpen())
                 project.open(monitor);

             IFile controllerFile =
project.getFile("GlobalController.groovy");
             String content = "some groovy content here";
             ByteArrayInputStream in = new
ByteArrayInputStream(content.getBytes());
             controllerFile.create(in, true, monitor);

             IEditorInput editorInput = new FileEditorInput(controllerFile);
             UIUtils.openEditor(event, editorInput, GroovyEditor.EDITOR_ID);

This opens the editor with the file content, and syntaxhl works good,
but content assist does not. Also I dont have a way to monitor the save
operation of the editor, but that's probably no biggie :)



Den 23.03.10 20:25, skrev Edvin Syse:

> Maybe I need to rethink this. To simplify my usecase:
>
> I have a String containing a Groovy script, and I want to edit it with
> the GroovyEditor. The string comees form a database, and should be
> saved back to the database when changed.
>
> Maybe I should create a normal workspace file, put the content of the
> string into that and open it with the GroovyEditor programatically.
> Then I would need to intercept save/change to the file somehow, so
> that I can update the database with the new content.
>
> What do you think of that approach?
>
> Den 23.03.10 18:41, skrev Andrew Eisenberg:
>> Careful there!  IGroovyDocumentProvider is not used for the editor.
>> It is a legacy class used for refactoring and will likely be removed
>> once I start reworking refactoring support in Groovy-Eclipse.
>>
>> As for your db-document implementing ICompilationUnit, that will open
>> up a world of complications if this is really necessary.
>> GroovyCompilationUnit objects are only instantiated from within the
>> groovy-jdt integration plugin.  So, if you need to subclass GCU, it
>> will never be instantiated.
>>
>> So, I can't say exactly what you need to do (partially because I don't
>> know what you are trying to do), but I think you are on the right
>> track if you take into account what I say above.
>>
>> On Tue, Mar 23, 2010 at 9:09 AM, Edvin Syse<[hidden email]>  wrote:
>>> I think you are right. Thanks for the insight, I'll post back with a
>>> solution when I find it :) I think I'll try to make my DocumentProvider
>>> implement IGroovyDocumentProvider and make my db-document implement
>>> ICompilationUnit.. Painful :)
>>>
>>> Sincerely,
>>> Edvin Syse
>>>
>>> Den 23.03.10 16:47, skrev Andrew Eisenberg:
>>>> It's possible that the content type of the document that you are
>>>> creating is not groovySource.  This means that your document is not
>>>> being partitiioned properly and so none of the groovy syntax
>>>> highlighting will apply. (But not sure exactly how to do this in your
>>>> situation.)
>>>>
>>>> Also, I think that you should be using a
>>>> org.eclipse.ui.editors.documentProviders extension point instead of
>>>> explicitly setting the document provider for your editor.
>>>>
>>>> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>    
>>>> wrote:
>>>>
>>>>> Thanks for your reply.
>>>>>
>>>>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>>>>> GroovyConfiguration object is returned from the implementation in
>>>>> GroovyEditor.
>>>>>
>>>>> The GroovyTagScanner is also instantiated. There are no
>>>>> additionalRules,
>>>>> additionalGroovyKeywords or additionalGJDKKeywords sent to it, but
>>>>> the
>>>>> IColorManager contains:
>>>>>
>>>>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0},
>>>>> java_keyword=RGB
>>>>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>>>>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>>>>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63,
>>>>> 127,
>>>>> 95},
>>>>> java_multi_line_comment=RGB {63, 127, 95},
>>>>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>>>>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0},
>>>>> java_operator=RGB {0,
>>>>> 0,
>>>>> 0}, java_keyword_return=RGB {127, 0, 85},
>>>>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>>>>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>>>>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0},
>>>>> java_doc_default=RGB
>>>>> {63,
>>>>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>>>>> semanticHighlighting.annotation.color=RGB {100, 100, 100},
>>>>> java_doc_tag=RGB
>>>>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0, 0},
>>>>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0},
>>>>> java_string=RGB
>>>>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>>>>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>>>>
>>>>> Here is my complete implementation:
>>>>>
>>>>> public class GlobalControllerEditor extends GroovyEditor {
>>>>>
>>>>>     public GlobalControllerEditor() {
>>>>>         super();
>>>>>         setDocumentProvider(new GlobalControllerDocumentProvider());
>>>>>     }
>>>>>
>>>>>     public JavaSourceViewerConfiguration
>>>>> createJavaSourceViewerConfiguration() {
>>>>>         return super.createJavaSourceViewerConfiguration();
>>>>>     }
>>>>>
>>>>>     protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>>>>         fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>>>>         ((IChangeRulerColumn)
>>>>> fLineNumberRulerColumn).setHover(createChangeHover());
>>>>>         initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>>>>         return fLineNumberRulerColumn;
>>>>>     }
>>>>>
>>>>>     protected IVerticalRuler createVerticalRuler() {
>>>>>         return new VerticalRuler(50);
>>>>>     }
>>>>>
>>>>>     public void init(IEditorSite site, IEditorInput input) throws
>>>>> PartInitException {
>>>>>         super.init(site, input);
>>>>>         setPartName("Global kontroller");
>>>>>     }
>>>>>
>>>>>     public void doSave(IProgressMonitor progressMonitor) {
>>>>>         super.doSave(progressMonitor);
>>>>>         TornadoEditorInput input = (TornadoEditorInput)
>>>>> getEditorInput();
>>>>>
>>>>>
>>>>>  
>>>>> BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>>>>
>>>>>     }
>>>>> }
>>>>>
>>>>>
>>>>> I had to override createLineNumerRulerColumn and
>>>>> createVerticalRuler to
>>>>> avoid some NPE's. I can send the stacktraces without these if it
>>>>> would
>>>>> help.
>>>>>
>>>>> The GlobalControllerDocumentProvider basically extends
>>>>> FileDocumentProvider
>>>>> and implements createDocument and doSaveDocument, nothing special
>>>>> there.
>>>>>
>>>>> Sincerely,
>>>>> Edvin Syse
>>>>>
>>>>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>>>>
>>>>>> I don't think that would be the problem.  It could be any number of
>>>>>> reasons.  Is the GroovyConfiguration class being instantiated in the
>>>>>> "createJavaSourceViewerConfiguration()" method?
>>>>>>
>>>>>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>>>>>> this class being instantiated?  What highlighting rules are being
>>>>>> sent
>>>>>> to it?
>>>>>>
>>>>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin
>>>>>> Syse<[hidden email]>      wrote:
>>>>>>
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I've extended GroovyEditor and uses it to edit groovy-scripts
>>>>>>> stored in
>>>>>>> a
>>>>>>> database. Hence, I use a custom DocumentProvider and the
>>>>>>> EditorInput
>>>>>>> does
>>>>>>> not extend IFileEditorInput. I suspect that for this reason I
>>>>>>> don't get
>>>>>>> syntax highlight and code assist.
>>>>>>>
>>>>>>> Can someone point towards a workaround for this? It's really a pain
>>>>>>> having
>>>>>>> to support IFileEditorInput when I don't need it :)
>>>>>>>
>>>>>>> Sincerely,
>>>>>>> Edvin Syse
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>>
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>      http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>    http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>      http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>      http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Edvin Syse
Just noticed I got an error in the console saying:

java.lang.InstantiationException:
org.codehaus.groovy.eclipse.refactoring.actions.RenameDispatcherAction

...

!MESSAGE Plugin 'org.codehaus.groovy.eclipse.ui' invalid Menu Extension
(Group 'edit' is invalid):
org.codehaus.groovy.eclipse.refactoring.refactoringMenu

That might be why content assist was never initialized? :) I guess I
just need to add an edit group to my menu.

Den 23.03.10 20:48, skrev Edvin Syse:

> I had some luck with this rudimentary approach:
>
>             IProject project =
> ResourcesPlugin.getWorkspace().getRoot().getProject("groovy");
>             if (!project.exists()) {
>                 project.create(monitor);
>                 project.open(monitor);
>                 ProjectDescription pdesc = new ProjectDescription();
>                 pdesc.setNatureIds(new String[] {
> "org.eclipse.jdt.groovy.core.groovyNature" } );
>                 project.setDescription(pdesc, monitor);
>             }
>
>             if (!project.isOpen())
>                 project.open(monitor);
>
>             IFile controllerFile =
> project.getFile("GlobalController.groovy");
>             String content = "some groovy content here";
>             ByteArrayInputStream in = new
> ByteArrayInputStream(content.getBytes());
>             controllerFile.create(in, true, monitor);
>
>             IEditorInput editorInput = new
> FileEditorInput(controllerFile);
>             UIUtils.openEditor(event, editorInput,
> GroovyEditor.EDITOR_ID);
>
> This opens the editor with the file content, and syntaxhl works good,
> but content assist does not. Also I dont have a way to monitor the
> save operation of the editor, but that's probably no biggie :)
>
>
>
> Den 23.03.10 20:25, skrev Edvin Syse:
>> Maybe I need to rethink this. To simplify my usecase:
>>
>> I have a String containing a Groovy script, and I want to edit it
>> with the GroovyEditor. The string comees form a database, and should
>> be saved back to the database when changed.
>>
>> Maybe I should create a normal workspace file, put the content of the
>> string into that and open it with the GroovyEditor programatically.
>> Then I would need to intercept save/change to the file somehow, so
>> that I can update the database with the new content.
>>
>> What do you think of that approach?
>>
>> Den 23.03.10 18:41, skrev Andrew Eisenberg:
>>> Careful there!  IGroovyDocumentProvider is not used for the editor.
>>> It is a legacy class used for refactoring and will likely be removed
>>> once I start reworking refactoring support in Groovy-Eclipse.
>>>
>>> As for your db-document implementing ICompilationUnit, that will open
>>> up a world of complications if this is really necessary.
>>> GroovyCompilationUnit objects are only instantiated from within the
>>> groovy-jdt integration plugin.  So, if you need to subclass GCU, it
>>> will never be instantiated.
>>>
>>> So, I can't say exactly what you need to do (partially because I don't
>>> know what you are trying to do), but I think you are on the right
>>> track if you take into account what I say above.
>>>
>>> On Tue, Mar 23, 2010 at 9:09 AM, Edvin Syse<[hidden email]>  wrote:
>>>> I think you are right. Thanks for the insight, I'll post back with a
>>>> solution when I find it :) I think I'll try to make my
>>>> DocumentProvider
>>>> implement IGroovyDocumentProvider and make my db-document implement
>>>> ICompilationUnit.. Painful :)
>>>>
>>>> Sincerely,
>>>> Edvin Syse
>>>>
>>>> Den 23.03.10 16:47, skrev Andrew Eisenberg:
>>>>> It's possible that the content type of the document that you are
>>>>> creating is not groovySource.  This means that your document is not
>>>>> being partitiioned properly and so none of the groovy syntax
>>>>> highlighting will apply. (But not sure exactly how to do this in your
>>>>> situation.)
>>>>>
>>>>> Also, I think that you should be using a
>>>>> org.eclipse.ui.editors.documentProviders extension point instead of
>>>>> explicitly setting the document provider for your editor.
>>>>>
>>>>> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>    
>>>>> wrote:
>>>>>
>>>>>> Thanks for your reply.
>>>>>>
>>>>>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>>>>>> GroovyConfiguration object is returned from the implementation in
>>>>>> GroovyEditor.
>>>>>>
>>>>>> The GroovyTagScanner is also instantiated. There are no
>>>>>> additionalRules,
>>>>>> additionalGroovyKeywords or additionalGJDKKeywords sent to it,
>>>>>> but the
>>>>>> IColorManager contains:
>>>>>>
>>>>>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0},
>>>>>> java_keyword=RGB
>>>>>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>>>>>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>>>>>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB
>>>>>> {63, 127,
>>>>>> 95},
>>>>>> java_multi_line_comment=RGB {63, 127, 95},
>>>>>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>>>>>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0},
>>>>>> java_operator=RGB {0,
>>>>>> 0,
>>>>>> 0}, java_keyword_return=RGB {127, 0, 85},
>>>>>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>>>>>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>>>>>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0},
>>>>>> java_doc_default=RGB
>>>>>> {63,
>>>>>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>>>>>> semanticHighlighting.annotation.color=RGB {100, 100, 100},
>>>>>> java_doc_tag=RGB
>>>>>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0,
>>>>>> 0},
>>>>>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0},
>>>>>> java_string=RGB
>>>>>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>>>>>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>>>>>
>>>>>> Here is my complete implementation:
>>>>>>
>>>>>> public class GlobalControllerEditor extends GroovyEditor {
>>>>>>
>>>>>>     public GlobalControllerEditor() {
>>>>>>         super();
>>>>>>         setDocumentProvider(new GlobalControllerDocumentProvider());
>>>>>>     }
>>>>>>
>>>>>>     public JavaSourceViewerConfiguration
>>>>>> createJavaSourceViewerConfiguration() {
>>>>>>         return super.createJavaSourceViewerConfiguration();
>>>>>>     }
>>>>>>
>>>>>>     protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>>>>>         fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>>>>>         ((IChangeRulerColumn)
>>>>>> fLineNumberRulerColumn).setHover(createChangeHover());
>>>>>>         initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>>>>>         return fLineNumberRulerColumn;
>>>>>>     }
>>>>>>
>>>>>>     protected IVerticalRuler createVerticalRuler() {
>>>>>>         return new VerticalRuler(50);
>>>>>>     }
>>>>>>
>>>>>>     public void init(IEditorSite site, IEditorInput input) throws
>>>>>> PartInitException {
>>>>>>         super.init(site, input);
>>>>>>         setPartName("Global kontroller");
>>>>>>     }
>>>>>>
>>>>>>     public void doSave(IProgressMonitor progressMonitor) {
>>>>>>         super.doSave(progressMonitor);
>>>>>>         TornadoEditorInput input = (TornadoEditorInput)
>>>>>> getEditorInput();
>>>>>>
>>>>>>
>>>>>>  
>>>>>> BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>>>>>
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> I had to override createLineNumerRulerColumn and
>>>>>> createVerticalRuler to
>>>>>> avoid some NPE's. I can send the stacktraces without these if it
>>>>>> would
>>>>>> help.
>>>>>>
>>>>>> The GlobalControllerDocumentProvider basically extends
>>>>>> FileDocumentProvider
>>>>>> and implements createDocument and doSaveDocument, nothing special
>>>>>> there.
>>>>>>
>>>>>> Sincerely,
>>>>>> Edvin Syse
>>>>>>
>>>>>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>>>>>
>>>>>>> I don't think that would be the problem.  It could be any number of
>>>>>>> reasons.  Is the GroovyConfiguration class being instantiated in
>>>>>>> the
>>>>>>> "createJavaSourceViewerConfiguration()" method?
>>>>>>>
>>>>>>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>>>>>>> this class being instantiated?  What highlighting rules are
>>>>>>> being sent
>>>>>>> to it?
>>>>>>>
>>>>>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin
>>>>>>> Syse<[hidden email]>      wrote:
>>>>>>>
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I've extended GroovyEditor and uses it to edit groovy-scripts
>>>>>>>> stored in
>>>>>>>> a
>>>>>>>> database. Hence, I use a custom DocumentProvider and the
>>>>>>>> EditorInput
>>>>>>>> does
>>>>>>>> not extend IFileEditorInput. I suspect that for this reason I
>>>>>>>> don't get
>>>>>>>> syntax highlight and code assist.
>>>>>>>>
>>>>>>>> Can someone point towards a workaround for this? It's really a
>>>>>>>> pain
>>>>>>>> having
>>>>>>>> to support IFileEditorInput when I don't need it :)
>>>>>>>>
>>>>>>>> Sincerely,
>>>>>>>> Edvin Syse
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>>
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>      http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>      http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>      http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Andrew Eisenberg
In reply to this post by Edvin Syse
It's likely that you are not getting content assist because your
project does not have the groovy library associated with it.

On Tue, Mar 23, 2010 at 12:48 PM, Edvin Syse <[hidden email]> wrote:

> I had some luck with this rudimentary approach:
>
>            IProject project =
> ResourcesPlugin.getWorkspace().getRoot().getProject("groovy");
>            if (!project.exists()) {
>                project.create(monitor);
>                project.open(monitor);
>                ProjectDescription pdesc = new ProjectDescription();
>                pdesc.setNatureIds(new String[] {
> "org.eclipse.jdt.groovy.core.groovyNature" } );
>                project.setDescription(pdesc, monitor);
>            }
>
>            if (!project.isOpen())
>                project.open(monitor);
>
>            IFile controllerFile =
> project.getFile("GlobalController.groovy");
>            String content = "some groovy content here";
>            ByteArrayInputStream in = new
> ByteArrayInputStream(content.getBytes());
>            controllerFile.create(in, true, monitor);
>
>            IEditorInput editorInput = new FileEditorInput(controllerFile);
>            UIUtils.openEditor(event, editorInput, GroovyEditor.EDITOR_ID);
>
> This opens the editor with the file content, and syntaxhl works good, but
> content assist does not. Also I dont have a way to monitor the save
> operation of the editor, but that's probably no biggie :)
>
>
>
> Den 23.03.10 20:25, skrev Edvin Syse:
>>
>> Maybe I need to rethink this. To simplify my usecase:
>>
>> I have a String containing a Groovy script, and I want to edit it with the
>> GroovyEditor. The string comees form a database, and should be saved back to
>> the database when changed.
>>
>> Maybe I should create a normal workspace file, put the content of the
>> string into that and open it with the GroovyEditor programatically. Then I
>> would need to intercept save/change to the file somehow, so that I can
>> update the database with the new content.
>>
>> What do you think of that approach?
>>
>> Den 23.03.10 18:41, skrev Andrew Eisenberg:
>>>
>>> Careful there!  IGroovyDocumentProvider is not used for the editor.
>>> It is a legacy class used for refactoring and will likely be removed
>>> once I start reworking refactoring support in Groovy-Eclipse.
>>>
>>> As for your db-document implementing ICompilationUnit, that will open
>>> up a world of complications if this is really necessary.
>>> GroovyCompilationUnit objects are only instantiated from within the
>>> groovy-jdt integration plugin.  So, if you need to subclass GCU, it
>>> will never be instantiated.
>>>
>>> So, I can't say exactly what you need to do (partially because I don't
>>> know what you are trying to do), but I think you are on the right
>>> track if you take into account what I say above.
>>>
>>> On Tue, Mar 23, 2010 at 9:09 AM, Edvin Syse<[hidden email]>  wrote:
>>>>
>>>> I think you are right. Thanks for the insight, I'll post back with a
>>>> solution when I find it :) I think I'll try to make my DocumentProvider
>>>> implement IGroovyDocumentProvider and make my db-document implement
>>>> ICompilationUnit.. Painful :)
>>>>
>>>> Sincerely,
>>>> Edvin Syse
>>>>
>>>> Den 23.03.10 16:47, skrev Andrew Eisenberg:
>>>>>
>>>>> It's possible that the content type of the document that you are
>>>>> creating is not groovySource.  This means that your document is not
>>>>> being partitiioned properly and so none of the groovy syntax
>>>>> highlighting will apply. (But not sure exactly how to do this in your
>>>>> situation.)
>>>>>
>>>>> Also, I think that you should be using a
>>>>> org.eclipse.ui.editors.documentProviders extension point instead of
>>>>> explicitly setting the document provider for your editor.
>>>>>
>>>>> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>
>>>>>  wrote:
>>>>>
>>>>>> Thanks for your reply.
>>>>>>
>>>>>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>>>>>> GroovyConfiguration object is returned from the implementation in
>>>>>> GroovyEditor.
>>>>>>
>>>>>> The GroovyTagScanner is also instantiated. There are no
>>>>>> additionalRules,
>>>>>> additionalGroovyKeywords or additionalGJDKKeywords sent to it, but the
>>>>>> IColorManager contains:
>>>>>>
>>>>>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0},
>>>>>> java_keyword=RGB
>>>>>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>>>>>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>>>>>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63,
>>>>>> 127,
>>>>>> 95},
>>>>>> java_multi_line_comment=RGB {63, 127, 95},
>>>>>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>>>>>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0}, java_operator=RGB
>>>>>> {0,
>>>>>> 0,
>>>>>> 0}, java_keyword_return=RGB {127, 0, 85},
>>>>>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>>>>>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>>>>>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0}, java_doc_default=RGB
>>>>>> {63,
>>>>>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>>>>>> semanticHighlighting.annotation.color=RGB {100, 100, 100},
>>>>>> java_doc_tag=RGB
>>>>>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0, 0},
>>>>>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0},
>>>>>> java_string=RGB
>>>>>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>>>>>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>>>>>
>>>>>> Here is my complete implementation:
>>>>>>
>>>>>> public class GlobalControllerEditor extends GroovyEditor {
>>>>>>
>>>>>>    public GlobalControllerEditor() {
>>>>>>        super();
>>>>>>        setDocumentProvider(new GlobalControllerDocumentProvider());
>>>>>>    }
>>>>>>
>>>>>>    public JavaSourceViewerConfiguration
>>>>>> createJavaSourceViewerConfiguration() {
>>>>>>        return super.createJavaSourceViewerConfiguration();
>>>>>>    }
>>>>>>
>>>>>>    protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>>>>>        fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>>>>>        ((IChangeRulerColumn)
>>>>>> fLineNumberRulerColumn).setHover(createChangeHover());
>>>>>>        initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>>>>>        return fLineNumberRulerColumn;
>>>>>>    }
>>>>>>
>>>>>>    protected IVerticalRuler createVerticalRuler() {
>>>>>>        return new VerticalRuler(50);
>>>>>>    }
>>>>>>
>>>>>>    public void init(IEditorSite site, IEditorInput input) throws
>>>>>> PartInitException {
>>>>>>        super.init(site, input);
>>>>>>        setPartName("Global kontroller");
>>>>>>    }
>>>>>>
>>>>>>    public void doSave(IProgressMonitor progressMonitor) {
>>>>>>        super.doSave(progressMonitor);
>>>>>>        TornadoEditorInput input = (TornadoEditorInput)
>>>>>> getEditorInput();
>>>>>>
>>>>>>
>>>>>>
>>>>>>  BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>>>>>    }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> I had to override createLineNumerRulerColumn and createVerticalRuler
>>>>>> to
>>>>>> avoid some NPE's. I can send the stacktraces without these if it would
>>>>>> help.
>>>>>>
>>>>>> The GlobalControllerDocumentProvider basically extends
>>>>>> FileDocumentProvider
>>>>>> and implements createDocument and doSaveDocument, nothing special
>>>>>> there.
>>>>>>
>>>>>> Sincerely,
>>>>>> Edvin Syse
>>>>>>
>>>>>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>>>>>
>>>>>>> I don't think that would be the problem.  It could be any number of
>>>>>>> reasons.  Is the GroovyConfiguration class being instantiated in the
>>>>>>> "createJavaSourceViewerConfiguration()" method?
>>>>>>>
>>>>>>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>>>>>>> this class being instantiated?  What highlighting rules are being
>>>>>>> sent
>>>>>>> to it?
>>>>>>>
>>>>>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse<[hidden email]>
>>>>>>>  wrote:
>>>>>>>
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I've extended GroovyEditor and uses it to edit groovy-scripts stored
>>>>>>>> in
>>>>>>>> a
>>>>>>>> database. Hence, I use a custom DocumentProvider and the EditorInput
>>>>>>>> does
>>>>>>>> not extend IFileEditorInput. I suspect that for this reason I don't
>>>>>>>> get
>>>>>>>> syntax highlight and code assist.
>>>>>>>>
>>>>>>>> Can someone point towards a workaround for this? It's really a pain
>>>>>>>> having
>>>>>>>> to support IFileEditorInput when I don't need it :)
>>>>>>>>
>>>>>>>> Sincerely,
>>>>>>>> Edvin Syse
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>   http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>   http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>     http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>   http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>     http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Edvin Syse
In reply to this post by Edvin Syse
Nearly there. I added the javaNature as well, and now content assist
works, so I guess the last step is to setup the classpath for the new
project. (No classes are resolved as of now, not even Object).

Are there some convenience methods in the GroovyEclips plugin I can use
to create the new project?

Den 23.03.10 20:50, skrev Edvin Syse:

> Just noticed I got an error in the console saying:
>
> java.lang.InstantiationException:
> org.codehaus.groovy.eclipse.refactoring.actions.RenameDispatcherAction
>
> ...
>
> !MESSAGE Plugin 'org.codehaus.groovy.eclipse.ui' invalid Menu
> Extension (Group 'edit' is invalid):
> org.codehaus.groovy.eclipse.refactoring.refactoringMenu
>
> That might be why content assist was never initialized? :) I guess I
> just need to add an edit group to my menu.
>
> Den 23.03.10 20:48, skrev Edvin Syse:
>> I had some luck with this rudimentary approach:
>>
>>             IProject project =
>> ResourcesPlugin.getWorkspace().getRoot().getProject("groovy");
>>             if (!project.exists()) {
>>                 project.create(monitor);
>>                 project.open(monitor);
>>                 ProjectDescription pdesc = new ProjectDescription();
>>                 pdesc.setNatureIds(new String[] {
>> "org.eclipse.jdt.groovy.core.groovyNature" } );
>>                 project.setDescription(pdesc, monitor);
>>             }
>>
>>             if (!project.isOpen())
>>                 project.open(monitor);
>>
>>             IFile controllerFile =
>> project.getFile("GlobalController.groovy");
>>             String content = "some groovy content here";
>>             ByteArrayInputStream in = new
>> ByteArrayInputStream(content.getBytes());
>>             controllerFile.create(in, true, monitor);
>>
>>             IEditorInput editorInput = new
>> FileEditorInput(controllerFile);
>>             UIUtils.openEditor(event, editorInput,
>> GroovyEditor.EDITOR_ID);
>>
>> This opens the editor with the file content, and syntaxhl works good,
>> but content assist does not. Also I dont have a way to monitor the
>> save operation of the editor, but that's probably no biggie :)
>>
>>
>>
>> Den 23.03.10 20:25, skrev Edvin Syse:
>>> Maybe I need to rethink this. To simplify my usecase:
>>>
>>> I have a String containing a Groovy script, and I want to edit it
>>> with the GroovyEditor. The string comees form a database, and should
>>> be saved back to the database when changed.
>>>
>>> Maybe I should create a normal workspace file, put the content of
>>> the string into that and open it with the GroovyEditor
>>> programatically. Then I would need to intercept save/change to the
>>> file somehow, so that I can update the database with the new content.
>>>
>>> What do you think of that approach?
>>>
>>> Den 23.03.10 18:41, skrev Andrew Eisenberg:
>>>> Careful there!  IGroovyDocumentProvider is not used for the editor.
>>>> It is a legacy class used for refactoring and will likely be removed
>>>> once I start reworking refactoring support in Groovy-Eclipse.
>>>>
>>>> As for your db-document implementing ICompilationUnit, that will open
>>>> up a world of complications if this is really necessary.
>>>> GroovyCompilationUnit objects are only instantiated from within the
>>>> groovy-jdt integration plugin.  So, if you need to subclass GCU, it
>>>> will never be instantiated.
>>>>
>>>> So, I can't say exactly what you need to do (partially because I don't
>>>> know what you are trying to do), but I think you are on the right
>>>> track if you take into account what I say above.
>>>>
>>>> On Tue, Mar 23, 2010 at 9:09 AM, Edvin Syse<[hidden email]>  wrote:
>>>>> I think you are right. Thanks for the insight, I'll post back with a
>>>>> solution when I find it :) I think I'll try to make my
>>>>> DocumentProvider
>>>>> implement IGroovyDocumentProvider and make my db-document implement
>>>>> ICompilationUnit.. Painful :)
>>>>>
>>>>> Sincerely,
>>>>> Edvin Syse
>>>>>
>>>>> Den 23.03.10 16:47, skrev Andrew Eisenberg:
>>>>>> It's possible that the content type of the document that you are
>>>>>> creating is not groovySource.  This means that your document is not
>>>>>> being partitiioned properly and so none of the groovy syntax
>>>>>> highlighting will apply. (But not sure exactly how to do this in
>>>>>> your
>>>>>> situation.)
>>>>>>
>>>>>> Also, I think that you should be using a
>>>>>> org.eclipse.ui.editors.documentProviders extension point instead of
>>>>>> explicitly setting the document provider for your editor.
>>>>>>
>>>>>> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>    
>>>>>> wrote:
>>>>>>
>>>>>>> Thanks for your reply.
>>>>>>>
>>>>>>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>>>>>>> GroovyConfiguration object is returned from the implementation in
>>>>>>> GroovyEditor.
>>>>>>>
>>>>>>> The GroovyTagScanner is also instantiated. There are no
>>>>>>> additionalRules,
>>>>>>> additionalGroovyKeywords or additionalGJDKKeywords sent to it,
>>>>>>> but the
>>>>>>> IColorManager contains:
>>>>>>>
>>>>>>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0},
>>>>>>> java_keyword=RGB
>>>>>>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>>>>>>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>>>>>>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB
>>>>>>> {63, 127,
>>>>>>> 95},
>>>>>>> java_multi_line_comment=RGB {63, 127, 95},
>>>>>>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>>>>>>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0},
>>>>>>> java_operator=RGB {0,
>>>>>>> 0,
>>>>>>> 0}, java_keyword_return=RGB {127, 0, 85},
>>>>>>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>>>>>>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>>>>>>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0},
>>>>>>> java_doc_default=RGB
>>>>>>> {63,
>>>>>>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>>>>>>> semanticHighlighting.annotation.color=RGB {100, 100, 100},
>>>>>>> java_doc_tag=RGB
>>>>>>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0,
>>>>>>> 0, 0},
>>>>>>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0},
>>>>>>> java_string=RGB
>>>>>>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>>>>>>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>>>>>>
>>>>>>> Here is my complete implementation:
>>>>>>>
>>>>>>> public class GlobalControllerEditor extends GroovyEditor {
>>>>>>>
>>>>>>>     public GlobalControllerEditor() {
>>>>>>>         super();
>>>>>>>         setDocumentProvider(new
>>>>>>> GlobalControllerDocumentProvider());
>>>>>>>     }
>>>>>>>
>>>>>>>     public JavaSourceViewerConfiguration
>>>>>>> createJavaSourceViewerConfiguration() {
>>>>>>>         return super.createJavaSourceViewerConfiguration();
>>>>>>>     }
>>>>>>>
>>>>>>>     protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>>>>>>         fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>>>>>>         ((IChangeRulerColumn)
>>>>>>> fLineNumberRulerColumn).setHover(createChangeHover());
>>>>>>>         initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>>>>>>         return fLineNumberRulerColumn;
>>>>>>>     }
>>>>>>>
>>>>>>>     protected IVerticalRuler createVerticalRuler() {
>>>>>>>         return new VerticalRuler(50);
>>>>>>>     }
>>>>>>>
>>>>>>>     public void init(IEditorSite site, IEditorInput input) throws
>>>>>>> PartInitException {
>>>>>>>         super.init(site, input);
>>>>>>>         setPartName("Global kontroller");
>>>>>>>     }
>>>>>>>
>>>>>>>     public void doSave(IProgressMonitor progressMonitor) {
>>>>>>>         super.doSave(progressMonitor);
>>>>>>>         TornadoEditorInput input = (TornadoEditorInput)
>>>>>>> getEditorInput();
>>>>>>>
>>>>>>>
>>>>>>>  
>>>>>>> BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>>>>>>
>>>>>>>     }
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> I had to override createLineNumerRulerColumn and
>>>>>>> createVerticalRuler to
>>>>>>> avoid some NPE's. I can send the stacktraces without these if it
>>>>>>> would
>>>>>>> help.
>>>>>>>
>>>>>>> The GlobalControllerDocumentProvider basically extends
>>>>>>> FileDocumentProvider
>>>>>>> and implements createDocument and doSaveDocument, nothing
>>>>>>> special there.
>>>>>>>
>>>>>>> Sincerely,
>>>>>>> Edvin Syse
>>>>>>>
>>>>>>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>>>>>>
>>>>>>>> I don't think that would be the problem.  It could be any
>>>>>>>> number of
>>>>>>>> reasons.  Is the GroovyConfiguration class being instantiated
>>>>>>>> in the
>>>>>>>> "createJavaSourceViewerConfiguration()" method?
>>>>>>>>
>>>>>>>> Also, set a breakpoint int he constructor for
>>>>>>>> GroovyTagScanner.  Is
>>>>>>>> this class being instantiated?  What highlighting rules are
>>>>>>>> being sent
>>>>>>>> to it?
>>>>>>>>
>>>>>>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin
>>>>>>>> Syse<[hidden email]>      wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I've extended GroovyEditor and uses it to edit groovy-scripts
>>>>>>>>> stored in
>>>>>>>>> a
>>>>>>>>> database. Hence, I use a custom DocumentProvider and the
>>>>>>>>> EditorInput
>>>>>>>>> does
>>>>>>>>> not extend IFileEditorInput. I suspect that for this reason I
>>>>>>>>> don't get
>>>>>>>>> syntax highlight and code assist.
>>>>>>>>>
>>>>>>>>> Can someone point towards a workaround for this? It's really a
>>>>>>>>> pain
>>>>>>>>> having
>>>>>>>>> to support IFileEditorInput when I don't need it :)
>>>>>>>>>
>>>>>>>>> Sincerely,
>>>>>>>>> Edvin Syse
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>
>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>
>>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>      http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>>
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>      http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>    http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>      http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Andrew Eisenberg
No convenience methods for that, but you can look at the GroovyRuntime
class that adds the groovy nature and library.

Also, you can have a peek at the org.codehaus.groovy.eclipse.tests
project and the TestProject class.  This class creates and destroys
projects while running tests.  You may be able to borrow some of that
code.

On Tue, Mar 23, 2010 at 1:01 PM, Edvin Syse <[hidden email]> wrote:

> Nearly there. I added the javaNature as well, and now content assist works,
> so I guess the last step is to setup the classpath for the new project. (No
> classes are resolved as of now, not even Object).
>
> Are there some convenience methods in the GroovyEclips plugin I can use to
> create the new project?
>
> Den 23.03.10 20:50, skrev Edvin Syse:
>>
>> Just noticed I got an error in the console saying:
>>
>> java.lang.InstantiationException:
>> org.codehaus.groovy.eclipse.refactoring.actions.RenameDispatcherAction
>>
>> ...
>>
>> !MESSAGE Plugin 'org.codehaus.groovy.eclipse.ui' invalid Menu Extension
>> (Group 'edit' is invalid):
>> org.codehaus.groovy.eclipse.refactoring.refactoringMenu
>>
>> That might be why content assist was never initialized? :) I guess I just
>> need to add an edit group to my menu.
>>
>> Den 23.03.10 20:48, skrev Edvin Syse:
>>>
>>> I had some luck with this rudimentary approach:
>>>
>>>            IProject project =
>>> ResourcesPlugin.getWorkspace().getRoot().getProject("groovy");
>>>            if (!project.exists()) {
>>>                project.create(monitor);
>>>                project.open(monitor);
>>>                ProjectDescription pdesc = new ProjectDescription();
>>>                pdesc.setNatureIds(new String[] {
>>> "org.eclipse.jdt.groovy.core.groovyNature" } );
>>>                project.setDescription(pdesc, monitor);
>>>            }
>>>
>>>            if (!project.isOpen())
>>>                project.open(monitor);
>>>
>>>            IFile controllerFile =
>>> project.getFile("GlobalController.groovy");
>>>            String content = "some groovy content here";
>>>            ByteArrayInputStream in = new
>>> ByteArrayInputStream(content.getBytes());
>>>            controllerFile.create(in, true, monitor);
>>>
>>>            IEditorInput editorInput = new
>>> FileEditorInput(controllerFile);
>>>            UIUtils.openEditor(event, editorInput,
>>> GroovyEditor.EDITOR_ID);
>>>
>>> This opens the editor with the file content, and syntaxhl works good, but
>>> content assist does not. Also I dont have a way to monitor the save
>>> operation of the editor, but that's probably no biggie :)
>>>
>>>
>>>
>>> Den 23.03.10 20:25, skrev Edvin Syse:
>>>>
>>>> Maybe I need to rethink this. To simplify my usecase:
>>>>
>>>> I have a String containing a Groovy script, and I want to edit it with
>>>> the GroovyEditor. The string comees form a database, and should be saved
>>>> back to the database when changed.
>>>>
>>>> Maybe I should create a normal workspace file, put the content of the
>>>> string into that and open it with the GroovyEditor programatically. Then I
>>>> would need to intercept save/change to the file somehow, so that I can
>>>> update the database with the new content.
>>>>
>>>> What do you think of that approach?
>>>>
>>>> Den 23.03.10 18:41, skrev Andrew Eisenberg:
>>>>>
>>>>> Careful there!  IGroovyDocumentProvider is not used for the editor.
>>>>> It is a legacy class used for refactoring and will likely be removed
>>>>> once I start reworking refactoring support in Groovy-Eclipse.
>>>>>
>>>>> As for your db-document implementing ICompilationUnit, that will open
>>>>> up a world of complications if this is really necessary.
>>>>> GroovyCompilationUnit objects are only instantiated from within the
>>>>> groovy-jdt integration plugin.  So, if you need to subclass GCU, it
>>>>> will never be instantiated.
>>>>>
>>>>> So, I can't say exactly what you need to do (partially because I don't
>>>>> know what you are trying to do), but I think you are on the right
>>>>> track if you take into account what I say above.
>>>>>
>>>>> On Tue, Mar 23, 2010 at 9:09 AM, Edvin Syse<[hidden email]>  wrote:
>>>>>>
>>>>>> I think you are right. Thanks for the insight, I'll post back with a
>>>>>> solution when I find it :) I think I'll try to make my
>>>>>> DocumentProvider
>>>>>> implement IGroovyDocumentProvider and make my db-document implement
>>>>>> ICompilationUnit.. Painful :)
>>>>>>
>>>>>> Sincerely,
>>>>>> Edvin Syse
>>>>>>
>>>>>> Den 23.03.10 16:47, skrev Andrew Eisenberg:
>>>>>>>
>>>>>>> It's possible that the content type of the document that you are
>>>>>>> creating is not groovySource.  This means that your document is not
>>>>>>> being partitiioned properly and so none of the groovy syntax
>>>>>>> highlighting will apply. (But not sure exactly how to do this in your
>>>>>>> situation.)
>>>>>>>
>>>>>>> Also, I think that you should be using a
>>>>>>> org.eclipse.ui.editors.documentProviders extension point instead of
>>>>>>> explicitly setting the document provider for your editor.
>>>>>>>
>>>>>>> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>
>>>>>>>  wrote:
>>>>>>>
>>>>>>>> Thanks for your reply.
>>>>>>>>
>>>>>>>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>>>>>>>> GroovyConfiguration object is returned from the implementation in
>>>>>>>> GroovyEditor.
>>>>>>>>
>>>>>>>> The GroovyTagScanner is also instantiated. There are no
>>>>>>>> additionalRules,
>>>>>>>> additionalGroovyKeywords or additionalGJDKKeywords sent to it, but
>>>>>>>> the
>>>>>>>> IColorManager contains:
>>>>>>>>
>>>>>>>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0},
>>>>>>>> java_keyword=RGB
>>>>>>>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>>>>>>>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>>>>>>>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63,
>>>>>>>> 127,
>>>>>>>> 95},
>>>>>>>> java_multi_line_comment=RGB {63, 127, 95},
>>>>>>>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>>>>>>>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0}, java_operator=RGB
>>>>>>>> {0,
>>>>>>>> 0,
>>>>>>>> 0}, java_keyword_return=RGB {127, 0, 85},
>>>>>>>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>>>>>>>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>>>>>>>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0},
>>>>>>>> java_doc_default=RGB
>>>>>>>> {63,
>>>>>>>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>>>>>>>> semanticHighlighting.annotation.color=RGB {100, 100, 100},
>>>>>>>> java_doc_tag=RGB
>>>>>>>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0,
>>>>>>>> 0},
>>>>>>>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0},
>>>>>>>> java_string=RGB
>>>>>>>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>>>>>>>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>>>>>>>
>>>>>>>> Here is my complete implementation:
>>>>>>>>
>>>>>>>> public class GlobalControllerEditor extends GroovyEditor {
>>>>>>>>
>>>>>>>>    public GlobalControllerEditor() {
>>>>>>>>        super();
>>>>>>>>        setDocumentProvider(new GlobalControllerDocumentProvider());
>>>>>>>>    }
>>>>>>>>
>>>>>>>>    public JavaSourceViewerConfiguration
>>>>>>>> createJavaSourceViewerConfiguration() {
>>>>>>>>        return super.createJavaSourceViewerConfiguration();
>>>>>>>>    }
>>>>>>>>
>>>>>>>>    protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>>>>>>>        fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>>>>>>>        ((IChangeRulerColumn)
>>>>>>>> fLineNumberRulerColumn).setHover(createChangeHover());
>>>>>>>>        initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>>>>>>>        return fLineNumberRulerColumn;
>>>>>>>>    }
>>>>>>>>
>>>>>>>>    protected IVerticalRuler createVerticalRuler() {
>>>>>>>>        return new VerticalRuler(50);
>>>>>>>>    }
>>>>>>>>
>>>>>>>>    public void init(IEditorSite site, IEditorInput input) throws
>>>>>>>> PartInitException {
>>>>>>>>        super.init(site, input);
>>>>>>>>        setPartName("Global kontroller");
>>>>>>>>    }
>>>>>>>>
>>>>>>>>    public void doSave(IProgressMonitor progressMonitor) {
>>>>>>>>        super.doSave(progressMonitor);
>>>>>>>>        TornadoEditorInput input = (TornadoEditorInput)
>>>>>>>> getEditorInput();
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>  BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>>>>>>>    }
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> I had to override createLineNumerRulerColumn and createVerticalRuler
>>>>>>>> to
>>>>>>>> avoid some NPE's. I can send the stacktraces without these if it
>>>>>>>> would
>>>>>>>> help.
>>>>>>>>
>>>>>>>> The GlobalControllerDocumentProvider basically extends
>>>>>>>> FileDocumentProvider
>>>>>>>> and implements createDocument and doSaveDocument, nothing special
>>>>>>>> there.
>>>>>>>>
>>>>>>>> Sincerely,
>>>>>>>> Edvin Syse
>>>>>>>>
>>>>>>>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>>>>>>>
>>>>>>>>> I don't think that would be the problem.  It could be any number of
>>>>>>>>> reasons.  Is the GroovyConfiguration class being instantiated in
>>>>>>>>> the
>>>>>>>>> "createJavaSourceViewerConfiguration()" method?
>>>>>>>>>
>>>>>>>>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>>>>>>>>> this class being instantiated?  What highlighting rules are being
>>>>>>>>> sent
>>>>>>>>> to it?
>>>>>>>>>
>>>>>>>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse<[hidden email]>
>>>>>>>>>  wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I've extended GroovyEditor and uses it to edit groovy-scripts
>>>>>>>>>> stored in
>>>>>>>>>> a
>>>>>>>>>> database. Hence, I use a custom DocumentProvider and the
>>>>>>>>>> EditorInput
>>>>>>>>>> does
>>>>>>>>>> not extend IFileEditorInput. I suspect that for this reason I
>>>>>>>>>> don't get
>>>>>>>>>> syntax highlight and code assist.
>>>>>>>>>>
>>>>>>>>>> Can someone point towards a workaround for this? It's really a
>>>>>>>>>> pain
>>>>>>>>>> having
>>>>>>>>>> to support IFileEditorInput when I don't need it :)
>>>>>>>>>>
>>>>>>>>>> Sincerely,
>>>>>>>>>> Edvin Syse
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>>
>>>>>>>>>>   http://xircles.codehaus.org/manage_email
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>
>>>>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>   http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>     http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>   http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>     http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>   http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>   http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extend GroovyEditor -> support none-file resources

Edvin Syse
Thank you for all the great help Andrew :))

-- Edvin

Den 23.03.10 21:04, skrev Andrew Eisenberg:

> No convenience methods for that, but you can look at the GroovyRuntime
> class that adds the groovy nature and library.
>
> Also, you can have a peek at the org.codehaus.groovy.eclipse.tests
> project and the TestProject class.  This class creates and destroys
> projects while running tests.  You may be able to borrow some of that
> code.
>
> On Tue, Mar 23, 2010 at 1:01 PM, Edvin Syse<[hidden email]>  wrote:
>    
>> Nearly there. I added the javaNature as well, and now content assist works,
>> so I guess the last step is to setup the classpath for the new project. (No
>> classes are resolved as of now, not even Object).
>>
>> Are there some convenience methods in the GroovyEclips plugin I can use to
>> create the new project?
>>
>> Den 23.03.10 20:50, skrev Edvin Syse:
>>      
>>> Just noticed I got an error in the console saying:
>>>
>>> java.lang.InstantiationException:
>>> org.codehaus.groovy.eclipse.refactoring.actions.RenameDispatcherAction
>>>
>>> ...
>>>
>>> !MESSAGE Plugin 'org.codehaus.groovy.eclipse.ui' invalid Menu Extension
>>> (Group 'edit' is invalid):
>>> org.codehaus.groovy.eclipse.refactoring.refactoringMenu
>>>
>>> That might be why content assist was never initialized? :) I guess I just
>>> need to add an edit group to my menu.
>>>
>>> Den 23.03.10 20:48, skrev Edvin Syse:
>>>        
>>>> I had some luck with this rudimentary approach:
>>>>
>>>>             IProject project =
>>>> ResourcesPlugin.getWorkspace().getRoot().getProject("groovy");
>>>>             if (!project.exists()) {
>>>>                 project.create(monitor);
>>>>                 project.open(monitor);
>>>>                 ProjectDescription pdesc = new ProjectDescription();
>>>>                 pdesc.setNatureIds(new String[] {
>>>> "org.eclipse.jdt.groovy.core.groovyNature" } );
>>>>                 project.setDescription(pdesc, monitor);
>>>>             }
>>>>
>>>>             if (!project.isOpen())
>>>>                 project.open(monitor);
>>>>
>>>>             IFile controllerFile =
>>>> project.getFile("GlobalController.groovy");
>>>>             String content = "some groovy content here";
>>>>             ByteArrayInputStream in = new
>>>> ByteArrayInputStream(content.getBytes());
>>>>             controllerFile.create(in, true, monitor);
>>>>
>>>>             IEditorInput editorInput = new
>>>> FileEditorInput(controllerFile);
>>>>             UIUtils.openEditor(event, editorInput,
>>>> GroovyEditor.EDITOR_ID);
>>>>
>>>> This opens the editor with the file content, and syntaxhl works good, but
>>>> content assist does not. Also I dont have a way to monitor the save
>>>> operation of the editor, but that's probably no biggie :)
>>>>
>>>>
>>>>
>>>> Den 23.03.10 20:25, skrev Edvin Syse:
>>>>          
>>>>> Maybe I need to rethink this. To simplify my usecase:
>>>>>
>>>>> I have a String containing a Groovy script, and I want to edit it with
>>>>> the GroovyEditor. The string comees form a database, and should be saved
>>>>> back to the database when changed.
>>>>>
>>>>> Maybe I should create a normal workspace file, put the content of the
>>>>> string into that and open it with the GroovyEditor programatically. Then I
>>>>> would need to intercept save/change to the file somehow, so that I can
>>>>> update the database with the new content.
>>>>>
>>>>> What do you think of that approach?
>>>>>
>>>>> Den 23.03.10 18:41, skrev Andrew Eisenberg:
>>>>>            
>>>>>> Careful there!  IGroovyDocumentProvider is not used for the editor.
>>>>>> It is a legacy class used for refactoring and will likely be removed
>>>>>> once I start reworking refactoring support in Groovy-Eclipse.
>>>>>>
>>>>>> As for your db-document implementing ICompilationUnit, that will open
>>>>>> up a world of complications if this is really necessary.
>>>>>> GroovyCompilationUnit objects are only instantiated from within the
>>>>>> groovy-jdt integration plugin.  So, if you need to subclass GCU, it
>>>>>> will never be instantiated.
>>>>>>
>>>>>> So, I can't say exactly what you need to do (partially because I don't
>>>>>> know what you are trying to do), but I think you are on the right
>>>>>> track if you take into account what I say above.
>>>>>>
>>>>>> On Tue, Mar 23, 2010 at 9:09 AM, Edvin Syse<[hidden email]>    wrote:
>>>>>>              
>>>>>>> I think you are right. Thanks for the insight, I'll post back with a
>>>>>>> solution when I find it :) I think I'll try to make my
>>>>>>> DocumentProvider
>>>>>>> implement IGroovyDocumentProvider and make my db-document implement
>>>>>>> ICompilationUnit.. Painful :)
>>>>>>>
>>>>>>> Sincerely,
>>>>>>> Edvin Syse
>>>>>>>
>>>>>>> Den 23.03.10 16:47, skrev Andrew Eisenberg:
>>>>>>>                
>>>>>>>> It's possible that the content type of the document that you are
>>>>>>>> creating is not groovySource.  This means that your document is not
>>>>>>>> being partitiioned properly and so none of the groovy syntax
>>>>>>>> highlighting will apply. (But not sure exactly how to do this in your
>>>>>>>> situation.)
>>>>>>>>
>>>>>>>> Also, I think that you should be using a
>>>>>>>> org.eclipse.ui.editors.documentProviders extension point instead of
>>>>>>>> explicitly setting the document provider for your editor.
>>>>>>>>
>>>>>>>> On Tue, Mar 23, 2010 at 8:03 AM, Edvin Syse<[hidden email]>
>>>>>>>>   wrote:
>>>>>>>>
>>>>>>>>                  
>>>>>>>>> Thanks for your reply.
>>>>>>>>>
>>>>>>>>> Yes, createJavaSourceViewerConfiguration is not overriden, so a
>>>>>>>>> GroovyConfiguration object is returned from the implementation in
>>>>>>>>> GroovyEditor.
>>>>>>>>>
>>>>>>>>> The GroovyTagScanner is also instantiated. There are no
>>>>>>>>> additionalRules,
>>>>>>>>> additionalGroovyKeywords or additionalGJDKKeywords sent to it, but
>>>>>>>>> the
>>>>>>>>> IColorManager contains:
>>>>>>>>>
>>>>>>>>> [groovy.editor.highlight.javatypes.color=RGB {0, 0, 0},
>>>>>>>>> java_keyword=RGB
>>>>>>>>> {127, 0, 85}, groovy.editor.highlight.numbers.color=RGB {0, 0, 0},
>>>>>>>>> java_doc_keyword=RGB {127, 159, 191}, java_bracket=RGB {0, 0, 0},
>>>>>>>>> java_doc_link=RGB {63, 63, 191}, java_single_line_comment=RGB {63,
>>>>>>>>> 127,
>>>>>>>>> 95},
>>>>>>>>> java_multi_line_comment=RGB {63, 127, 95},
>>>>>>>>> groovy.editor.highlight.strings.color=RGB {0, 0, 0},
>>>>>>>>> groovy.editor.groovyDoc.link.color=RGB {0, 0, 0}, java_operator=RGB
>>>>>>>>> {0,
>>>>>>>>> 0,
>>>>>>>>> 0}, java_keyword_return=RGB {127, 0, 85},
>>>>>>>>> groovy.editor.groovyDoc.tag.color=RGB {0, 0, 0},
>>>>>>>>> groovy.editor.highlight.multilinecomments.color=RGB {0, 0, 0},
>>>>>>>>> groovy.editor.highlight.gjdk.color=RGB {0, 0, 0},
>>>>>>>>> java_doc_default=RGB
>>>>>>>>> {63,
>>>>>>>>> 95, 191}, java_comment_task_tag=RGB {127, 159, 191},
>>>>>>>>> semanticHighlighting.annotation.color=RGB {100, 100, 100},
>>>>>>>>> java_doc_tag=RGB
>>>>>>>>> {127, 127, 159}, groovy.editor.groovyDoc.keyword.color=RGB {0, 0,
>>>>>>>>> 0},
>>>>>>>>> groovy.editor.highlight.javakeywords.color=RGB {0, 0, 0},
>>>>>>>>> java_string=RGB
>>>>>>>>> {42, 0, 255}, java_default=RGB {0, 0, 0},
>>>>>>>>> groovy.editor.highlight.default.color=RGB {0, 0, 0}]
>>>>>>>>>
>>>>>>>>> Here is my complete implementation:
>>>>>>>>>
>>>>>>>>> public class GlobalControllerEditor extends GroovyEditor {
>>>>>>>>>
>>>>>>>>>     public GlobalControllerEditor() {
>>>>>>>>>         super();
>>>>>>>>>         setDocumentProvider(new GlobalControllerDocumentProvider());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     public JavaSourceViewerConfiguration
>>>>>>>>> createJavaSourceViewerConfiguration() {
>>>>>>>>>         return super.createJavaSourceViewerConfiguration();
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     protected IVerticalRulerColumn createLineNumberRulerColumn() {
>>>>>>>>>         fLineNumberRulerColumn = new GroovyLineNumberRulerColumn();
>>>>>>>>>         ((IChangeRulerColumn)
>>>>>>>>> fLineNumberRulerColumn).setHover(createChangeHover());
>>>>>>>>>         initializeLineNumberRulerColumn(fLineNumberRulerColumn);
>>>>>>>>>         return fLineNumberRulerColumn;
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     protected IVerticalRuler createVerticalRuler() {
>>>>>>>>>         return new VerticalRuler(50);
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     public void init(IEditorSite site, IEditorInput input) throws
>>>>>>>>> PartInitException {
>>>>>>>>>         super.init(site, input);
>>>>>>>>>         setPartName("Global kontroller");
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     public void doSave(IProgressMonitor progressMonitor) {
>>>>>>>>>         super.doSave(progressMonitor);
>>>>>>>>>         TornadoEditorInput input = (TornadoEditorInput)
>>>>>>>>> getEditorInput();
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>   BeanLocator.getCmsService().updateController((String)input.getModelObject());
>>>>>>>>>     }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I had to override createLineNumerRulerColumn and createVerticalRuler
>>>>>>>>> to
>>>>>>>>> avoid some NPE's. I can send the stacktraces without these if it
>>>>>>>>> would
>>>>>>>>> help.
>>>>>>>>>
>>>>>>>>> The GlobalControllerDocumentProvider basically extends
>>>>>>>>> FileDocumentProvider
>>>>>>>>> and implements createDocument and doSaveDocument, nothing special
>>>>>>>>> there.
>>>>>>>>>
>>>>>>>>> Sincerely,
>>>>>>>>> Edvin Syse
>>>>>>>>>
>>>>>>>>> Den 23.03.10 15:05, skrev Andrew Eisenberg:
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>>>> I don't think that would be the problem.  It could be any number of
>>>>>>>>>> reasons.  Is the GroovyConfiguration class being instantiated in
>>>>>>>>>> the
>>>>>>>>>> "createJavaSourceViewerConfiguration()" method?
>>>>>>>>>>
>>>>>>>>>> Also, set a breakpoint int he constructor for GroovyTagScanner.  Is
>>>>>>>>>> this class being instantiated?  What highlighting rules are being
>>>>>>>>>> sent
>>>>>>>>>> to it?
>>>>>>>>>>
>>>>>>>>>> On Mon, Mar 22, 2010 at 1:51 PM, Edvin Syse<[hidden email]>
>>>>>>>>>>   wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                      
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> I've extended GroovyEditor and uses it to edit groovy-scripts
>>>>>>>>>>> stored in
>>>>>>>>>>> a
>>>>>>>>>>> database. Hence, I use a custom DocumentProvider and the
>>>>>>>>>>> EditorInput
>>>>>>>>>>> does
>>>>>>>>>>> not extend IFileEditorInput. I suspect that for this reason I
>>>>>>>>>>> don't get
>>>>>>>>>>> syntax highlight and code assist.
>>>>>>>>>>>
>>>>>>>>>>> Can someone point towards a workaround for this? It's really a
>>>>>>>>>>> pain
>>>>>>>>>>> having
>>>>>>>>>>> to support IFileEditorInput when I don't need it :)
>>>>>>>>>>>
>>>>>>>>>>> Sincerely,
>>>>>>>>>>> Edvin Syse
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>>>
>>>>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>                        
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>>
>>>>>>>>>>      http://xircles.codehaus.org/manage_email
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>                      
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>>
>>>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>>
>>>>>>>>      http://xircles.codehaus.org/manage_email
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                  
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe from this list, please visit:
>>>>>>>
>>>>>>>    http://xircles.codehaus.org/manage_email
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe from this list, please visit:
>>>>>>
>>>>>>      http://xircles.codehaus.org/manage_email
>>>>>>
>>>>>>
>>>>>>              
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe from this list, please visit:
>>>>>
>>>>>    http://xircles.codehaus.org/manage_email
>>>>>
>>>>>
>>>>>            
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>    http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>          
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>>        
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>>      
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>    

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

AW: [groovy-eclipse-plugin-dev] Extend GroovyEditor -> support none-file resources

Jayet, Patrick
Hi Edvin,

I had the same problem than you (open a Groovy editor for a Groovy string). I could not find a solution for syntax hilighting and code completion going the way of implementing a DocumentProvider.

I finally found another way which is working (without creating a real file). Let me describe it here:

- I implement an editor input FooEditorInput which is a subclass of IStorageEditorInput

- I implement FooStorage which is a subclass of IStorage. It contains my Groovy string and is a member of FooEditorInput

In there, I am overriding the following methods:

    @Override
    public InputStream getContents() throws CoreException {
        return new ByteArrayInputStream(myGroovyString.getBytes());
    }

    @Override
    public String getName() {
        // this name is not used excepted for activating suffix-based syntax highlighting
        return "file.groovy";
    }

- In FooEditorInput I override the following method:

    @Override
    public IStorage getStorage() throws CoreException {
        return fooStorage;
    }

- I have subclassed the GroovyEditor because I was getting some NPE (I had to tune a few things in createPartControl)

- Then I am showing my editor normally (in my case as a subpage of a main editor)

        FooEditor groovyEditor = new FooEditor();
        FooEditorInput input = new FooEditorInput(...);
        addPage(groovyEditor, input);

I think that's all. I am then getting the syntax highlighting and code completion working correctly. I hope that I have mentioned everything, since I have done that some time ago already.

Hope it helps.
Cheers,

Patrick


P.S. I think that the problem that we had (non-file based editor without syntax hilighting) is not specific to the GroovyEditor but is an issue wrt to Eclipse RCP in general.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: AW: [groovy-eclipse-plugin-dev] Extend GroovyEditor -> support none-file resources

Edvin Syse
Hi Patrick

Thank you very much! My current solution works, but this is a lot
better. I'll get around to trying it out in a couple of weeks, busy with
other projects right now :)

-- Edvin

> Hi Edvin,
>
> I had the same problem than you (open a Groovy editor for a Groovy string). I could not find a solution for syntax hilighting and code completion going the way of implementing a DocumentProvider.
>
> I finally found another way which is working (without creating a real file). Let me describe it here:
>
> - I implement an editor input FooEditorInput which is a subclass of IStorageEditorInput
>
> - I implement FooStorage which is a subclass of IStorage. It contains my Groovy string and is a member of FooEditorInput
>
> In there, I am overriding the following methods:
>
>      @Override
>      public InputStream getContents() throws CoreException {
>          return new ByteArrayInputStream(myGroovyString.getBytes());
>      }
>
>      @Override
>      public String getName() {
>          // this name is not used excepted for activating suffix-based syntax highlighting
>          return "file.groovy";
>      }
>
> - In FooEditorInput I override the following method:
>
>      @Override
>      public IStorage getStorage() throws CoreException {
>          return fooStorage;
>      }
>
> - I have subclassed the GroovyEditor because I was getting some NPE (I had to tune a few things in createPartControl)
>
> - Then I am showing my editor normally (in my case as a subpage of a main editor)
>
>          FooEditor groovyEditor = new FooEditor();
>          FooEditorInput input = new FooEditorInput(...);
>          addPage(groovyEditor, input);
>
> I think that's all. I am then getting the syntax highlighting and code completion working correctly. I hope that I have mentioned everything, since I have done that some time ago already.
>
> Hope it helps.
> Cheers,
>
> Patrick
>
>
> P.S. I think that the problem that we had (non-file based editor without syntax hilighting) is not specific to the GroovyEditor but is an issue wrt to Eclipse RCP in general.
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>    

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email