DLTK Freemarker Plugin. and Autocompletion with DataModel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
Hi Daniel,

I have attached screen test_autocompletion.png to show you
autocompletion in action. There is a lot of thing to do, but code
assist satrt working. You can see that autocompletion display :

* fields of POJO Product. I have display the field value but I don't
know if it's a good idea? Perhaps it should be better to display field
Type? But it's not easy for me because I'm using TemplateModel
interface and this interface doesn't retuens this information.
 * methods of POJO Product. There is problem with method parameters.
How can I get it from the TemplateModel?

test_autocompletion_xml.png show you teh autocompletion with XML
DataModel (your XML book sample). As you can see there is a lot of
problems, I must filter instance because today chapter is display
several thing.

The autocmpletion use the Java instance model coming from Data-Model
(and not the metadata). It means that user must fill the whole fields
to have a pertinent autocompletion . Do you understand what I mean? If
you udenrstand, do you think it's a good? I don't know how use
metadata?

To manage the autocompletion, I have created
https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal/src/freemarker/provisionnal/ext/ide/TemplateEntriesModel.java
which is  eanble to :

* get key/values of DataModel
* search with path the list of Data-Model accorfing a key (content
types by user. In this case latestProduc is used to retrieve url,
class... fields).

I have start to create Junit
https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelTestCase.java
and
https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelXMLTestCase.java

Perhaps you could see and help me to improve the TemplateEntriesModel
(do you think name is ok?).

I would like improve a lot like  show build-in (according type of teh
expression data-model. Ex : display node_type for XML bode)

Is it possible to play with the autocompletion? I would like know if
you like this. For instance you must type '${' + Ctrl+Space to display
autompletion and show fields used for interpolation. Do you like that?
Do you prefer type Ctrl+Space (without ${ and autompltion display?)

Sorry for my lot of questions. Don't hesitate to give me your suggestions.

Thank a lot!

Regards Angelo

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel

test_autocompletion.png (36K) Download Attachment
test_autocompletion_xml.png (33K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
Friday, July 23, 2010, 8:46:33 PM, Angelo zerr wrote:

> Hi Daniel,
>
> I have attached screen test_autocompletion.png to show you
> autocompletion in action. There is a lot of thing to do, but code
> assist satrt working. You can see that autocompletion display :
>
> * fields of POJO Product. I have display the field value but I don't
> know if it's a good idea? Perhaps it should be better to display field
> Type? But it's not easy for me because I'm using TemplateModel
> interface and this interface doesn't retuens this information.

As far a template is concerned, the type of a value directly
corresponds to the particular TemplateModel interface(s) it
implements. To visualize the type, you could just show the values with
FTL literal syntax for strings, numbers and booleans. For Dates you
could use ISO format maybe. For others just could just print the FTL
types that the value implements (with italic or with different color
or something, so it's obvious that it's the type, not the value).

>  * methods of POJO Product. There is problem with method parameters.
> How can I get it from the TemplateModel?

TemplateMethodModel (and TemplateDirectiveModel-s) can have arbitrary
number of parameters (only the result can be *runtime* error if the
method/directive doesn't like the parameter list, but it's a fully
runtime decision made by the method/directive itself), so you can't
extract that information purely by using TemplateModel API-s. What you
can do is exploiting that you know BeansWrapper, and so if the value
was wrapped with that (or with some other wrapper that you know), thus
you can use BeansWrapper-specific API-s to extract the wrapped POJO.
Then you can do things like showing the parameter list, and the class
of the *wrapped* object. This last could be quite handy BTW.

> test_autocompletion_xml.png show you teh autocompletion with XML
> DataModel (your XML book sample). As you can see there is a lot of
> problems, I must filter instance because today chapter is display
> several thing.

Also of course showing the IDE-specific classes
(freemarker.provisional) is not good. It should show the classes that
the actual wrapper has used (XML is not necessarily wrapped with
freemarker.ext.dom).

> The autocmpletion use the Java instance model coming from Data-Model
> (and not the metadata).

What metadata do you mean here?

> It means that user must fill the whole fields
> to have a pertinent autocompletion.

Which fields for the the auto-completion of what part? You mean, if I
have to type the whole "latestProducts." thing to get the names of
it's sub-variables? That's of course good that way.

> Do you understand what I mean?

I'm afraid I don't...

> If you udenrstand, do you think it's a good? I don't know how use
> metadata?
>
> To manage the autocompletion, I have created
> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal/src/freemarker/provisionnal/ext/ide/TemplateEntriesModel.java
> which is  eanble to :
>
> * get key/values of DataModel
> * search with path the list of Data-Model accorfing a key (content
> types by user. In this case latestProduc is used to retrieve url,
> class... fields).
>
> I have start to create Junit
> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelTestCase.java
> and
> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelXMLTestCase.java
>
> Perhaps you could see and help me to improve the TemplateEntriesModel
> (do you think name is ok?).

Well, I don't fully get the concept yet. Yeah, I guess I should read
more of the source-code... Still, let me put some questions for now.

If I understand well, this is something that helps the IDE in showing
hints and do auto-completion. But why is it a TemplateModel then?
TemplateModel interfaces correspond to the types in the type-system of
FTL. Surely you don't plan to extend that (or do you?).

Also, the doc string of the class says "store list of the keys/values
of a {@link TemplateHashModelEx}.", which isn't enough to grasp the
role of this class, as TemplateHashModelEx can already list its own
keys and values.

There is also some kind of terminological issues here, and I wouldn't
be fussy about that for now if it's only in the javadocs, but it's
reflected in the method names too: you have "findDataModel". But there
is only one data-model. Data-model is the whole stuff that you pass to
Template.process: template + data-model = output. It has values inside
it, possibly accessible with string keys or integer indexes or with
enumeration; those aren't called data-models themselves, those are
just values in the data-model. (Even methods are values in FTL.)

BTW, what's up with the CLA? I'm asking because some of these classes
meant to be moved into freemarker.jar later.

> I would like improve a lot like  show build-in (according type of teh
> expression data-model. Ex : display node_type for XML bode)
>
> Is it possible to play with the autocompletion? I would like know if
> you like this. For instance you must type '${' + Ctrl+Space to display
> autompletion and show fields used for interpolation. Do you like that?
> Do you prefer type Ctrl+Space (without ${ and autompltion display?)

I promise I will try this thing... certainly today. (If not, then I
will not be around for 3 days. /-:)

> Sorry for my lot of questions. Don't hesitate to give me your suggestions.
>
> Thank a lot!
>
> Regards Angelo

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
I tried to test the plugin briefly, on a clean Helios installation
that has nothing installed but the DLTK 2.0 plugin. I pressed "Launch
an Eclipse application" for the org.eclipse.dltk.freemarker.ui bundle,
then in the newly launched Eclipse I created a new Java project, added
FreeMarker nature to it, and started creating a model provider
class... then it become almost irresponsible, and logged
"java.lang.OutOfMemoryError: PermGen space" errors. I modified the
launch configuration by adding "-XX:MaxPermSize=160m" to the VM
arguments to fix this. I'm telling this so that if someone else wants
to test the stuff, that's the solution for this issue.

I created an FTL file in the com.example package (BTW, I haven't found
FreeMarker category when creating new file, so I just created it as
plain a file, not as an FTL file), but when I save it, I get:

  Error while saving settings
    Resource '/MyFMDLTKTest/.metadata/fm/src/com/example' does not exist.

I assume the plugin forgets to create the missing directories
automatically. I created them manually to work this around.

The auto completion worked after '${', but not after something '${1+'
like. Surely you know that though; auto-completion should work on all
places where a variable name can occur. I also tried it after stuff
like '${aProduct.', which worked as expected.

An usability challenge with auto-completion and the data-model
inspector in general is that it lists a lot of "noise" keys, like
getClass, equals, hashCode, etc. These should be hidden by default in
the Data-Model Details view, and should be listed after the others in
the auto-completion lists. Especially, if you are using BeansWrapper
instead of the DefaultObjectWrapper (that wrapper can spoil a lot of
things in this plugin, and it's a widely-used wrapper, so the plugin
should know it and react intelligently), even numbers will have a lot
of exposed methods and like... those should be seldom visible.

I notice that the project-level configurations and data-models aren't
available under the project properties (only under the corresponding
tabs of FTL files). These should be there later, of course.

I create a configuration provider, but when I associated it with the
template, the preview died with this:

  org.eclipse.dltk.freemarker.core.settings.provider.InstanceProviderException: CONFIGURATION provider problem.
  java.lang.reflect.InvocationTargetException
        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:504)
        [snip]
  Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.eclipse.dltk.freemarker.core.util.ClassUtils.execute(ClassUtils.java:54)
        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:468)
        ... 45 more
  Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
        at freemarker.log.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:65)
        at freemarker.log.Logger.getLogger(Logger.java:255)
        at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
        at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
        at com.example.MyConfigurationProvider.getConfiguration(MyConfigurationProvider.java:10)
        ... 51 more
  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
        [snip]

Maybe a FreeMarker bug with freemarker.log.Logger.LIBRARY_AUTO? Don't
know, I just worked this around be adding this to the configuration
provider method:

  freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);

Something I noticed is that when I change and save the model provider,
the contents of the data-model tab is not updated. I guess it's
difficult to register some kind of listener for automatically updating
it, so a "refresh" would be nice.

Also, small thing, but auto-completion for the provider method names
doesn't work.


Sunday, July 25, 2010, 1:16:05 PM, Daniel Dekany wrote:

> Friday, July 23, 2010, 8:46:33 PM, Angelo zerr wrote:
>
>> Hi Daniel,
>>
>> I have attached screen test_autocompletion.png to show you
>> autocompletion in action. There is a lot of thing to do, but code
>> assist satrt working. You can see that autocompletion display :
>>
>> * fields of POJO Product. I have display the field value but I don't
>> know if it's a good idea? Perhaps it should be better to display field
>> Type? But it's not easy for me because I'm using TemplateModel
>> interface and this interface doesn't retuens this information.
>
> As far a template is concerned, the type of a value directly
> corresponds to the particular TemplateModel interface(s) it
> implements. To visualize the type, you could just show the values with
> FTL literal syntax for strings, numbers and booleans. For Dates you
> could use ISO format maybe. For others just could just print the FTL
> types that the value implements (with italic or with different color
> or something, so it's obvious that it's the type, not the value).
>
>>  * methods of POJO Product. There is problem with method parameters.
>> How can I get it from the TemplateModel?
>
> TemplateMethodModel (and TemplateDirectiveModel-s) can have arbitrary
> number of parameters (only the result can be *runtime* error if the
> method/directive doesn't like the parameter list, but it's a fully
> runtime decision made by the method/directive itself), so you can't
> extract that information purely by using TemplateModel API-s. What you
> can do is exploiting that you know BeansWrapper, and so if the value
> was wrapped with that (or with some other wrapper that you know), thus
> you can use BeansWrapper-specific API-s to extract the wrapped POJO.
> Then you can do things like showing the parameter list, and the class
> of the *wrapped* object. This last could be quite handy BTW.
>
>> test_autocompletion_xml.png show you teh autocompletion with XML
>> DataModel (your XML book sample). As you can see there is a lot of
>> problems, I must filter instance because today chapter is display
>> several thing.
>
> Also of course showing the IDE-specific classes
> (freemarker.provisional) is not good. It should show the classes that
> the actual wrapper has used (XML is not necessarily wrapped with
> freemarker.ext.dom).
>
>> The autocmpletion use the Java instance model coming from Data-Model
>> (and not the metadata).
>
> What metadata do you mean here?
>
>> It means that user must fill the whole fields
>> to have a pertinent autocompletion.
>
> Which fields for the the auto-completion of what part? You mean, if I
> have to type the whole "latestProducts." thing to get the names of
> it's sub-variables? That's of course good that way.
>
>> Do you understand what I mean?
>
> I'm afraid I don't...
>
>> If you udenrstand, do you think it's a good? I don't know how use
>> metadata?
>>
>> To manage the autocompletion, I have created
>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal/src/freemarker/provisionnal/ext/ide/TemplateEntriesModel.java
>> which is  eanble to :
>>
>> * get key/values of DataModel
>> * search with path the list of Data-Model accorfing a key (content
>> types by user. In this case latestProduc is used to retrieve url,
>> class... fields).
>>
>> I have start to create Junit
>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelTestCase.java
>> and
>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelXMLTestCase.java
>>
>> Perhaps you could see and help me to improve the TemplateEntriesModel
>> (do you think name is ok?).
>
> Well, I don't fully get the concept yet. Yeah, I guess I should read
> more of the source-code... Still, let me put some questions for now.
>
> If I understand well, this is something that helps the IDE in showing
> hints and do auto-completion. But why is it a TemplateModel then?
> TemplateModel interfaces correspond to the types in the type-system of
> FTL. Surely you don't plan to extend that (or do you?).
>
> Also, the doc string of the class says "store list of the keys/values
> of a {@link TemplateHashModelEx}.", which isn't enough to grasp the
> role of this class, as TemplateHashModelEx can already list its own
> keys and values.
>
> There is also some kind of terminological issues here, and I wouldn't
> be fussy about that for now if it's only in the javadocs, but it's
> reflected in the method names too: you have "findDataModel". But there
> is only one data-model. Data-model is the whole stuff that you pass to
> Template.process: template + data-model = output. It has values inside
> it, possibly accessible with string keys or integer indexes or with
> enumeration; those aren't called data-models themselves, those are
> just values in the data-model. (Even methods are values in FTL.)
>
> BTW, what's up with the CLA? I'm asking because some of these classes
> meant to be moved into freemarker.jar later.
>
>> I would like improve a lot like  show build-in (according type of teh
>> expression data-model. Ex : display node_type for XML bode)
>>
>> Is it possible to play with the autocompletion? I would like know if
>> you like this. For instance you must type '${' + Ctrl+Space to display
>> autompletion and show fields used for interpolation. Do you like that?
>> Do you prefer type Ctrl+Space (without ${ and autompltion display?)
>
> I promise I will try this thing... certainly today. (If not, then I
> will not be around for 3 days. /-:)
>
>> Sorry for my lot of questions. Don't hesitate to give me your suggestions.
>>
>> Thank a lot!
>>
>> Regards Angelo
>

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
In reply to this post by Daniel Dekany
Hi Daniel,

> As far a template is concerned, the type of a value directly
> corresponds to the particular TemplateModel interface(s) it
> implements. To visualize the type, you could just show the values with
> FTL literal syntax for strings, numbers and booleans. For Dates you
> could use ISO format maybe. For others just could just print the FTL
> types that the value implements (with italic or with different color
> or something, so it's obvious that it's the type, not the value).

It looks like that I have done . No?

* url field display the String value "product/greenmouse.html"
* what class parameter should display? FM BeanModel class?

>
>>  * methods of POJO Product. There is problem with method parameters.
>> How can I get it from the TemplateModel?
>
> TemplateMethodModel (and TemplateDirectiveModel-s) can have arbitrary
> number of parameters (only the result can be *runtime* error if the
> method/directive doesn't like the parameter list, but it's a fully
> runtime decision made by the method/directive itself), so you can't
> extract that information purely by using TemplateModel API-s. What you
> can do is exploiting that you know BeansWrapper, and so if the value
> was wrapped with that (or with some other wrapper that you know), thus
> you can use BeansWrapper-specific API-s to extract the wrapped POJO.
> Then you can do things like showing the parameter list, and the class
> of the *wrapped* object. This last could be quite handy BTW.

Ok thank a lot for this information. I will try it.

>
>> test_autocompletion_xml.png show you teh autocompletion with XML
>> DataModel (your XML book sample). As you can see there is a lot of
>> problems, I must filter instance because today chapter is display
>> several thing.
>
> Also of course showing the IDE-specific classes
> (freemarker.provisional) is not good. It should show the classes that
> the actual wrapper has used (XML is not necessarily wrapped with
> freemarker.ext.dom).

I'm using TemplateNodeModel interface to get some informations (like
children node). You mean that we should display :

