Package org.springframework.richclient.core

Examples of org.springframework.richclient.core.Guarded


    // The form's action commands should get enabled/disabled based on the form's state
   
    public void testNewFormCommandGuarding() {
        TestForm form = new TestForm(formModel);
        form.attachFormGuard(guarded, FormGuard.LIKE_NEWFORMOBJCOMMAND);
        Guarded nfCmd = form.getNewFormObjectCommand();
       
        //default enabled
        assertTrue("guarded like newForm should be initially enabled", guarded.isEnabled());
        assertTrue("newForm should be initially enabled", nfCmd.isEnabled());
       
        // disable form --> disabled
        form.setEnabled(false);
        assertFalse("guarded like newform should be disabled with form", guarded.isEnabled());
        assertFalse("newform should be disabled with form", nfCmd.isEnabled());
       
        // enable form --> enabled
        form.setEnabled(true);
        assertTrue("guarded like newForm should be initially enabled", guarded.isEnabled());
        assertTrue("newForm should be initially enabled", nfCmd.isEnabled());
       
        // trigger validation-error --> still enabled
        ((JTextField)form.getControl()).setText(null);
        assertTrue(formModel.getValidationResults().getHasErrors());
        assertTrue("guarded like newForm should be initially enabled", guarded.isEnabled());
        assertTrue("newForm should be initially enabled", nfCmd.isEnabled());
    }
View Full Code Here


    }
   
    public void testRevertCommandGuarding() {
        TestForm form = new TestForm(formModel);
        form.attachFormGuard( guarded, FormGuard.LIKE_REVERTCOMMAND);
        Guarded rvtCmd = form.getRevertCommand();
       
        // initially --> disabled
        assertFalse("guarded like revert should be initially disabled", guarded.isEnabled());
        assertFalse("revert should be initially disabled", rvtCmd.isEnabled());

        // create dirt with errors --> enabled
        ((JTextField)form.getControl()).setText(null);
        assertTrue(formModel.getValidationResults().getHasErrors());
        assertTrue(formModel.isDirty());
        assertTrue("guarded like revert should be enabled when there are changes", guarded.isEnabled());
        assertTrue("revert should be enabled when there are changes", rvtCmd.isEnabled());
       
        // relieve errors --> enabled
        ((JTextField)form.getControl()).setText("nok");
        assertFalse(formModel.getValidationResults().getHasErrors());
        assertTrue(formModel.isDirty());
        assertTrue("guarded like revert should be enabled when there are changes", guarded.isEnabled());
        assertTrue("revert should be enabled when there are changes", rvtCmd.isEnabled());
       
        // disable form --> disabled
        form.setEnabled(false);
        assertFalse("guarded like revert should be disabled with form", guarded.isEnabled());
        assertFalse("revert should be disabled with form", rvtCmd.isEnabled());
       
        // enable form --> enabled
        form.setEnabled(true);
        assertTrue("guarded like revert should be enabled with form", guarded.isEnabled());
        assertTrue("revert should be enabled with form", rvtCmd.isEnabled());
       
        // revert --> disabled
        form.revert();
        assertFalse("guarded like revert should be disabled when no changes left", guarded.isEnabled());
        assertFalse("revert should be disabled when no changes left", rvtCmd.isEnabled());
    }
View Full Code Here

    }

    public void testCommitCommandGuarding() {
        TestForm form = new TestForm(formModel);
        new FormGuard(formModel, guarded, FormGuard.LIKE_COMMITCOMMAND);
        Guarded cmtCmd = form.getCommitCommand();
       
        // initially --> disabled
        assertFalse("guarded like commit should be initially disabled", guarded.isEnabled());
        assertFalse("commit should be initially disabled", cmtCmd.isEnabled());

        // create dirt with errors --> disabled
        ((JTextField)form.getControl()).setText(null);
        assertTrue(formModel.getValidationResults().getHasErrors());
        assertTrue(formModel.isDirty());
        assertFalse("guarded like commit should be disabled when model has validation-errors", guarded.isEnabled());
        assertFalse("commit should be disabled when model has validation-errors", cmtCmd.isEnabled());
       
        // relieve errors --> enabled
        ((JTextField)form.getControl()).setText("nok");
        assertFalse(formModel.getValidationResults().getHasErrors());
        assertTrue(formModel.isDirty());
        assertTrue("guarded like commit should be enabled if there are errors", guarded.isEnabled());
        assertTrue("commit should be enabled if there are errors", cmtCmd.isEnabled());
       
        // disable form --> disabled
        form.setEnabled(false);
        assertFalse("guarded like commit should be disabled with form", guarded.isEnabled());
        assertFalse("commit should be disabled with form", cmtCmd.isEnabled());
       
        // enable form --> enabled
        form.setEnabled(true);
        assertTrue("guarded like commit should be enabled with form", guarded.isEnabled());
        assertTrue("commit should be enabled with form", cmtCmd.isEnabled());
       
        // revert --> disabled
        form.revert();
        assertFalse("guarded like commit should be disabled when no changes left", guarded.isEnabled());
        assertFalse("commit should be disabled when no changes left", cmtCmd.isEnabled());
    }
View Full Code Here

        assertEquals("Message count incorrect", 2, monitor.getMessageCount());
    }

    public void testPageCompleteAdapter() {
        TestDialogPage page = new TestDialogPage();
        Guarded guarded = new TestGuarded();

        DialogPageUtils.adaptPageCompletetoGuarded(page, guarded);

        page.setPageComplete(false);
        assertFalse("guarded should be disabled", guarded.isEnabled());

        page.setPageComplete(true); // Change it
        assertTrue("guarded should be enabled", guarded.isEnabled());
    }
View Full Code Here

    private void updateAllGuarded() {
        int formState = getFormModelState();

        Iterator guardedIter = this.guardedEntries.keySet().iterator();
        while (guardedIter.hasNext()) {
            Guarded guarded = (Guarded) guardedIter.next();
            int mask = ((Integer) this.guardedEntries.get(guarded)).intValue();

            boolean b = stateMatchesMask(formState, mask);
            guarded.setEnabled(b);
        }
    }
View Full Code Here

TOP

Related Classes of org.springframework.richclient.core.Guarded

Copyright © 2018 www.massapicom. 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.