I have following code:
public class MyClass{
...
}
At same workspace I have following class
public class AnotherClass{
#Autowired
MyClass myClass;
...
}
If I click right mouse button on MyClass(first mentioned) and select "open call hierarchy" I don't see anything.
How to find this usage in Eclipse?
PC:
Select a word (class name, method name, variable name, etc.)
Press Ctrl+Shift+G
Mac:
Select a word (class name, method name, variable name, etc.)
Press Alt+Cmd+G (⌥+⌘+G)
Right click on Myclass, find references in project|workspace.
Open call hierarchy, open inheritance hierarchy.
For your case, I think both of (Ctrl +Shift+G) and (Ctrl +Alt+H) work.
To make it more clear:
(Ctrl +Shift+G) is shortkey for Search->References->workspace
Ctrl +Alt+H is short key for Call hierarchy.
Some other useful short keys like:
(Ctrl+G) : Search->Declaration->worksapce
(Alt+Left) : Back position
(Alt+Right) : Forward position
Try right-click on MyClassand then References->Workspace. I think this might be what you're looking for.
Also works on methods, variables etc.
Select the resource (method name, class name ) & right click . You will find a menu with title 'Open Call Hierarchy' (shortcut key : alt + Ctrl + H ).
This will enlist all the usage in project.
For Mac, press cmd + Shift + G
To my knowledge, both of Ctrl+Shift+G and Ctrl+Alt+H should work.
For Your Information:
Ctrl+Shift+G --> is the short key for Search --> References --> workspace
Ctrl+Alt+H --> is the short key for Call hierarchy.
Related
I want to add a quick shortcut like (sout + Tab = System.out.println() ) in eclipse how I can do this?
There is already a shortcut for System.out.println().
just type sysout then press ctrl + space.
If you want to make a template for other code, for example System.out.print(), Go to Preferences > Java > Editor > Templates and create a new template. To use the newly created template, type the name of the template + ctrl + space.
Window>Preferences>Java>Editor>Templates>New
edit name and pattern
try it
Is there a way how to search a file or class (I mean by Ctrl + Shift + T or R) only in some particular project and not in all workspace?I have Eclipse Indigo.
On Menu of Ctrl + Shift + T or R dialogue Small down arrow on extreme right use option Select Working Set then set the working set and you are done now you can only search files from selected working set.
Ctrl + Shift + T Or R
>Menu
>Select Working Set
>New
>Java
>Add Or Add All
>Click on Selected Working set in Select Working set Dialog
>Select Working set and you are done.
Select the project in project explorer -> Ctrl + H -> File Search Tab -> enter file name in containing text -> Check Selected Resources under Scope.
One more trick -> if you want to search only from *.java files then in File name patterns text box in the same File Search Tab enter *.java or *.props. This will filter out for you
Click on file search
select enclosing projects under the subcategory 'scope'.
this will enable you to search inside a specific project
For that you have the Search menu. You could use Search > File or Search > Java for that. In the search dialog, you can restrict the search scope as only the selected project, or as a predefined working set, as long as some additional options.
I want to find out how to do custom binding on java, I've searching on google but not found any.
It's simple problem,
I have two jSpinner, jSpin1 and jSpin2.
jSpin2 value is half from jSpin1.
when I do binding, there is
Binding source : jSpin1
Binding expression : ${value}
so the value in jSpin2 exactly the same with jSpin1. then how could I make its value half from jSpin1?
thank you.
As I Understand you use NetBeans GUI Builder. You can do it by the next steps:
- do right click on jSpin2 (in design view) and select ‘Properties’
- select ‘Binding’ at the top of dialog
- click on ‘...’ button on ‘value’ property
- select ‘jSpin1’ from ‘Binding Source’
- select ‘value’ from ‘Binding Expression’
- edit ‘Binding Expression’ to ‘${value/2}’
(Also you can put ‘jSpin1[${value/2}]’ in ‘value’ property)
When I type this
private MyKlass myklass;
and hit 'save' in Eclipse, it becomes this:
private final MyKlass myklass;
How do I stop Eclipse from doing this?
You need to disable that option in your 'save actions'.
right click your project > properties, then go to java editor > save actions. go to 'configure', 'code style' tab, and you have it on the bottom ('private fields').
Window - Preferences - Java - Editor - Save Actions - Configure... - Code Style - Use modifier final when possible
The same option can be found in Java - Code Style - Clean up.
If you want to leave this feature enabled in general but turn it off for a specific field, I found a simple workaround. Just declare a protected method that assigns to this field.
protected void preventFinal() {
field = null;
}
You can go to Project --> Properties --> Java Editor --> Save actions , Uncheck "Enable project specific settings"
There is Section called Save Actions in Eclipse Window -> Preferences -> Java -> Editor. There You can Configure Aditional actions - > (tab) code style - > Variable declarations -> edit use of final keyword.
Initialize the field with null:
private File tempDir = null;
Currently in IntelliJ, if I right-click a package in the Project pane, I can see things such as:
new > Java class
new > File
new > Package
I want to add some new menu items in the 'new' context menu such as Interface and Enum. Does anyone know how to do this?
I've been playing around in the Settings > Menus and Toolbars without any luck.
Edit: The funny thing is if I right click a package and choose New > Edit File Templates..., I can see the template for an Interface and in the description it actually says:
This is a built-in template used by IDEA each time you create a new Java interface, by selecting New | Interface from the popup menu in one of the project views.
Unless I need to look at a different pane other than Project, I can't seem to find any context menu that lets me choose New > Interface as suggested by the above description.
New | Java Class, Create New Class dialog appears, in this dialog you can choose Kind between one of the following:
Class
Interface
Enum
Annotation
(tested with IDEA 9.0.3)
If you want Interface directly in the New list, then you have to add new template in Settings | File Templates, name it something like Java Interface and copy the contents of the Interface template into this one.
Also you can create a shortcut to save some secs.
Alt+Ctr+S -> Keymap -> in search box type 'create new' and select Java class and then assign any shortcut like Ctrl+N.
It's under the New Java Class menu.
Yes its available in Class menu : New--> Java class --> Interface .
create a package and then select create new class from that select interface and give a name.
enter image description here
then; you need to import the references files.