Thursday, October 17, 2013

SAP Transaction codes

You can find all transaction codes @ http://www.tcodesearch.com/


SE37 - ABAP Function Modules
SE16 - Data Browser(Table search)
SE11 - ABAP Dictionary Maintenance

GIT: Finding a commit based on SHA1 ID

> git show <sha1-id>

Example: > git show e43db49

This will display the complete changes including the with commit message.

Adding a new menu item in Eclipse Help Menu

As shown in the image below, if you want to add 'Tutorials' menu item in the Help Menu in Eclipse.




Adding command extension:

      <command
            defaultHandler="com.kk.help.TutorialsHelpHandler"
            id="com.kk.command.tutorialshelp"
            name="Tutorials">
      </command>


Adding menu extension:

 <menuContribution
            allPopups="false"
            locationURI="menu:help?after=intro">
         <separator
               name="slot1"
               visible="true">
         </separator>
         <command
               commandId="com.kk.command.tutorialshelp"
               label="Tutorials"
               style="push">
         </command>
         <separator
               name="slot2"
               visible="true">
         </separator>
      </menuContribution>


Handler implementation:

public class TutorialsHelpHandler extends AbstractHandler implements IHandler{

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
//implemention here

retun null;

}
}

Launching a URL in external browser from an eclipse plugin

public class HelpHandler extends AbstractHandler implements IHandler{


public static final String HELP_LIBRARY = "http:/kk.com/KKLibrary/";

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

try {
PlatformUI.getWorkbench().getBrowserSupport().getExternalBrowser().openURL(new URL(HELP_LIBRARY ));
} catch (PartInitException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
}

Tuesday, October 15, 2013

toArray Dynamic behaviour

public class ToArrayTest {

public static void main(String[] args) {

ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("1");
arrayList.add("2");
arrayList.add("3");
arrayList.add("4");

//what happens here??, since I have allocated new String[0] for single element, will it return single element or all elements ??
String[] array = arrayList.toArray(new String[0]); 
System.out.println(array.length);

}
}


Output:  4


As per spec, it's going to create a new array, if it does not fit in.
Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list. 

Wednesday, October 9, 2013

Understanding how Eclipse plug-ins work with OSGi

Install the plug-in bundle in the Equinox console


  1. Install the plug-in bundle in the Equinox console.
    osgi> install file:///<path to bundle>
    Equinox lists the bundle ID for the newly installed bundle:
    Bundle id is 17
  2. Enter the following line to start the bundle in the Equinox console, where <id> is the bundle ID assigned when the bundle was installed:
    osgi>  start <id>
  3. Retrieve the service status in the Equinox console to verify that the bundle started:
    osgi> ss
    When the bundle starts, the bundle lists the ACTIVE state, for example:
    17      ACTIVE      com.mycompany.plugin.bundle_xx