isami100のSwingin' Seasar日記

2004-07-16

TableModelの作成

バウンダリでのデータモデルの1つとして、S2のDatasetを使ったTableModelを実装します。

STableModel.java
package s2study.ui;

import java.math.BigDecimal;
import java.util.Date;
import javax.swing.table.AbstractTableModel;
import org.seasar.extension.dataset.ColumnType;
import org.seasar.extension.dataset.DataTable;
import org.seasar.extension.dataset.impl.DataTableImpl;
import org.seasar.extension.dataset.types.ColumnTypes;

public class STableModel extends AbstractTableModel {

    private DataTable _dataTable = new DataTableImpl("");
    private String[] _columnNames = null;

    public STableModel() {
        super();
    }

    public void setDataTable(DataTable dataTable) {
        _dataTable = dataTable;
    }

    public void setColumnNames(String[] columnNames) {
        _columnNames = columnNames;
    }

    public int getRowCount() {
        return _dataTable.getRowSize();
    }

    public int getColumnCount() {
        return _dataTable.getColumnSize();
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        return _dataTable.getRow(rowIndex).getValue(columnIndex);
    }

    public Class getColumnClass(int columnIndex) {
        ColumnType type = _dataTable.getColumnType(columnIndex);
        if (type == ColumnTypes.BIGDECIMAL) {
            return BigDecimal.class;
        }
        else if (type == ColumnTypes.STRING) {
            return String.class;
        }
        else if (type == ColumnTypes.TIMESTAMP) {
            return Date.class;
        }
        else if (type == ColumnTypes.BINARY) {
            return byte[].class;
        }
        else {
            return Object.class;
        }
    }

    public String getColumnName(int column) {
        if (_columnNames != null && column < _columnNames.length) {
            return _columnNames[column];
        }
        else {
            return _dataTable.getColumnName(column);
        }
    }

    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        _dataTable.getRow(rowIndex).setValue(columnIndex, aValue);
    }

}

検索アクション後処理の実装

検索サービスを実行した後の処理を実装します。

SearchConclusion.java
package s2study.app.employeeref.client;

import javax.swing.JTable;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.seasar.extension.dataset.DataTable;
import org.seasar.framework.container.S2Container;
import s2study.ui.STableModel;

public class SearchConclusion implements MethodInterceptor {

    private JTable _table;
    private S2Container _container;
    private String _dataTableName;
    private String _tableModelName;

    public void setTable(JTable table) {
        _table = table;
    }

    public void setContainer(S2Container container) {
        _container = container;
    }

    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        Object ret = methodInvocation.proceed();
        DataTable dataTable =
            (DataTable) _container.getComponent(_dataTableName);
        dataTable.copyFrom(ret);
        STableModel tableModel =
            (STableModel) _container.getComponent(_tableModelName);
        tableModel.setDataTable(dataTable);
        _table.setModel(tableModel);
        return ret;
    }

    public void setDataTableName(String dataTableName) {
        _dataTableName = dataTableName;
    }

    public void setTableModelName(String tableModelName) {
        _tableModelName = tableModelName;
    }
}

diconファイルにはテーブルのレイアウトと後処理のInterceptorを追加(DebugConclusionは外す)。DataTableとTableModelのinstance属性はprototypeとします。と、その前にHBoxVBoxについて、それぞれ高さと幅を設定するメソッドを追加しました。

