Saturday, December 31, 2011

Code Clips Eclipse Plug-in

The Code Clips Eclipse Plug-in lets you create code clips on the fly and associate abbreviations with them. The abbreviations are expanded using the TAB key.



If there is more than one abbreviation that matches the prefix before the caret then a content assist style popup is shown. You may select the item in the popup by clicking on it or typing it's ordinal number. Once selected the expansion associated with the selected abbreviation is inserted in place of the prefix.



The expansion text may contain the following variables:



The numbered variables ${1} through ${9} act as tab stops. The ${clipboard} variable will be replaced by the contents of the clipboard at the time of expansion. You can use the Variablize... dialog to convert multiple occurrence of same word into a variables. All occurrences of the same variable can be edited together using the Linked editing support of Eclipse editors.

To create a code clips use the Edit > Create Code Clip menu item


or use Control+5 (windows and linux) or Command+5 (mac) keyboard shortcuts. This will show the Create Code Clip dialog.


If you had any text selected in the editor that will be populated in the Expansion text area. You may insert the above mentioned variables using the Insert Variables menu button.

You can manager the Code Clips using the Manage Code Clips dialog which can be invoked by clicking on the Manage... button in Create Code Clips dialog :


The Code Clips Eclipse Plug-in is available on Eclipse Marketplace!

Tuesday, December 27, 2011

UPDATED:One-click editor splitting in Eclipse

In the One-click editor splitting in Eclipse post I blogged about a simple Eclipse plug-in that lets you split the active editor. I have updated the plug-in to let you split the active editor with any other editors in the same tab. The functionality is available in the Split Editor toolbar's Horizontal and Vertical split button's drop down menu.


The updated Split Editor Plug-in is available on Eclipse Marketplace!

Saturday, December 10, 2011

TIP: Stable history navigation using Eclipse toolbar

Eclipse has a nice location history navigation toolbar. By repeatedly clicking on the history toolbar buttons you can quickly navigate to the locations the cursor/focus was at in various editors that are open. Unfortunately, out of the box, the position of the history navigation toolbar buttons is not stable if you have files of varying types open in the editor area. That is because the toolbar contributed by various editors are shown and hidden as the focused editor changes. These editor contributed toolbars (shown in blue rectangle below), when shown, are inserted to the left of history navigation toolbar. The following two screenshots demonstrates the behavior.



Fortunately there is a way to fix this behavior. It is possible to to drag the editor toolbar to the right-most side of the toolbar strip like shown in the following screenshot:



With this adjustment the history navigation toolbar remains in same place making it easier to use.

You may have to unlock the toolbars to see the drag handles as shown in the screenshot below:


I think this should be the default location of editor toolbars in Eclipse. Just filed this enhancement.

Such small adjustments makes the tool more productive.


Sunday, December 04, 2011

Selection Explorer Eclipse Plug-in


This Selection Explorer feature shows information about:
  • Active Part (this is somewhat similar to Plug-in spy action)
    • Part name
    • Part Id
    • Class implementing the part
    • Super class of the class implementing the part
    • Interfaces
    • Contributing Plugin
  • Active Selection
    • Class of selection objects
    • Superclass of selection object
    • Interfaces
    • Adapted Types
    • toString() value
  • Active Contexts
  • Active ActionSet Contexts

in the Selection Explorer view. Here are some screenshots:


Clicking on the hyperlinks shows the Open Type dialog:


Thursday, December 01, 2011

Close Views Eclipse Plug-in


The Close Views feature provides commands related to closing views:
  • Window > Close (active) View - This closes the last active view.
  • Window > Close All Views in Tab - This closes all views in the tab containing the last active view.
  • Window > Close Other Views in Tab - This closes other views in the tab containing the last active view.
  • Window > Other Views -  This closes all views except the last active view.
  • Window > Close All Views - As such this closes all the open views. If all the views are already closed it offers to reset the perspectives.
Here is a screenshot:



Update site:
http://sandipchitaleseclipseplugins.googlecode.com/svn/trunk/CloseViewsFeatureUpdateSite/site.xml

Also on Eclipse Marketplace.

Monday, November 28, 2011

Path Tools Eclipse Plug-in Updated


