Friday, June 7, 2013

Eclipse window builder installation guide set up tutorial sample simple program

In Eclipse, go to
Help -> Install new software
Work with -> Juno - http://download.eclipse.org/releases/juno
It will list available plugins, Navigate to General purpose, select all window builder components and swt, swing designer components and then click install.

Once installed, it will prompt for restart.

Below is the sample program

Create a new class with name One, Right Click on it from Package Explorer -> open with Window builder editor. Then insert below sample code to it and then click design tab in left bottom corner of editor window.


import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JTextArea;


public class One {    // Your class name

  public static void main(String[] args) {
    
    JFrame f = new JFrame("A JFrame");
    f.setSize(250, 250);
    f.setLocation(300,200);
    f.getContentPane().add(BorderLayout.CENTER, new JTextArea(10, 40));
    f.setVisible(true);
    
  }
}

Thursday, June 6, 2013

Eclipse window builder error - This is not a GUI class and cant be edited graphically

The parser parsed the compilation unit, but can't identify any GUI toolkit.
Possible reasons:
  • You open a compilation unit without any GUI, such as an empty class, data bean, etc.
  • Classpath of project is not valid, does not include all required toolkit libraries.
  • You attempt to open UI for toolkit, support for which is not installed in WindowBuilder.
    Use button Show UI Toolkits to install new toolkit.  

Even after installing Window builder components in eclipse, if you get this error, switch to code and insert below code and then switch to design


import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JTextArea;


public class One {    // Your class name

 public static void main(String[] args) {
   
   JFrame f = new JFrame("A JFrame");
   f.setSize(250, 250);
   f.setLocation(300,200);
   f.getContentPane().add(BorderLayout.CENTER, new JTextArea(10, 40));
   f.setVisible(true);
   
 }
}

Tuesday, May 14, 2013

cognos javascript multi select checkbox default checked all checkbox


Cognos Javascript prompt functions does not work with checkbox prompts. So you have to do using following functions. It is working for me.


<script type="text/javascript">
var fW = (typeof getFormWarpRequest == "function" ? getFormWarpRequest() : document.forms);

if ( !fW || fW == undefined) {
fW = ( formWarpRequest_THIS_ ? formWarpRequest_THIS_ : formWarpRequest_NS_ );
}

if (fW) {
var list = fW._oLstChoicesChkbox1;
if(list.length == null) {             // if there is only one option
list.checked = "checked";
list.onclick();
}
else {
for( i=0; i<list.length;i++) {
list[i].checked = "checked";
list[i].onclick();
}
}
}
</script>

Friday, April 26, 2013

Cognos javascript to format color every numeric digits in page



<script>
window.onload=coloring();

function coloring()
{
    var spans = document.getElementsByTagName('span'),
    obj = {};
    var r = /[(]\d+[)]/;   /////////pattern will color every number of pattern: (1234)
    for (var i = 0, l = spans.length; i < l; i++) {
    obj[spans[i].id] = spans[i].textContent || spans[i].innerText;
        if (spans[i].innerText.match(r))    {
          alert( spans[i].innerText);
          spans[i].style.color="#FF0000";
        }
    }
}
</Script>

Thursday, April 25, 2013

JavaScript function to call another link in background applicable to Cognos too


<div id="bgFrame"></div>

<script type="text/javascript">
setTimeout(prepareiFrame,100);
function prepareiFrame() {
bgifrm = document.createElement("IFRAME");
document.getElementById("bgFrame").appendChild(bgifrm );
bgifrm.style.display="none";
bgifrm.setAttribute("src", " http://10.11.11.181:5050/Default.aspx?UserName=Cognos");
}
 </script>

JavaScript function to place div above another object


<!-- DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" -->
<script type="text/javascript" language="javascript">

function show_hide_functiondf()
{
if(document.all("MyDivdf").style. visibility =="visible")
{
document.all("MyDivdf").style. visibility ="hidden";
}
else
{
document.all("MyDivdf").style. visibility ="visible";
}
}
</Script>

<html>
<head>
<body>
<input id="Button1" type="button" value="Select Date" onclick="show_hide_functiondf()" />
</br>
<Div id="MyDivdf" style="visibility : hidden; position: absolute; border : red 3px solid; background: green">
Above
</Div>
Bottom
</body>
</head>
</html>

Saturday, May 19, 2012

Multiply records / rows retrieved Oracle query


EMP_NO     EMP_NAME    EMP_DEPTID   SALARY              
-----------     --------------    ----------------   -----------
1                          aaa                     3                  8000                
2                          bbb                    5                  12500                
3                          ccc                     6                  1200                
4                          ddd                    4                   500                  



with data
  as
  (select level-1 l from dual connect by level < = 100 )
  select emp_no, emp_name
from nz_test1, data
where l < emp_deptid
order by 1, 2;



EMP_NO    EMP_NAME     EMP_DEPTID     SALARY              
-----------   ---------------    ----------------     ----------
1                          aaa                        3                 8000                
1                          aaa                        3                 8000                
1                          aaa                        3                 8000                
2                          bbb                       5                 12500                
2                         bbb                        5                 12500                
2                         bbb                        5                 12500                
2                         bbb                        5                 12500                
2                         bbb                        5                 12500                
3                         ccc                         6                 1200                
3                         ccc                         6                 1200                
3                         ccc                         6                 1200                
3                         ccc                         6                 1200                
3                         ccc                         6                 1200                
3                         ccc                         6                 1200                
4                         ddd                        4                 500                  
4                         ddd                        4                 500                  
4                         ddd                        4                 500                  
4                         ddd                        4                 500                  

 18 rows selected