Examples of gKarSQLToken


Examples of gkarsql.utilities.gKarSQLToken

        String mustFill = "reserved";
       String str = getCurrentStatement(gKarEditorPanel1.getEditor().getCaretPosition());
        boolean decide=false;
        int caretPos = gKarEditorPanel1.getEditor().getCaretPosition();
        while(!decide){
            gKarSQLToken strText = getPrevToken(str,caretPos);
//dbg("search for <"+str+">:"+strText.getToken()+".");
            if(words.indexOf(strText.getToken().toLowerCase())>=0){
                decide = true;
                str = strText.getToken().toLowerCase();
                break;
            }
            if(strText.getToken()==null){
                decide = true;
            }
            str = str.substring(0,strText.getStartPos());
            caretPos = strText.getStartPos()-1;
        }
        if(str.equalsIgnoreCase("from")){
            mustFill = "tables";
        }
        if(str.equalsIgnoreCase("select")||str.equalsIgnoreCase("where")){
            mustFill = "columns";
        }
        String tables = "EC_REF_DATA";

        if(mustFill.equalsIgnoreCase("tables")){
            gKarSQLToken lex = getCurrentWord(gKarEditorPanel1.getEditor().getText(),gKarEditorPanel1.getEditor().getCaretPosition());
            fillPopupItems(mustFill,lex.getToken(),"");
        }
        if(mustFill.equalsIgnoreCase("columns")){
            str = getCurrentStatement(gKarEditorPanel1.getEditor().getCaretPosition()).toLowerCase();
            int fromStart = str.indexOf(" from ");
            int whereStart = str.indexOf(" where ");
            if(whereStart<0){
                whereStart = str.length();
            }
            tables = "'"+str.substring(fromStart+6,whereStart).toUpperCase().replace(" ","").replace(",","','")+"'";
            fillPopupItems(mustFill,"",tables);
        }
        if(mustFill.equalsIgnoreCase("reserved")){
            gKarSQLToken lex = getCurrentWord(gKarEditorPanel1.getEditor().getText(),gKarEditorPanel1.getEditor().getCaretPosition());
            fillPopupItems(mustFill,lex.getToken(),"");
        }
//        popupMenu1.show(com,x,y);
    }
View Full Code Here

Examples of gkarsql.utilities.gKarSQLToken

            }
        }
        return prevSpace;
    }
    private gKarSQLToken getCurrentWord(String str, int caret){
        gKarSQLToken ans = new gKarSQLToken();
        int startPos = getPrevSpace(caret)+1;
        int endPos   = caret;
        ans.setStartPos(startPos);
        ans.setEndPos(endPos);
        ans.setToken(str.substring(startPos,endPos));
        return ans;
    }
View Full Code Here

Examples of gkarsql.utilities.gKarSQLToken

        ans.setEndPos(endPos);
        ans.setToken(str.substring(startPos,endPos));
        return ans;
    }
        private gKarSQLToken getPrevToken(String str, int caretPos){
        gKarSQLToken ans = new gKarSQLToken();
        int i = caretPos-1;
        int endPos =0;
        boolean inWord = str.substring(i,i+1).equalsIgnoreCase(" ");
        if( inWord ){
            while((i>0)&&(!str.substring(i,i+1).equalsIgnoreCase(" "))){
                i--;
            }
            while((i>0)&&(str.substring(i,i+1).equalsIgnoreCase(" "))){
                i--;
            }
        }
        endPos = i+1;
        while((i>0)&&(!str.substring(i,i+1).equalsIgnoreCase(" "))){
            i--;
        }
        ans.setToken(str.substring(i,endPos+1).trim());
        ans.setStartPos(i);
        ans.setEndPos(endPos);
        return ans;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.