How to customize 'new' option in Eclipse - java

When I'm using Eclipse to code in Java, I want to use the 'New' button (located below File, Edit...) to create a new class. I know it's possible because I've been able to use it like that on a different computer. However, the only options displayed are "Project", "Example", "Other...". So I have to select other and go find "Class".
I want a way to modify this list to include Java Project, Class, and whatever else I need. It's the same story when I right-click the src folder in the package explorer. I want to make a class in that folder, but I have to click other, navigate the new window to class, etc.
Can this be simplified?

Make sure you're in the right perspective. I see what you're looking for if I'm in the "Java" perspective, but not in other perspectives, such as "Java EE" or "Debug".
A "perspective" in Eclipse is the set of panes, toolbars, menus, etc. for a particular purpose. There should be toolbar buttons all the way on the right for them.

in order to customize new option in Eclipse, On the top of Eclipse, click on Window, Navigate to > Perspective > Customize Perspective > Menu Visibility > file > new.
now you can customize new Option.

Related

How to change popup in Eclipse?

I am new to using Eclipse (I just downloaded it).
I began creating a new project, wrote some code, added some packages and classes and closed the project.
Now, I opened it again and I'd like to add a class to a package. So I right-click on that package and the standard popup window appears. But when I now hover over "New ->", there are only three options: "Project", "Example" and "Other". The first time I worked on the project, there were many more options, f.ex. I was able to click on "Class" direct. Right now, I have to select "Other", type "Class" into another window and click "Ok".
Is there any switch or so in the settings that I accidentally enabled that changes the default right-click popup?
I added an image.
Thank you for help!
It seems you are not in the Java perspective: Window > Perspective > Open Perspective > Java

create a new class do not appear right click menu eclipse

I have a really annoying problem in Eclipse java neon, when i do a right click on a package in order to create a new class or in any area, Eclipse don't show me proposition like class, package or even project but only a incomplete menu unusable
I have already launch eclipse with -clean but not help
An illustration of the problem, I also notice that Eclipse is in... debug mode ? (upper left corner)
Select menu Window -> Perspective -> Customize Perspective....
Select Menu Visibility tab.
Select tree node File -> New.
Toggle check box of menu items as you like.
You are in the Debug Perspective (see What is a Perspective?). You can switch back to the Java or JEE perspective (where most development activities are typically performed) by using the perspective switcher toolbar in the upper-right corner of the Eclipse window.
I suggest you learn about the use of Perspectives in Eclipse.
Try
File --> New --> (Then choose what you want)
Specify the Source folder and package.
When I don't find something in the menu there, I just click on Other... and search for whatever I want to create. Regardless of the Perspective.
Of course it could more practical to customize the Perspective to include the frequently used items as mentioned.

Eclipse: change default file templates

How can I change the default file templates for new classes, interfaces, JavaEE servlets, etc. in Eclipse? I know that it is possible somehow, but I did some research, and haven't found any information about it.
Try Window -> Preferences -> Java -> Code Style -> Code Templates.
There you can edit existing code templates and even import new ones.
To change default templates of Class, Interfaces and etc you need to navigate to following location in eclipse
select Window --> Preferences, then Preferences window will be opened.From the left part of window, Expand "java" option by clicking on it. Then Expand "CodeStyle" option by clicking on it. Then select "Code Templates" option. You can find "Configure generated code and comments" box at top of the window at right position. Expand "Code" option by selecting it. Then you can find list of templates. You select one template which you want to change and click on "Edit" button. Then, "Edit Template" window will be opened, there you can define the pattern and click on "Ok" button and as well as "Apply" buttons.

How can I change top level package name in IntelliJ IDEA?

I have a package structure: com.report.domain.model
I would like to change it to com.reporting.domain.model. When I select Refactor → Rename on package com.report.domain.model, I only see an option to rename 'model'. I have tried switching between Project view and Package, but to no avail. I know how to make this change in Eclipse via Navigator view, but how can I do the same in IntelliJ IDEA?
In the Project Window, click on the Gears icon in the title bar and deselect "Compact Empty Middle Packages". Then you can separately select the report package and rename it.
See also: http://www.jetbrains.com/idea/webhelp/project-tool-window.html#d242351e401
N.B. As of IntelliJ IDEA 2016.3, there is a bug in the menu and when the option is selected, it has a different label "Hide Empty Middle Packages", see https://youtrack.jetbrains.com/issue/IDEA-168362.
To change the full package name:
User jkovacs has already answered this, but I'm going to cover this in a bit more detail. For example, if you want to change com.example.app to my.awesome.game, then:
In your Project pane, click on the little gear icon ()
Uncheck / de-select the Compact Empty Middle Packages option:
Your package directory will now be broken up in individual directories.
Individually select each directory you want to rename, and:
Right-click it
Select Refactor
Click on Rename
In the Pop-up dialog, click on Rename Package instead of Rename Directory
Enter the new name and hit Refactor
Allow a minute to let Android Studio update all changes
Note: When renaming com in Android Studio, it might give a warning. In such case, select Rename All:
Now open your Gradle Build File (build.gradle - Usually app or mobile). Update the applicationId to your new Package Name and Sync Gradle, if it hasn't already been updated automatically:
Done! Anyway, Android Studio needs to make this process a little simpler.

How to add a preference page?

I want to add a preference page in my RCP program, just like you see in the eclipse, when you click Windows->Preferences->General, a preference page appears in the right panel. But I'm not familiar about RCP, how can I add a option in the Windows->Preferences lists, and make it work like the "General" option?
Thanks a lot.
There are several tutorials out there:
http://www.eclipse.org/articles/Article-Preferences/preferences.htm
http://www.vogella.de/articles/EclipsePreferences/article.html
Open the plugin.xml from the Package explorer and go to Extensions tab. Click add and search for org.eclipse.ui.preferencePage and Finish. Right click on the preferncePage plugin, choose New-->Page. On the right hand side, fill the required fields and save it.
Run the plugin as an Eclipse application. Go to Windows-->Preferences and you will find your custom preference page.

Categories

Resources