chapter - org.w3c.dom.Element
title - org.w3c.dom.Element
@text - ????? (I have not studied what it means)

>
>> The autocmpletion use the Java instance model coming from Data-Model
>> (and not the metadata).
>
> What metadata do you mean here?

Ok sorry with my very bad explanation. JBoss Freemarker plugin give
the capability to define Data-Model which is used for autocmpletion
but only with Metatada Java Class. You have a Context tab which
contains a list an you can add row to this list with key/value where
value is a Java Class. Ex :

key  | value
user | java.lang.String
lastetProduct | com.mycompany.Product

Autocompletion use this configuration. I call that Metadata means.
Plugin use Metadata class to manage autocompletion.

In my case Data-Model is managed with Instance. I prefer that because
you can preview the template+model and Data-Model looks like
Data-Model used into a real application.

>
>> It means that user must fill the whole fields
>> to have a pertinent autocompletion.

Imagine you have a Data-Model User which have getter Role. If the
DataModel provider don't instantiate the Role linked to the User,
Autompletion will not display role field. Do you understand the
problem?

>
> Which fields for the the auto-completion of what part? You mean, if I
> have to type the whole "latestProducts." thing to get the names of
> it's sub-variables? That's of course good that way.
>
>> Do you understand what I mean?
>
> I'm afraid I don't...

Hope you will understand my explanation.

>
>> If you udenrstand, do you think it's a good? I don't know how use
>> metadata?
>>
>> To manage the autocompletion, I have created
>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal/src/freemarker/provisionnal/ext/ide/TemplateEntriesModel.java
>> which is  eanble to :
>>
>> * get key/values of DataModel
>> * search with path the list of Data-Model accorfing a key (content
>> types by user. In this case latestProduc is used to retrieve url,
>> class... fields).
>>
>> I have start to create Junit
>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelTestCase.java
>> and
>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelXMLTestCase.java
>>
>> Perhaps you could see and help me to improve the TemplateEntriesModel
>> (do you think name is ok?).
>
> Well, I don't fully get the concept yet. Yeah, I guess I should read
> more of the source-code... Still, let me put some questions for now.

