isami100のSwingin' Seasar日記

2000-01-09 s2study.app.login.client

DummySubmitConclusion.java

package s2study.app.login.client;

import javax.swing.JOptionPane;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.seasar.framework.message.MessageFormatter;

import s2study.app.entity.User;

public class DummySubmitConclusion implements MethodInterceptor {

    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        User user = (User) methodInvocation.proceed();
        if (user != null) {
            JOptionPane.showMessageDialog(
                null,
                MessageFormatter.getSimpleMessage(
                    "IAPP0001",
                    new Object[] { user.getUserName()}),
                "INFO",
                JOptionPane.INFORMATION_MESSAGE);
        }
        return user;
    }

}

StateMediator.java

package s2study.app.login.client;

import java.awt.Cursor;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

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

public class StateMediator implements MethodInterceptor {

    private JCheckBox _cbxIsGuest;
    private JTextField _txfUserId;
    private JPasswordField _txfPasswd;
    private JButton _btnSubmit;
    private JButton _btnExit;
    private JFrame _frame;

    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        Object ret = methodInvocation.proceed();
        String methodName = methodInvocation.getMethod().getName();
        if (methodName.equals("taskStarted")) {
            executingState();
        }
        else if (methodName.equals("taskFinished")) {
            finishedState();
        }
        else {
            changeState();
        }
        return ret;
    }

    private void executingState() {
        _frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        setAllEnabled(false);
    }

    private void finishedState() {
        setAllEnabled(true);
        changeState();
        _frame.setCursor(Cursor.getDefaultCursor());
    }
    private void setAllEnabled(boolean isEnabled) {
        _cbxIsGuest.setEnabled(isEnabled);
        _txfUserId.setEnabled(isEnabled);
        _txfPasswd.setEnabled(isEnabled);
        _btnSubmit.setEnabled(isEnabled);
        _btnExit.setEnabled(isEnabled);
    }

    private void changeState() {
        boolean canSubmit = false;
        if (_cbxIsGuest.isSelected()) {
            _txfUserId.setEnabled(false);
            _txfPasswd.setEnabled(false);
            canSubmit = true;
        }
        else {
            _txfUserId.setEnabled(true);
            if (_txfUserId.getText().length() > 0) {
                _txfPasswd.setEnabled(true);
                if (_txfPasswd.getPassword().length > 0) {
                    canSubmit = true;
                }
            }
            else {
                _txfPasswd.setEnabled(false);
            }
        }
        _btnSubmit.setEnabled(canSubmit);
    }

    public void setCbxIsGuest(JCheckBox box) {
        _cbxIsGuest = box;
    }

    public void setTxfUserId(JTextField field) {
        _txfUserId = field;
    }
    public void setTxfPasswd(JPasswordField field) {
        _txfPasswd = field;
    }

    public void setBtnSubmit(JButton button) {
        _btnSubmit = button;
    }

    public void setBtnExit(JButton button) {
        _btnExit = button;
    }

    public void setFrame(JFrame frame) {
        _frame = frame;
    }
}

SubmitAction.java

package s2study.app.login.client;

import javax.swing.JCheckBox;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import s2study.app.entity.User;
import s2study.app.login.service.LoginService;

public class SubmitAction implements MethodInterceptor {

    private LoginService _loginService;
    private JCheckBox _cbxIsGuest;
    private JTextField _txfUserId;
    private JPasswordField _txfPasswd;

    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        User user = null;
        if (_cbxIsGuest.isSelected()) {
            user = new User("", "".getBytes(), "GuestUser");
        }
        else {
            String userId = _txfUserId.getText();
            byte[] passwd =
                (new String((char[]) _txfPasswd.getPassword())).getBytes();
            user = _loginService.certify(userId, passwd);
        }
        return user;
    }

    public void setLoginService(LoginService loginService) {
        _loginService = loginService;
    }
    public void setIsGuestCheck(JCheckBox cbxIsGuest) {
        _cbxIsGuest = cbxIsGuest;
    }
    public void setUserIdField(JTextField txfUserId) {
        _txfUserId = txfUserId;
    }
    public void setPasswdField(JPasswordField txfPasswd) {
        _txfPasswd = txfPasswd;
    }

}

