This Question is Not Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
7 Replies Last post: Sep 4, 2007 3:59 PM by Frederick N. Brier  
Frederick N. Brier Newbie 23 posts since
Jun 25, 2003
Currently Being Moderated

Sep 2, 2007 11:59 AM

DataKey - howto ?

I was looking at writing an IntelliJ plugin.  Downloaded the devkit, watched the flash tutorial, keyed it into 7.0M2, and it showed DataConstants as deprecated.

 

Editor editor = (Editor)event.getDataContext().getData( DataConstants.EDITOR );

 

The OpenAPI JavaDoc says to use DataKey instead.  I would assume I need to make a series of calls like:

 

DataKey.create( editorDataKeyName );

 

Is it supposed to be the FQN?  Editor.class.getName() or "com.intellij.openapi.editor.Editor".  If that were the case, then why not have the create method take the class object:, ie Editor.class, as a parameter?

 

A small code example in the JavaDoc would be extremely helpful.  Thank you.

Guest
Currently Being Moderated
Sep 2, 2007 3:14 PM in response to: Frederick N. Brier
Re: DataKey - howto ?

DataKeys.EDITOR.getData(e.getDataContext())

 

Frederick N. Brier wrote:

I was looking at writing an IntelliJ plugin.  Downloaded the devkit, watched the flash tutorial, keyed it into 7.0M2, and it showed DataConstants as deprecated.

 

Editor editor = (Editor)e.getDataContext().getData( DataConstants.EDITOR );

 

The OpenAPI JavaDoc says to use DataKey instead.  I would assume I need to make a series of calls like:

 

DataKey<Editor> myDataKey = ???;

 

Editor editor = myDataKey.getData( event.getDataContext() );

 

Now DataKey has a static method that returns a DataKey<T>, but it needs a String name parameter, and what is that supposed to be?

 

String editorDataKeyName = ???;

DataKey<Editor> my DataKey = DataKey<Editor>.create( editorDataKeyName );

 

Is it supposed to be the FQN?  Editor.class.getName() or "com.intellij.openapi.editor.Editor";

 

A small code example in the JavaDoc would be extremely helpful.  Thank you.

 

 

--

Best regards,

   Maxim Mossienko

IntelliJ Labs / JetBrains Inc.

http://www.intellij.com

"Develop with pleasure!"

 

Guest
Currently Being Moderated
Sep 3, 2007 11:24 AM in response to: Frederick N. Brier
Re: DataKey - howto ?

Hello Frederick,

 

I was looking at writing an IntelliJ plugin.  Downloaded the devkit,

watched the flash tutorial, keyed it into 7.0M2, and it showed

DataConstants as deprecated.

 

Editor editor = (Editor)e.getDataContext().getData(

DataConstants.EDITOR );

 

e.getData(DataKeys.EDITOR);

 

--

Dmitry Jemerov

Software Developer

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

 

 

 

Guest
Currently Being Moderated
Sep 4, 2007 12:55 PM in response to: Frederick N. Brier
Re: DataKey - howto ?

Hello Frederick,

 

Thank you both for the replies.  Both solutions work, and that is

wonderful.  However, if I might ask, why, if DataKeys.Editor is an

object of DataKeys<Editor>, does DataKeys<Editor>.getData( context )

return type Object instead of type Editor?  I am assuming that is why

you chose to switch to templates.  Thank you.

 

Well, it does return Editor.

 

public class DataKey {

  public T getData() { ... }

}

 

--

Dmitry Jemerov

Software Developer

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

 

 

 

Martin Fuhrer Expert 1,655 posts since
Oct 9, 2002
Currently Being Moderated
Sep 4, 2007 3:35 PM in response to: Frederick N. Brier
Re: DataKey - howto ?

Please check your language level. I'm pretty sure it is on 1.3 or 1.4. After changing it to 5.0 everything should be ok.

More Like This

  • Retrieving data ...