What is new?

  • Added support for Copy Path, Explore and Command Line Shell actions to local resources in RSE (needs RSE)
  • Added Copy SVN URL for resources in SVN based projects (needs Subclipse)

Read more here.

Wednesday, July 13, 2011

Google Factor

Recently I joined the Google+. Today I got an invite for Google Music. Was looking at my Google Accounts page and realized so much of our life is on Google based services.

Just came up with a new term - Google Factor or GF for short

Google Factor, noun
GF, acronym

definition:
  • Percentage or ratio of your waking life that involves Google services
usage:
  • What is your GF?
  • Just signed up for new Google Service FOO, now my Google Factor is .37.
Kind of scary!

Friday, June 17, 2011

Eclipse: Key Strokes display utility

Key Strokes is a simple Eclipse plug-in to display the typed Key Strokes in a small, always-on-top window. Useful for doing Eclipse screen casts no matter which platform you are on. Only works when working inside Eclipse.



You can install the plug-in from it's update site:

http://sandipchitaleseclipseplugins.googlecode.com/svn/trunk/KeyStrokesUpdateSite

Please file any issues at:

http://code.google.com/p/sandipchitaleseclipseplugins/issues/list

Enjoy!

Saturday, June 04, 2011

Eclipse: Command Key binding Cross Reference

I dusted off an Eclispe Plug-in that I had developed a few years ago. The idea is similar to Emac's describe-key (Ctrl+h) and where-is (Ctrl+w) but applied to Eclipse with some additional bells and whistles.

The  Command Key binding Cross Reference Plug-in shows a pop-up dialog. The dialog can be invoked in two modes:
  • Key binding centric
  • Command centric
Key binding centric mode can be invoked by clicking on the keys icon (Ctrl+Alt+Shift+K) in the status bar. It shows the following pop-up dialog:



The focus is in the Keysequence: field. You can type any modified keys and it shows the key sequence in text for e.g. Ctrl+D in the screenshot above. The BACKSPACE works normally. If you want to enter the BACKSPACE key itself use the small left arrow menu next to the Keysequence: field. In the bottom table it shows all the commands that match the key  sequence text. The current hierarchy of contexts, platform, and some help info is shows in the legend at the bottom. For example, the legend is showing that the Editing Java Source context is the most active context. The commands applicable in the context are shown in normal font. The commands not applicable in any of the active contexts are shown in disabled font. You can invoked the active commands by double clicking on the row or selecting the row and typing Enter key.

Eclipse has different key binding schemes. You can explore the key bindings of other schemes by selecting it in the Scheme: combo box.

You can type the keys without any modifiers. In that case commands matching all modifier variants of the key sequence are shown:



This can help you see if you are defining the key binding modifiers in a consistent fashion.

Command centric mode can be invoked by clicking on the keys icon(Ctrl+Alt+Shift+L) in the status bar. It shows the following pop-up dialog:



In this mode the Command: field has the focus. You can just type part of the command name and it will filter out the matching commands. To anchor the match at the beginning use the ^. You can use the * and ? as the wildcards. You  can easily switch Key binding centric mode by hitting tab.

Lastly, the P column shows the icon of the platform if the command is defined for a specific platform such as Windows, Macor Linux. The U column shows the icon if the user has customized the key binding using Preferences > General > Keys.

You can install the plug-in from it's update site:

http://sandipchitaleseclipseplugins.googlecode.com/svn/trunk/commandkeybinding.xref.updatesite


Please file any issues at:

http://code.google.com/p/sandipchitaleseclipseplugins/issues/list


Works in Eclipse 3.5.x and 3.6.x.

Enjoy!

Sunday, May 29, 2011

Eclipse: Show all instances of selected Java Class

As mentioned in the Eclipse help Java Development User Guide Tips and tricks Debugging section, when debugging with JavaSE-1.6 you can see all instances of a particular class. You can invoke this functionality via the popup menu (All Instances...) of Variables view rows for reference type values or in the Java editor by positioning the cursor on or selecting a reference type expression. However it is not possible to see all instances of an arbitrary class. The All Instances plug-in adds this functionality. It can be invoked using the:
  • Run > All Instances of Java Class... 
  • All Instances of Java Class... toolbar buttons in the Variables and Expressions views
Once invoked it shows the following customized Open Type dialog of JDT.


