intellij etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
intellij etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

6 Aralık 2016 Salı

MacOs Friendly Intellij IDEA Shortcuts

Shortcuts help developers to be more productive and prevent distraction caused by mouse. Unfortunately, there are subtle shortcut differences between different platforms. Following Intellij IDEA shortcuts will increase productivity in MacOs environment:

VCS
Intellij IDEA does not provide preconfigured VCS shortcuts. To make it easy to remember, all shortcuts are assigned to ALT button and all shortcuts denote the first letter of assigned action (except Commit/Check In).

Alt+A                        Annotate
Alt+U                        Update
Alt+R                        Rollback
Alt+H                        History

Alt+C                        Commit/Check In
Alt+P                        Push

The reason why 'I' character is selected as shortcut of "Commit/Check In" is, because Intellij IDEA already used this character in "Commit Changes" dialog for "Commit/Check In" action .



Intellij IDEA already provides a shortcut for Push action which is SHIFT+COMMAND+K. This shortcut is not easy to remember. It is suggested to use ALT+P for Push action.

31 Mart 2009 Salı

Intellij Knows How To "Extract Method"

Intellij has a great refactoring feature called "Extract Method". You can convert a code piece into a method using this feature. In this process, Intellij can handle all method parameters and return values. You can use this feature first by selecting the code piece you wish to convert to method, and press CTRL+ALT+M.

I will explain what impressed me most about this feature using following example. In the following code, I am not comfortable with the first try/catch block and I want to hide this dirty code inside a method.
 1     public static void main(String[] args) {
2 Connection conn = null;
3
4
//I am not comfortable with following try/catch block
5 try {
6 Class.forName("com.mysql.jdbc.Driver");
7 } catch (ClassNotFoundException e) {
8 e.printStackTrace();
9 System.out.println("Driver not found");
10 return;
11 }
12
13
try {
14 conn = DriverManager.getConnection(
15 "jdbc:mysql://localhost/petshop", "root", "changeme");
16 Statement statement = conn.createStatement();
17 } catch (SQLException e) {
18 e.printStackTrace();
19 }
20 }
21
To achieve this, position the cursor over 5th line and press CTRL+W. By the way, this is another nice Intellij feature called "Incremental Select" :).



Then, press CTRL+ALT+M. Notice that, the return type of the method is boolean. Click OK and see what we'll get:


Following is the refactored version of our code. Let's see what happened. Intellij put the code inside a method which returns boolean and wrapped the method call inside an if statement. This was the only possible solution which wouldn't violate the flow of program:).

 1     public static void main(String[] args) {
2 Connection conn = null;
3
4
//I am comfortable now
5 if (lookupClass()) return;
6
7
try {
8 conn = DriverManager.getConnection(
9 "jdbc:mysql://localhost/petshop", "root", "changeme");
10 Statement statement = conn.createStatement();
11 } catch (SQLException e) {
12 e.printStackTrace();
13 }
14 }
15
16
private static boolean lookupClass() {
17 try {
18 Class.forName("com.mysql.jdbc.Driver");
19 } catch (ClassNotFoundException e) {
20 e.printStackTrace();
21 System.out.println("Driver not found");
22 return true;
23 }
24 return false;
25 }
26

30 Eylül 2008 Salı

A Nice Maven Feature In Intellij 8

There is a useful maven feature in Intellij 8. As you know, maven doesn't download the sources.jar files of the libraries into the local repository, by default. You can download the sources.jar files of the dependencies of the project by just one click of a button. First open the Maven view in Intellij. Then press the "Download artifacts" button from the toolbar:



Actually this feature also exists in Intellij IDEA v7 but I can't make it work. Probably, there is a bug. Please inform me, if there is anyone who can use the feature in version 7.

17 Ağustos 2008 Pazar

Intellij Knows Swing

As I use Intellij more and more, I get more and more suprised, more and more excited.

Yesterday, I was trying to change the cursor in a swing project, using setCursor() method. I expected Cursor.W_RESIZE_CURSOR would return a java.awt.Cursor object and coded as below. But something was wrong with my code:












...And immediately, Intellij told me what was wrong with my code:). I should have called Cursor.getPreferredCursor(). I applied Intellij's suggestion, and the error was corrected. My intelligent IDE again saved me to search for example codes on the internet:

2 Kasım 2006 Perşembe

My First Intellij Plugin: Classpath Complete

I have just released my first open-source Intellij plugin. The plugin is hosted in Intellij's web site: http://plugins.intellij.net/plugin/?id=1214. This is an alpha release. There are a couple of missing features that I am planning to implement soon.

The source code can be downloaded here.

What the plugin does:

There are plenty of jar files around that a java developer should be aware of. Sometimes, we need some classes but we may not know which jar files contain these classes. In the build process, if the jar files does not exist in the classpath of java projects, the compiler throws "cannot resolve symbol" errors for classes which cannot be found in the classpath. My plugin comes into play in this situation. The plugin finds all the jar files on all of the drives of the computer. Then it finds the classes inside the jar files. The information is saved in Intellij IDEA's configuration file. This process needs to be done only once. After the plugin is initialized, you can search the missing classes using a dialog box, to find which jar file contains the class and later add the jar to the project's classpath.