isami100のSwingin' Seasar日記

2000-01-15 s2study.app.employeeref.client

SearchAction.java

package s2study.app.employeeref.client;

import java.util.Date;

import javax.swing.JFormattedTextField;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import s2study.app.employeeref.service.EmployeeRefService;

public class SearchAction implements MethodInterceptor {

    private EmployeeRefService _employeeRefService;
    private JFormattedTextField _txfEmpNoFrom;
    private JFormattedTextField _txfEmpNoTo;
    private JFormattedTextField _txfEmpName;
    private JFormattedTextField _txfHireDateFrom;
    private JFormattedTextField _txfHireDateTo;
    private JFormattedTextField _txfSalaryFrom;
    private JFormattedTextField _txfSalaryTo;

    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        return _employeeRefService.findEmployees(
            (Number) _txfEmpNoFrom.getValue(),
            (Number) _txfEmpNoTo.getValue(),
            convertNull( (String) _txfEmpName.getText() ),
            (Date) _txfHireDateFrom.getValue(),
            (Date) _txfHireDateTo.getValue(),
            (Number) _txfSalaryFrom.getValue(),
            (Number) _txfSalaryTo.getValue());
    }

    private String convertNull(String value) {
        if (value != null && value.length() > 0) {
            return value;
        }
        else {
            return null;
        }
    }

    public void setEmployeeRefService(EmployeeRefService employeeRefService) {
        _employeeRefService = employeeRefService;
    }

    public void setEmpNoFromField(JFormattedTextField txfEmpNoFrom) {
        _txfEmpNoFrom = txfEmpNoFrom;
    }
    public void setEmpNoToField(JFormattedTextField txfEmpNoTo) {
        _txfEmpNoTo = txfEmpNoTo;
    }
    public void setEmpNameField(JFormattedTextField txfEmpName) {
        _txfEmpName = txfEmpName;
    }
    public void setHireDateFromField(JFormattedTextField txfHireDateFrom) {
        _txfHireDateFrom = txfHireDateFrom;
    }
    public void setHireDateToField(JFormattedTextField txfHireDateTo) {
        _txfHireDateTo = txfHireDateTo;
    }
    public void setSalaryFromField(JFormattedTextField txfSalaryFrom) {
        _txfSalaryFrom = txfSalaryFrom;
    }
    public void setSalaryToField(JFormattedTextField txfSalaryTo) {
        _txfSalaryTo = txfSalaryTo;
    }

}

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;
    }

}

SearchRequirement.java

package s2study.app.employeeref.client;

import java.util.Date;
import javax.swing.JFormattedTextField;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.seasar.framework.exception.SRuntimeException;

public class SearchRequirement implements MethodInterceptor {

    private JFormattedTextField _txfEmpNoFrom;
    private JFormattedTextField _txfEmpNoTo;
    private JFormattedTextField _txfHireDateFrom;
    private JFormattedTextField _txfHireDateTo;
    private JFormattedTextField _txfSalaryFrom;
    private JFormattedTextField _txfSalaryTo;

    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        checkEmpNoConsistency();
        checkHireDateConsistency();
        checkSalaryConsistency();
        return methodInvocation.proceed();
    }

    private void checkEmpNoConsistency() {
        try {
            Number empNoFrom = (Number) _txfEmpNoFrom.getValue();
            Number empNoTo = (Number) _txfEmpNoTo.getValue();
            if (empNoFrom != null && empNoTo != null) {
                if (empNoFrom.intValue() > empNoTo.intValue()) {
                    throw new SRuntimeException(
                        "EAPP0102",
                        new Object[] { "EMP NO(FROM) <= EMP NO(TO)" });
                }
            }
        }
        catch (ClassCastException cce) {
            throw new SRuntimeException("EAPP0101", new Object[] { "EMP NO" });
        }
    }

    private void checkHireDateConsistency() {
        try {
            Date hireDateFrom = (Date) _txfHireDateFrom.getValue();
            Date hireDateTo = (Date) _txfHireDateTo.getValue();
            if (hireDateFrom != null && hireDateTo != null) {
                if (hireDateFrom.getTime() > hireDateTo.getTime()) {
                    throw new SRuntimeException(
                        "EAPP0102",
                        new Object[] { "HIRE DATE(FROM) <= HIRE DATE(TO)" });
                }
            }
        }
        catch (ClassCastException cce) {
            throw new SRuntimeException(
                "EAPP0101",
                new Object[] { "HIRE DATE" });
        }
    }

    private void checkSalaryConsistency() {
        try {
            Number salaryFrom = (Number) _txfSalaryFrom.getValue();
            Number salaryTo = (Number) _txfSalaryTo.getValue();
            if (salaryFrom != null && salaryTo != null) {
                if (salaryFrom.floatValue() > salaryTo.floatValue()) {
                    throw new SRuntimeException(
                        "EAPP0102",
                        new Object[] { "SALARY(FROM) <= SALARY(TO)" });
                }
            }
        }
        catch (ClassCastException cce) {
            throw new SRuntimeException("EAPP0101", new Object[] { "SALARY" });
        }
    }

    public void setEmpNoFromField(JFormattedTextField txfEmpNoFrom) {
        _txfEmpNoFrom = txfEmpNoFrom;
    }
    public void setEmpNoToField(JFormattedTextField txfEmpNoTo) {
        _txfEmpNoTo = txfEmpNoTo;
    }
    public void setHireDateFromField(JFormattedTextField txfHireDateFrom) {
        _txfHireDateFrom = txfHireDateFrom;
    }
    public void setHireDateToField(JFormattedTextField txfHireDateTo) {
        _txfHireDateTo = txfHireDateTo;
    }
    public void setSalaryFromField(JFormattedTextField txfSalaryFrom) {
        _txfSalaryFrom = txfSalaryFrom;
    }
    public void setSalaryToField(JFormattedTextField txfSalaryTo) {
        _txfSalaryTo = txfSalaryTo;
    }

}