Once you selects the class it adds the <Java Class> Instances expression to the Expressions view. Please note that instances of sub classes are also shown if the Show instances of subclasses checkbox is selected. For example, when java.io.OutputStream is selected it shows the instances of it's subclasses also. You can further filter out inner and anonymous inner classes using the additional check boxes. This functionality is not provided by Eclipse Java debugger's All Instances... action.


In addition, an expression showing java.security.CodeSource info for the class is also added if that information is available.



NOTE: The selected class (FQN) may have been loaded by different ClassLoaders. Entries for each class loaded by distinct Classloader are shown independently. This is helpful in debugging issues related to class loading and seemingly mysterious ClassCastExceptions.

These expressions are automatically removed from the Expressions view when the debug session terminates.

You can further explore the instances using the All References... popup menu item provided by the Eclipse Expressions view. This can help you track down who is holding on to the instance potentially causing a memory leak.

The functionality works only if you have a active Java debug session, running under a JavaSE-1.6 (and above) that supports the all instances retrieval functionality, selected in the Debug view.

You can install the plug-in from the plug-in's update site:

http://sandipchitaleseclipseplugins.googlecode.com/svn/trunk/AllInstancesUpdateSite

Please file any issues at:

http://code.google.com/p/sandipchitaleseclipseplugins/issues/list

It works in Eclipse 3.5.2, 3.6.x and 3.7.x.

Also available on Eclipse Marketplace!

Enjoy!

Thursday, April 21, 2011

Eclipse: Find/Replace Bar

I prefer NetBeans style Incremental Search Bar interface instead of the usual Find/Replace Dialog. Eclipse only has the Find/Replace Dialog. So I implemented a similar Find/Replace Bar for Eclipse. Here are the screenshots:



Known issue: If you have customized the perspective, the Find bar view will be shown with a tab unlike the above screenshot. Try resetting the perspective and the tab may go away. I had mixed success with that though.

Find/Replace Bar Plug-in is on Eclipse Marketplace !

