How to reuse the "Introduce Variable" dialog?


In a plugin, I'd like to show the user/reuse the system "Introduce
Variable" dialog.
Is this possible?

I've browsed openapi.jar, but couldn't find anything that looked like this.

Alain

7 comments
Comment actions Permalink

Alain Ravet wrote:


In a plugin, I'd like to show the user/reuse the system "Introduce
Variable" dialog.
Is this possible?


It is not possible at the moment. Sorry.
BTW, do you mean the dialog itself, or the refactoring?

Friendly,
Dmitry

P.S. "Introduce Variable" dialog is surely a masterpiece and accumulation of the best in IntelliJ IDEA UI design. No plugin writer have enough abilities to create anything vaguely resembling it. Only the mighty JetBrain have enough mind powers to concieve and, in one shot of brilliant coding, implement this pearl of human-computer interaction.]]>
:):):):):):):)

I guess I need a vacation badly...



--
Dmitry Lomov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Dmitry Lomov wrote:

>It is not possible at the moment. Sorry.
>
Should I post a request, or is already on your map?

>BTW, do you mean the dialog itself, or the refactoring?

>
The dialog, only. I'm working on a "remove_duplication" series of
intentions, and at one stage, some data has to be moved into a new variable.
Hence my request.

Alain

0
Comment actions Permalink

Alain Ravet wrote:

Dmitry Lomov wrote:

>>It is not possible at the moment. Sorry.
>>

Should I post a request, or is already on your map?


Well, I am afraid it is not on the map. So post the req.

>>BTW, do you mean the dialog itself, or the refactoring?
>>
>>

The dialog, only. I'm working on a "remove_duplication" series of
intentions, and at one stage, some data has to be moved into a new
variable.


Wow, that is fun! Looking forward to see it!

Cheers,
Dmitry
--
Dmitry Lomov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

See also com.intellij.openapi.ui.DialogWrapper

0
Comment actions Permalink

Timur Zambalayev wrote:

>See also com.intellij.openapi.ui.DialogWrapper
>

I know, but I'm lazy. I want to just have to write code like this :

ExtractVariableDialogResult r = SysDialogs.ExtractVariable
(Person.class, "firstName", 2) ;

String varName = r.newVariableName ();
boolean makeFinal = r.mustMakeFinal() ;
boolean replaceAll = r.mustReplaceAllOccurences();



I could settle for :

String varTypes [] = SysDialogs.extractVarTypesFor
(AClass.class);
String defNames [] = SysDialogs.extractVarSuggestedNamesFor
("firstName");
boolean declareFinal = SysDialogs.extractVarLastDeclareFinalChoice();
boolean replaceAllOcc=
SysDialogs.extractVarLastReplaceAllOccurenceChoice();
int nofOccurences = 2 ;

ExtractVariableDialogResult r = SysDialogs.ExtractVariable (varTypes,
defNames, declareFinal, replaceAllOcc, nofOccurences) ;

...

Alain

0
Comment actions Permalink

Alain Ravet wrote:

Timur Zambalayev wrote:

>>See also com.intellij.openapi.ui.DialogWrapper
>>


I know, but I'm lazy. I want to just have to write code like this :

ExtractVariableDialogResult r = SysDialogs.ExtractVariable
(Person.class, "firstName", 2) ;

String varName = r.newVariableName ();
boolean makeFinal = r.mustMakeFinal() ;
boolean replaceAll = r.mustReplaceAllOccurences();



I could settle for :

String varTypes [] = SysDialogs.extractVarTypesFor
(AClass.class);
String defNames [] = SysDialogs.extractVarSuggestedNamesFor
("firstName");
boolean declareFinal = SysDialogs.extractVarLastDeclareFinalChoice();
boolean replaceAllOcc=
SysDialogs.extractVarLastReplaceAllOccurenceChoice();
int nofOccurences = 2 ;

ExtractVariableDialogResult r = SysDialogs.ExtractVariable (varTypes,
defNames, declareFinal, replaceAllOcc, nofOccurences) ;


Aha, so you actually need the refactoring functionality in the end - that
is, what type can variable be and such.
I am afraid this is quite difficult right now to extract this kind of
(Open)API from IDEA code. Do not expect this anytime soon....

Friendly,
Dmitry

--
Dmitry Lomov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Dmitry Lomov wrote:

> Aha, so you actually need the refactoring functionality in the end ..

No, not at all Dmitry :

I just need the exact same dialog because I need to ask the exact same
question, and get the same answers :
: variable name ?
: variable type (from a suggested list)?
: final or not ?
: replace 1 or xxx occurences ?



I'd like a simple way to create, display the dialog, and obtain the
user's choice, like :

ExtractVariableDialogResult r
= SysDialogs.ExtractVariable (Person.class, "firstName", 2) ;

String varName = r.newVariableName ();
boolean makeFinal = r.mustMakeFinal() ;
boolean replaceAll = r.mustReplaceAllOccurences();




I think you were misled by the few utilities I suggested, but that you
must already be using when preparing the "Extract Variable" dialog :

> - that is, what type can variable be ..

You mean
>> String acceptableVarTypes []
>> = SysDialogs.extractVarTypesFor (AClass.class);
?

Well, that's just a little bit of reflection, isn't it?
I could write it myself, but you already have one, that you use before
calling the "Extract Variable" dialog.



> ..and such.
You mean :
>> String suggestedDefaultNames []
>> = SysDialogs.extractVarSuggestedNamesFor ("firstName");

I could write it myself, but you already ...


Alain

0

Please sign in to leave a comment.