EmployeeRefAction.dicon

削除→EmployeeRefFrame.diconに統合

EmployeeRefFrame.dicon



"http://www.seasar.org/dtd/components.dtd">
<components namespace="EmployeeRefFrame">
    <include path="s2study/app/employeeref/service/EmployeeRefService.dicon"/>
    <include path="s2study/ui/Formatter.dicon"/>
    <!-- Parts -->
    <component name="lblEmpNoFrom" class="javax.swing.JLabel">
        <arg>"EMPLOYEE NO between"</arg>
    </component>
    <component name="txfEmpNoFrom" class="javax.swing.JFormattedTextField" autoBinding="none">
        <property name="formatterFactory">fmfCode4</property>
    </component>
    <component name="lblEmpNoTo" class="javax.swing.JLabel">
        <arg>"and"</arg>
    </component>
    <component name="txfEmpNoTo" class="javax.swing.JFormattedTextField" autoBinding="none">
        <property name="formatterFactory">fmfCode4</property>
    </component>

    <component name="lblEmpName" class="javax.swing.JLabel">
        <arg>"EMPLOYEE NAME includes"</arg>
    </component>
    <component name="txfEmpName" class="javax.swing.JFormattedTextField" autoBinding="none">
    </component>

    <component name="lblHireDateFrom" class="javax.swing.JLabel">
        <arg>"HIRE DATE between"</arg>
    </component>
    <component name="txfHireDateFrom" class="javax.swing.JFormattedTextField" autoBinding="none">
        <property name="formatterFactory">fmfDate</property>
    </component>
    <component name="lblHireDateTo" class="javax.swing.JLabel">
        <arg>"and"</arg>
    </component>
    <component name="txfHireDateTo" class="javax.swing.JFormattedTextField" autoBinding="none">
        <property name="formatterFactory">fmfDate</property>
    </component>

    <component name="lblSalaryFrom" class="javax.swing.JLabel">
        <arg>"SALARY between"</arg>
    </component>
    <component name="txfSalaryFrom" class="javax.swing.JFormattedTextField" autoBinding="none">
        <property name="formatterFactory">fmfDecimal5p2</property>
        <property name="horizontalAlignment">@javax.swing.JTextField@RIGHT</property>
    </component>
    <component name="lblSalaryTo" class="javax.swing.JLabel">
        <arg>"and"</arg>
    </component>
    <component name="txfSalaryTo" class="javax.swing.JFormattedTextField" autoBinding="none">
        <property name="formatterFactory">fmfDecimal5p2</property>
        <property name="horizontalAlignment">@javax.swing.JTextField@RIGHT</property>
    </component>

    <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="boxEmpNo" class="s2study.ui.HBox">
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblEmpNoFrom)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfEmpNoFrom)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblEmpNoTo)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfEmpNoTo)</initMethod>
        <initMethod>#self.addStrut(540)</initMethod>
        <initMethod>#self.addGlue()</initMethod>
    </component>

    <component name="boxEmpName" class="s2study.ui.HBox">
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblEmpName)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfEmpName)</initMethod>
        <initMethod>#self.addStrut(550)</initMethod>
        <initMethod>#self.addGlue()</initMethod>
    </component>

    <component name="boxHireDate" class="s2study.ui.HBox">
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblHireDateFrom)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfHireDateFrom)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblHireDateTo)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfHireDateTo)</initMethod>
        <initMethod>#self.addStrut(500)</initMethod>
        <initMethod>#self.addGlue()</initMethod>
    </component>

    <component name="boxSalary" class="s2study.ui.HBox">
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblSalaryFrom)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfSalaryFrom)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblSalaryTo)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfSalaryTo)</initMethod>
        <initMethod>#self.addStrut(480)</initMethod>
        <initMethod>#self.addGlue()</initMethod>
    </component>

    <component name="boxCondition" class="s2study.ui.VBox">
        <property name="border">@javax.swing.BorderFactory@createRaisedBevelBorder()</property>
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(boxEmpNo)</initMethod>
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(boxEmpName)</initMethod>
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(boxHireDate)</initMethod>
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(boxSalary)</initMethod>
	    <initMethod>#self.addStrut(10)</initMethod>
    </component>

    <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>

    <component name="boxRoot" class="s2study.ui.HBox">
        <property name="height">600</property>
        <initMethod>#self.add(boxVRoot)</initMethod>
    </component>


    <!-- Frame -->
    <component name="frame" class="javax.swing.JFrame">
        <arg>"Employee Reference"</arg>
        <property name="defaultCloseOperation">@javax.swing.JFrame@EXIT_ON_CLOSE</property>
        <property name="jMenuBar">menuBar</property>
        <property name="resizable">false</property>
        <initMethod>#self.getContentPane().add(boxRoot)</initMethod>
        <initMethod>#self.pack()</initMethod>
        <initMethod>#self.show()</initMethod>
        <aspect pointcut="show">centering</aspect>
    </component>

    <!-- MenuItems -->
    <component name="search" class="javax.swing.JMenuItem">
        <property name="action">searchTrigger</property>
    </component>
    <component name="exit" class="javax.swing.JMenuItem">
        <property name="action">exitTrigger</property>
    </component>

    <!-- Menus -->
    <component name="menu" class="javax.swing.JMenu" autoBinding="none">
        <arg>"Menu"</arg>
        <!--
        <property name="mnemonic">@java.awt.event.KeyEvent@VK_M</property>
        -->
        <initMethod>#self.add(search)</initMethod>
        <initMethod>#self.addSeparator()</initMethod>
        <initMethod>#self.add(exit)</initMethod>
    </component>

    <!-- MenuBar -->
    <component name="menuBar" class="javax.swing.JMenuBar">
        <initMethod>#self.add(menu)</initMethod>
    </component>

    <!-- ToolButtons -->
    <component name="btnExit" class="javax.swing.JButton">
        <property name="action">exitTrigger</property>
    </component>
    <component name="btnSearch" class="javax.swing.JButton">
        <property name="action">searchTrigger</property>
    </component>

    <!-- ToolBar -->
    <component name="toolBar" class="javax.swing.JToolBar">
        <property name="borderPainted">false</property>
        <property name="floatable">false</property>
        <property name="rollover">true</property>
        <initMethod>#self.add(btnExit)</initMethod>
        <initMethod>#self.add(btnSearch)</initMethod>
    </component>
    <component name="boxToolBar" class="s2study.ui.HBox">
        <property name="border">@javax.swing.BorderFactory@createEtchedBorder()</property>
        <initMethod>#self.add(toolBar)</initMethod>
        <initMethod>#self.addGlue()</initMethod>
    </component>


    <!-- Interceptors -->
    <component name="centering" class="s2study.ui.interceptors.CenteringInterceptor"/>
    <component name="exitAction" class="s2study.app.action.ExitAction"/>
    <component name="messageBoxHandler" class="s2study.ui.interceptors.MessageBoxThrowsInterceptor"/>

    <component name="searchRequirement" class="s2study.app.employeeref.client.SearchRequirement">
        <property name="empNoFromField">txfEmpNoFrom</property>
        <property name="empNoToField">txfEmpNoTo</property>
        <property name="hireDateFromField">txfHireDateFrom</property>
        <property name="hireDateToField">txfHireDateTo</property>
        <property name="salaryFromField">txfSalaryFrom</property>
        <property name="salaryToField">txfSalaryTo</property>
    </component>
    <component name="searchAction" class="s2study.app.employeeref.client.SearchAction">
        <property name="employeeRefService">employeeRefService</property>
        <property name="empNoFromField">txfEmpNoFrom</property>
        <property name="empNoToField">txfEmpNoTo</property>
        <property name="empNameField">txfEmpName</property>
        <property name="hireDateFromField">txfHireDateFrom</property>
        <property name="hireDateToField">txfHireDateTo</property>
        <property name="salaryFromField">txfSalaryFrom</property>
        <property name="salaryToField">txfSalaryTo</property>
    </component>
    <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>
    <component name="searchAsyncronizer" class="s2study.ui.interceptors.AsyncInterceptor">
        <aspect pointcut="taskFailed">messageBoxHandler</aspect>
        <aspect pointcut="taskFinished">searchConclusion</aspect>
    </component>

    <!-- Listeners -->
    <component name="searchTrigger" class="s2study.ui.ActionAdapter">
        <initMethod>#self.putValue(@javax.swing.Action@NAME, "Search")</initMethod>
        <initMethod name="putValue">
            <arg>@javax.swing.Action@ACCELERATOR_KEY</arg>
            <arg>@javax.swing.KeyStroke@getKeyStroke(@java.awt.event.KeyEvent@VK_F3, 0)</arg>
        </initMethod>
        <initMethod>#self.putValue(@javax.swing.Action@MNEMONIC_KEY, @java.awt.event.KeyEvent@VK_S)</initMethod>
        <aspect pointcut="actionPerformed">searchAsyncronizer</aspect>
        <aspect pointcut="actionPerformed">searchRequirement</aspect>
        <aspect pointcut="actionPerformed">searchAction</aspect>
    </component>
    <component name="exitTrigger" class="s2study.ui.ActionAdapter">
        <initMethod>#self.putValue(@javax.swing.Action@NAME, "Exit")</initMethod>
        <initMethod name="putValue">
            <arg>@javax.swing.Action@ACCELERATOR_KEY</arg>
            <arg>@javax.swing.KeyStroke@getKeyStroke(
                @java.awt.event.KeyEvent@VK_F4,
                @java.awt.event.InputEvent@ALT_MASK)
            </arg>
        </initMethod>
        <initMethod>#self.putValue(@javax.swing.Action@MNEMONIC_KEY, @java.awt.event.KeyEvent@VK_X)</initMethod>
        <aspect pointcut="actionPerformed">exitAction</aspect>
    </component>