Currently the Find/Replace Bar supports the following features:
  • Find as you type
  • Find Next/Find Previous
    • same key bindings as Eclipse
  • Show the total number of occurrences in the document
  • Case sensitive mode
  • Whole word only mode
  • Regular Expression mode
    • Indicate illegal regular expression
  • Show Find/Replace dialog by pressing CTRL+F on Windows and Linux and COMMAND+F on Mac
  • Enable/Disable Find/Replace Bar using preferences
    • Show Preferences button on the Find/Replace Bar
  • Optionally override the standard Find/Replace Dialog of Eclipse. Control the override through preference page.
  • Press CTRL+F on Windows and Linux and COMMAND+F on Mac to show the Find/Replace Bar
    • Press ESCAPE to hide the Find/Replace bar
    • Find/Replace Bar works with text editors inside a Multi page editor e.g. plugin.xml XML editor inside the Plug-in Manifest editor.
    • Show the preceding and succeeding match count
    • Show text matching groups in regular expressions in a combobox
    I am planning to implement the following enhancements:
    • Full Replace/Find,Replace and Replace All support
    • Find in selection
    • Highlight current and other occurrences of the matched text
      • Highlight groups in regular expressions in different colors
    • Show current line number and column range of the match
    • Make it work in Console and other views where Find/Replace dialog is applicable
      You can install it from the plug-in's update site:

      http://sandipchitaleseclipseplugins.googlecode.com/svn/trunk/FindReplaceBarUpdateSite/

      Please file any issues at:

      http://code.google.com/p/sandipchitaleseclipseplugins/issues/list

      After installing the plug-in, go the Find/Replace Bar preferences page to enable the Find/Replace Bar as shown in the screenshot below:



      Works on Eclipse 3.6 and 3.5.2

      Enjoy!

      Wednesday, March 30, 2011

      One-click editor splitting in Eclipse

      [Note: Does not work in Eclipse 4.x]
      UPDATE: Eclipse Luna 4.4 M4 now supports editor splitting... NEW and NOTEWORTHY.

      You may know that one can split layout the editors in Eclipse by dragging the editor tab to any edge of the editor area. This works only if you have more than one editor. However there are times when I want to work on two parts of the same file. To do that I first do Window > New Editor to duplicate the editor and then drag it to split the editor in a side-by-side or top-bottom layout. But that is too many clicks and drags. I developed a simple Eclipse Plugin which will help you split the active editor either horizontally or vertically with a single click. It is based on some code I found here that was written by Dimitri Missoh (thanks Dimitri - I have given you credit in the source code of the plug-in). I adapted his code to suite our purpose.

      Here is the screenshot:


      Split Editor Plug-in is available on Eclipse Marketplace!

      You can install it from the plug-in's update site:

      http://sandipchitaleseclipseplugins.googlecode.com/svn/trunk/SplitEditorFeatureUpdateSite

      Source code is here.

      Works in Eclipse 3.4, 3.5, 3.6, 3.7 and 3.8.

      Also available on Eclipse Marketplace.

      Enjoy!

      Tuesday, March 15, 2011

      XCode: Corrected user scripts - Delete Line, Copy/Move line Up/Down

      [Note: It is a shame that XCode 4 does not have the Scripts menu]

      XCode has the following scripts:
      • Delete Line
      • Move Line Up
      • Move Line Down
      I added two more (as described in this post):
      • Copy Line Up
      • Copy Line Down
      However there was a problem. The script always worked on the first text document. That meant that when you had multiple documents open, the commands sometimes modified the document which did not have focus (baaad!).

      It turns out the window 1 is always the window which has the focus. I corrected the scripts to make use of this fact. Here is the general strategy behind the modifications I made to the scripts:
      :
      :
      using terms from application "Xcode"
       set selectedDocument to missing value
       repeat with index from 1 to (count of text documents)
        if (associated file name of window 1 as string) is equal to (path of text document index) then
         -- found the document
         set selectedDocument to (text document index)
         exit repeat
        end if
       end repeat
       if (selectedDocument is not missing value) then
        tell selectedDocument
         -- do the modifications to document
        end tell
       else
        beep 1
       end if
      end using terms from
      

      Download the scripts here. Just unzip and drop the scripts in /Developer/Library/Xcode/User Scripts/ .

      I have filed a bug at http://radar.apple.com for this. The problem Id is 9138643. I have attached the fixed scripts to the problem.

      Wednesday, March 09, 2011

      XCode: Copy/Move Up/Down line


      [Note: Please see this post for corrected scripts]

      XCode already has the following scripts under Script Menu > Text
      • Delete Line
      • Move Line Up
      • Move Line Down
      I added the following two scripts:
      • Copy Line Up
      • Copy Line Down
      Basically I started by creating the following Applescript files:

      /Developer/Library/Xcode/User Scripts/Copy Line Up.scpt with content:

      --
      (*
      To edit this script, choose Save As... and save it in your home directory, then re-add it to the User Scripts list.
      *)
      using terms from application "Xcode"
      tell first text document
      set {startLine, endLine} to selected paragraph range
      if startLine > 1 then
      set theText to (paragraphs startLine through endLine)
      set theText to (theText as string)
      make new paragraph at beginning of paragraph (startLine) with data theText
      set selected paragraph range to {startLine, endLine}
      else
      beep 1
      end if
      end tell
      end using terms from
      --

      /Developer/Library/Xcode/User Scripts/Copy Line Down.scpt with content:

      --
      (*
      To edit this script, choose Save As... and save it in your home directory, then re-add it to the User Scripts list.
      *)
      using terms from application "Xcode"
      tell first text document
      set {startLine, endLine} to selected paragraph range
      if endLine < (count paragraphs) then
      set theText to (paragraphs startLine through endLine)
      set theText to (theText as string)
      make new paragraph at beginning of paragraph (startLine + 1) with data theText
      set selected paragraph range to {endLine + 1, endLine + 1}
      else
      beep 1
      end if
      end tell
      end using terms from
      --

      and then added those scripts using the Script Menu > Edit User Scripts... dialog.


      While I was at it I added the following keybindings:

      Delete Line Command+D
      Move Line Up Alt+UP
      Copy Line Up Control+Alt+UP
      Move Line Down Alt+Down
      Copy Line Down Control+Alt+Down

      Note: The Command+D keybinding for Delete Line conflicts with the default Add Bookmark keybinding. I changed that keybinding to something else in Preference > Key Bindings > Menu Key Bindings > Edit section.

      Here is the screenshot:


      Now I have my LineTools NetBeans plugin like functionality in XCode. Yay!