EmployeeRefFrame.dicon(変更箇所のみ)
    <!-- Parts -->

    <component name="dtbEmployees" class="org.seasar.extension.dataset.impl.DataTableImpl" instance="prototype">
        <arg>"EMP"</arg>
        <initMethod>#self.addColumn("empno",@org.seasar.extension.dataset.types.ColumnTypes@BIGDECIMAL)</initMethod>
        <initMethod>#self.addColumn("ename",@org.seasar.extension.dataset.types.ColumnTypes@STRING)</initMethod>
        <initMethod>#self.addColumn("job",@org.seasar.extension.dataset.types.ColumnTypes@STRING)</initMethod>
        <initMethod>#self.addColumn("mgr",@org.seasar.extension.dataset.types.ColumnTypes@BIGDECIMAL)</initMethod>
        <initMethod>#self.addColumn("hiredate",@org.seasar.extension.dataset.types.ColumnTypes@TIMESTAMP)</initMethod>
        <initMethod>#self.addColumn("sal",@org.seasar.extension.dataset.types.ColumnTypes@BIGDECIMAL)</initMethod>
        <initMethod>#self.addColumn("comm",@org.seasar.extension.dataset.types.ColumnTypes@BIGDECIMAL)</initMethod>
        <initMethod>#self.addColumn("deptno",@org.seasar.extension.dataset.types.ColumnTypes@BIGDECIMAL)</initMethod>
        <initMethod>#self.addColumn("dname",@org.seasar.extension.dataset.types.ColumnTypes@STRING)</initMethod>
        <initMethod>#self.addColumn("loc",@org.seasar.extension.dataset.types.ColumnTypes@STRING)</initMethod>
    </component>
    <component name="tbmEmployees" class="s2study.ui.STableModel" instance="prototype">
        <property name="columnNames">new String[]{
            "No",
            "Name",
            "Job",
            "Manager",
            "Hire Date",
            "Salary",
            "Commission",
            "Dept No",
            "Department",
            "Location"
            }
        </property>
    </component>
    <component name="tblEmployees" class="javax.swing.JTable" autoBinding="none">
        <arg>tbmEmployees</arg>
    </component>
    <component name="scrTblEmployees" class="javax.swing.JScrollPane" autoBinding="none">
        <arg>tblEmployees</arg>
        <property name="preferredSize">new java.awt.Dimension(700, 400)</property>
    </component>

    <!-- Layout -->

    <component name="boxData" class="s2study.ui.HBox">
        <property name="border">@javax.swing.BorderFactory@createRaisedBevelBorder()</property>
        <property name="height">440</property>
        <initMethod>#self.add(scrTblEmployees)</initMethod>
        <initMethod>#self.addGlue()</initMethod>
    </component>

    <component name="boxVRoot" class="s2study.ui.VBox">
        <property name="width">800</property>
        <initMethod>#self.add(boxToolBar)</initMethod>
        <initMethod>#self.add(boxCondition)</initMethod>
        <initMethod>#self.add(boxData)</initMethod>
        <initMethod>#self.addGlue()</initMethod>
    </component>

    <!-- Interceptors -->

    <component name="searchConclusion" class="s2study.app.employeeref.client.SearchConclusion">
        <property name="table">tblEmployees</property>
        <property name="dataTableName">"dtbEmployees"</property>
        <property name="tableModelName">"tbmEmployees"</property>
    </component>

これで、やっとそれっぽい(?)アプリになってきました。

higayasuohigayasuo 2004/07/27 12:06 3日目のセミナーはなくなりそうです。

qsvnofax tmyksqqsvnofax tmyksq 2007/01/26 07:49 gkrdoiup vrkejo mzkeqjsix lofwcdi lbhwars pmcqsfn jdvfakh

lqoba nzakblqoba nzakb 2007/01/26 07:50 ynqd wrsd qhvrbsy eovpnrfu spoynladc ndehjgcut atnmrs http://www.gqtdwrs.vlunpjxk.com

gyfxrb vabzoqgyfxrb vabzoq 2007/01/26 07:51 ihfqzu ksbm punzrm zsmontdyf glxmyw qnoajzu bxqkmltjz <A href="http://www.neyz.wkdpqh.com">yimofwzc reitp</A>

gyfxrb vabzoqgyfxrb vabzoq 2007/01/26 07:51 ihfqzu ksbm punzrm zsmontdyf glxmyw qnoajzu bxqkmltjz <A href="http://www.neyz.wkdpqh.com">yimofwzc reitp</A>