Ok. TemplateEntriesModel return list of TemplateEntiyModel which can
be compared to Map.Entry (key+value). TemplateEntriesModel extends
TemplateModel because I work with TemplateModel (I use the
TemplateModel coming from ObjectWrapper OR I wrap  TemplateHashModelEx
with my TemplateEntriesModel to have directly key/value list. Do you
understand?

But pehaps this name is not very good?
>
> If I understand well, this is something that helps the IDE in showing
> hints and do auto-completion. But why is it a TemplateModel then?
> TemplateModel interfaces correspond to the types in the type-system of
> FTL. Surely you don't plan to extend that (or do you?).

I have explained that below.

>
> Also, the doc string of the class says "store list of the keys/values
> of a {@link TemplateHashModelEx}.", which isn't enough to grasp the
> role of this class, as TemplateHashModelEx can already list its own
> keys and values.
>
> There is also some kind of terminological issues here, and I wouldn't
> be fussy about that for now if it's only in the javadocs, but it's
> reflected in the method names too: you have "findDataModel". But there
> is only one data-model. Data-model is the whole stuff that you pass to
> Template.process: template + data-model = output. It has values inside
> it, possibly accessible with string keys or integer indexes or with
> enumeration; those aren't called data-models themselves, those are
> just values in the data-model. (Even methods are values in FTL.)

You are right, findDataModel method name is not very good. This method
is enable to find list of TemplateEntryModel wich are displayed for
autocompletion. I have created a JUnit at
https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesFindDataModelTestCase.java

This sample simulate the autocompletion when user type ${latestProduct.u

Which must returns url field. Hope you will understand findDataModel
with this sample :

Map<String, Object> models = new HashMap<String, Object>();
Product latestProduct = new Product();
latestProduct.setUrl("products/greenmouse.html");
latestProduct.setName("green mouse");
models.put("latestProduct", latestProduct);
               
TemplateHashModelEx hashModel = new SimpleHash(models);
TemplateEntriesModel entriesModel = new SimpleEntries(hashModel);
       
String[] paths = {"latestProduct", "u"};
entriesModel.findDataModel(paths, new TemplateModelCollector() {
               
        public void collect(TemplateModel modelKey, TemplateModel modelValue,
                        String[] paths, int indexPath) {
                //key=url, indexPath=1, value=products/greenmouse.html
                System.out.println("key="+ modelKey + ", indexPath=" + indexPath +",
value=" + modelValue);
               
                assertEquals(modelKey.toString(), "url");
                assertEquals(1, indexPath);
                assertEquals(modelValue.toString(), "products/greenmouse.html");
        }
});


>
> BTW, what's up with the CLA? I'm asking because some of these classes
> meant to be moved into freemarker.jar later.

I do it.

>
>> I would like improve a lot like  show build-in (according type of teh
>> expression data-model. Ex : display node_type for XML bode)
>>
>> Is it possible to play with the autocompletion? I would like know if
>> you like this. For instance you must type '${' + Ctrl+Space to display
>> autompletion and show fields used for interpolation. Do you like that?
>> Do you prefer type Ctrl+Space (without ${ and autompltion display?)
>
> I promise I will try this thing... certainly today. (If not, then I
> will not be around for 3 days. /-:)
Thank a lot!

>
>> Sorry for my lot of questions. Don't hesitate to give me your suggestions.
>>
>> Thank a lot!
>>
>> Regards Angelo
>
> --
> Best regards,
>  Daniel Dekany
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
Monday, July 26, 2010, 9:51:47 AM, Angelo zerr wrote:

> Hi Daniel,
>
>> As far a template is concerned, the type of a value directly
>> corresponds to the particular TemplateModel interface(s) it
>> implements. To visualize the type, you could just show the values with
>> FTL literal syntax for strings, numbers and booleans. For Dates you
>> could use ISO format maybe. For others just could just print the FTL
>> types that the value implements (with italic or with different color
>> or something, so it's obvious that it's the type, not the value).
>
> It looks like that I have done . No?
> * url field display the String value "product/greenmouse.html"

No, it shows something like

  name = product/greenmouse.html

but it should show

  name = "product/greenmouse.html"

The quotation marks would indicate clearly that it's a string.

> * what class parameter should display? FM BeanModel class?

You should display the FTL type-name, like "string", "number",
"boolean", "hash", "sequence", etc. But of course, if something is
only one of "string", "number" and "boolean", then you shouldn't print
the type name at all, because that's obvious from the value, assuming
you are using the FTL literal syntax.

You should also show the class of the *wrapped* object (in gray or
something modest) (like com.example.Product or HashMap). This
information can't always be extracted, however.

>>>  * methods of POJO Product. There is problem with method parameters.
>>> How can I get it from the TemplateModel?
>>
>> TemplateMethodModel (and TemplateDirectiveModel-s) can have arbitrary
>> number of parameters (only the result can be *runtime* error if the
>> method/directive doesn't like the parameter list, but it's a fully
>> runtime decision made by the method/directive itself), so you can't
>> extract that information purely by using TemplateModel API-s. What you
>> can do is exploiting that you know BeansWrapper, and so if the value
>> was wrapped with that (or with some other wrapper that you know), thus
>> you can use BeansWrapper-specific API-s to extract the wrapped POJO.
>> Then you can do things like showing the parameter list, and the class
>> of the *wrapped* object. This last could be quite handy BTW.
>
> Ok thank a lot for this information. I will try it.
>>
>>> test_autocompletion_xml.png show you teh autocompletion with XML
>>> DataModel (your XML book sample). As you can see there is a lot of
>>> problems, I must filter instance because today chapter is display
>>> several thing.
>>
>> Also of course showing the IDE-specific classes
>> (freemarker.provisional) is not good. It should show the classes that
>> the actual wrapper has used (XML is not necessarily wrapped with
>> freemarker.ext.dom).
>
> I'm using TemplateNodeModel interface to get some informations (like
> children node). You mean that we should display :

Above I just meant that you are showing freemarker.provisional classes
in the Data-Model Details view, and of course you shouldn't do that.

> chapter - org.w3c.dom.Element
> title - org.w3c.dom.Element
> @text - ????? (I have not studied what it means)

That's the character data enclosed by the XML element. (But I think
that's "@@text", with two "@"-s.) It's not something people often use,
as element nodes are converted to text automatically in most
use-cases.

I think that inspecting wrapped XML is a special field... (If you want
to do it well, you certainly need to read the
http://freemarker.org/docs/xgui.html part of the Manual.) I think that
in the Data-Model Details view you should just show that XML markup
(extractable with the @@markup key) as the value; you don't need to
show XML nodes as an expandable tree, as that tree is so huge and
complicated, it doesn't help in practice. However showing the markup
is also tricky as it can be long... it should be collapsed to a single
line sample by default. For auto-completion after "someXMLNode."
showing all the possible keys (see
http://freemarker.org/docs/xgui_imperative_formal.html) can be useful,
however.

>>> The autocmpletion use the Java instance model coming from Data-Model
>>> (and not the metadata).
>>
>> What metadata do you mean here?
>
> Ok sorry with my very bad explanation. JBoss Freemarker plugin give
> the capability to define Data-Model which is used for autocmpletion
> but only with Metatada Java Class. You have a Context tab which
> contains a list an you can add row to this list with key/value where
> value is a Java Class. Ex :
>
> key  | value
> user | java.lang.String
> lastetProduct | com.mycompany.Product
>
> Autocompletion use this configuration. I call that Metadata means.
> Plugin use Metadata class to manage autocompletion.
>
> In my case Data-Model is managed with Instance. I prefer that because
> you can preview the template+model and Data-Model looks like
> Data-Model used into a real application.

OK.

>>
>>> It means that user must fill the whole fields
>>> to have a pertinent autocompletion.
>
> Imagine you have a Data-Model User which have getter Role. If the
> DataModel provider don't instantiate the Role linked to the User,
> Autompletion will not display role field. Do you understand the
> problem?

So, say I have "user." in the source code, and you press Ctrl+space
after it. Now even if user.role is null, since the User class has a
getRole() method and hence a "role" JavaBean property, the "user" hash
variable still has a "role" key, and so you can offer "role" in the
auto-completion. But you can't offer anything when Ctrl+space is
pressed after "user.role.", as the "role" happens to be null. That's
what you mean, right? Well, this is an unfortunate situation compared
to what the JBoss meta-data can do, but I guess we will have to live
with it. Or, if you know the object wrapper in use (like you do know
BeansWrapper, which is also what DefaultObjectWrapper falls back to
when facing user-defined classes that aren't Map-s or like), then
maybe there is a way to extract that "meta-information", after all
it's known that the "role" JavaBean property has type
com.example.Role, and the BeansWrapper also knows how it would wrap a
non-null com.example.Role, since it caches information regarding the
possible keys per class, not per instance. But that's BeansWrapper
black-magic, so ask Attila if it's already doable or if BeansWrapper
could be easily improved to support this thing.

>> Which fields for the the auto-completion of what part? You mean, if I
>> have to type the whole "latestProducts." thing to get the names of
>> it's sub-variables? That's of course good that way.
>>
>>> Do you understand what I mean?
>>
>> I'm afraid I don't...
>
> Hope you will understand my explanation.

Yes, I did now.

>>
>>> If you udenrstand, do you think it's a good? I don't know how use
>>> metadata?
>>>
>>> To manage the autocompletion, I have created
>>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal/src/freemarker/provisionnal/ext/ide/TemplateEntriesModel.java
>>> which is  eanble to :
>>>
>>> * get key/values of DataModel
>>> * search with path the list of Data-Model accorfing a key (content
>>> types by user. In this case latestProduc is used to retrieve url,
>>> class... fields).
>>>
>>> I have start to create Junit
>>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelTestCase.java
>>> and
>>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesModelXMLTestCase.java
>>>
>>> Perhaps you could see and help me to improve the TemplateEntriesModel
>>> (do you think name is ok?).
>>
>> Well, I don't fully get the concept yet. Yeah, I guess I should read
>> more of the source-code... Still, let me put some questions for now.
>
> Ok. TemplateEntriesModel return list of TemplateEntiyModel which can
> be compared to Map.Entry (key+value). TemplateEntriesModel extends
> TemplateModel because I work with TemplateModel (I use the
> TemplateModel coming from ObjectWrapper OR I wrap  TemplateHashModelEx
> with my TemplateEntriesModel to have directly key/value list. Do you
> understand?

Kind of, but what you are saying sound suspiciously to me. These
TemplateModel-s inside the freemarker.provisional package you only
need for the plugin functionality. But the plugin (as opposed to
FreeMarker) doesn't have to expect that the tree only contains
TemplateModel-s. It can introduce its own family of interfaces, like
DataInspectionHelper-s or something. Then it becomes obvious what is
indeed part of the data-model, and what's only inserted into it to
help the plugin, and hence should remain hidden from the user as an
internal implementation detail.

> But pehaps this name is not very good?

What I find problematic here is that you classify these things as
TemplateModel-s (which is itself a horrible name, but I wasn't here
yet when it happened). But see above. If we will agree on that, then
that will naturally lead to a different class name.

>> If I understand well, this is something that helps the IDE in showing
>> hints and do auto-completion. But why is it a TemplateModel then?
>> TemplateModel interfaces correspond to the types in the type-system of
>> FTL. Surely you don't plan to extend that (or do you?).
>
> I have explained that below.
>
>>
>> Also, the doc string of the class says "store list of the keys/values
>> of a {@link TemplateHashModelEx}.", which isn't enough to grasp the
>> role of this class, as TemplateHashModelEx can already list its own
>> keys and values.
>>
>> There is also some kind of terminological issues here, and I wouldn't
>> be fussy about that for now if it's only in the javadocs, but it's
>> reflected in the method names too: you have "findDataModel". But there
>> is only one data-model. Data-model is the whole stuff that you pass to
>> Template.process: template + data-model = output. It has values inside
>> it, possibly accessible with string keys or integer indexes or with
>> enumeration; those aren't called data-models themselves, those are
>> just values in the data-model. (Even methods are values in FTL.)
>
> You are right, findDataModel method name is not very good. This method
> is enable to find list of TemplateEntryModel wich are displayed for
> autocompletion. I have created a JUnit at
> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesFindDataModelTestCase.java
>
> This sample simulate the autocompletion when user type ${latestProduct.u
>
> Which must returns url field. Hope you will understand findDataModel
> with this sample :
>
> Map<String, Object> models = new HashMap<String, Object>();        
> Product latestProduct = new Product();
> latestProduct.setUrl("products/greenmouse.html");
> latestProduct.setName("green mouse");          
> models.put("latestProduct", latestProduct);
>                
> TemplateHashModelEx hashModel = new SimpleHash(models);
> TemplateEntriesModel entriesModel = new SimpleEntries(hashModel);
>        
> String[] paths = {"latestProduct", "u"};

(Misnomer here... This is not "paths", this is the "path" itself,
which of course usually consist of multiple steps.)

> entriesModel.findDataModel(paths, new TemplateModelCollector() {
>                
>         public void collect(TemplateModel modelKey, TemplateModel modelValue,
>                         String[] paths, int indexPath) {

Should be called "indexInPath" or "pathIndex". "indexPath" rather
means the "path of the index" in English.

>                 //key=url, indexPath=1, value=products/greenmouse.html
>                 System.out.println("key="+ modelKey + ", indexPath=" + indexPath +",
> value=" + modelValue);
>                
>                 assertEquals(modelKey.toString(), "url");
>                 assertEquals(1, indexPath);
>                 assertEquals(modelValue.toString(), "products/greenmouse.html");

Doesn't this always auto-complete the last step of the path? If so,
what's the paths + pathIndex parameters for?

>         }
> });
>
>
>>
>> BTW, what's up with the CLA? I'm asking because some of these classes
>> meant to be moved into freemarker.jar later.
>
> I do it.
>
>>
>>> I would like improve a lot like  show build-in (according type of teh
>>> expression data-model. Ex : display node_type for XML bode)
>>>
>>> Is it possible to play with the autocompletion? I would like know if
>>> you like this. For instance you must type '${' + Ctrl+Space to display
>>> autompletion and show fields used for interpolation. Do you like that?
>>> Do you prefer type Ctrl+Space (without ${ and autompltion display?)
>>
>> I promise I will try this thing... certainly today. (If not, then I
>> will not be around for 3 days. /-:)
> Thank a lot!
>>
>>> Sorry for my lot of questions. Don't hesitate to give me your suggestions.
>>>
>>> Thank a lot!
>>>
>>> Regards Angelo
>>
>> --
>> Best regards,
>>  Daniel Dekany

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
In reply to this post by Daniel Dekany
Hi Daniel,

Thank a lot to have testing the plugin. So many bugs you have founded
-( Hope you are not disapointed with the plugin.

2010/7/25 Daniel Dekany <[hidden email]>:

> I tried to test the plugin briefly, on a clean Helios installation
> that has nothing installed but the DLTK 2.0 plugin. I pressed "Launch
> an Eclipse application" for the org.eclipse.dltk.freemarker.ui bundle,
> then in the newly launched Eclipse I created a new Java project, added
> FreeMarker nature to it, and started creating a model provider
> class... then it become almost irresponsible, and logged
> "java.lang.OutOfMemoryError: PermGen space" errors. I modified the
> launch configuration by adding "-XX:MaxPermSize=160m" to the VM
> arguments to fix this. I'm telling this so that if someone else wants
> to test the stuff, that's the solution for this issue.

Thanks Daniel. In my case I had not the problem. I will modify the
documentation (or is it possible to modify the documentation with
screen to explain how resolve the problem. If you have not time I will
do that but it's difficult for me to do screen because I have not the
problem.

>
> I created an FTL file in the com.example package (BTW, I haven't found
> FreeMarker category when creating new file, so I just created it as
> plain a file, not as an FTL file), but when I save it, I get:
>
>  Error while saving settings
>    Resource '/MyFMDLTKTest/.metadata/fm/src/com/example' does not exist.
>
> I assume the plugin forgets to create the missing directories
> automatically. I created them manually to work this around.

Ouch -( Ok I hav e fixed this problem. You can synchronise with the
org.eclipse.dltk.freemarker.core and problem should be resolved.

>
> The auto completion worked after '${', but not after something '${1+'
> like. Surely you know that though; auto-completion should work on all
> places where a variable name can occur. I also tried it after stuff
> like '${aProduct.', which worked as expected.

You are right, I must manage this case with '+' character. It means I
must manage several operator :

* +
* -
* *
* /
* >
* <

Do you know another case?

>
> An usability challenge with auto-completion and the data-model
> inspector in general is that it lists a lot of "noise" keys, like
> getClass, equals, hashCode, etc. These should be hidden by default in
> the Data-Model Details view, and should be listed after the others in
> the auto-completion lists. Especially, if you are using BeansWrapper
> instead of the DefaultObjectWrapper (that wrapper can spoil a lot of
> things in this plugin, and it's a widely-used wrapper, so the plugin
> should know it and react intelligently), even numbers will have a lot
> of exposed methods and like... those should be seldom visible.

I'm using ObjectWrapper coming from the Configuration (if you
specified a Configuration Provider) and DefaultObjectWrapper
otherwise. This wrapper returns me getClass, hashCode... I don't
understand why I must filter it if Freemarker can use it?

>
> I notice that the project-level configurations and data-models aren't
> available under the project properties (only under the corresponding
> tabs of FTL files). These should be there later, of course.

Yes, my TODO list contains this feature.

>
> I create a configuration provider, but when I associated it with the
> template, the preview died with this:
>
>  org.eclipse.dltk.freemarker.core.settings.provider.InstanceProviderException: CONFIGURATION provider problem.
>  java.lang.reflect.InvocationTargetException
>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:504)
>        [snip]
>  Caused by: java.lang.reflect.InvocationTargetException
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at org.eclipse.dltk.freemarker.core.util.ClassUtils.execute(ClassUtils.java:54)
>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:468)
>        ... 45 more
>  Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
>        at freemarker.log.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:65)
>        at freemarker.log.Logger.getLogger(Logger.java:255)
>        at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
>        at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
>        at com.example.MyConfigurationProvider.getConfiguration(MyConfigurationProvider.java:10)
>        ... 51 more
>  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
>        [snip]
>
> Maybe a FreeMarker bug with freemarker.log.Logger.LIBRARY_AUTO? Don't
> know, I just worked this around be adding this to the configuration
> provider method:

Indead log4j is not included to the Plugin classpath. Which
Configuration Provider have you done? In my case I have just tested
with square bracket configuration and it works.

>
>  freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
>
> Something I noticed is that when I change and save the model provider,
> the contents of the data-model tab is not updated. I guess it's
> difficult to register some kind of listener for automatically updating
> it, so a "refresh" would be nice.

Yes it's difficult. I have tried to manage that, but it seems that you
have founded a bug with that. This tab should be refreshed when :

* Java code is modified.
* Template settings is saved.

Perhaps I have forgotten a case? I will add a Refresh Button.

>
> Also, small thing, but auto-completion for the provider method names
> doesn't work.

Could you give me some details please. In my case it works?

Have you test Preview View. Do you like this feature?

Anyway thank a lot to have taking time to test the plugin, and I hope
the plugin please you and you are not dispaointed with bugs you have
founded.

Regards Angelo

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
In reply to this post by Daniel Dekany
>
> No, it shows something like
>
>  name = product/greenmouse.html
>
> but it should show
>
>  name = "product/greenmouse.html"
>
> The quotation marks would indicate clearly that it's a string.

Ok. It's done for TemplateScalarModel (works only for autocompletion)
. Synchronize you with freemarker.provisionnal and
org.eclipse.dltk.freemarker.core.

>
>> * what class parameter should display? FM BeanModel class?
>
> You should display the FTL type-name, like "string", "number",
> "boolean", "hash", "sequence", etc. But of course, if something is
> only one of "string", "number" and "boolean", then you shouldn't print
> the type name at all, because that's obvious from the value, assuming
> you are using the FTL literal syntax.
>
> You should also show the class of the *wrapped* object (in gray or
> something modest) (like com.example.Product or HashMap). This
> information can't always be extracted, however.

Ok. For gray color, I don't know how manage that.

>> I'm using TemplateNodeModel interface to get some informations (like
>> children node). You mean that we should display :
>
> Above I just meant that you are showing freemarker.provisional classes
> in the Data-Model Details view, and of course you shouldn't do that.
>
>> chapter - org.w3c.dom.Element
>> title - org.w3c.dom.Element
>> @text - ????? (I have not studied what it means)
>
> That's the character data enclosed by the XML element. (But I think
> that's "@@text", with two "@"-s.) It's not something people often use,
> as element nodes are converted to text automatically in most
> use-cases.
>
> I think that inspecting wrapped XML is a special field... (If you want
> to do it well, you certainly need to read the
> http://freemarker.org/docs/xgui.html part of the Manual.) I think that
> in the Data-Model Details view you should just show that XML markup
> (extractable with the @@markup key) as the value; you don't need to
> show XML nodes as an expandable tree, as that tree is so huge and
> complicated, it doesn't help in practice. However showing the markup
> is also tricky as it can be long... it should be collapsed to a single
> line sample by default. For auto-completion after "someXMLNode."
> showing all the possible keys (see
> http://freemarker.org/docs/xgui_imperative_formal.html) can be useful,
> however.
>

Ok, I will study that.

>> In my case Data-Model is managed with Instance. I prefer that because
>> you can preview the template+model and Data-Model looks like
>> Data-Model used into a real application.
>
> OK.
>
>>>
>>>> It means that user must fill the whole fields
>>>> to have a pertinent autocompletion.


>>
>> Imagine you have a Data-Model User which have getter Role. If the
>> DataModel provider don't instantiate the Role linked to the User,
>> Autompletion will not display role field. Do you understand the
>> problem?
>
> So, say I have "user." in the source code, and you press Ctrl+space
> after it. Now even if user.role is null, since the User class has a
> getRole() method and hence a "role" JavaBean property, the "user" hash
> variable still has a "role" key, and so you can offer "role" in the
> auto-completion. But you can't offer anything when Ctrl+space is
> pressed after "user.role.", as the "role" happens to be null. That's
> what you mean, right? Well, this is an unfortunate situation compared
> to what the JBoss meta-data can do, but I guess we will have to live
> with it. Or, if you know the object wrapper in use (like you do know
> BeansWrapper, which is also what DefaultObjectWrapper falls back to
> when facing user-defined classes that aren't Map-s or like), then
> maybe there is a way to extract that "meta-information", after all
> it's known that the "role" JavaBean property has type
> com.example.Role, and the BeansWrapper also knows how it would wrap a
> non-null com.example.Role, since it caches information regarding the
> possible keys per class, not per instance. But that's BeansWrapper
> black-magic, so ask Attila if it's already doable or if BeansWrapper
> could be easily improved to support this thing.

Sorry with this wrong notice (you are right). Autocompletion works
even if User#getRole() return null value. The case is more complex.
Imagine you have User#getRole() and Role#getId();

If teh Model Provider don't instiate the Role, autocmpletion :

* will works if you have ${user.  (it show you role field).
* doesn't works if you have ${user.role. (id field is not showed).

Ok I will do ask to Attila.

>
>>> Which fields for the the auto-completion of what part? You mean, if I
>>> have to type the whole "latestProducts." thing to get the names of
>>> it's sub-variables? That's of course good that way.
>>>
Ok.

>> Ok. TemplateEntriesModel return list of TemplateEntiyModel which can
>> be compared to Map.Entry (key+value). TemplateEntriesModel extends
>> TemplateModel because I work with TemplateModel (I use the
>> TemplateModel coming from ObjectWrapper OR I wrap  TemplateHashModelEx
>> with my TemplateEntriesModel to have directly key/value list. Do you
>> understand?
>
> Kind of, but what you are saying sound suspiciously to me. These
> TemplateModel-s inside the freemarker.provisional package you only
> need for the plugin functionality. But the plugin (as opposed to
> FreeMarker) doesn't have to expect that the tree only contains
> TemplateModel-s. It can introduce its own family of interfaces, like
> DataInspectionHelper-s or something. Then it becomes obvious what is
> indeed part of the data-model, and what's only inserted into it to
> help the plugin, and hence should remain hidden from the user as an
> internal implementation detail.

I want use TemplateHashModelEx because I can use ObjectWrapper that
user could customize. When I loop for TemplateHashModelEx#keys(), I'm
using the TemplateModel (key+value) managed with ObjectWrapper. I
could create another interface  DataInspectionHelper-s but it means
that I will  create new instance of TemplateScalarModel although I can
use it directly.

>
>> But pehaps this name is not very good?
>
> What I find problematic here is that you classify these things as
> TemplateModel-s (which is itself a horrible name, but I wasn't here
> yet when it happened). But see above. If we will agree on that, then
> that will naturally lead to a different class name.
>
>>> If I understand well, this is something that helps the IDE in showing
>>> hints and do auto-completion.

Right!

>>
>> You are right, findDataModel method name is not very good. This method
>> is enable to find list of TemplateEntryModel wich are displayed for
>> autocompletion. I have created a JUnit at
>> https://freemarker.svn.sourceforge.net/svnroot/freemarker/sandbox/org.eclipse.dltk.freemarker/freemarker.provisionnal.tests/src/freemarker/provisionnal/ext/ide/TemplateEntriesFindDataModelTestCase.java
>>
>> This sample simulate the autocompletion when user type ${latestProduct.u
>>
>> Which must returns url field. Hope you will understand findDataModel
>> with this sample :
>>
>> Map<String, Object> models = new HashMap<String, Object>();
>> Product latestProduct = new Product();
>> latestProduct.setUrl("products/greenmouse.html");
>> latestProduct.setName("green mouse");
>> models.put("latestProduct", latestProduct);
>>
>> TemplateHashModelEx hashModel = new SimpleHash(models);
>> TemplateEntriesModel entriesModel = new SimpleEntries(hashModel);
>>
>> String[] paths = {"latestProduct", "u"};
>
> (Misnomer here... This is not "paths", this is the "path" itself,
> which of course usually consist of multiple steps.)
>
>> entriesModel.findDataModel(paths, new TemplateModelCollector() {
>>
>>         public void collect(TemplateModel modelKey, TemplateModel modelValue,
>>                         String[] paths, int indexPath) {
>
> Should be called "indexInPath" or "pathIndex". "indexPath" rather
> means the "path of the index" in English.

Ok.

>
>>                 //key=url, indexPath=1, value=products/greenmouse.html
>>                 System.out.println("key="+ modelKey + ", indexPath=" + indexPath +",
>> value=" + modelValue);
>>
>>                 assertEquals(modelKey.toString(), "url");
>>                 assertEquals(1, indexPath);
>>                 assertEquals(modelValue.toString(), "products/greenmouse.html");
>
> Doesn't this always auto-complete the last step of the path? If so,
> what's the paths + pathIndex parameters for?
>
>>         }
>> });

You are right!!! Ok I have removed this parameter and commit this modification.

>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://ad.doubleclick.net/clk;226879339;13503038;l?
> http://clk.atdmt.com/CRS/go/247765532/direct/01/
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
In reply to this post by angelozerr
Monday, July 26, 2010, 12:00:32 PM, Angelo zerr wrote:

> Hi Daniel,
>
> Thank a lot to have testing the plugin. So many bugs you have founded
> -( Hope you are not disapointed with the plugin.

This is very much work in progress, so... I assumed you know that
there are rough edges all around.

> 2010/7/25 Daniel Dekany <[hidden email]>:
>> I tried to test the plugin briefly, on a clean Helios installation
>> that has nothing installed but the DLTK 2.0 plugin. I pressed "Launch
>> an Eclipse application" for the org.eclipse.dltk.freemarker.ui bundle,
>> then in the newly launched Eclipse I created a new Java project, added
>> FreeMarker nature to it, and started creating a model provider
>> class... then it become almost irresponsible, and logged
>> "java.lang.OutOfMemoryError: PermGen space" errors. I modified the
>> launch configuration by adding "-XX:MaxPermSize=160m" to the VM
>> arguments to fix this. I'm telling this so that if someone else wants
>> to test the stuff, that's the solution for this issue.
>
> Thanks Daniel. In my case I had not the problem. I will modify the
> documentation (or is it possible to modify the documentation with
> screen to explain how resolve the problem. If you have not time I will
> do that but it's difficult for me to do screen because I have not the
> problem.

There is no need for screen-shots for this... It's something that can
happen in all Java applications with a huge number of classes.
(Although it's maybe the symptom of bugs that it happens in this
case... and I'm not sure if it would happen in the main Eclipse JVM as
well.)

>> I created an FTL file in the com.example package (BTW, I haven't found
>> FreeMarker category when creating new file, so I just created it as
>> plain a file, not as an FTL file), but when I save it, I get:
>>
>>  Error while saving settings
>>    Resource '/MyFMDLTKTest/.metadata/fm/src/com/example' does not exist.
>>
>> I assume the plugin forgets to create the missing directories
>> automatically. I created them manually to work this around.
>
> Ouch -( Ok I hav e fixed this problem. You can synchronise with the
> org.eclipse.dltk.freemarker.core and problem should be resolved.

OK, now it works.

>>
>> The auto completion worked after '${', but not after something '${1+'
>> like. Surely you know that though; auto-completion should work on all
>> places where a variable name can occur. I also tried it after stuff
>> like '${aProduct.', which worked as expected.
>
> You are right, I must manage this case with '+' character. It means I
> must manage several operator :
>
> * +
> * -
> * *
> * /
> * >
> * <
>
> Do you know another case?

This is a complex expression language so certainly it's better to do
the the other way around: when you do NOT try to auto-complete an
apparent variable name. I mean, pressing Ctrl+space is a pretty direct
call for auto-completion, so unless we are outside interpolations and
FTL tags and string literals (unless we are inside an interpolation
inside a string literal...), and unless it can be detected that at the
place of the cursor it's a built-in or core directive name that fits
(like after "?" and after "<#"/"[#" or "</#"/"[/#"), I think it always
should try to auto-complete a variable name. After all, if sometimes
it auto-completes something that shouldn't be auto-completed, well,
not a big deal, it was a bad guess from the IDE.

>> An usability challenge with auto-completion and the data-model
>> inspector in general is that it lists a lot of "noise" keys, like
>> getClass, equals, hashCode, etc. These should be hidden by default in
>> the Data-Model Details view, and should be listed after the others in
>> the auto-completion lists. Especially, if you are using BeansWrapper
>> instead of the DefaultObjectWrapper (that wrapper can spoil a lot of
>> things in this plugin, and it's a widely-used wrapper, so the plugin
>> should know it and react intelligently), even numbers will have a lot
>> of exposed methods and like... those should be seldom visible.
>
> I'm using ObjectWrapper coming from the Configuration (if you
> specified a Configuration Provider) and DefaultObjectWrapper
> otherwise. This wrapper returns me getClass, hashCode... I don't
> understand why I must filter it if Freemarker can use it?

Because people are not interested in those keys... in the 98% of
cases. So it's just noise for them. They want to see the
application-specific keys, like "price" and such.

>> I notice that the project-level configurations and data-models aren't
>> available under the project properties (only under the corresponding
>> tabs of FTL files). These should be there later, of course.
>
> Yes, my TODO list contains this feature.
>>
>> I create a configuration provider, but when I associated it with the
>> template, the preview died with this:
>>
>>  org.eclipse.dltk.freemarker.core.settings.provider.InstanceProviderException: CONFIGURATION provider problem.
>>  java.lang.reflect.InvocationTargetException
>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:504)
>>        [snip]
>>  Caused by: java.lang.reflect.InvocationTargetException
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at org.eclipse.dltk.freemarker.core.util.ClassUtils.execute(ClassUtils.java:54)
>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:468)
>>        ... 45 more
>>  Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
>>        at freemarker.log.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:65)
>>        at freemarker.log.Logger.getLogger(Logger.java:255)
>>        at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
>>        at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
>>        at com.example.MyConfigurationProvider.getConfiguration(MyConfigurationProvider.java:10)
>>        ... 51 more
>>  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
>>        [snip]
>>
>> Maybe a FreeMarker bug with freemarker.log.Logger.LIBRARY_AUTO? Don't
>> know, I just worked this around be adding this to the configuration
>> provider method:
>
> Indead log4j is not included to the Plugin classpath.

I guess it's so, but then I don't understand why FreeMarker tries to
use Log4J at all. It's supposed to automatically chose a logging
solution on runtime that's available. Anyway, maybe a bug in
FreeMarker... I will look into this.

> Which Configuration Provider have you done?

I wrote my own... and it was almost empty.

> In my case I have just tested with square bracket configuration and
> it works.
>
>>
>>  freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
>>
>> Something I noticed is that when I change and save the model provider,
>> the contents of the data-model tab is not updated. I guess it's
>> difficult to register some kind of listener for automatically updating
>> it, so a "refresh" would be nice.
>
> Yes it's difficult. I have tried to manage that, but it seems that you
> have founded a bug with that. This tab should be refreshed when :
>
> * Java code is modified.
> * Template settings is saved.
>
> Perhaps I have forgotten a case? I will add a Refresh Button.

Both the data-model provider and the configuration-provider can be
modified, so both should be reloaded by the refresh button.

>>
>> Also, small thing, but auto-completion for the provider method names
>> doesn't work.
>
> Could you give me some details please. In my case it works?

For example select the "Model" tab of an FTL file, under
"Template-specific data-model" fill the "Class" field, then go to the
"Method" field and press Ctrl+Space... nothing happens. The
"Browse..." button works though.

> Have you test Preview View. Do you like this feature?

I would, however it has two key problems, and I don't know if these
can be realistically solved in Eclipse:

- It doesn't keep the position: Whenever I scroll to the relevant part
  of the output, and then go back to the template editor, it jumps
  back to beginning of the output. I suppose it also does it when it
  re-generates the output.

- It has no HTML mode, when it renders the output. Ok, this one is a
  bit in the wished-and bells category...

Also I think refreshing it after each key stroke (yes, with a delay)
is possibly too aggressive, especially because the unsaved states are
often half-done and thus will dump stack trace. Also it would be
helpful if the error messages are written with red. Especially when
the error comes after a section of output, it's can be helpful.

> Anyway thank a lot to have taking time to test the plugin, and I hope
> the plugin please you and you are not dispaointed with bugs you have
> founded.

BTW, I saw you have committed this:

+                       result.append("\"");
+                       result.append(value.toString());
+                       result.append("\"");

That doesn't handle quotation marks in the value etc. You could use
freemarker.template.utility.StringUtil.FTLStringLiteralEnc(value.toString())
for this.

> Regards Angelo

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
2010/7/26 Daniel Dekany <[hidden email]>:
> Monday, July 26, 2010, 12:00:32 PM, Angelo zerr wrote:
>
>> Hi Daniel,
>>
>> Thank a lot to have testing the plugin. So many bugs you have founded
>> -( Hope you are not disapointed with the plugin.
>
> This is very much work in progress, so... I assumed you know that
> there are rough edges all around.

Thank's for your understand.

> There is no need for screen-shots for this... It's something that can
> happen in all Java applications with a huge number of classes.
> (Although it's maybe the symptom of bugs that it happens in this
> case... and I'm not sure if it would happen in the main Eclipse JVM as
> well.)

Ok.

>
>>> I created an FTL file in the com.example package (BTW, I haven't found
>>> FreeMarker category when creating new file, so I just created it as
>>> plain a file, not as an FTL file), but when I save it, I get:

I have planed to create this wizard and I have a lot of ideas with
this wizzard. I will explain you when I will start developping this
feature.

>>>
>>>  Error while saving settings
>>>    Resource '/MyFMDLTKTest/.metadata/fm/src/com/example' does not exist.
>>>
>>> I assume the plugin forgets to create the missing directories
>>> automatically. I created them manually to work this around.
>>
>> Ouch -( Ok I hav e fixed this problem. You can synchronise with the
>> org.eclipse.dltk.freemarker.core and problem should be resolved.
>
> OK, now it works.

Cool:)

>
>>>
>>> The auto completion worked after '${', but not after something '${1+'
>>> like. Surely you know that though; auto-completion should work on all
>>> places where a variable name can occur. I also tried it after stuff
>>> like '${aProduct.', which worked as expected.
>>
>> You are right, I must manage this case with '+' character. It means I
>> must manage several operator :
>>
>> * +
>> * -
>> * *
>> * /
>> * >
>> * <
>>
>> Do you know another case?

Ok I have fixed this problem. Synchronize with
freemarker.provisionnal. I have too managed color for interpolation.
Please synchronize with org.eclipse.dltk.freemarker.ui and
org.eclipse.dltk.freemarker.core.

>
> This is a complex expression language so certainly it's better to do
> the the other way around: when you do NOT try to auto-complete an
> apparent variable name. I mean, pressing Ctrl+space is a pretty direct
> call for auto-completion, so unless we are outside interpolations and
> FTL tags and string literals (unless we are inside an interpolation
> inside a string literal...), and unless it can be detected that at the
> place of the cursor it's a built-in or core directive name that fits
> (like after "?" and after "<#"/"[#" or "</#"/"[/#"), I think it always
> should try to auto-complete a variable name. After all, if sometimes
> it auto-completes something that shouldn't be auto-completed, well,
> not a big deal, it was a bad guess from the IDE.

Sorry Daniel, I have not understand what you mean?

>
>>> An usability challenge with auto-completion and the data-model
>>> inspector in general is that it lists a lot of "noise" keys, like
>>> getClass, equals, hashCode, etc. These should be hidden by default in
>>> the Data-Model Details view, and should be listed after the others in
>>> the auto-completion lists. Especially, if you are using BeansWrapper
>>> instead of the DefaultObjectWrapper (that wrapper can spoil a lot of
>>> things in this plugin, and it's a widely-used wrapper, so the plugin
>>> should know it and react intelligently), even numbers will have a lot
>>> of exposed methods and like... those should be seldom visible.
>>
>> I'm using ObjectWrapper coming from the Configuration (if you
>> specified a Configuration Provider) and DefaultObjectWrapper
>> otherwise. This wrapper returns me getClass, hashCode... I don't
>> understand why I must filter it if Freemarker can use it?
>
> Because people are not interested in those keys... in the 98% of
> cases. So it's just noise for them. They want to see the
> application-specific keys, like "price" and such.

Ok I understand, but why display getClass with autocmpletion and NOT
displayed it for Data-Model details?

>
>>> I notice that the project-level configurations and data-models aren't
>>> available under the project properties (only under the corresponding
>>> tabs of FTL files). These should be there later, of course.
>>
>> Yes, my TODO list contains this feature.
>>>
>>> I create a configuration provider, but when I associated it with the
>>> template, the preview died with this:
>>>
>>>  org.eclipse.dltk.freemarker.core.settings.provider.InstanceProviderException: CONFIGURATION provider problem.
>>>  java.lang.reflect.InvocationTargetException
>>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:504)
>>>        [snip]
>>>  Caused by: java.lang.reflect.InvocationTargetException
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at org.eclipse.dltk.freemarker.core.util.ClassUtils.execute(ClassUtils.java:54)
>>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:468)
>>>        ... 45 more
>>>  Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
>>>        at freemarker.log.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:65)
>>>        at freemarker.log.Logger.getLogger(Logger.java:255)
>>>        at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
>>>        at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
>>>        at com.example.MyConfigurationProvider.getConfiguration(MyConfigurationProvider.java:10)
>>>        ... 51 more
>>>  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
>>>        [snip]
>>>
>>> Maybe a FreeMarker bug with freemarker.log.Logger.LIBRARY_AUTO? Don't
>>> know, I just worked this around be adding this to the configuration
>>> provider method:
>>
>> Indead log4j is not included to the Plugin classpath.
>
> I guess it's so, but then I don't understand why FreeMarker tries to
> use Log4J at all. It's supposed to automatically chose a logging
> solution on runtime that's available. Anyway, maybe a bug in
> FreeMarker... I will look into this.
>
>> Which Configuration Provider have you done?
>
> I wrote my own... and it was almost empty.

Its strange? In my case I have done :

public static Configuration getConfiguration2() {
                Configuration configuration = new Configuration();
                try {
                        configuration.setSharedVariable("YES", true);
                } catch (TemplateModelException e) {
                        e.printStackTrace();
                }
                configuration.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
                return configuration;
        }

and it works?

>
>> In my case I have just tested with square bracket configuration and
>> it works.
>>
>>>
>>>  freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
>>>
>>> Something I noticed is that when I change and save the model provider,
>>> the contents of the data-model tab is not updated. I guess it's
>>> difficult to register some kind of listener for automatically updating
>>> it, so a "refresh" would be nice.
>>
>> Yes it's difficult. I have tried to manage that, but it seems that you
>> have founded a bug with that. This tab should be refreshed when :
>>
>> * Java code is modified.
>> * Template settings is saved.
>>
>> Perhaps I have forgotten a case? I will add a Refresh Button.
>
> Both the data-model provider and the configuration-provider can be
> modified, so both should be reloaded by the refresh button.
>
>>>
>>> Also, small thing, but auto-completion for the provider method names
>>> doesn't work.
>>
>> Could you give me some details please. In my case it works?
>
> For example select the "Model" tab of an FTL file, under
> "Template-specific data-model" fill the "Class" field, then go to the
> "Method" field and press Ctrl+Space... nothing happens. The
> "Browse..." button works though.

Ok I understand what you mean (I believed that you told about
Autocmpletion used for Template Editor). Yes it's normal because I
have not developped this feature?

>
>> Have you test Preview View. Do you like this feature?
>
> I would, however it has two key problems, and I don't know if these
> can be realistically solved in Eclipse:
>
> - It doesn't keep the position: Whenever I scroll to the relevant part
>  of the output, and then go back to the template editor, it jumps
>  back to beginning of the output. I suppose it also does it when it
>  re-generates the output.

Ok you wish  that Preview View store the last cursor position and when
Prview View has focus again, cursor position use the last cursor
position. Is that? I don't know if it's possible?

>
> - It has no HTML mode, when it renders the output. Ok, this one is a
>  bit in the wished-and bells category...

Yes I know. I would like studied if it's possible to manage Output View like :
* HTML ouptut
* XML output
* Java output.

But I think develop that I think it's more important to develop
syntaxt highlighting + autocompletion. My TODO list contains this
Output feature. But I think Preview View can help a lot the user which
create a FTL file.  No?

>
> Also I think refreshing it after each key stroke (yes, with a delay)
> is possibly too aggressive, especially because the unsaved states are
> often half-done and thus will dump stack trace.
The Freemarker Preview View works like Javadoc View. When user type
some content, it's refreshed.

> Also it would be
> helpful if the error messages are written with red. Especially when
> the error comes after a section of output, it's can be helpful.

When error occues, Freemarker Preview View must be colored with red
color for instance. Is that?

>
>> Anyway thank a lot to have taking time to test the plugin, and I hope
>> the plugin please you and you are not dispaointed with bugs you have
>> founded.
>
> BTW, I saw you have committed this:
>
> +                       result.append("\"");
> +                       result.append(value.toString());
> +                       result.append("\"");
>
> That doesn't handle quotation marks in the value etc. You could use
> freemarker.template.utility.StringUtil.FTLStringLiteralEnc(value.toString())
> for this.
>
>> Regards Angelo
>
> --
> Best regards,
>  Daniel Dekany
>
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://ad.doubleclick.net/clk;226879339;13503038;l?
> http://clk.atdmt.com/CRS/go/247765532/direct/01/
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
Ok Daniel,

If you synchronize to org.eclipse.dltk.freemarker.ui project, the
backround color of the Freemarker Preview View is red when there is
error.

>> That doesn't handle quotation marks in the value etc. You could use
>> freemarker.template.utility.StringUtil.FTLStringLiteralEnc(value.toString())
>> for this.

Sorry I have not understood? I have tried to use this method but the
result has no quote?


2010/7/26 Angelo zerr <[hidden email]>:

> 2010/7/26 Daniel Dekany <[hidden email]>:
>> Monday, July 26, 2010, 12:00:32 PM, Angelo zerr wrote:
>>
>>> Hi Daniel,
>>>
>>> Thank a lot to have testing the plugin. So many bugs you have founded
>>> -( Hope you are not disapointed with the plugin.
>>
>> This is very much work in progress, so... I assumed you know that
>> there are rough edges all around.
>
> Thank's for your understand.
>
>> There is no need for screen-shots for this... It's something that can
>> happen in all Java applications with a huge number of classes.
>> (Although it's maybe the symptom of bugs that it happens in this
>> case... and I'm not sure if it would happen in the main Eclipse JVM as
>> well.)
>
> Ok.
>
>>
>>>> I created an FTL file in the com.example package (BTW, I haven't found
>>>> FreeMarker category when creating new file, so I just created it as
>>>> plain a file, not as an FTL file), but when I save it, I get:
>
> I have planed to create this wizard and I have a lot of ideas with
> this wizzard. I will explain you when I will start developping this
> feature.
>
>>>>
>>>>  Error while saving settings
>>>>    Resource '/MyFMDLTKTest/.metadata/fm/src/com/example' does not exist.
>>>>
>>>> I assume the plugin forgets to create the missing directories
>>>> automatically. I created them manually to work this around.
>>>
>>> Ouch -( Ok I hav e fixed this problem. You can synchronise with the
>>> org.eclipse.dltk.freemarker.core and problem should be resolved.
>>
>> OK, now it works.
>
> Cool:)
>>
>>>>
>>>> The auto completion worked after '${', but not after something '${1+'
>>>> like. Surely you know that though; auto-completion should work on all
>>>> places where a variable name can occur. I also tried it after stuff
>>>> like '${aProduct.', which worked as expected.
>>>
>>> You are right, I must manage this case with '+' character. It means I
>>> must manage several operator :
>>>
>>> * +
>>> * -
>>> * *
>>> * /
>>> * >
>>> * <
>>>
>>> Do you know another case?
>
> Ok I have fixed this problem. Synchronize with
> freemarker.provisionnal. I have too managed color for interpolation.
> Please synchronize with org.eclipse.dltk.freemarker.ui and
> org.eclipse.dltk.freemarker.core.
>>
>> This is a complex expression language so certainly it's better to do
>> the the other way around: when you do NOT try to auto-complete an
>> apparent variable name. I mean, pressing Ctrl+space is a pretty direct
>> call for auto-completion, so unless we are outside interpolations and
>> FTL tags and string literals (unless we are inside an interpolation
>> inside a string literal...), and unless it can be detected that at the
>> place of the cursor it's a built-in or core directive name that fits
>> (like after "?" and after "<#"/"[#" or "</#"/"[/#"), I think it always
>> should try to auto-complete a variable name. After all, if sometimes
>> it auto-completes something that shouldn't be auto-completed, well,
>> not a big deal, it was a bad guess from the IDE.
>
> Sorry Daniel, I have not understand what you mean?
>
>>
>>>> An usability challenge with auto-completion and the data-model
>>>> inspector in general is that it lists a lot of "noise" keys, like
>>>> getClass, equals, hashCode, etc. These should be hidden by default in
>>>> the Data-Model Details view, and should be listed after the others in
>>>> the auto-completion lists. Especially, if you are using BeansWrapper
>>>> instead of the DefaultObjectWrapper (that wrapper can spoil a lot of
>>>> things in this plugin, and it's a widely-used wrapper, so the plugin
>>>> should know it and react intelligently), even numbers will have a lot
>>>> of exposed methods and like... those should be seldom visible.
>>>
>>> I'm using ObjectWrapper coming from the Configuration (if you
>>> specified a Configuration Provider) and DefaultObjectWrapper
>>> otherwise. This wrapper returns me getClass, hashCode... I don't
>>> understand why I must filter it if Freemarker can use it?
>>
>> Because people are not interested in those keys... in the 98% of
>> cases. So it's just noise for them. They want to see the
>> application-specific keys, like "price" and such.
>
> Ok I understand, but why display getClass with autocmpletion and NOT
> displayed it for Data-Model details?
>>
>>>> I notice that the project-level configurations and data-models aren't
>>>> available under the project properties (only under the corresponding
>>>> tabs of FTL files). These should be there later, of course.
>>>
>>> Yes, my TODO list contains this feature.
>>>>
>>>> I create a configuration provider, but when I associated it with the
>>>> template, the preview died with this:
>>>>
>>>>  org.eclipse.dltk.freemarker.core.settings.provider.InstanceProviderException: CONFIGURATION provider problem.
>>>>  java.lang.reflect.InvocationTargetException
>>>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:504)
>>>>        [snip]
>>>>  Caused by: java.lang.reflect.InvocationTargetException
>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>>        at org.eclipse.dltk.freemarker.core.util.ClassUtils.execute(ClassUtils.java:54)
>>>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:468)
>>>>        ... 45 more
>>>>  Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
>>>>        at freemarker.log.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:65)
>>>>        at freemarker.log.Logger.getLogger(Logger.java:255)
>>>>        at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
>>>>        at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
>>>>        at com.example.MyConfigurationProvider.getConfiguration(MyConfigurationProvider.java:10)
>>>>        ... 51 more
>>>>  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
>>>>        [snip]
>>>>
>>>> Maybe a FreeMarker bug with freemarker.log.Logger.LIBRARY_AUTO? Don't
>>>> know, I just worked this around be adding this to the configuration
>>>> provider method:
>>>
>>> Indead log4j is not included to the Plugin classpath.
>>
>> I guess it's so, but then I don't understand why FreeMarker tries to
>> use Log4J at all. It's supposed to automatically chose a logging
>> solution on runtime that's available. Anyway, maybe a bug in
>> FreeMarker... I will look into this.
>>
>>> Which Configuration Provider have you done?
>>
>> I wrote my own... and it was almost empty.
>
> Its strange? In my case I have done :
>
> public static Configuration getConfiguration2() {
>                Configuration configuration = new Configuration();
>                try {
>                        configuration.setSharedVariable("YES", true);
>                } catch (TemplateModelException e) {
>                        e.printStackTrace();
>                }
>                configuration.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
>                return configuration;
>        }
>
> and it works?
>>
>>> In my case I have just tested with square bracket configuration and
>>> it works.
>>>
>>>>
>>>>  freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
>>>>
>>>> Something I noticed is that when I change and save the model provider,
>>>> the contents of the data-model tab is not updated. I guess it's
>>>> difficult to register some kind of listener for automatically updating
>>>> it, so a "refresh" would be nice.
>>>
>>> Yes it's difficult. I have tried to manage that, but it seems that you
>>> have founded a bug with that. This tab should be refreshed when :
>>>
>>> * Java code is modified.
>>> * Template settings is saved.
>>>
>>> Perhaps I have forgotten a case? I will add a Refresh Button.
>>
>> Both the data-model provider and the configuration-provider can be
>> modified, so both should be reloaded by the refresh button.
>>
>>>>
>>>> Also, small thing, but auto-completion for the provider method names
>>>> doesn't work.
>>>
>>> Could you give me some details please. In my case it works?
>>
>> For example select the "Model" tab of an FTL file, under
>> "Template-specific data-model" fill the "Class" field, then go to the
>> "Method" field and press Ctrl+Space... nothing happens. The
>> "Browse..." button works though.
>
> Ok I understand what you mean (I believed that you told about
> Autocmpletion used for Template Editor). Yes it's normal because I
> have not developped this feature?
>>
>>> Have you test Preview View. Do you like this feature?
>>
>> I would, however it has two key problems, and I don't know if these
>> can be realistically solved in Eclipse:
>>
>> - It doesn't keep the position: Whenever I scroll to the relevant part
>>  of the output, and then go back to the template editor, it jumps
>>  back to beginning of the output. I suppose it also does it when it
>>  re-generates the output.
>
> Ok you wish  that Preview View store the last cursor position and when
> Prview View has focus again, cursor position use the last cursor
> position. Is that? I don't know if it's possible?
>
>>
>> - It has no HTML mode, when it renders the output. Ok, this one is a
>>  bit in the wished-and bells category...
>
> Yes I know. I would like studied if it's possible to manage Output View like :
> * HTML ouptut
> * XML output
> * Java output.
>
> But I think develop that I think it's more important to develop
> syntaxt highlighting + autocompletion. My TODO list contains this
> Output feature. But I think Preview View can help a lot the user which
> create a FTL file.  No?
>
>>
>> Also I think refreshing it after each key stroke (yes, with a delay)
>> is possibly too aggressive, especially because the unsaved states are
>> often half-done and thus will dump stack trace.
> The Freemarker Preview View works like Javadoc View. When user type
> some content, it's refreshed.
>
>> Also it would be
>> helpful if the error messages are written with red. Especially when
>> the error comes after a section of output, it's can be helpful.
>
> When error occues, Freemarker Preview View must be colored with red
> color for instance. Is that?
>
>>
>>> Anyway thank a lot to have taking time to test the plugin, and I hope
>>> the plugin please you and you are not dispaointed with bugs you have
>>> founded.
>>
>> BTW, I saw you have committed this:
>>
>> +                       result.append("\"");
>> +                       result.append(value.toString());
>> +                       result.append("\"");
>>
>> That doesn't handle quotation marks in the value etc. You could use
>> freemarker.template.utility.StringUtil.FTLStringLiteralEnc(value.toString())
>> for this.
>>
>>> Regards Angelo
>>
>> --
>> Best regards,
>>  Daniel Dekany
>>
>>
>> ------------------------------------------------------------------------------
>> The Palm PDK Hot Apps Program offers developers who use the
>> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
>> of $1 Million in cash or HP Products. Visit us here for more details:
>> http://ad.doubleclick.net/clk;226879339;13503038;l?
>> http://clk.atdmt.com/CRS/go/247765532/direct/01/
>> _______________________________________________
>> FreeMarker-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>>
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
Monday, July 26, 2010, 6:22:57 PM, Angelo zerr wrote:

> Ok Daniel,
>
> If you synchronize to org.eclipse.dltk.freemarker.ui project, the
> backround color of the Freemarker Preview View is red when there is
> error.

That's not what I meant. The lines in the preview that doesn't belong
to the normal output, but are error information, should be printed
with red foreground color.

>>> That doesn't handle quotation marks in the value etc. You could use
>>> freemarker.template.utility.StringUtil.FTLStringLiteralEnc(value.toString())
>>> for this.
>
> Sorry I have not understood? I have tried to use this method but the
> result has no quote?

Yes, you have to add the quotes around it. It does the escapings that
are needed *inside* string literals.

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
In reply to this post by angelozerr
Monday, July 26, 2010, 12:36:20 PM, Angelo zerr wrote:

[snip]

>>> Ok. TemplateEntriesModel return list of TemplateEntiyModel which can
>>> be compared to Map.Entry (key+value). TemplateEntriesModel extends
>>> TemplateModel because I work with TemplateModel (I use the
>>> TemplateModel coming from ObjectWrapper OR I wrap  TemplateHashModelEx
>>> with my TemplateEntriesModel to have directly key/value list. Do you
>>> understand?
>>
>> Kind of, but what you are saying sound suspiciously to me. These
>> TemplateModel-s inside the freemarker.provisional package you only
>> need for the plugin functionality. But the plugin (as opposed to
>> FreeMarker) doesn't have to expect that the tree only contains
>> TemplateModel-s. It can introduce its own family of interfaces, like
>> DataInspectionHelper-s or something. Then it becomes obvious what is
>> indeed part of the data-model, and what's only inserted into it to
>> help the plugin, and hence should remain hidden from the user as an
>> internal implementation detail.
>
> I want use TemplateHashModelEx because I can use ObjectWrapper that
> user could customize.

I didn't say not to use TemplateHashModelEx, I was talking about
freemareker.provisional.TemplateEntriesModel.

> When I loop for TemplateHashModelEx#keys(), I'm
> using the TemplateModel (key+value) managed with ObjectWrapper. I
> could create another interface  DataInspectionHelper-s but it means
> that I will  create new instance of TemplateScalarModel although I can
> use it directly.
[snip]

What I'm said is that you certainly should use a DataInspectionHelper
subinterface (which is not a TemplateModel) instead of
TemplateEntriesModel (which interface hence shouldn't exist). I don't
get how it interferes with using the TemplateModel instances that you
get from the Data-model provider method. (Since in Java Language you
can't dynamically "inject" freemarker.provisional interfaces and
methods into existing object, TemplateEntriesModel has to be a wrapper
of TemplateModel-s as well, not something that extends them...)

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
In reply to this post by Daniel Dekany
2010/7/27 Daniel Dekany <[hidden email]>:

> Monday, July 26, 2010, 6:22:57 PM, Angelo zerr wrote:
>
>> Ok Daniel,
>>
>> If you synchronize to org.eclipse.dltk.freemarker.ui project, the
>> backround color of the Freemarker Preview View is red when there is
>> error.
>
> That's not what I meant. The lines in the preview that doesn't belong
> to the normal output, but are error information, should be printed
> with red foreground color.
Ok I have commited my work and now I set the backround (and not teh
foreground) only for teh exception. I have attached a screen. Do you
like or do you prefer foreground color?

>
>>>> That doesn't handle quotation marks in the value etc. You could use
>>>> freemarker.template.utility.StringUtil.FTLStringLiteralEnc(value.toString())
>>>> for this.
>>
>> Sorry I have not understood? I have tried to use this method but the
>> result has no quote?
>
> Yes, you have to add the quotes around it. It does the escapings that
> are needed *inside* string literals.
Sorry Daniel, I don't understand? Could you change the code please and
I will see what you mean. Thanks.

>
> --
> Best regards,
>  Daniel Dekany
>
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://ad.doubleclick.net/clk;226879339;13503038;l?
> http://clk.atdmt.com/CRS/go/247765532/direct/01/
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel

preview_error.png (39K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
In reply to this post by Daniel Dekany
Ok I will try to create my own DataInspectionHelper interface.

2010/7/27 Daniel Dekany <[hidden email]>:

> Monday, July 26, 2010, 12:36:20 PM, Angelo zerr wrote:
>
> [snip]
>>>> Ok. TemplateEntriesModel return list of TemplateEntiyModel which can
>>>> be compared to Map.Entry (key+value). TemplateEntriesModel extends
>>>> TemplateModel because I work with TemplateModel (I use the
>>>> TemplateModel coming from ObjectWrapper OR I wrap  TemplateHashModelEx
>>>> with my TemplateEntriesModel to have directly key/value list. Do you
>>>> understand?
>>>
>>> Kind of, but what you are saying sound suspiciously to me. These
>>> TemplateModel-s inside the freemarker.provisional package you only
>>> need for the plugin functionality. But the plugin (as opposed to
>>> FreeMarker) doesn't have to expect that the tree only contains
>>> TemplateModel-s. It can introduce its own family of interfaces, like
>>> DataInspectionHelper-s or something. Then it becomes obvious what is
>>> indeed part of the data-model, and what's only inserted into it to
>>> help the plugin, and hence should remain hidden from the user as an
>>> internal implementation detail.
>>
>> I want use TemplateHashModelEx because I can use ObjectWrapper that
>> user could customize.
>
> I didn't say not to use TemplateHashModelEx, I was talking about
> freemareker.provisional.TemplateEntriesModel.
>
>> When I loop for TemplateHashModelEx#keys(), I'm
>> using the TemplateModel (key+value) managed with ObjectWrapper. I
>> could create another interface  DataInspectionHelper-s but it means
>> that I will  create new instance of TemplateScalarModel although I can
>> use it directly.
> [snip]
>
> What I'm said is that you certainly should use a DataInspectionHelper
> subinterface (which is not a TemplateModel) instead of
> TemplateEntriesModel (which interface hence shouldn't exist). I don't
> get how it interferes with using the TemplateModel instances that you
> get from the Data-model provider method. (Since in Java Language you
> can't dynamically "inject" freemarker.provisional interfaces and
> methods into existing object, TemplateEntriesModel has to be a wrapper
> of TemplateModel-s as well, not something that extends them...)
>
> --
> Best regards,
>  Daniel Dekany
>
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://ad.doubleclick.net/clk;226879339;13503038;l?
> http://clk.atdmt.com/CRS/go/247765532/direct/01/
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
In reply to this post by angelozerr
Monday, July 26, 2010, 4:59:29 PM, Angelo zerr wrote:

> 2010/7/26 Daniel Dekany <[hidden email]>:
[snip]

>> This is a complex expression language so certainly it's better to do
>> the the other way around: when you do NOT try to auto-complete an
>> apparent variable name. I mean, pressing Ctrl+space is a pretty direct
>> call for auto-completion, so unless we are outside interpolations and
>> FTL tags and string literals (unless we are inside an interpolation
>> inside a string literal...), and unless it can be detected that at the
>> place of the cursor it's a built-in or core directive name that fits
>> (like after "?" and after "<#"/"[#" or "</#"/"[/#"), I think it always
>> should try to auto-complete a variable name. After all, if sometimes
>> it auto-completes something that shouldn't be auto-completed, well,
>> not a big deal, it was a bad guess from the IDE.
>
> Sorry Daniel, I have not understand what you mean?

When the user presses Ctrl + Space, you have to find out if at what
kind of place you are. These places could be:

1. Outside interpolations and FTL tags (except FTL commends). In that
   case Ctrl + Space should do nothing. Later this could be extended
   to help HTML editing.

2. Inside an interpolation or FTL tag:

   2.1. If you are inside a string literal but outside an interpolation
        that's nested into a string literal: Ctrl + Space does nothing

   2.2. If you are after the initial "#": Ctrl + Space should list the core
        directive names ("if", "macro", etc.)

   2.3. If you are after a "?": Ctrl + Space lists the names of
        built-ins

   2.4. Otherwise assume we are at a place where variable names
        can occur, and so do that auto-completion what you do now.

So as you see 2.4 is applied only when none of the other circumstances
(where you know that you can NOT have a variable name) stand.

>>>> An usability challenge with auto-completion and the data-model
>>>> inspector in general is that it lists a lot of "noise" keys, like
>>>> getClass, equals, hashCode, etc. These should be hidden by default in
>>>> the Data-Model Details view, and should be listed after the others in
>>>> the auto-completion lists. Especially, if you are using BeansWrapper
>>>> instead of the DefaultObjectWrapper (that wrapper can spoil a lot of
>>>> things in this plugin, and it's a widely-used wrapper, so the plugin
>>>> should know it and react intelligently), even numbers will have a lot
>>>> of exposed methods and like... those should be seldom visible.
>>>
>>> I'm using ObjectWrapper coming from the Configuration (if you
>>> specified a Configuration Provider) and DefaultObjectWrapper
>>> otherwise. This wrapper returns me getClass, hashCode... I don't
>>> understand why I must filter it if Freemarker can use it?
>>
>> Because people are not interested in those keys... in the 98% of
>> cases. So it's just noise for them. They want to see the
>> application-specific keys, like "price" and such.
>
> Ok I understand, but why display getClass with autocmpletion and NOT
> displayed it for Data-Model details?

Because with auto-completion you filter the list with typing, and also
because the auto-completion list only have a given number of items
visible at once, and the uninteresting keys can just be at the end of
this list. So it's practically not that annoying to have those keys in
the auto-completion list than confusing it would be to hide them.
(Also ideally these uninteresting keys are not just always hidden in
the Data-Model Details view, only hidden by default. So if someone
wants to see them, he can, and otherwise it's visible that there may
be hidden keys, as the "Hide keys from standard Java classes" is
checked.)

>>>> I notice that the project-level configurations and data-models aren't
>>>> available under the project properties (only under the corresponding
>>>> tabs of FTL files). These should be there later, of course.
>>>
>>> Yes, my TODO list contains this feature.
>>>>
>>>> I create a configuration provider, but when I associated it with the
>>>> template, the preview died with this:
>>>>
>>>>  org.eclipse.dltk.freemarker.core.settings.provider.InstanceProviderException: CONFIGURATION provider problem.
>>>>  java.lang.reflect.InvocationTargetException
>>>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:504)
>>>>        [snip]
>>>>  Caused by: java.lang.reflect.InvocationTargetException
>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>>        at org.eclipse.dltk.freemarker.core.util.ClassUtils.execute(ClassUtils.java:54)
>>>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:468)
>>>>        ... 45 more
>>>>  Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
>>>>        at freemarker.log.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:65)
>>>>        at freemarker.log.Logger.getLogger(Logger.java:255)
>>>>        at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
>>>>        at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
>>>>        at com.example.MyConfigurationProvider.getConfiguration(MyConfigurationProvider.java:10)
>>>>        ... 51 more
>>>>  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
>>>>        [snip]
>>>>
>>>> Maybe a FreeMarker bug with freemarker.log.Logger.LIBRARY_AUTO? Don't
>>>> know, I just worked this around be adding this to the configuration
>>>> provider method:
>>>
>>> Indead log4j is not included to the Plugin classpath.
>>
>> I guess it's so, but then I don't understand why FreeMarker tries to
>> use Log4J at all. It's supposed to automatically chose a logging
>> solution on runtime that's available. Anyway, maybe a bug in
>> FreeMarker... I will look into this.
>>
>>> Which Configuration Provider have you done?
>>
>> I wrote my own... and it was almost empty.
>
> Its strange? In my case I have done :
>
> public static Configuration getConfiguration2() {
>                 Configuration configuration = new Configuration();
>                 try {
>                         configuration.setSharedVariable("YES", true);
>                 } catch (TemplateModelException e) {
>                         e.printStackTrace();
>                 }
>                
> configuration.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
>                 return configuration;
>         }
>
> and it works?

I don't yet know why it happens... I will look into this.

>>> In my case I have just tested with square bracket configuration and
>>> it works.
>>>
>>>>
>>>>  freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
>>>>
>>>> Something I noticed is that when I change and save the model provider,
>>>> the contents of the data-model tab is not updated. I guess it's
>>>> difficult to register some kind of listener for automatically updating
>>>> it, so a "refresh" would be nice.
>>>
>>> Yes it's difficult. I have tried to manage that, but it seems that you
>>> have founded a bug with that. This tab should be refreshed when :
>>>
>>> * Java code is modified.
>>> * Template settings is saved.
>>>
>>> Perhaps I have forgotten a case? I will add a Refresh Button.
>>
>> Both the data-model provider and the configuration-provider can be
>> modified, so both should be reloaded by the refresh button.
>>
>>>>
>>>> Also, small thing, but auto-completion for the provider method names
>>>> doesn't work.
>>>
>>> Could you give me some details please. In my case it works?
>>
>> For example select the "Model" tab of an FTL file, under
>> "Template-specific data-model" fill the "Class" field, then go to the
>> "Method" field and press Ctrl+Space... nothing happens. The
>> "Browse..." button works though.
>
> Ok I understand what you mean (I believed that you told about
> Autocmpletion used for Template Editor). Yes it's normal because I
> have not developped this feature?
>>
>>> Have you test Preview View. Do you like this feature?
>>
>> I would, however it has two key problems, and I don't know if these
>> can be realistically solved in Eclipse:
>>
>> - It doesn't keep the position: Whenever I scroll to the relevant part
>>  of the output, and then go back to the template editor, it jumps
>>  back to beginning of the output. I suppose it also does it when it
>>  re-generates the output.
>
> Ok you wish  that Preview View store the last cursor position and when
> Prview View has focus again, cursor position use the last cursor
> position. Is that?

Yes. Anyone who will use this will need that, unless the template
output is short.

> I don't know if it's possible?
>
>>
>> - It has no HTML mode, when it renders the output. Ok, this one is a
>>  bit in the wished-and bells category...
>
> Yes I know. I would like studied if it's possible to manage Output View like :
> * HTML ouptut
> * XML output
> * Java output.
>
> But I think develop that I think it's more important to develop
> syntaxt highlighting + autocompletion.
[snip]

Yes, of course.

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
2010/7/27 Daniel Dekany <[hidden email]>:

> Monday, July 26, 2010, 4:59:29 PM, Angelo zerr wrote:
>
>> 2010/7/26 Daniel Dekany <[hidden email]>:
> [snip]
>>> This is a complex expression language so certainly it's better to do
>>> the the other way around: when you do NOT try to auto-complete an
>>> apparent variable name. I mean, pressing Ctrl+space is a pretty direct
>>> call for auto-completion, so unless we are outside interpolations and
>>> FTL tags and string literals (unless we are inside an interpolation
>>> inside a string literal...), and unless it can be detected that at the
>>> place of the cursor it's a built-in or core directive name that fits
>>> (like after "?" and after "<#"/"[#" or "</#"/"[/#"), I think it always
>>> should try to auto-complete a variable name. After all, if sometimes
>>> it auto-completes something that shouldn't be auto-completed, well,
>>> not a big deal, it was a bad guess from the IDE.
>>
>> Sorry Daniel, I have not understand what you mean?
>
> When the user presses Ctrl + Space, you have to find out if at what
> kind of place you are. These places could be:
>
> 1. Outside interpolations and FTL tags (except FTL commends). In that
>   case Ctrl + Space should do nothing. Later this could be extended
>   to help HTML editing.
>
> 2. Inside an interpolation or FTL tag:
>
>   2.1. If you are inside a string literal but outside an interpolation
>        that's nested into a string literal: Ctrl + Space does nothing
>
>   2.2. If you are after the initial "#": Ctrl + Space should list the core
>        directive names ("if", "macro", etc.)
>
>   2.3. If you are after a "?": Ctrl + Space lists the names of
>        built-ins
>
>   2.4. Otherwise assume we are at a place where variable names
>        can occur, and so do that auto-completion what you do now.

Ok, you mean that Ctrl+Space display lastestProduct, user key (from my
sample). Imagien I have written

<h1>Welcome u
I do Ctrl+Space the completion show me user. When I select this key,
what I must do? Write :

<h1>Welcome user

OR write

<h1>Welcome ${user}

I think it should be better but it means that I must manage case <#if
too (no generate ${}).

>
> So as you see 2.4 is applied only when none of the other circumstances
> (where you know that you can NOT have a variable name) stand.
>
>>>>> An usability challenge with auto-completion and the data-model
>>>>> inspector in general is that it lists a lot of "noise" keys, like
>>>>> getClass, equals, hashCode, etc. These should be hidden by default in
>>>>> the Data-Model Details view, and should be listed after the others in
>>>>> the auto-completion lists. Especially, if you are using BeansWrapper
>>>>> instead of the DefaultObjectWrapper (that wrapper can spoil a lot of
>>>>> things in this plugin, and it's a widely-used wrapper, so the plugin
>>>>> should know it and react intelligently), even numbers will have a lot
>>>>> of exposed methods and like... those should be seldom visible.
>>>>
>>>> I'm using ObjectWrapper coming from the Configuration (if you
>>>> specified a Configuration Provider) and DefaultObjectWrapper
>>>> otherwise. This wrapper returns me getClass, hashCode... I don't
>>>> understand why I must filter it if Freemarker can use it?
>>>
>>> Because people are not interested in those keys... in the 98% of
>>> cases. So it's just noise for them. They want to see the
>>> application-specific keys, like "price" and such.
>>
>> Ok I understand, but why display getClass with autocmpletion and NOT
>> displayed it for Data-Model details?
>
> Because with auto-completion you filter the list with typing, and also
> because the auto-completion list only have a given number of items
> visible at once, and the uninteresting keys can just be at the end of
> this list. So it's practically not that annoying to have those keys in
> the auto-completion list than confusing it would be to hide them.
> (Also ideally these uninteresting keys are not just always hidden in
> the Data-Model Details view, only hidden by default. So if someone
> wants to see them, he can, and otherwise it's visible that there may
> be hidden keys, as the "Hide keys from standard Java classes" is
> checked.)

Ok.

>
>>>>> I notice that the project-level configurations and data-models aren't
>>>>> available under the project properties (only under the corresponding
>>>>> tabs of FTL files). These should be there later, of course.
>>>>
>>>> Yes, my TODO list contains this feature.
>>>>>
>>>>> I create a configuration provider, but when I associated it with the
>>>>> template, the preview died with this:
>>>>>
>>>>>  org.eclipse.dltk.freemarker.core.settings.provider.InstanceProviderException: CONFIGURATION provider problem.
>>>>>  java.lang.reflect.InvocationTargetException
>>>>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:504)
>>>>>        [snip]
>>>>>  Caused by: java.lang.reflect.InvocationTargetException
>>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>        at org.eclipse.dltk.freemarker.core.util.ClassUtils.execute(ClassUtils.java:54)
>>>>>        at org.eclipse.dltk.freemarker.internal.core.settings.FreemarkerProjectSettings.getInstance(FreemarkerProjectSettings.java:468)
>>>>>        ... 45 more
>>>>>  Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
>>>>>        at freemarker.log.Log4JLoggerFactory.getLogger(Log4JLoggerFactory.java:65)
>>>>>        at freemarker.log.Logger.getLogger(Logger.java:255)
>>>>>        at freemarker.template.utility.SecurityUtilities.<clinit>(SecurityUtilities.java:67)
>>>>>        at freemarker.ext.beans.BeansWrapper.<clinit>(BeansWrapper.java:147)
>>>>>        at com.example.MyConfigurationProvider.getConfiguration(MyConfigurationProvider.java:10)
>>>>>        ... 51 more
>>>>>  Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Priority
>>>>>        [snip]
>>>>>
>>>>> Maybe a FreeMarker bug with freemarker.log.Logger.LIBRARY_AUTO? Don't
>>>>> know, I just worked this around be adding this to the configuration
>>>>> provider method:
>>>>
>>>> Indead log4j is not included to the Plugin classpath.
>>>
>>> I guess it's so, but then I don't understand why FreeMarker tries to
>>> use Log4J at all. It's supposed to automatically chose a logging
>>> solution on runtime that's available. Anyway, maybe a bug in
>>> FreeMarker... I will look into this.
>>>
>>>> Which Configuration Provider have you done?
>>>
>>> I wrote my own... and it was almost empty.
>>
>> Its strange? In my case I have done :
>>
>> public static Configuration getConfiguration2() {
>>                 Configuration configuration = new Configuration();
>>                 try {
>>                         configuration.setSharedVariable("YES", true);
>>                 } catch (TemplateModelException e) {
>>                         e.printStackTrace();
>>                 }
>>
>> configuration.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
>>                 return configuration;
>>         }
>>
>> and it works?
>
> I don't yet know why it happens... I will look into this.
>
>>>> In my case I have just tested with square bracket configuration and
>>>> it works.
>>>>
>>>>>
>>>>>  freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_NONE);
>>>>>
>>>>> Something I noticed is that when I change and save the model provider,
>>>>> the contents of the data-model tab is not updated. I guess it's
>>>>> difficult to register some kind of listener for automatically updating
>>>>> it, so a "refresh" would be nice.
>>>>
>>>> Yes it's difficult. I have tried to manage that, but it seems that you
>>>> have founded a bug with that. This tab should be refreshed when :
>>>>
>>>> * Java code is modified.
>>>> * Template settings is saved.
>>>>
>>>> Perhaps I have forgotten a case? I will add a Refresh Button.
>>>
>>> Both the data-model provider and the configuration-provider can be
>>> modified, so both should be reloaded by the refresh button.
>>>
>>>>>
>>>>> Also, small thing, but auto-completion for the provider method names
>>>>> doesn't work.
>>>>
>>>> Could you give me some details please. In my case it works?
>>>
>>> For example select the "Model" tab of an FTL file, under
>>> "Template-specific data-model" fill the "Class" field, then go to the
>>> "Method" field and press Ctrl+Space... nothing happens. The
>>> "Browse..." button works though.
>>
>> Ok I understand what you mean (I believed that you told about
>> Autocmpletion used for Template Editor). Yes it's normal because I
>> have not developped this feature?
>>>
>>>> Have you test Preview View. Do you like this feature?
>>>
>>> I would, however it has two key problems, and I don't know if these
>>> can be realistically solved in Eclipse:
>>>
>>> - It doesn't keep the position: Whenever I scroll to the relevant part
>>>  of the output, and then go back to the template editor, it jumps
>>>  back to beginning of the output. I suppose it also does it when it
>>>  re-generates the output.
>>
>> Ok you wish  that Preview View store the last cursor position and when
>> Prview View has focus again, cursor position use the last cursor
>> position. Is that?
>
> Yes. Anyone who will use this will need that, unless the template
> output is short.
>
>> I don't know if it's possible?
>>
>>>
>>> - It has no HTML mode, when it renders the output. Ok, this one is a
>>>  bit in the wished-and bells category...
>>
>> Yes I know. I would like studied if it's possible to manage Output View like :
>> * HTML ouptut
>> * XML output
>> * Java output.
>>
>> But I think develop that I think it's more important to develop
>> syntaxt highlighting + autocompletion.
> [snip]
>
> Yes, of course.
>
> --
> Best regards,
>  Daniel Dekany
>
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://ad.doubleclick.net/clk;226879339;13503038;l?
> http://clk.atdmt.com/CRS/go/247765532/direct/01/
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
In reply to this post by angelozerr
Tuesday, July 27, 2010, 4:51:55 PM, Angelo zerr wrote:

> 2010/7/27 Daniel Dekany <[hidden email]>:
>> Monday, July 26, 2010, 6:22:57 PM, Angelo zerr wrote:
>>
>>> Ok Daniel,
>>>
>>> If you synchronize to org.eclipse.dltk.freemarker.ui project, the
>>> backround color of the Freemarker Preview View is red when there is
>>> error.
>>
>> That's not what I meant. The lines in the preview that doesn't belong
>> to the normal output, but are error information, should be printed
>> with red foreground color.
>
> Ok I have commited my work and now I set the backround (and not teh
> foreground) only for teh exception. I have attached a screen. Do you
> like or do you prefer foreground color?

Looks fine. However using a hard-coded RGB value is maybe not a good
practice. Certainly Eclipse defines some kind of error color or like.

>>
>>>>> That doesn't handle quotation marks in the value etc. You could use
>>>>> freemarker.template.utility.StringUtil.FTLStringLiteralEnc(value.toString())
>>>>> for this.
>>>
>>> Sorry I have not understood? I have tried to use this method but the
>>> result has no quote?
>>
>> Yes, you have to add the quotes around it. It does the escapings that
>> are needed *inside* string literals.
>
> Sorry Daniel, I don't understand? Could you change the code please and
> I will see what you mean. Thanks.

I have committed it. But note that you had to use the same kind of
value formatting in the Data-Model Details view too.

>> --
>> Best regards,
>>  Daniel Dekany
>>
>>
>> ------------------------------------------------------------------------------
>> The Palm PDK Hot Apps Program offers developers who use the
>> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
>> of $1 Million in cash or HP Products. Visit us here for more details:
>> http://ad.doubleclick.net/clk;226879339;13503038;l?
>> http://clk.atdmt.com/CRS/go/247765532/direct/01/
>> _______________________________________________
>> FreeMarker-devel mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>>

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

Daniel Dekany
In reply to this post by angelozerr
Tuesday, July 27, 2010, 6:51:05 PM, Angelo zerr wrote:

> 2010/7/27 Daniel Dekany <[hidden email]>:
>> Monday, July 26, 2010, 4:59:29 PM, Angelo zerr wrote:
>>
>>> 2010/7/26 Daniel Dekany <[hidden email]>:
>> [snip]
>>>> This is a complex expression language so certainly it's better to do
>>>> the the other way around: when you do NOT try to auto-complete an
>>>> apparent variable name. I mean, pressing Ctrl+space is a pretty direct
>>>> call for auto-completion, so unless we are outside interpolations and
>>>> FTL tags and string literals (unless we are inside an interpolation
>>>> inside a string literal...), and unless it can be detected that at the
>>>> place of the cursor it's a built-in or core directive name that fits
>>>> (like after "?" and after "<#"/"[#" or "</#"/"[/#"), I think it always
>>>> should try to auto-complete a variable name. After all, if sometimes
>>>> it auto-completes something that shouldn't be auto-completed, well,
>>>> not a big deal, it was a bad guess from the IDE.
>>>
>>> Sorry Daniel, I have not understand what you mean?
>>
>> When the user presses Ctrl + Space, you have to find out if at what
>> kind of place you are. These places could be:
>>
>> 1. Outside interpolations and FTL tags (except FTL commends). In that
>>    case Ctrl + Space should do nothing. Later this could be extended
>>    to help HTML editing.
>>
>> 2. Inside an interpolation or FTL tag:
>>
>>   2.1. If you are inside a string literal but outside an interpolation
>>        that's nested into a string literal: Ctrl + Space does nothing
>>
>>   2.2. If you are after the initial "#": Ctrl + Space should list the core
>>        directive names ("if", "macro", etc.)
>>
>>   2.3. If you are after a "?": Ctrl + Space lists the names of
>>        built-ins
>>
>>   2.4. Otherwise assume we are at a place where variable names
>>        can occur, and so do that auto-completion what you do now.
>
> Ok, you mean that Ctrl+Space display lastestProduct, user key (from my
> sample). Imagien I have written
>
> <h1>Welcome u
> I do Ctrl+Space the completion show me user.

No, it shouldn't. You are at point 1 above, "Outside interpolations
and FTL tags", so you don't do auto-completion at all.

> When I select this key,
> what I must do? Write :
>
> <h1>Welcome user
>
> OR write
>
> <h1>Welcome ${user}

Neither... but see above.

> I think it should be better but it means that I must manage case <#if
> too (no generate ${}).
[snip]

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
Daniel I'm very sorry but today autocompletion works as you have
suggested (with Data-Model). No?

If you do Ctrl+Space, the autocompletion is displayed with Data-Model
only if cusrsor is positionned to Interpolation, <#if or <#list
directive. After I agree with you, keyword of autocomplete is not
managed very good (ex : with '!=' character we will have problem).

Thanks to have commiting the code.

Angelo

2010/7/27 Daniel Dekany <[hidden email]>:

> Tuesday, July 27, 2010, 6:51:05 PM, Angelo zerr wrote:
>
>> 2010/7/27 Daniel Dekany <[hidden email]>:
>>> Monday, July 26, 2010, 4:59:29 PM, Angelo zerr wrote:
>>>
>>>> 2010/7/26 Daniel Dekany <[hidden email]>:
>>> [snip]
>>>>> This is a complex expression language so certainly it's better to do
>>>>> the the other way around: when you do NOT try to auto-complete an
>>>>> apparent variable name. I mean, pressing Ctrl+space is a pretty direct
>>>>> call for auto-completion, so unless we are outside interpolations and
>>>>> FTL tags and string literals (unless we are inside an interpolation
>>>>> inside a string literal...), and unless it can be detected that at the
>>>>> place of the cursor it's a built-in or core directive name that fits
>>>>> (like after "?" and after "<#"/"[#" or "</#"/"[/#"), I think it always
>>>>> should try to auto-complete a variable name. After all, if sometimes
>>>>> it auto-completes something that shouldn't be auto-completed, well,
>>>>> not a big deal, it was a bad guess from the IDE.
>>>>
>>>> Sorry Daniel, I have not understand what you mean?
>>>
>>> When the user presses Ctrl + Space, you have to find out if at what
>>> kind of place you are. These places could be:
>>>
>>> 1. Outside interpolations and FTL tags (except FTL commends). In that
>>>    case Ctrl + Space should do nothing. Later this could be extended
>>>    to help HTML editing.
>>>
>>> 2. Inside an interpolation or FTL tag:
>>>
>>>   2.1. If you are inside a string literal but outside an interpolation
>>>        that's nested into a string literal: Ctrl + Space does nothing
>>>
>>>   2.2. If you are after the initial "#": Ctrl + Space should list the core
>>>        directive names ("if", "macro", etc.)
>>>
>>>   2.3. If you are after a "?": Ctrl + Space lists the names of
>>>        built-ins
>>>
>>>   2.4. Otherwise assume we are at a place where variable names
>>>        can occur, and so do that auto-completion what you do now.
>>
>> Ok, you mean that Ctrl+Space display lastestProduct, user key (from my
>> sample). Imagien I have written
>>
>> <h1>Welcome u
>> I do Ctrl+Space the completion show me user.
>
> No, it shouldn't. You are at point 1 above, "Outside interpolations
> and FTL tags", so you don't do auto-completion at all.
>
>> When I select this key,
>> what I must do? Write :
>>
>> <h1>Welcome user
>>
>> OR write
>>
>> <h1>Welcome ${user}
>
> Neither... but see above.
>
>> I think it should be better but it means that I must manage case <#if
>> too (no generate ${}).
> [snip]
>
> --
> Best regards,
>  Daniel Dekany
>
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://ad.doubleclick.net/clk;226879339;13503038;l?
> http://clk.atdmt.com/CRS/go/247765532/direct/01/
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: DLTK Freemarker Plugin. and Autocompletion with DataModel

angelozerr
In reply to this post by Daniel Dekany
>>
>> Ok I have commited my work and now I set the backround (and not teh
>> foreground) only for teh exception. I have attached a screen. Do you
>> like or do you prefer foreground color?
>
> Looks fine.

Cool:)

> However using a hard-coded RGB value is maybe not a good
> practice. Certainly Eclipse defines some kind of error color or like.

I think the better thing is to manage this Color with new Preferences
Page for Preview View. I will add to my TODO list.

>
>>>
>>>>>> That doesn't handle quotation marks in the value etc. You could use
>>>>>> freemarker.template.utility.StringUtil.FTLStringLiteralEnc(value.toString())
>>>>>> for this.
>>>>
>>>> Sorry I have not understood? I have tried to use this method but the
>>>> result has no quote?
>>>
>>> Yes, you have to add the quotes around it. It does the escapings that
>>> are needed *inside* string literals.
>>
>> Sorry Daniel, I don't understand? Could you change the code please and
>> I will see what you mean. Thanks.
>
> I have committed it. But note that you had to use the same kind of
> value formatting in the Data-Model Details view too.
>
>>> --
>>> Best regards,
>>>  Daniel Dekany
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> The Palm PDK Hot Apps Program offers developers who use the
>>> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
>>> of $1 Million in cash or HP Products. Visit us here for more details:
>>> http://ad.doubleclick.net/clk;226879339;13503038;l?
>>> http://clk.atdmt.com/CRS/go/247765532/direct/01/
>>> _______________________________________________
>>> FreeMarker-devel mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>>>
>
> --
> Best regards,
>  Daniel Dekany
>
>
> ------------------------------------------------------------------------------
> The Palm PDK Hot Apps Program offers developers who use the
> Plug-In Development Kit to bring their C/C++ apps to Palm for a share
> of $1 Million in cash or HP Products. Visit us here for more details:
> http://ad.doubleclick.net/clk;226879339;13503038;l?
> http://clk.atdmt.com/CRS/go/247765532/direct/01/
> _______________________________________________
> FreeMarker-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/freemarker-devel
>

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
12