Create a preview wizard Follow
Hi, I am a bit new to the open api plugin development and I couldnt find a correct existing function though it seems a bit trivial.
I need to show a preview or a refactor window so that the user can edit and change the specific piece of code directly shown in the popup window or it can be like a before-after preview pane that user changes code by simply pressing ok
instead of going through all the code by himself. right now i am using something like :
EditorEx myEditor1 = (EditorEx) editorFactory.createEditor(document1, project);
box1.add(myEditor1.getScrollPane());//box1 is a jpanel
is there any inbuilt api, so that i need not use the javax library?
Thanks in advance :D
Please sign in to leave a comment.
An API for what? There is absolutely nothing wrong in using javax.swing.JPanel to implement the UI of an IntelliJ IDEA plugin.
Not that its wrong but i have the popups in a for loop. So when there is an overlap of code between two popups or same doc is changed by two popups, the first change is overwritten by the second and i had to have a listner for the doc change to wait for the change to finish. So its very messy and i thought there would be some inbuilt function like
Somefunction(new text, the corresponding doc)
For preview popup and
For refactor popup. Is there any?
There is no support for having multiple versions of text for a single document. You can either show the actual document corresponding to the file, or create a new document with your text and then merge the changes with the changes in the original document (if any).
Yeah I can do that in the background but still i have to manage the multiple popups. How do i do that? I'm looking for something similar to the show local history of the file option in the intellij.
Create a panel, add a JBSplitter to it and put an Editor on each side of the splitter.
Thank you this is the one im looking for. Will post as soon as i try it tomorrow.
Hi, I am going through the source code and found TwosideTextDiffViewer class.
How to use this?
Can it handle multiple versions of a document?
Is this the class used in localHistory->ShowHistory in the left-click(in a editor) menu?
Any diff viewer shows a difference between two blocks of text. A block of text can ether represent the contents of a document, or it can contain static text. That static text may be the contents of the same file at a previous point in time, which is the case when you invoke the diff viewer from local history. But this is still static text, and does not allow editing. As I said before, there is no support in IntelliJ IDEA for having multiple editable versions of the same document.
Can you give me a pointer about how to use it? I might need it in my other project i am working on.
This class is not indended to be used directly from plugin code. If you need to show a diff, use the DiffManager.showDiff() method.
Thank you for the tip!!.
Is there a quick reference for the usage of this method?
On a completely different note.. I want to ask about the bulb icons.
I used EditorImpl.getMarkupModel.addRangeHighlighter to highlight the text. so I want to show the bulb icons which after clicking do some runnable actions.
I used annotation.registerFix(QuickFixFactory.getInstance().createAddToDependencyInjectionAnnotationsFix(project,"one","two");
But i dont see anything. What am I missing here?
Thanks for the tip again :)
Its working now thanks. How to change the Documents using this wizard? Like as in the "Keep memory changes" vs " Load disk changes"
PS: I am creating a new discussion thread for the bulb question. Felt like too much deviation from current topic. :p
To create a DiffContent representing a document, use DiffContentFactory.getInstance().createDocument().
But the user cant control the file creation right?
I want the user to be able to control the file creation like as in a ok-cancel situation
And will be the document created a physical one? Can we see the file on the disk or its like creating the Psifile without a physical one?
I don't understand what you want to achieve. The diff UI shows the difference between two pieces of content that you give to it. It has no support for creating files. Any additional UI is something that you need to implement yourself.
You can create a document in memory, or you can obtain the document corresponding to an actual file on disk - this is entirely up to you.
So how can I embed that diff ui into a Jframe? The manager.showdiff doesn't return anything.
I figured it out!!.
I found this DiffRequestPanel and used it to showcase the two versions of the virtual file i created and embedded the panel.getComponent in the Jframe I created.
According to the user click ok/cancel I choose whether to write to document or not.
Thanks for the tips :)