It's like "Ctrl-shift-T" combination, but for package name instead of class name. I have a project with lots of hierarchy package, and when I need to add a new class, it's hard to find the right one.
I think there must be some way in Eclipse to quickly navigate to a package. Does anyone know about this thing?
1) Open Eclipse->windows->Preferecnces->General->Keys
2) Find the Entry Goto Package
3) If not configured, configure it witha key config like Cntrl+Shift+G it should be in the In Windows type. Now Click Ok..
4) Get your work done with that key combination
I don't think there is a standard way of doing this. As a hint I could propose using:
Ctrl+Shift+T together with wildcards.
Suppose we have the same class in two different packages:
com.mycompany.myapp.foo.bar.MyClass
and
com.mycompany.myapp.baz.bar.MyClass
using: *baz*.MyClass inside Open Type window will do the trick (open the second class inside Eclipse editor).
Now assuming you have Link with editor option enabled, now whenever you press Ctrl+Shift+N to create a new class, your package will be filled automatically from the resource previously opened.
Related
I'm using Eclipse Eclipse IDE for Java Developers [Version: 2018-12 (4.10.0)
Build id: 20181214-0600] to develop a JavaFX project but I got some problems.
After a Java update, I've found several errors in my CSS files. Eclipse seems to think the CSS files are Java source code, as figured in the image below.
When I drag the mouse on a error, the description is "Syntax error on token 'Invalid character', interface expected" (because of # symbol)
I'm sure the code is correct because there are no errors before the latest java update to version 1.8.2.
Anyone can help me?
Most likely what happened here is what #Gianpio Benincasa said: You've created a new class, then in the file explorer you renamed it.
However, it's worth checking this one: Go to window/preferences, type 'associations' in the filter box to quickly nav to setting General>Editors>File Associations, and scroll through the file types list for *.css. Click on it, and check which editors are associated with it.
An eclipse with no particularly relevant plugins should only list 'Text Editor', and it should be marked as default. If you added plugins specifically for editing CSS, those will also be listed (and one of those is now probably default instead). Perhaps you or someone else went out of their way to add the java editor to this list somehow. If that is the case, simply make 'text editor' the default again (click it, click 'default'), then click on the java editor, and click 'remove'.
for eclipse that is a java class, in fact the icon has the "J". Probably when you created it you have created a new class and then have renamed it.
Create a new generic file instead a java class and copy the contents to the new file.
For create a generic file, rightclick and follow new-> other-> General-> files
Have a nice day
Is there any way to ask the auto-generate methods created by intellij to be generated at the end of the class?
currently when i generate a method (⌥⌘M) it is created right below the function I extracted the method from, and I would like it to be at the end of the file.
Does intellij offer that option?
You can re-arrange the code in IntelliJ after code generation manually even though this does not guarantee that the code will go to the bottom of the file. You can do that by clicking on the "Rearrange" menu item in the "Code" menu:
Another option to re-arrange the code without having to use the menus would be via the "Reformat" file dialogue, by pressing on Windows Ctrl+Shift+Alt+L and by activating in it the "Re-format code" checkbox.
You can change the pattern of code arrangement in the settings in the following dialogue:
There is no such option in Intellij, Once you extract method you can move method up and down using Press Up( ⌥ ⇧ Up) or Down( ⌥ ⇧ Down).
This is not a code-related, but a pure IDE work efficiency question.
Is there any Eclipse plugin or built-in feature to provide "links" (shortcuts) to open other relevant .java files in the current project (or any files for that matter) from within a file.
To be more specific, here is an example of what I want to do:
I added new functionality to a class called MyClass in my project.
I also have a unit test file for that class called MyClassTest within another "test" project under a parent project.
Now I want to jump to MyClassTest.java and add new unit tests.
I'm lazy so I don't want to browse with the mouse in the Project Explorer (too many packages) and don't want to press Ctrl+Shift+T and type the class name.
I want some sort of shortcut planted in MyClass.java (or even a side panel window) which when clicked, opens MyClassTest.java for me.
This can be useful for the programmer to "link" related files (.xml, .java, .jsp) so he/she can open them quicker.
The MoreUnit plugin solves exactly this problem for unit tests. You press Ctrl-J while in a class to jump to its test class (and vice versa).
It even simplifies the process of creating the test class in the first place, with naming conventions and method stubs.
Typically in your described scenario I will right click on the "MyClass" (the text name in source) and go "References -> Workspace". This will show me all other "related" classes referring to MyClass. I can then double click on any of them to open which have appeared in the bottom search tab.
This also works great on methods to find out who is using the method in a particular class.
You can make the "Open type" dialog work more easily in this case, if you have selected the name of the current class before opening the dialog. Your current class name is then already filled in.
Then hit End or Cursor right in the open type dialog to remove the selection, type T (for Test) and hit Enter to open the test class.
I want to be able to open up the JButton class and see the code inside it. The reason is because I want to override one of the methods, but I want to make sure I include all the functionality that that method normally has. Also, it'd be a good way to learn. I know I can do it when I've had errors by clicking on the class in the error messages. But any ideas on how to bring it up normally?
Go To | Class (Ctrl+N), type JButton (Include non-project classes checkbox will be enabled automatically if no such classes are found in your project).
If you already have JButton usage in your code, you can navigate to its source using Ctrl+B while the caret is on it.
Of course you need sources attached to the JSDK, but it should be fine by default (as JSDK installation has sources on most platforms). If you are on Mac, you will have to download them separately and attach to the JSDK configuration in File | Project Structure | SDKs.
If you have sources just press Ctrl+B on JButton, if you have no, download sources, add to configuration of project and press the same combination
Download the Java Source code here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Also don't forget about the super keyword which you can use to interact with the extended class
You need to download the Java source code. If you're using Java 1.6, for example, you can go here to get it. Unzip it somewhere on your local disk.
When I need to look at the source code of a Java class I then navigate to the source class and drag it into my IDE.
If you want to ensure you get all the functionality of the original method, call the original method as part of your method. Using super gives you a reference to the overridden method, e.g. super.overridden();. Don't just copy the Java source into your method.
How do I make something like 4 project and make them see each other, like a .xhtml to a Bean and a Bean to the interface that implements the method to save or read something from the database?
The other solution would be to:
use only one workspace (meaning each components see each other)
define task context with Mylyn in order to switch from one component to another and see only what you need.
You cannot split workspace. You can create as many workspaces as you want and add there as many projects as you want. To create new workspace just create directory and then start eclipse and give it this directory as a workspace. It will do everything automatically.
Unfortunately your second question is unclear.
Right-click on the project; choose Properties. Click on Project References and select the other projects.