https://marketplace.eclipse.org/content/cut-copy-paste-plus
Wednesday, February 01, 2012
Eclipse: Cut Copy Paste Plus Plug-in
The Cut Copy Paste Plus Eclipse Plug-in enhances the cut, copy functionality by recording the history of the text that was cut or copied. It enhances the paste functionality by allowing you to paste the text from the history. To use the cut and copy history functionality you do not have have to do anything special. To access the special paste functionality you have to invoke Paste Plus command which is by default bound to Ctrl+Shift+V on windows and linux and Command+Shift+V on mac. You can change the keybindings to liking using the Preferences > General > Keys preference page. When you invoke this command the text that was last copied is pasted. If you re-invoke the same commands within a short period of time (default 1 second) - the text from the history is pasted.
The behavior of the plug-in can be configured in the Cut Copy Paste Plus preference page:
In the following example I copied the words three, four and five. Then I invoked the Paste Plus command. The first time it pasted five :
Ctrl+Shift+V
Ctrl+Shift+V (within 1000 millisecond)
Ctrl+Shift+V (within 1000 millisecond )
BTW this works in any StyledText and Text widgets.
You can install the plug-in from Eclipse Marketplace:
https://marketplace.eclipse.org/content/cut-copy-paste-plus
https://marketplace.eclipse.org/content/cut-copy-paste-plus
Enjoy!
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 :
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.
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:
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.
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:
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
, Mac
or 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!
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.
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:

