<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 119  文章 - 3173  trackbacks - 0
    <2007年8月>
    2930311234
    567891011
    12131415161718
    19202122232425
    2627282930311
    2345678

    交友莫獨酒,茅臺西鳳游。
    口干古井貢,心徜洋河流。
    稱多情杜康,趟無量雙溝。
    贊中華巍巍,無此不銷愁。

    常用鏈接

    留言簿(68)

    隨筆分類(136)

    隨筆檔案(122)

    最新隨筆

    搜索

    •  

    積分與排名

    • 積分 - 525135
    • 排名 - 93

    最新評論

    應朋友要求,寫了一個小工具,主要就是實現下面的要求:
    FormatSqlResult.jpg

    ??1?import?java.util.LinkedList;
    ??2?
    ??3?import?org.eclipse.swt.SWT;
    ??4?import?org.eclipse.swt.events.SelectionAdapter;
    ??5?import?org.eclipse.swt.events.SelectionEvent;
    ??6?import?org.eclipse.swt.layout.FormAttachment;
    ??7?import?org.eclipse.swt.layout.FormData;
    ??8?import?org.eclipse.swt.layout.FormLayout;
    ??9?import?org.eclipse.swt.widgets.Button;
    ?10?import?org.eclipse.swt.widgets.Display;
    ?11?import?org.eclipse.swt.widgets.Label;
    ?12?import?org.eclipse.swt.widgets.Shell;
    ?13?import?org.eclipse.swt.widgets.Text;
    ?14?
    ?15?public?class?FormatSqlResult?{
    ?16?
    ?17?????private?Text?text;
    ?18?
    ?19?????protected?Shell?shell;
    ?20?
    ?21?????/**
    ?22??????*?Launch?the?application
    ?23??????*?
    ?24??????*?@param?args
    ?25??????*/
    ?26?????public?static?void?main(String[]?args)?{
    ?27?????????try?{
    ?28?????????????FormatSqlResult?window?=?new?FormatSqlResult();
    ?29?????????????window.open();
    ?30?????????}?catch?(Exception?e)?{
    ?31?????????????e.printStackTrace();
    ?32?????????}
    ?33?????}
    ?34?
    ?35?????/**
    ?36??????*?Open?the?window
    ?37??????*/
    ?38?????public?void?open()?{
    ?39?????????final?Display?display?=?Display.getDefault();
    ?40?????????createContents();
    ?41?????????shell.open();
    ?42?????????shell.layout();
    ?43?????????while?(!shell.isDisposed())?{
    ?44?????????????if?(!display.readAndDispatch())
    ?45?????????????????display.sleep();
    ?46?????????}
    ?47?????}
    ?48?
    ?49?????/**
    ?50??????*?Create?contents?of?the?window
    ?51??????*/
    ?52?????protected?void?createContents()?{
    ?53?????????shell?=?new?Shell();
    ?54?????????shell.setLayout(new?FormLayout());
    ?55?????????shell.setSize(631,?414);
    ?56?????????shell.setText("FormatSqlResult");
    ?57?
    ?58?????????text?=?new?Text(shell,?SWT.V_SCROLL?|?SWT.MULTI?|?SWT.H_SCROLL?|?SWT.BORDER);
    ?59?????????final?FormData?fd_text?=?new?FormData();
    ?60?????????fd_text.bottom?=?new?FormAttachment(100,?-34);
    ?61?????????fd_text.right?=?new?FormAttachment(100,?-5);
    ?62?????????fd_text.left?=?new?FormAttachment(0,?0);
    ?63?????????fd_text.top?=?new?FormAttachment(0,?0);
    ?64?????????text.setLayoutData(fd_text);
    ?65?????????final?Button?formatButton?=?new?Button(shell,?SWT.NONE);
    ?66?????????formatButton.addSelectionListener(new?SelectionAdapter()?{
    ?67?????????????public?void?widgetSelected(SelectionEvent?e)?{
    ?68?????????????????String?str?=?text.getText();
    ?69?????????????????if?(str?!=?null?&&?str.length()?>?0)?{
    ?70?????????????????????text.setText(getSpaceText(str.replaceAll("\r",?"")));
    ?71?????????????????????text.selectAll();
    ?72?????????????????}
    ?73?
    ?74?????????????}
    ?75?????????});
    ?76?????????final?FormData?fd_formatButton?=?new?FormData();
    ?77?????????fd_formatButton.left?=?new?FormAttachment(0,?286);
    ?78?????????fd_formatButton.right?=?new?FormAttachment(100,?-287);
    ?79?????????fd_formatButton.top?=?new?FormAttachment(100,?-26);
    ?80?????????fd_formatButton.bottom?=?new?FormAttachment(100,?-4);
    ?81?????????formatButton.setLayoutData(fd_formatButton);
    ?82?????????formatButton.setText("Format");
    ?83?
    ?84?????????final?Label?label?=?new?Label(shell,?SWT.NONE);
    ?85?????????final?FormData?fd_label?=?new?FormData();
    ?86?????????fd_label.top?=?new?FormAttachment(100,?-19);
    ?87?????????fd_label.left?=?new?FormAttachment(100,?-130);
    ?88?????????fd_label.bottom?=?new?FormAttachment(100,?-4);
    ?89?????????fd_label.right?=?new?FormAttachment(100,?-5);
    ?90?????????label.setLayoutData(fd_label);
    ?91?????????label.setText("版權所有:交口稱贊");
    ?92?
    ?93?????????final?Label?formatsqlresult10Label?=?new?Label(shell,?SWT.NONE);
    ?94?????????final?FormData?fd_formatsqlresult10Label?=?new?FormData();
    ?95?????????fd_formatsqlresult10Label.top?=?new?FormAttachment(100,?-19);
    ?96?????????fd_formatsqlresult10Label.right?=?new?FormAttachment(0,?180);
    ?97?????????fd_formatsqlresult10Label.bottom?=?new?FormAttachment(100,?-4);
    ?98?????????fd_formatsqlresult10Label.left?=?new?FormAttachment(0,?5);
    ?99?????????formatsqlresult10Label.setLayoutData(fd_formatsqlresult10Label);
    100?????????formatsqlresult10Label.setText("FormatSqlResult?version?1.5");
    101?????}
    102?
    103?????public?String?getSpaceText(String?allStr)?{
    104?????????String[]?strs?=?allStr.split("\n");
    105?????????String?lineStr;
    106?????????int?row?=?-1;
    107?????????if?(strs?!=?null?&&?strs.length?>?0)?{
    108?????????????lineStr?=?strs[0];
    109?????????????String[]?lineStrs?=?lineStr.split("\t");
    110?????????????row?=?lineStrs.length;
    111?????????}
    112?????????int[]?max?=?new?int[row];
    113?????????for?(int?i?=?0;?i?<?max.length;?i++)?{
    114?????????????max[i]?=?-1;
    115?????????}
    116?????????LinkedList?all?=?new?LinkedList();
    117?????????for?(int?i?=?0;?i?<?row;?i++)?{
    118?????????????LinkedList?list?=?new?LinkedList();
    119?????????????all.add(list);
    120?????????}
    121?????????for?(int?i?=?0;?i?<?strs.length;?i++)?{
    122?????????????lineStr?=?strs[i];
    123?????????????String[]?lineStrs?=?lineStr.split("\t");
    124?????????????for?(int?j?=?0;?j?<?lineStrs.length;?j++)?{
    125?????????????????int?length?=?lineStrs[j].length();
    126?????????????????if?(length?>?max[j])?{
    127?????????????????????max[j]?=?length;
    128?????????????????}
    129?????????????????((LinkedList)?all.get(j)).add(lineStrs[j]);
    130?????????????}
    131?????????}
    132?
    133?????????StringBuffer?sb?=?new?StringBuffer();
    134?????????int?line?=?((LinkedList)?all.get(0)).size();
    135?????????for?(int?i?=?0;?i?<?line;?i++)?{
    136?????????????for?(int?j?=?0;?j?<?all.size();?j++)?{
    137?????????????????String?str?=?(String)?((LinkedList)?all.get(j)).get(i);
    138?????????????????int?length?=?max[j]?-?str.length()?+?1;
    139?????????????????sb.append(str);
    140?????????????????for?(int?k?=?0;?k?<?length;?k++)?{
    141?????????????????????sb.append("?");
    142?????????????????}
    143?????????????}
    144?????????????sb.append("\n");
    145?????????}
    146?????????return?sb.toString();
    147?????}
    148?
    149?}
    150?


    已制作成exe,可以雙擊執行,只支持Windows,為了兼容jdk版本,沒敢用泛型。

    下載:FormatSqlResult1.rar

    posted on 2007-08-09 11:02 交口稱贊 閱讀(1737) 評論(2)  編輯  收藏 所屬分類: Eclipse RCP SWTjava相關

    FeedBack:
    # re: FormatSqlResult--SQL查詢結果,格式化工具,已作成exe,付源碼 2007-08-10 16:45 good
    good  回復  更多評論
      
    # re: FormatSqlResult--SQL查詢結果,格式化工具,已作成exe,付源碼 2007-10-29 21:58 隨筆
    兄弟永遠支持你!  回復  更多評論
      
    主站蜘蛛池模板: 特级精品毛片免费观看| 国产无遮挡又黄又爽免费视频| 亚洲精品在线视频观看| 久久久久国产精品免费免费搜索 | 亚洲影院天堂中文av色| 国产jizzjizz视频全部免费| 国产午夜成人免费看片无遮挡| 亚洲AV成人无码天堂| 亚洲国产香蕉人人爽成AV片久久| 无码精品国产一区二区三区免费 | 亚洲成av人片在线天堂无| 亚洲综合伊人久久综合| 人妻视频一区二区三区免费| 国产精品美女久久久免费| 亚洲国产精品一区二区久| 三上悠亚亚洲一区高清| 99在线视频免费观看视频| 中文字幕乱码免费看电影| 亚洲国产精品网站在线播放| 亚洲成A人片在线观看WWW| 免费看国产精品麻豆| 国产大片免费网站不卡美女| 国产V片在线播放免费无码| 日本亚洲免费无线码| 亚洲AV无码久久精品成人 | 亚洲av片一区二区三区| 在线观看成人免费视频不卡| 成人妇女免费播放久久久| 精品国产亚洲一区二区三区在线观看| 亚洲爆乳无码专区| 四虎影永久在线高清免费| 美女网站免费福利视频| 国产三级在线免费| yellow视频免费看| 亚洲成a人片在线不卡一二三区| 亚洲综合在线成人一区| 亚洲国产精品无码久久一线| 亚洲麻豆精品国偷自产在线91| 天堂在线免费观看中文版| 国产免费久久精品99re丫y| 久久久久久国产精品免费免费男同 |