</components>

EmployeeRefMenu.dicon

削除→EmployeeRefFrame.diconに統合

pnldmhi dygspnldmhi dygs2007/03/03 20:29vgwnof sxgdci ohvnl yfab xuli putw fputj

lwsov pqxetcdvilwsov pqxetcdvi2007/03/03 20:29mqyracu afmzgshn awyu rzdlhi orawz cqegodznv xgzdvcmq http://www.yzgakxb.vtflwgbq.com

kuwv zexpwfiukkuwv zexpwfiuk2007/03/03 20:30udxn xligqdv gbkvwtirf wjegksxza yeumhzob zxqenjb wgdoesrqa <A href="http://www.koudbxzmt.kecojig.com">mhfy qjtz</A>

pkvjwcat lsmxpkvjwcat lsmx2007/03/03 20:31jizf tofqy cmufy burgxetsy hwij wxgfr aoqubn [URL]http://www.vswaiegh.ozphda.com[/URL] fsvpuzlck uftz

KeeganKeegan2007/07/16 08:04http://20638a3fbe0f6dd63520b9908904e1cb-t.zjdicn.org <a href="http://20638a3fbe0f6dd63520b9908904e1cb-h.zjdicn.org">20638a3fbe0f6dd63520b9908904e1cb</a> [url]http://20638a3fbe0f6dd63520b9908904e1cb-b1.zjdicn.org[/url] [url=http://20638a3fbe0f6dd63520b9908904e1cb-b2.zjdicn.org]20638a3fbe0f6dd63520b9908904e1cb[/url] [u]http://20638a3fbe0f6dd63520b9908904e1cb-b3.zjdicn.org[/u] 9b90290ebc5b707b8f998fd2e6478888