Lastly, the P column shows the icon of the platform if the command is defined for a specific platform such as Windows




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:
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.
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
- Run > All Instances of Java Class...
- All Instances of Java Class... toolbar buttons in the Variables and Expressions views
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
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/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:
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.
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:
XCode has the following scripts:
- Delete Line
- Move Line Up
- Move Line Down
- 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:
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.
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
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:
Here is the screenshot:
Now I have my LineTools NetBeans plugin like functionality in XCode. Yay!
Sunday, September 05, 2010
Updated Path Tools Eclipse plug-in
What's new?
- The Custom commands can now we edited using the table editor which allows you to use a display labels and wildcard patterns for the command. The display label is used in the menu items that invoke the commands. The wildcard patterns are used to determine if the command applies to the selected file.
- The Path Tools commands remain enabled even if there is no file selected in the Eclipse workbench. The commands operate on the workspace folder when no file is selected in the workbench.
Read more about Path Tools here.
Tuesday, May 11, 2010
LinearLayout gravity and layout_gravity explained
Recently I started hacking on Android. Android uses Java as the development language which made it very easy to get started :) .
I am very familiar with Swing and SWT GUI layout mechanism of Layout Managers and Layouts respectively. I was happy to find out that Android also uses a notion of View Groups which are analogous to the Layout Managers. The Android supports several View Groups, LinearLayout, RelativeLayout to name a few. There many more.
The Android View Groups employ a notion of LayoutParams that are analogous to layout constraints used by Swing Layout Managers. The LayoutParams configure the way the Android View Group lays out it's children views. In Android the GUI can be either built programmatically using Java code or using an XML file. The structure of the XML elements parallels the structure of View object you may build programatically. The XML attributes are used to configure the Layout Params.
LinearLayout
The LinearLayout is a commonly used View Group that lays out it's children views either horizontally or vertically. More details of LinearLayout read this.
android:gravity and android:layout_gravity
After reading the documentation I set out to use the Linear Layout and I came across the the following layout params:
- android:gravity
- android:layout_gravity
I must say that my initial experience was a little frustrating. Based on the documentation it was not very clear how the above layout parameters work. After a little bit of googling I soon found out that many people have run into this. So I dove in to find out more details and finally understood how to use these layout parameters with Linear Layout. I will explain using an example layout:
<?xml version="1.0" encoding="utf-8"?>This results in the following layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:background="#666666">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Linear Layout - horizontal, gravity=center"
android:textColor="#FFFFFF" android:padding="2dip" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="horizontal"
android:layout_height="0dip" android:layout_weight="1"
android:gravity="center" android:background="#EEEEEE">
<Button android:id="@+id/Button01" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="top"
android:text="top"></Button>
<Button android:id="@+id/Button02" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center"
android:text="center"></Button>
<Button android:id="@+id/Button03" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="bottom"
android:layout_gravity="bottom"></Button>
</LinearLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Linear Layout - vertical, gravity=center"
android:textColor="#FFFFFF" android:padding="2dip" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="vertical"
android:layout_height="0dip" android:layout_weight="1"
android:gravity="center" android:background="#DDDDDD">
<Button android:id="@+id/Button04" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="left"
android:text="left"></Button>
<Button android:id="@+id/Button05" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center"
android:text="center"></Button>
<Button android:id="@+id/Button06" android:layout_height="wrap_content"
android:text="right" android:layout_gravity="right"
android:layout_width="wrap_content"></Button>
</LinearLayout>
</LinearLayout>
android:gravity attribute
Strictly speaking android:gravity is not a Layout Param. The android:gravity is really an attribute of the View Group. It controls the way the contents of the View Group will be positioned horizontally and vertically.
In the above example the top Linear Layout is a horizontal Linear Layout. So setting the android:gravity=center has an effect of positioning the set of buttons in the horizontal center.
In the above example the bottom Linear Layout is a vertical Linear Layout. So setting the android:gravity=center has an effect of positioning the set of buttons in the vertical center.
android:layout_gravity Layout Param
The android:layout_gravity is a Layout Param. Not all View Groups support this Layout Param. See the documentation to find out which Layout Params are supported by a particular View Group. Linear Layout does support android:layout_gravity Layout Param.
For a horizontal Linear Layout the following values make sense:
- top
- center
- bottom
That is because the children of a horizontal Linear Layout are layed out horizontally one after the other. Only thing can be controlled using the android:layout_gravity is how a child view is positioned vertically.
In the above example the top Linear Layout is a horizontal Linear Layout. Setting the android:layout_gravity=top on the l_g=top Button has an effect of positioning it at the top. Setting the android:layout_gravity=center on the l_g=center Button has an effect of positioning it at the vertical center. Setting the android:layout_gravity=bottom on the l_g=bottom Button has an effect of positioning it at the bottom.
For a vertical Linear Layout the following values make sense:
- left
- center
- right
That is because the children of a vertical Linear Layout are layed out vertically one below the other. Only thing can be controlled using the android:layout_gravity is how a child view is positioned horizontally.
In the about example the bottom Linear Layout is a vertical Linear Layout. Setting the android:layout_gravity=left on the l_g=left Button has an effect of positioning it at the left. Setting the android:layout_gravity=center on the l_g=center Button has an effect of positioning it at the horizontal center. Setting the android:layout_gravity=right on the l_g=right Button has an effect of positioning it at the right.
Wednesday, December 23, 2009
Mac Win Man - a unified Mac OS X Desktop Window and Application Manager
- Hide/Unhide Application
- Minimize/Unminimize Window
- Show window with same action no matter it was minimized or hidden
- Zoom/Unzoom Window
- Move and Resize windows using keyboard and mouse
- Resize windows by dragging on the window edges and corners
- Snap window to edges and center of the display using keystrokes
- Precisely position and size the windows by entering the location and size values
- Tile Windows Vertically
- Tile Windows Horizontally
- Cascade Windows
- Close Window
- Quit Application
Now works with multiple displays.
Friday, October 16, 2009
TIP:Applescript to invoke All Windows function of Exposé and bind it to key you please
Here is the applescript to invoke the All Windows function of Exposé :
So you say - what is the big deal?
Well, if you look at System Preferences... > Exposé and Spaces pane > Exposé Tab , you will see that it allows you to bind various functions to limited set of keys. The script enables you to bind it to any key such as Option+Tab. How? Heres how:
Save the above script in ~/Library/Scripts/Expose.app . Then bind it to Option+Tab using Quicksilver or Launchbar or Fastscripts.
on runAssuming you have bound Exposé:All Windows function to F9 key.
-- delay is needed so that keybindings defined in
-- tools like Fastscripts works
delay 0.1
tell application "System Events"
-- 101 is key code for F9 key
key code 101
end tell
end run
So you say - what is the big deal?
Well, if you look at System Preferences... > Exposé and Spaces pane > Exposé Tab , you will see that it allows you to bind various functions to limited set of keys. The script enables you to bind it to any key such as Option+Tab. How? Heres how:
Save the above script in ~/Library/Scripts/Expose.app . Then bind it to Option+Tab using Quicksilver or Launchbar or Fastscripts.
Saturday, October 03, 2009
Un-minimize minimized windows and bring them to front using Applescript
While implementing the AWS tool that I talked about in the last post - I learned a cool new Applescript technique to unminimize minimized windows. Here it is:
-- assuming you have name of a minimized window
set theWindowName to ....
-- is it minimized?
if (value of attribute "AXMinimized" of window theWindowName is true) then
-- first un-minimize the window
value of attribute "AXMinimized" of window theWindowName to false
end if
-- raise it
perform action "AXRaise" of window theWindowName
I had not much documentation on attributes such as "AXMinimized" and perform action "AXRaise".
-- assuming you have name of a minimized window
set theWindowName to ....
-- is it minimized?
if (value of attribute "AXMinimized" of window theWindowName is true) then
-- first un-minimize the window
value of attribute "AXMinimized" of window theWindowName to false
end if
-- raise it
perform action "AXRaise" of window theWindowName
I had not much documentation on attributes such as "AXMinimized" and perform action "AXRaise".
Friday, October 02, 2009
Ruby on Rails : Injecting routes from a separate file
I am currently working on a Ruby on Rails (RoR) application and needed a mechanism to load routes that are generated into a file by another tool. After some experimentation I came up with the following solution.
In a Ruby on Rails application the routing is configured using the config/routes.rb file. The routes are defined using the draw method of ActionController::Routing::Routes class like this:
Basically it is evaluating the contents of a file in the instance (current) scope. The File.expand_path(File.dirname(__FILE__)) simply computes the path to folder that contains routes.rb file. To that I append the name of generated routes file which lives next to routes.rb file.
Is there a better/idiomtic way to do this?
In a Ruby on Rails application the routing is configured using the config/routes.rb file. The routes are defined using the draw method of ActionController::Routing::Routes class like this:
ActionController::Routing::Routes.draw do |map|The block is executed with a local variable map in the scope. I wanted to insert routes defined in a separate file that is generated by another tool. To do that I tried to use the load or require methods. However I realized that it will not work because the load or require methods reset the scope to the top level. So I came up with the following:
...
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
# insert routes from generated file
instance_eval(File.read(File.expand_path(File.dirname(__FILE__)) + "/generated-routes.rb"))
Basically it is evaluating the contents of a file in the instance (current) scope. The File.expand_path(File.dirname(__FILE__)) simply computes the path to folder that contains routes.rb file. To that I append the name of generated routes file which lives next to routes.rb file.
Is there a better/idiomtic way to do this?
AWS - a unified Application and Window Switcher i.e. a Command TAB alternative
My other pet peeve with Mac OS X is how it deals differently with Applications and Windows that are minimized or hidden when one navigates using Command TAB(
TAB)/Command Shift Tab (
TAB).
Tuesday, July 14, 2009
Tuesday, July 07, 2009
Subscribe to:
Posts (Atom)