Wednesday, October 26, 2011

Eclipse Development Environments : WorkSpace Provisioning

last week i was going through Yoxos 5 WorkSpace  profiling tools by eclipse Source(http://eclipsesource.com/en/yoxos/) . i found very interesting  to customize the download plugin based on requirement of development.

http://www.youtube.com/watch?v=-8IMuwKz2b4&feature=related




Tuesday, October 25, 2011

Programming and Algorithm : Find first Non repeated character in a string


possible solution to find non-repeated character in a string


package findFirstRepeatedCharInString;

import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;

public class findFirstNonRepeatedCharInString {

/*=================================Solution1=========================*/
public static char firstNonRepeatingCharacterInString1(String str) {
boolean found;
char[] chars = str.toCharArray();
for (int i = 0; i < chars.length; i++) {
found = false;
for (int j = 0; j < chars.length; j++) {
found = (i != j) && (chars[i] == chars[j]);
if (found) {
break;
}
}
if (!found) {
return chars[i];
}
}
return '-';
}

/*===================================solution2========================*/
public static char firstNonRepeatingCharacterInString2(String str) {
Set<Character> chSet = new LinkedHashSet<Character>();
char[] charArray = str.toCharArray();
for (int i = 0; i < charArray.length; i++) {
if (!chSet.add(charArray[i])) {
chSet.remove(charArray[i]);
}
}
if (chSet.isEmpty())
return '-';
else
return (Character) (chSet.toArray())[0];
}

/*=============================================================*/

/*============================solution 3===============================*/
/* To find first non repeating character in a string
     * eg: if string is 'total' then 'o' is the answer
     * eg: if string is 'tweetwer' then 'r' is the answer
     * time complexity :
     * space complexity;
     */
    public static char firstNonRepeatingCharacterInString3(String s) {
        if (s == null)
            return '-';
        Map<String, Integer> inputMap = new HashMap<String, Integer>();
        for(int i=0; i < s.length(); i++) {
            String key = s.substring(i, i+1);
            if (inputMap.get(key) == null) {
                inputMap.put(key, new Integer(0));
            }
            else {
            int it = inputMap.get(key)+1;
                inputMap.put(key, it);
            }
        }
        //Now start from the start of the string and find the character which has count 1
        // first in order from left to right
        boolean found = false;
        String nonRepeatingStr = null;
        for(int i=0; i < s.length(); i++) {
            String key = s.substring(i, i+1);
            if(inputMap.get(key) == 0) {
            nonRepeatingStr = key;
            found= true;
                break;
            }
        }
        if(found){
        return nonRepeatingStr.toCharArray()[0];
        }
        return '-';
    }
 
 

/*==============================================================*/

public static void main(String[] args) {
System.out.println(firstNonRepeatingCharacterInString1("abcxafabc"));
System.out.println(firstNonRepeatingCharacterInString2("abcxafabc"));
System.out.println(firstNonRepeatingCharacterInString3("abcxafabc"));

System.out.println("====================================");
System.out.println(firstNonRepeatingCharacterInString1("tweetwer"));
System.out.println(firstNonRepeatingCharacterInString2("tweetwer"));
System.out.println(firstNonRepeatingCharacterInString3("tweetwer"));

System.out.println("====================================");
System.out.println(firstNonRepeatingCharacterInString1("total"));
System.out.println(firstNonRepeatingCharacterInString2("total"));
System.out.println(firstNonRepeatingCharacterInString3("total"));


}

}

Monday, December 28, 2009

Eclipse - Customization using "plugin_customization.ini"


plugin_customization.ini is actually a file that can be used to set any Eclipse preference on startup.  Given that, the settings that can go in there are basically whatever preferences any plugin sets.  So, do you want to know where those settings are persisted in the client?  In the Notes data directory follow this path:
workspace\.metadata\.plugins\org.eclipse.core.runtime\.settings
That directory contains all of the “.prefs” files for each and every plugin – ie. each one of those files is a preference store.  They are readable to the human eye in a text editor so crack one open in your favorite text editor.
Here is how it works;  we will use the preference setting :
com.ibm.notes.branding/enable.update.ui=true
The format of the entry is this:     <plugin id> / <setting> = <value>

So if you look for the file “com.ibm.notes.branding.prefs” and open it you will see all of the Eclipse preferences this plugin supports.  Usually these can be controlled by the Application | Preferences panels but some are only set in code.  Just depends if you want users changing them or not.

Here is  some of example for plugin_customization.ini

# plugin_customization.ini
# sets default values for plug-in-specific preferences
# keys are qualified by plug-in id
# e.g., com.example.acmeplugin/myproperty=myvalue

# show progress on startup
org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP=true

# new-style tabs by default
org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false


# show memory monitor by default
org.eclipse.ui/SHOW_MEMORY_MONITOR = true

#####################################Perspective#############################################################
# put the perspective switcher on the top right
org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight

# Property "org.eclipse.ui/defaultPerspectiveId" controls the
# perspective that the workbench opens initially
org.eclipse.ui/defaultPerspectiveId=com.khalid.perspectives.myPerspective

#sets of perspectives be closed/opened by actions
org.eclipse.ui/PERSPECTIVE_BAR_EXTRAS =com.khalid.perspectives.myPerspective, org.eclipse.cdt.ui.CPerspective, org.python.pydev.ui.PythonPerspective

###################################################################################################


#############################################WELCOME(INTRO)########################################################
# Preference settings for universal intro pages (as of Eclipse 3.2)
#please see "http://www.eclipse.org/eclipse/platform-ua/proposals/shared-intro/shared-intro.htm"

#a unique identifier of the presentation theme to be used for this product.
org.eclipse.ui.intro/INTRO_THEME = org.eclipse.ui.intro.universal.circles

#a comma-separated list of root page identifiers that should be visible in the home page
org.eclipse.ui.intro.universal/INTRO_ROOT_PAGES = overview,firststeps

#a file name pointing at the XML file with the page layout settings org.eclipse.ui.intro.universal/INTRO_DATA = product:intro-data.xml

#the id of the page which will be shown when Eclipse starts the first time. org.eclipse.ui.intro/INTRO_START_PAGE = overview

#the id of the page which will be shown when the home button is pressed.org.eclipse.ui.intro/INTRO_HOME_PAGE = firststeps

#the id of the page which will be shown when welcome is displayed in a non-maximized form.org.eclipse.ui.intro/INTRO_STANDBY_PAGE =  firststeps
#######################################################################################################
plugin_customization.ini will be added under the "org.eclipse.core.runtime.products" extension as specified below

 <?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         id="khalidProduct"
         point="org.eclipse.core.runtime.products">
      <product
            application="org.eclipse.ui.ide.workbench"
            description="%productDesc"
            name="%productName">
         <property
               name="windowImages"
               value="icons/product.png,icons/About_Box_sdk.png,icons/About_Box_text_sdk.png,">
         </property>
          <property
               name="preferenceCustomization"
               value="plugin_customization.ini">
         </property>
    </extension>
    </plugin>

the property for the product is available under "org.eclipse.ui.branding.IProductConstants"
:

Friday, January 16, 2009

Eclipse - Efficiently using shortcut keys


I’ve found a few Eclipse shortcut tutorials around that explain how to access features through shortcuts in Eclipse. One of the most useful I’ve found, and use all the time is the old CTRL+SHIFT+R shortcut for opening a resource.  I’ve noticed that there are a number of these documented within the Eclipse help menu here:

You can also view a list of common shortcut keys using the shortcut:
CTRL+SHIFT+L
http://blog.oogly.co.uk/wp-content/uploads/2009/01/shortcutkeys.jpg
From here you can also access the key bindings menu by hitting CTRL+SHIFT+L again (as indicated in the diagram).  This allows you to remap the key bindings or setup new key bindings.  Eclipse also supports Emacs type bindings.
There are also a number of cheat sheets on the internet that you can print out and stick on the wall (or cubicle or whatever) to help you out. I’ve not found an editable template for these so I created my own in Microsoft Word format which can be found below.  This includes a list of the shortcuts I commonly use on a day to day basis.


CTRL+SHIFT+G – search references of class in workspace

SHIFT+F2 – open external javadoc

ALT+LEFT ARROW – back

CTRL+SHIFT+O – organize imports

CTRL+M maximalize window

ALT+SHIFT+J – add javadoc

Ctrl+Shift+O -  is a really big one. Just enter unqualified class names and use Ctrl+Shift+O to resolve everything. If there’s only one class with that name, it will be auto-imported. If there’s more than one, you get a dialog similar to Open Type in which you can choose the correct class.

Ctrl+Alt+H - (show call hierarchy) is another I use on a daily basis.

Shift+Alt+L  - extracts an expression to a variable.

Alt+Shift+W: “Show in…”, easy way to highlight the file you’re currently editing in the Navigator panel.

Alt+Shift+T: Refactor sub-menu

Alt+Shift+S: Source sub-menu

Alt+Shift+V: Move (refactor)

alt+shift+S R – generate java bean getters and setters for fields

alt+shift+S V – override methods

alt+shift+S O – generate constructor from fields

alt+shift+S C – generate constructors from superclass

alt+shift+M extract method

alt+shift+L extract variable

alt+shift+I inline variable

alt+shift+C change method sig

alt+shift+Z surround with
 

Open Type (Ctrl-Shift-T) -  to open a class, and Open Resource to browse to a file.

Ctrl-O in a class definition brings up Quick Outline. Start typing a member name and hit return once it’s unambiguous. Combined with Open Type this is a lightning fast way to go to any method in any class.

Ctrl-F6 is a great way to jump around between open editors. 

Ctrl-F7 does the same for views

Ctrl-F8 for perspectives.

Shift-Alt-X T to run the unit tests in the class you’re working on.

Alt+Shift+W: “Show in…”, easy way to highlight the file you’re currently editing in the Navigator panel.
Alt+Shift+T: Refactor sub-menu
Alt+Shift+S: Source sub-menu
Alt+Shift+V: Move (refactor)