Inspect UI in IntelliJ IDEs - java

I want to modify some UI in IntelliJ straight from the code (https://github.com/JetBrains/intellij-community), but I am having a hard time to identify which panel/class that particular UI component is.
Is there a way to tell "Hey, what panel is beneath the mouse cursor?"? - just like "Inspect element" in a browser.
The particular UI piece is the "file + line number" from the find panel:
I've added the code from https://github.com/JetBrains/intellij-community and tried searching by strings found in the "Find" panel, but as I'm not a Java developer, haven't found what I'm looking for.

When running IntelliJ in internal mode (should be by default in your sandbox), you get the UI inspector under Tools > Internal Actions > UI > UI Inspector.
The specific UI element you are looking for is hard to get this way though, because when transferring focus to the UI inspector you lose the find popup.
My guess is that you are looking for an implementation of ItemPresentation, the one in PsiFileImpl might give you a good starting point.

Related

Java AWT Window management, user input, and focus?

I'm trying to hunt down the source of a bug that relates to window management, and possibly awt specifically. However, I have little to no familiarity with window management in general, or awt, so I'm even sure what I searching for. I'm hoping for some general guidance on terminology or otherwise that might help guide me in the correct direction.
In the program I am working on, the user can open windows that can be interacted with (i.e. they have text input boxes, drop down menus, etc) and windows that cannot be interacted with (i.e. they just display dialog). When the user opens a "non-interactive" window, the user can still use the underlying program. However, when an "interactive" window is opened, the user is blocked from using the underlying program until the window is closed. Additionally, "interactive" windows seem to stack themselves on top of "non-interactive" windows. That is to say, if I open a "non-interactive" window and then open an "interactive" window after, the "interactive" window will place itself on top of the "non-interactive" window and won't allow the user to use any of the title bar widgets. In this program, this behavior is not always desirable.
I assumed that this would have something to do with focusing, but I read through this document without much luck (this could be that I just don't know what I'm looking for). Particularly, I noticed the mention of "VetoableChangeLister" which doesn't seem to appear anywhere in the code I'm working with, as well as the method "requestFocusInWindow", which does appear in the code I'm working with but not in any way that I could see that relates to my above problem description.
Would the above problem be related to window focusing? Or am I barking up the wrong tree here? If nothing else, even some basic terminology so I can at least Google search intelligently.
The question I was asking relates to the "modality" of windows and was answered in the comments. The link provided explaining modality is https://docs.oracle.com/javase/tutorial/uiswing/misc/modality.html

Disable the Refreshed Selected Content Root Pop-up in IntelliJ gradle project

In IntelliJ it seems like whenever I save a file there is this annoying green pop-up notifier at the very bottom that obscures my bottom toolbar, i.e. where terminal, messages, debug usually are.
It's usually "Refreshed selected content roots" which I believe is a gradle thing. There is no obvious way to dismiss it and it just trips me up every time.
As I often make a change and then want to switch to SonarLint or Terminal or whatever and it's blocking the button.
I know obvious workarounds like moving buttons around, but I kind of don't understand what that notifier is even called to configure it or even google it.
As #CrazyCoder would know what he's talking about, I found that the alert is caused by the (hasn't been updated in years with no configurable settings) AccuRev Plugin.
You can search this PDF for "Selected Content Roots" and you'll find it:
https://supportline.microfocus.com/Documentation/books/AccuRev/Plugins/IntelliJ/2014.2/intellij-2014.2-users_guide-en.pdf
This means if I don't plan on moving files around I can logout or disable the plugin then run accurev stat -mO when I'm done. There have been plenty of other reasons to do that, so this just added to the heap.

How can I make it so Eclipse automatically updates my code in a window as I edit it?

How can I make it so Eclipse automatically updates my code in a window as I edit it? I've seen the feature before in youtube videos but I cannot find it. For example : I change a JApplet rectangle width from 20 to 10, I want to see it update immediately.
I've seen Notch do this on development videos (Minecraft), it is awesome but I don't know exactly how he does it.
-- EDIT --
This has been bugging me so I went and googled "how does notch code" and found this on a blog page https://gun.io/blog/what-i-learned-from-watching-notch-code/. It doesn't say exactly how it was done but gives a good hint (HotSwap) and makes it seem like he set it up himself without external software. Here's the most relevant section:
Incredibly Fast Testing
He began by building the engine, and to do this he used the ‘HotSwap’ functionality of the Java JVM 1.4.2, which continuously updates the running code when it detects that a class has changed.
When building the engine, Notch wrote a function which would continuously pan the camera around and clip through the walls and keep the view on top, so he could make changes to the code and see the effects they made in real time. I’m used to testing by writing a function, building it, installing it on the device I’m testing on, and then seeing the result, which can take up to a minute at a time, so it’s easy to see how HotSwapping could save a lot of development time.
--- ORIGINAL POST CONTINUED ---
I get a similar effect by using groovysh though, works smoothly and can use all your java classes as is.
What I'll usually do is write all my code in java, then go and fire up "Groovysh" where it will give you a little window to enter commands (You may have to ensure the classpath works correctly outside of eclipse). I can then "new" any of my classes and call methods on them one line at a time. When you do myFrame.setSize([100,100]) you will see it change immediately.
A good test is to just run groovysh and type something like:
import javax.swing.*
f=new JFrame()
f.setVisible(true)
f.setSize(100,100)
or the groovier version:
f=new JFrame(visible:true, size:[100,100])
and you will see your frame resize on the screen. You can even drag it bigger and then do something like:
println f.getWidth()
to show your new width. It's fun to interact this way but it's more complicated if you want to actually change your class definition and see it pick up the change, I have no idea how Notch did that. I looked into it a little--it's possible he was using something like JRebel
It requires something special since you would have to dynamically reload the classfile into your running system on every save--something that should have serious classloader issues.
By the way there is also a way to get your Java program to throw out a little GroovyConsole which will allow you to inspect and modify all the variables in your running code (but again you can't replace definitions of existing classes).
Also see answer here:
Change a method at runtime via a hot swap mechanism

Eclipse debugging : Stack trace on event

Im trying to get the code flow of an open source platform. I have got the source code and ran the program from eclipse. The program has an option called "Run job" and I want to know where the control goes when that option is clicked. How can achieve this?
First, try to identify the control with the label "Run job".
You could do this by searching the source code in Eclipse with Search > File and then setting "Containing Text" to "Run job" and "File name patterns" to "*.java".
Probably in the same file, there is an ActionListener (or similar) added to the control that calls a method, when the control is clicked. This is the method you're looking for. (Add a breakpoint to see the flow in the debugger or try to understand it from the code.)
Apart from searching for the appropriate handlers and buttons in the source code (if you know the names), you can also enable tracing.
In your run configuration, there should be a tab for tracing. There, you'll want to enable some of the options under org.eclipse.ui that start with trace/.
You will get a lot of debug output, and there might be no trace option for the event you'd like to see. However it works well for things like keybindings (trace/keyBindings) and knowing which UI element got an event (trace/graphics). Note that some also take arguments, e.g. a commandId (something like org.eclipse.ui.edit.copy, will depend on your application).
You can find a small help text for each option here.

Keep Component Inspector state between applications switch in NetBeans

On NetBeans 7.0.1, if you are designing two User Interfaces, the "Component Inspector" becomes available while at "Design View", if you switch from one UI to another the Inspector randomly collapses all nodes and you lose focus of the component you had previously selected.
This is annoying because you have to keep expanding the nodes to get focus on what you were working.
One solution is to have multiple NetBeans instances, this may work if you must have two UI opened at the same time, but what if you must have five UIs opened at the same time? 5 NetBeans instances is not an option.
So, do you know what do I have to do so the Component Inspector does not collapse when switching between files? or in another words, how to keep the component inspector state between applications switch?
Thanks for your help!
(Posting this as an answer to show screenshots)
I do not get the same behavior as you do. In my case the Inspector does not collapse the panels when switching between open files, only when closing & opening a file. My IDE looks like the screenshots below when switching between the file tabs (CheckPanel.java & PasswordEditPanel.java).
So the functionality is definitely there, but something is amiss in your case.

Categories

Resources