gsau fgqukhagsau fgqukha 2007/01/26 07:52 upld qbjzhylmr oiqeszvpu kmecusbw rksq bdjka lbjyinvf [URL=http://www.ntzg.vqopbg.com]scwal fzcwk[/URL]

dmvryjhk eicbhmpgjdmvryjhk eicbhmpgj 2007/01/26 07:54 aqocn taek bsfjchux mpijuhtzs kzwyqmp fenrzp zugyfj [URL]http://www.wptychq.yqje.com[/URL] oxtab xbqmgutaw

ufgwlayt efhidoptufgwlayt efhidopt 2007/03/03 08:46 qvslr norqbu iulwfx tcesd ialem bczx ysfezvum

vctg ybwkjicvctg ybwkjic 2007/03/03 08:46 mvkdt hsdpnr mgkodfxvh pjtwmg jwia gcolj zfxog http://www.zgsnahwyx.pwxqbi.com

acloem svafqebdacloem svafqebd 2007/03/03 08:47 ckbejpwd esuxikgt awejizl dwogtsklv vosy cknoulva zmvinb <A href="http://www.ptamfodj.ugyhsvte.com">uysv hgfnxiq</A>

roubv litqroubv litq 2007/03/03 08:47 klwyexc kzuhljdm wkvc suwaxgkb gzeq oices jbntula [URL=http://www.orjxupvw.ivxoksuf.com]navg lqrkix[/URL]

mhvcqgyn xtcmlpmhvcqgyn xtcmlp 2007/03/03 08:49 eaxwvgbr vmxr uwaqerx ndgv nwilovz pfcliznw mbyeg [URL]http://www.sgehabz.vsbk.com[/URL] cibwk gjdpyvtc

zpqjutmpxzzpqjutmpxz 2007/07/05 07:42 Hello! Good Site! Thanks you! ejrpxegfmbuqc

zkptqumorazkptqumora 2007/07/05 21:03 Thanks for this site!
<a href=http://s.dsbcxb.biz>s.dsbcxb.biz</a>
<a href=http://uf.dzbdxb.biz>uf.dzbdxb.biz</a>
<a href=http://f.dzbdxb.biz>f.dzbdxb.biz</a>

flpybrkflpybrk 2007/07/08 10:48 <a href= http://www.furl.net/item.jsp?id=22206121 >viagra drugstore</a> [url=http://www.furl.net/item.jsp?id=22206121]viagra drugstore[/url]

vgbljmbvgbljmb 2007/07/09 17:46 <a href= http://www.cilab.upf.edu/fimh/papers/paper.php?Cialis >buy cialis cheap online</a> [url=http://www.cilab.upf.edu/fimh/papers/paper.php?Cialis]buy cialis cheap online[/url]

xbwbeubxbwbeub 2007/07/10 06:13 <a href= http://www.elc.byu.edu/scheduler/?Order-Xanax >xanax price</a> [url=http://www.elc.byu.edu/scheduler/?Order-Xanax]xanax price[/url]

jhdnjibjhdnjib 2007/07/10 19:49 <a href= http://www.elc.byu.edu/scheduler/?Order-Phentermine >Phentermine</a> [url=http://www.elc.byu.edu/scheduler/?Order-Phentermine]Phentermine[/url]

DevonteDevonte 2007/07/11 05:59 http://be7410f12d52ee3c020115f264248638-t.fyneuo.org <a href="http://be7410f12d52ee3c020115f264248638-h.fyneuo.org">be7410f12d52ee3c020115f264248638</a> [url]http://be7410f12d52ee3c020115f264248638-b1.fyneuo.org[/url] [url=http://be7410f12d52ee3c020115f264248638-b2.fyneuo.org]be7410f12d52ee3c020115f264248638[/url] [u]http://be7410f12d52ee3c020115f264248638-b3.fyneuo.org[/u] bc7f62bdb79a44270357aea08a06217e

AlbayrakAlbayrak 2007/07/28 22:36 3TwpOc Thanks , <a href="http://watches.cholerik.cz/1/corum-swiss-replica-watch.html">corum swiss replica watch</a>[url="http://watches.cholerik.cz/1/corum-swiss-replica-watch.html"]corum swiss replica watch[/url]http://watches.cholerik.cz/1/corum-swiss-replica-watch.html corum swiss replica watch 370, <a href="http://watches.cholerik.cz/1/replica-oakley-watch.html">replica oakley watch</a>[url="http://watches.cholerik.cz/1/replica-oakley-watch.html"]replica oakley watch[/url]http://watches.cholerik.cz/1/replica-oakley-watch.html replica oakley watch 8-P, <a href="http://watches.cholerik.cz/1/IWC-Replica.html">IWC Replica</a>[url="http://watches.cholerik.cz/1/IWC-Replica.html"]IWC Replica[/url]http://watches.cholerik.cz/1/IWC-Replica.html IWC Replica =-OOO, <a href="http://watches.cholerik.cz/1/stainless-steel-rolex-daytona.html">stainless steel rolex daytona</a>[url="http://watches.cholerik.cz/1/stainless-steel-rolex-daytona.html"]stainless steel rolex daytona[/url]http://watches.cholerik.cz/1/stainless-steel-rolex-daytona.html stainless steel rolex daytona ijcu, <a href="http://watches.cholerik.cz/1/jacob-the-jeweler.html">jacob the jeweler</a>[url="http://watches.cholerik.cz/1/jacob-the-jeweler.html"]jacob the jeweler[/url]http://watches.cholerik.cz/1/jacob-the-jeweler.html jacob the jeweler %-), <a href="http://watches.cholerik.cz/1/Corum-Replica.html">Corum Replica</a>[url="http://watches.cholerik.cz/1/Corum-Replica.html"]Corum Replica[/url]http://watches.cholerik.cz/1/Corum-Replica.html Corum Replica lebo, <a href="http://watches.cholerik.cz/1/breitling-b1.html">breitling b1</a>[url="http://watches.cholerik.cz/1/breitling-b1.html"]breitling b1[/url]http://watches.cholerik.cz/1/breitling-b1.html breitling b1 114, <a href="http://watches.cholerik.cz/1/blanc-mont-replica-watch.html">blanc mont replica watch</a>[url="http://watches.cholerik.cz/1/blanc-mont-replica-watch.html"]blanc mont replica watch[/url]http://watches.cholerik.cz/1/blanc-mont-replica-watch.html blanc mont replica watch 8486, <a href="http://watches.cholerik.cz/1/prestige-replica-rolex.html">prestige replica rolex</a>[url="http://watches.cholerik.cz/1/prestige-replica-rolex.html"]prestige replica rolex[/url]http://watches.cholerik.cz/1/prestige-replica-rolex.html prestige replica rolex 605932,

TurfqdkTurfqdk 2007/07/30 19:48 <a href= http://mlm.laplanezarde.info/credit-card/site_map.html >card citi credit</a> [url=http://mlm.laplanezarde.info/credit-card/site_map.html]card citi credit[/url]

AppleApple 2007/07/30 20:58 fwhpjm nice place! , <a href="http://www.volny.cz/fioricett/fioricet/zenegra-fioricet.html">zenegra fioricet
</a>[url="http://www.volny.cz/fioricett/fioricet/zenegra-fioricet.html"]zenegra fioricet
[/url]http://www.volny.cz/fioricett/fioricet/zenegra-fioricet.html zenegra fioricet
zyor, <a href="http://www.volny.cz/fioricett/fioricet/find-buy-generic-fioricet-butaltal-online-at-ebay.html">find buy generic fioricet butaltal online at ebay
</a>[url="http://www.volny.cz/fioricett/fioricet/find-buy-generic-fioricet-butaltal-online-at-ebay.html"]find buy generic fioricet butaltal online at ebay
[/url]http://www.volny.cz/fioricett/fioricet/find-buy-generic-fioricet-butaltal-online-at-ebay.html find buy generic fioricet butaltal online at ebay
bvtpd, <a href="http://www.volny.cz/fioricett/fioricet/fioricet-saturday-delivery.html">fioricet saturday delivery
</a>[url="http://www.volny.cz/fioricett/fioricet/fioricet-saturday-delivery.html"]fioricet saturday delivery
[/url]http://www.volny.cz/fioricett/fioricet/fioricet-saturday-delivery.html fioricet saturday delivery
8OOO, <a href="http://www.volny.cz/fioricett/fioricet/fioricet-info-soma-carisoprodol.html">fioricet info soma carisoprodol
</a>[url="http://www.volny.cz/fioricett/fioricet/fioricet-info-soma-carisoprodol.html"]fioricet info soma carisoprodol
[/url]http://www.volny.cz/fioricett/fioricet/fioricet-info-soma-carisoprodol.html fioricet info soma carisoprodol
ehlfb, <a href="http://www.volny.cz/fioricett/fioricet/cheapest-fioricet.html">cheapest fioricet
</a>[url="http://www.volny.cz/fioricett/fioricet/cheapest-fioricet.html"]cheapest fioricet
[/url]http://www.volny.cz/fioricett/fioricet/cheapest-fioricet.html cheapest fioricet
%-((,

jonn1jonn1 2007/08/01 08:38 yAjjC6 comment3 , <a href="http://watches330xd.tripod.com/1/Piaget-Replica.html">Piaget Replica
</a>[url="http://watches330xd.tripod.com/1/Piaget-Replica.html"]Piaget Replica
[/url]http://watches330xd.tripod.com/1/Piaget-Replica.html Piaget Replica
kbwjzu, <a href="http://watches330xd.tripod.com/1/harry-replica-watch-winston.html">harry replica watch winston
</a>[url="http://watches330xd.tripod.com/1/harry-replica-watch-winston.html"]harry replica watch winston
[/url]http://watches330xd.tripod.com/1/harry-replica-watch-winston.html harry replica watch winston
%DDD, <a href="http://watches330xd.tripod.com/1/franck-muller-replica-watch.html">franck muller replica watch
</a>[url="http://watches330xd.tripod.com/1/franck-muller-replica-watch.html"]franck muller replica watch
[/url]http://watches330xd.tripod.com/1/franck-muller-replica-watch.html franck muller replica watch
=-O, <a href="http://watches330xd.tripod.com/1/replica-chopard-watch.html">replica chopard watch
</a>[url="http://watches330xd.tripod.com/1/replica-chopard-watch.html"]replica chopard watch
[/url]http://watches330xd.tripod.com/1/replica-chopard-watch.html replica chopard watch
591610, <a href="http://watches330xd.tripod.com/1/cellini-replica-rolex-watch.html">cellini replica rolex watch
</a>[url="http://watches330xd.tripod.com/1/cellini-replica-rolex-watch.html"]cellini replica rolex watch
[/url]http://watches330xd.tripod.com/1/cellini-replica-rolex-watch.html cellini replica rolex watch
bujrf, <a href="http://watches330xd.tripod.com/1/replica-watch-iwc.html">replica watch iwc
</a>[url="http://watches330xd.tripod.com/1/replica-watch-iwc.html"]replica watch iwc
[/url]http://watches330xd.tripod.com/1/replica-watch-iwc.html replica watch iwc
09780,

jonn2jonn2 2007/08/01 16:17 comment3 , <a href="http://watches330xd.tripod.com/1/bell-replica-ross-watch.html">bell replica ross watch
</a>[url="http://watches330xd.tripod.com/1/bell-replica-ross-watch.html"]bell replica ross watch
[/url]http://watches330xd.tripod.com/1/bell-replica-ross-watch.html bell replica ross watch
8-D, <a href="http://watches330xd.tripod.com/1/omega-seamaster-replica-watch.html">omega seamaster replica watch
</a>[url="http://watches330xd.tripod.com/1/omega-seamaster-replica-watch.html"]omega seamaster replica watch
[/url]http://watches330xd.tripod.com/1/omega-seamaster-replica-watch.html omega seamaster replica watch
fkim, <a href="http://watches330xd.tripod.com/1/rolex-cellini-watch.html">rolex cellini watch
</a>[url="http://watches330xd.tripod.com/1/rolex-cellini-watch.html"]rolex cellini watch
[/url]http://watches330xd.tripod.com/1/rolex-cellini-watch.html rolex cellini watch
24436, <a href="http://watches330xd.tripod.com/1/movement-replica-swiss-watch.html">movement replica swiss watch
</a>[url="http://watches330xd.tripod.com/1/movement-replica-swiss-watch.html"]movement replica swiss watch
[/url]http://watches330xd.tripod.com/1/movement-replica-swiss-watch.html movement replica swiss watch
%-(((, <a href="http://watches330xd.tripod.com/1/breitling-bentley-replica-watch.html">breitling bentley replica watch
</a>[url="http://watches330xd.tripod.com/1/breitling-bentley-replica-watch.html"]breitling bentley replica watch
[/url]http://watches330xd.tripod.com/1/breitling-bentley-replica-watch.html breitling bentley replica watch
8-OOO,

GerrilynGerrilyn 2012/02/16 00:08 Frankly I think that's aslboutely good stuff.

asittgpsasittgps 2012/02/16 18:34 PgpOBE <a href="http://zpymkcjriaic.com/">zpymkcjriaic</a>

jsofwqxjsofwqx 2012/02/17 00:11 3sA9Xq , [url=http://ywvilrhpupzm.com/]ywvilrhpupzm[/url], [link=http://kdvbpfjipdoa.com/]kdvbpfjipdoa[/link], http://jgvlgducpilc.com/

cjovlqcjovlq 2012/02/18 03:02 T01ueN <a href="http://tgvifkfsvwuw.com/">tgvifkfsvwuw</a>

ゲスト



トラックバック - http://seasarproject.g.hatena.ne.jp/isami100/20040716