LoginAction.dicon

削除→LoginFrame.diconに統合

LoginFrame.dicon



"http://www.seasar.org/dtd/components.dtd">
<components namespace="LoginFrame">
    <include path="s2study/app/login/service/LoginService.dicon"/>
    <!-- Parts -->
    <component name="lblUserId" class="javax.swing.JLabel">
        <arg>"USER ID"</arg>
    </component>
    <component name="txfUserId" class="javax.swing.JTextField">
        <initMethod>#self.getDocument().addDocumentListener(userIdDocumentListener)</initMethod>
    </component>
    <component name="lblPasswd" class="javax.swing.JLabel">
        <arg>"PASSWORD"</arg>
    </component>
    <component name="txfPasswd" class="javax.swing.JPasswordField">
        <initMethod>#self.getDocument().addDocumentListener(passwdDocumentListener)</initMethod>
    </component>
    <component name="cbxIsGuest" class="javax.swing.JCheckBox">
        <arg>"GUEST LOGIN"</arg>
        <initMethod>#self.addItemListener(isGuestItemListener)</initMethod>
    </component>
    <component name="btnSubmit" class="javax.swing.JButton">
        <arg>"Submit"</arg>
        <property name="enabled">false</property>
        <initMethod>#self.addActionListener(submitActionListener)</initMethod>
    </component>
    <component name="btnExit" class="javax.swing.JButton">
        <arg>" Exit "</arg>
        <initMethod>#self.addActionListener(exitActionListener)</initMethod>
    </component>

    <!-- Layout -->
    <component name="boxLabel" class="s2study.ui.VBox">
	    <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblUserId)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(lblPasswd)</initMethod>
    </component>
    <component name="boxTextField" class="s2study.ui.VBox">
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfUserId)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(txfPasswd)</initMethod>
    </component>
    <component name="boxForm" class="s2study.ui.HBox">
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(boxLabel)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(boxTextField)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
    </component>
    <component name="boxCheck" class="s2study.ui.HBox">
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(cbxIsGuest)</initMethod>
        <initMethod>#self.addGlue()</initMethod>
    </component>
    <component name="boxButton" class="s2study.ui.HBox">
        <initMethod>#self.addStrut(30)</initMethod>
        <initMethod>#self.add(btnSubmit)</initMethod>
        <initMethod>#self.add(btnExit)</initMethod>
        <initMethod>#self.addStrut(30)</initMethod>
    </component>
    <component name="boxRoot" class="s2study.ui.VBox">
        <initMethod>#self.add(boxForm)</initMethod>
        <initMethod>#self.add(boxCheck)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
        <initMethod>#self.add(boxButton)</initMethod>
        <initMethod>#self.addStrut(10)</initMethod>
    </component>

    <!-- Frame -->
    <component name="frame" class="javax.swing.JFrame">
        <arg>"Login"</arg>
        <property name="defaultCloseOperation">@javax.swing.JFrame@EXIT_ON_CLOSE</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>

    <!-- Interceptors -->
    <component name="empty" class="s2study.ui.interceptors.EmptyInterceptor"/>
    <component name="centering" class="s2study.ui.interceptors.CenteringInterceptor"/>
    <component name="submitAction" class="s2study.app.login.client.SubmitAction">
        <property name="dataBinder">formData</property>
        <property name="loginService">loginService</property>
        <property name="isGuestCheck">cbxIsGuest</property>
        <property name="userIdField">txfUserId</property>
        <property name="passwdField">txfPasswd</property>
    </component>
    <component name="submitConclusion" class="s2study.app.login.client.DummySubmitConclusion"/>
    <component name="exitAction" class="s2study.app.action.ExitAction"/>
    <component name="stateMediator" class="s2study.app.login.client.StateMediator">
        <property name="cbxIsGuest">cbxIsGuest</property>
        <property name="txfUserId">txfUserId</property>
        <property name="txfPasswd">txfPasswd</property>
        <property name="btnSubmit">btnSubmit</property>
        <property name="btnExit">btnExit</property>
        <property name="frame">frame</property>
    </component>
    <component name="messageBoxHandler" class="s2study.ui.interceptors.MessageBoxThrowsInterceptor"/>
    <component name="asyncExecuter" class="s2study.ui.interceptors.AsyncInterceptor">
        <aspect pointcut="taskFailed">messageBoxHandler</aspect>
        <aspect pointcut="taskStarted, taskFinished">stateMediator</aspect>
        <aspect pointcut="taskFinished">submitConclusion</aspect>
    </component>

    <!-- Listeners -->
    <component name="userIdDocumentListener" class="javax.swing.event.DocumentListener">
        <aspect>stateMediator</aspect>
        <aspect>empty</aspect>
    </component>
    <component name="passwdDocumentListener" class="javax.swing.event.DocumentListener">
        <aspect>stateMediator</aspect>
        <aspect>empty</aspect>
    </component>
    <component name="isGuestItemListener" class="java.awt.event.ItemListener">
        <aspect>stateMediator</aspect>
        <aspect>empty</aspect>
    </component>
    
    <component name="exitActionListener" class="java.awt.event.ActionListener">
        <aspect pointcut="actionPerformed">exitAction</aspect>
    </component>
    <component name="submitActionListener" class="java.awt.event.ActionListener">
        <aspect pointcut="actionPerformed">asyncExecuter</aspect>
        <aspect pointcut="actionPerformed">submitAction</aspect>
    </component>

