Examples of ActionCommand


Examples of org.springframework.richclient.command.ActionCommand

    }

    private void initializeNavigationCommands()
    {
        this.navigationCommands = new AbstractCommand[4];
        this.navigationCommands[NAVIGATE_FIRST] = new ActionCommand(NAVIGATE_FIRSTROW_CMDID)
        {

            @Override
            protected void doExecuteCommand()
            {
                selectionModel.setSelectionInterval(0, 0);
                scrollToSelectedRow();
            }
        };
        this.navigationCommands[NAVIGATE_PREVIOUS] = new ActionCommand(NAVIGATE_PREVIOUSROW_CMDID)
        {

            @Override
            protected void doExecuteCommand()
            {
                int newIndex = selectionModel.getAnchorSelectionIndex() - 1;
                newIndex = (newIndex < 0) ? 0 : newIndex;
                selectionModel.setSelectionInterval(newIndex, newIndex);
                scrollToSelectedRow();
            }
        };
        this.navigationCommands[NAVIGATE_NEXT] = new ActionCommand(NAVIGATE_NEXTROW_CMDID)
        {

            @Override
            protected void doExecuteCommand()
            {
                int newIndex = selectionModel.getAnchorSelectionIndex() + 1;
                int lastIndex = shownList.size() - 1;
                newIndex = (newIndex > lastIndex) ? lastIndex : newIndex;
                selectionModel.setSelectionInterval(newIndex, newIndex);
                scrollToSelectedRow();
            }
        };
        this.navigationCommands[NAVIGATE_LAST] = new ActionCommand(NAVIGATE_LASTROW_CMDID)
        {

            @Override
            protected void doExecuteCommand()
            {
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

    private void initializeSelectColumnCommands()
    {
        final WritableTableFormat writableTableFormat = (WritableTableFormat) this.tableModel
                .getTableFormat();
        AbstractCommand selectAll = new ActionCommand(SELECT_ALL_ID)
        {

            @Override
            protected void doExecuteCommand()
            {
                shownList.getReadWriteLock().writeLock().lock();
                Iterator i = shownList.iterator();
                while (i.hasNext())
                {
                    writableTableFormat.setColumnValue(i.next(), Boolean.TRUE, 0);
                }
                shownList.getReadWriteLock().writeLock().unlock();
                theTable.repaint();
                fireUserSelectionChangedEvent();
            }
        };
        this.commandConfigurer.configure(selectAll);
        AbstractCommand selectNone = new ActionCommand(SELECT_NONE_ID)
        {

            @Override
            protected void doExecuteCommand()
            {
                shownList.getReadWriteLock().writeLock().lock();
                Iterator i = shownList.iterator();
                while (i.hasNext())
                {
                    writableTableFormat.setColumnValue(i.next(), Boolean.FALSE, 0);
                }
                shownList.getReadWriteLock().writeLock().unlock();
                theTable.repaint();
                fireUserSelectionChangedEvent();
            }
        };
        this.commandConfigurer.configure(selectNone);
        AbstractCommand selectInverse = new ActionCommand(SELECT_INVERSE_ID)
        {

            @Override
            protected void doExecuteCommand()
            {
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

     * @return apply command.
     */
    protected ActionCommand getApplyCommand()
    {
        if (applyCommand == null) {
            applyCommand = new ActionCommand("applyCommand") {
          public void doExecuteCommand() {
            onApply();
          }
        };
        }
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

     * @return restore defaults command.
     */
    protected ActionCommand getRestoreDefaultsCommand()
    {
        if (restoreDefaultsCommand == null){
            restoreDefaultsCommand = new ActionCommand("restoreDefaultsCommand") {
          public void doExecuteCommand() {
            onDefaults();
          }
        };
        }
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

        assertFalse( "Object should not be authorized", testAuth1.isAuthorized() );
        assertEquals( "Object should be updated", authorizeCount++, testAuth1.getAuthCount() );

        CommandManager cmgr = Application.instance().getActiveWindow().getCommandManager();
        ActionCommand cmdWrite = cmgr.getActionCommand( "cmdWrite" );
        ActionCommand cmdAdmin = cmgr.getActionCommand( "cmdAdmin" );
        ActionCommand cmdAdminAlias = cmgr.getActionCommand( "cmdAdminAlias" );

        assertFalse( "Object should not be authorized", cmdWrite.isAuthorized() );
        assertFalse( "Object should not be authorized", cmdAdmin.isAuthorized() );
        assertFalse( "Object should not be authorized", cmdAdminAlias.isAuthorized() );

        // Now login with ROLE_WRITE
        Authentication auth = TestAuthenticationManager.makeAuthentication( "test", "test", "ROLE_WRITE" );
        securityManager.doLogin( auth );

        assertTrue( "Object should be authorized", cmdWrite.isAuthorized() );
        assertFalse( "Object should not be authorized", cmdAdmin.isAuthorized() );
        assertFalse( "Object should not be authorized", cmdAdminAlias.isAuthorized() );
        assertFalse( "Object should not be authorized", testAuth1.isAuthorized() );
        assertEquals( "Object should be updated", authorizeCount++, testAuth1.getAuthCount() );

        // Now login with ROLE_ADMIN
        auth = TestAuthenticationManager.makeAuthentication( "test", "test", "ROLE_ADMIN" );
        securityManager.doLogin( auth );

        assertTrue( "Object should be authorized", cmdWrite.isAuthorized() );
        assertTrue( "Object should be authorized", cmdAdmin.isAuthorized() );
        assertTrue( "Object should be authorized", cmdAdminAlias.isAuthorized() );
        assertTrue( "Object should be authorized", testAuth1.isAuthorized() );
        assertEquals( "Object should be updated", authorizeCount++, testAuth1.getAuthCount() );
    }
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

  private ActionCommand createNewFormObjectCommand() {
    String commandId = getNewFormObjectCommandId();
    if (!StringUtils.hasText(commandId)) {
      return null;
    }
    ActionCommand newFormObjectCmd = new ActionCommand(commandId) {
      protected void doExecuteCommand() {
        getFormModel().setFormObject(createNewObject());
        getFormModel().setEnabled(true);
        editingNewFormObject = true;
        if (isEditingFormObjectSelected()) {
          setEditingFormObjectIndexSilently(-1);
        }
      }
    };
    newFormObjectCmd.setSecurityControllerId(getNewFormObjectSecurityControllerId());
    attachFormGuard(newFormObjectCmd, FormGuard.LIKE_NEWFORMOBJCOMMAND);
    return (ActionCommand) getCommandConfigurer().configure(newFormObjectCmd);
  }
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

  private final ActionCommand createCommitCommand() {
    String commandId = getCommitCommandFaceDescriptorId();
    if (!StringUtils.hasText(commandId)) {
      return null;
    }
    ActionCommand commitCmd = new ActionCommand(commandId) {
      protected void doExecuteCommand() {
        commit();
      }
    };
    commitCmd.setSecurityControllerId(getCommitSecurityControllerId());
    attachFormGuard(commitCmd, FormGuard.LIKE_COMMITCOMMAND);
    return (ActionCommand) getCommandConfigurer().configure(commitCmd);
  }
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

  private final ActionCommand createRevertCommand() {
    String commandId = getRevertCommandFaceDescriptorId();
    if (!StringUtils.hasText(commandId)) {
      return null;
    }
    ActionCommand revertCmd = new ActionCommand(commandId) {
      protected void doExecuteCommand() {
        revert();
      }
    };
    attachFormGuard(revertCmd, FormGuard.LIKE_REVERTCOMMAND);
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

    protected ActionCommand getSelectNoneCommand()
    {
      if (selectNoneCommand == null)
      {
        selectNoneCommand = new ActionCommand(getSelectNoneCommandId()) {
          public void doExecuteCommand() {
            onSelectNone();
          }
        };
        selectNoneCommand.setSecurityControllerId(getFinishSecurityControllerId());
View Full Code Here

Examples of org.springframework.richclient.command.ActionCommand

     * Test that the authorized state overrides the enabled state
     */
    public void testAuthorizedOverridesEnabled() {
        ApplicationSecurityManager securityManager = (ApplicationSecurityManager)ApplicationServicesLocator.services().getService(ApplicationSecurityManager.class);
        CommandManager cmgr = Application.instance().getActiveWindow().getCommandManager();
        ActionCommand cmdWrite = cmgr.getActionCommand( "cmdWrite" );

        // We start with no authentication, so nothing should be authorized
        assertFalse( "Object should not be authorized", cmdWrite.isAuthorized() );
        assertFalse( "Object should not be enabled", cmdWrite.isEnabled() );

        // Try to enable them, should not happen
        cmdWrite.setEnabled( true );
        assertFalse( "Object should not be enabled", cmdWrite.isEnabled() );

        // Now authorize it
        Authentication auth = TestAuthenticationManager.makeAuthentication( "test", "test", "ROLE_WRITE" );
        securityManager.doLogin( auth );

        assertTrue( "Object should be authorized", cmdWrite.isAuthorized() );
        assertTrue( "Object should be enabled", cmdWrite.isEnabled() );

        // Now we should be able to disable and re-enabled it
        cmdWrite.setEnabled( false );
        assertFalse( "Object should not be enabled", cmdWrite.isEnabled() );
        cmdWrite.setEnabled( true );
        assertTrue( "Object should be enabled", cmdWrite.isEnabled() );

        // Now leave it disabled, remove the authorization, re-authorize and it
        // should still be disabled
        cmdWrite.setEnabled( false );
        assertFalse( "Object should not be enabled", cmdWrite.isEnabled() );
        securityManager.doLogout();

        assertFalse( "Object should not be authorized", cmdWrite.isAuthorized() );
        assertFalse( "Object should not be enabled", cmdWrite.isEnabled() );

        securityManager.doLogin( auth );

        assertTrue( "Object should be authorized", cmdWrite.isAuthorized() );
        assertFalse( "Object should not be enabled", cmdWrite.isEnabled() );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.