Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [Dltk-dev] Re: DLTK Editor Interaction

Hi all,

Small addition to Andrei's detailed message:
discardWorkingCopy() should be called when you finish editing the file, i.e. editor is disposed or editor input is changed.
This method removes the 'working copy' status of the source module.

Regards,
Alex

----- Original Message -----
From: "Andrei Sovolev" <andrei.sobolev@xxxxxxxxx>
To: ramang@xxxxxxx
Cc: "DLTK Developer Discussions" <dltk-dev@xxxxxxxxxxx>
Sent: Tuesday, April 28, 2009 5:09:27 PM GMT +06:00 Almaty, Novosibirsk
Subject: [Dltk-dev] Re: DLTK Editor Interaction


Hi Raman, 

DLTK support working copy management so it is possibly to modify module buffer content directly. 

Please do following steps in your editor: 

1) On opening of editor please call ISourceModule.becomeWorkingCopy(IProblemRequestor requestor, IProgressMonitor monitor) method. 
This method will mark source module as working copy. Content will be shared with different editors. 

2) Then you modify your editor please call ISourceModule.getBuffer().setContents(String contents) method. 
This method will set content of current buffer used for module. 
But this operation doesn't trigger model delta processing of new source. 

To force model delta processing please call ISourceModule.reconcile(boolean forceProblemDetection, WorkingCopyOwner owner, IProgressMonitor monitor) method. 
You need to pass owner as null. 
This method will will process delta changes for module source code (parser will be called). 

3) Then you need to save editor please all ISourceModule.commitWorkingCopy(boolean force, IProgressMonitor monitor) method. 
Module content will be saved. 

If you need to discard module changes please use ISourceModule.discardWorkingCopy() method. 

Best regards, 
Andrei Sobolev. 







Hi Raman, 


Thank you very much for sharing definitely interesting use-case. >From DLTK standpoint changes propagation from graphical editor back to the source should be done via the mechanism similar to JDT's AST Rewrite. AST Rewrite allows you to change AST nodes (corresponding to your graphical element(s)) and changes to AST transforms source code accordingly. This would allow you fine-grained modifications of the sources. 


Unfortunately DLTK do not support AST Rewrite yet, moreover you'd need some support for this mechanism from your language-specific plugin since DLTK is language-independent framework. AFAIK PDT guys have some work done in this area so you may try to look at PDT sources. 


Anyway, AST rewrite implementation is a challenging task, so for now the only way we can suggest is to regenerate source code completely using your graphical information. Of course this solution is far from good, since a) you'd need to keep all the information within graphical parts (including comments) b) you'd loose source code formatting, etc... But I hope such approach may work for you as a proof of two-way editing concept. 


Please let me know if you need more information/thoughts. 


Kind Regards, 
Andrey 

----- Original Message ----- 
From: "Raman Grover" <ramang@xxxxxxx> 
To: "Andrey Platov" <andrey@xxxxxxxxx> 
Cc: "Michael Carey" <mjcarey@xxxxxxxxxxx> , gabipetrovay@xxxxxxxxx , "aatish mandelecha" <aatish.mandelecha@xxxxxxxxx> 
Sent: Tuesday, April 28, 2009 1:42:41 AM GMT +06:00 Almaty, Novosibirsk 
Subject: Re: DLTK Editor Interaction 

Hi , 

Please find attached a document that elaborates the use case (discussed 
previously in the thread). 

Please suggest as to how the DLTK-team feels about the use case and what 
can be a way ahead ? 

> Raman, could you please elaborate on your language nature, and which 
> technologies you're using to build graphical editor for the project? 

Answers: 
The Editor described is primarily for XQuery.For the Graphical Editor, GEF 
would be be used. The work is part of Open II project, headed by Professor 
Michael Carey at UCI. 


Regards, 
Raman 


On Tue, April 21, 2009 11:26 am, Andrey Platov wrote: 
> Hi Folks, 
> 
> I guess such a use-case would be interested to DLTK, however I'd also 
> like to point Raman to Xtext project. Also Webtools' Structured Text 
> Editor + GMF-based editor could be a great solution for XML-based 
> languages. 
> 
> Raman, could you please elaborate on your language nature, and which 
> technologies you're using to build graphical editor for the project? 
> 
> Thank you very much, and 
> Kind Regards, 
> Andrey 
> 
> 
> 
> On Apr 20, 2009, at 2:46 PM, Raman Grover wrote: 
> 
>> Hi 
>> 
>> I am Raman Grover, a graduate student at the University of California, 
>> Irvine. I have a small question in relation to Eclipse DLTK. Please 
>> help 
>> me in answering this. 
>> 
>> Consider a case where one needs to have a graphical editor and a text 
>> editor for a language. The text editor is implemented using DLTK. The 
>> graphical editor must generate source code which is editable from 
>> the text 
>> editor and vice versa. 
>> 
>> Since DLTK monitors the text editor, it calls the parse method 
>> (implemented by the editor developer) to check for syntax errors. The 
>> graphical editor needs to communicate with the text editor and feed it 
>> with the generated source code. The text editor gets notified 
>> whenever the 
>> source code changes as the parse( ) method is called. However, the 
>> source 
>> code can also change when graphical editor changes the source code and 
>> hence DLTK must be informed so that it can update its internal data 
>> structures holding information about the source file contents. 
>> 
>> 
>> Please suggest ! 
>> 
>> Thank You ! 
>> 
>> Raman Grover 
>> I love Eclipse ! 
>> 
>> 
>> ModuleDecleration parse(char[] filename[], char [] source, IReporter 
>> reporter) so 
>> that DLTK framework gets to call the parse method, whenever the source 
>> code in the 
>> editor changes. 
>> I need to build a graphical editor which generates source code and 
>> feeds 
>> into the 
>> DLTK framework instead of user typing the source code by hand. 
>> 
>> 
>> 
> 
> 


_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev


Back to the top