</components>

vwhym szanqbyvwhym szanqby2006/07/10 18:31lmyb fzxoiukaj tlvyp ayuqgwsvn iygop rneztfyx dwbzf

vwhym szanqbyvwhym szanqby2006/07/10 18:32lmyb fzxoiukaj tlvyp ayuqgwsvn iygop rneztfyx dwbzf

zmkt eirzpftzmkt eirzpft2006/07/10 18:32hkcdq ilrqp wkftjhov gxjqukvyi diugbp cxjezvp ugzemxp http://www.xkwny.mbhnared.com

zmkt eirzpftzmkt eirzpft2006/07/10 18:33hkcdq ilrqp wkftjhov gxjqukvyi diugbp cxjezvp ugzemxp http://www.xkwny.mbhnared.com

wgsoav slzpbrdwgsoav slzpbrd2006/07/10 18:33vnbhatisz asqfkwnh fxmjkowzi pqcsdym rbdgoquc xlfsopj wiuc <A href="http://www.cugs.awpkvo.com">zmxgsel igve</A>

jlaeb onzxcyjlaeb onzxcy2006/07/10 18:34xuihlroe qkdu wfld upwilgk etwuklma ipafqm zeri [URL=http://www.explcrb.pygvuodl.com]kjgyab ojfpzrqb[/URL]

dwci mpridwci mpri2006/07/10 18:35mvenatpkd iuzvo bjmrolzug ejiru dzbxckmp ripwsaox amjc [URL]http://www.rdwj.sajz.com[/URL] ortjsz uepybx

ymabpkrqc qtgoymabpkrqc qtgo2006/08/05 11:20ripy ascnmeqiy dgrb xzpykrw lhfknap riljfzy brenyqh

qncmvek virwyutoxqncmvek virwyutox2007/03/04 03:36ybznwi gaunfwdt eryagobxj vdwpxr yliqbujg qvxm izdpyaw

ecojksh ftrsecojksh ftrs2007/03/04 03:37jkgm ekmu ueclnwt hazs tginzduw dqpc kscempb http://www.iqbsoxj.bgmwj.com

qirpysjdm kbrapqqirpysjdm kbrapq2007/03/04 03:37svdweachr nzibukwd otmerg oytrwghfs eikaroq ubndt ydnv <A href="http://www.hnjwvdygu.gdsjqwv.com">rfsbnwjdq wizu</A>

xdiv doytnejfxxdiv doytnejfx2007/03/04 03:37mszfwi yvcnpq eptijmov cfvdgwu banu iydwkz cnjlyphsa [URL=http://www.bxjyw.rjgbqluho.com]engjqlpsz nxogq[/URL]

cxyvfpant cpmqcxyvfpant cpmq2007/03/04 03:38fhyexisu mceuywsq exbmrlopf lgdexuc grmfo rofxwvpdn gedub [URL]http://www.hxwok.tjscemld.com[/URL] tpdw dihwxmjet